From a7bf1522d815e7ed5b01434bda610a60f8bd48ac Mon Sep 17 00:00:00 2001 From: Steve Kim Date: Tue, 12 Nov 2024 11:05:49 -0800 Subject: [PATCH 01/13] switch to using a role for integrated tests --- .github/workflows/ci.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f1d8dfa..0ca1911 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,8 +8,8 @@ on: env: RUN: ${{ github.run_id }}-${{ github.run_number }} - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_DEFAULT_REGION: us-east-1 + CI_SDK_V1_ROLE: arn:aws:iam::123124136734:role/CI_SDK_V1_ROLE PACKAGE_NAME: aws-iot-device-sdk-python AWS_EC2_METADATA_DISABLED: true @@ -41,8 +41,11 @@ jobs: steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 + - uses: aws-actions/configure-aws-credentials@v2 with: python-version: ${{ matrix.python-version }} + role-to-assume: ${{ env.CI_SDK_V1_ROLE }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: Integration tests run: | pip install pytest From 11352f7533395eba513fbd166545f27936e54a00 Mon Sep 17 00:00:00 2001 From: Steve Kim Date: Tue, 12 Nov 2024 11:16:13 -0800 Subject: [PATCH 02/13] separate python --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0ca1911..0a3d4ef 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,9 +41,10 @@ jobs: steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 - - uses: aws-actions/configure-aws-credentials@v2 with: python-version: ${{ matrix.python-version }} + - uses: aws-actions/configure-aws-credentials@v2 + with: role-to-assume: ${{ env.CI_SDK_V1_ROLE }} aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: Integration tests From 120a8fcd28e32ba1336d39b288e0a15f7fa47d32 Mon Sep 17 00:00:00 2001 From: Vera Xia Date: Wed, 13 Nov 2024 10:52:03 -0800 Subject: [PATCH 03/13] setup permision&test against CI_PubSub_Role --- .github/workflows/ci.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0a3d4ef..95df595 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,6 +10,7 @@ env: RUN: ${{ github.run_id }}-${{ github.run_number }} AWS_DEFAULT_REGION: us-east-1 CI_SDK_V1_ROLE: arn:aws:iam::123124136734:role/CI_SDK_V1_ROLE + CI_PUBSUB_ROLE: arn:aws:iam::180635532705:role/CI_PubSub_Role PACKAGE_NAME: aws-iot-device-sdk-python AWS_EC2_METADATA_DISABLED: true @@ -33,6 +34,9 @@ jobs: integration-tests: runs-on: ubuntu-latest + permissions: + id-token: write # This is required for requesting the JWT + contents: read # This is required for actions/checkout strategy: fail-fast: false matrix: @@ -45,7 +49,7 @@ jobs: python-version: ${{ matrix.python-version }} - uses: aws-actions/configure-aws-credentials@v2 with: - role-to-assume: ${{ env.CI_SDK_V1_ROLE }} + role-to-assume: ${{ env.CI_PUBSUB_ROLE }} aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: Integration tests run: | From 3d967d8f50a652b49c25ab0d980116c97eee9795 Mon Sep 17 00:00:00 2001 From: Vera Xia Date: Fri, 15 Nov 2024 14:27:24 -0800 Subject: [PATCH 04/13] test against iot account --- test-integration/run/run.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test-integration/run/run.sh b/test-integration/run/run.sh index 0eb933b..c241711 100755 --- a/test-integration/run/run.sh +++ b/test-integration/run/run.sh @@ -33,8 +33,8 @@ # Define const USAGE="usage: run.sh " -AWSMutualAuth_TodWorker_private_key="arn:aws:secretsmanager:us-east-1:123124136734:secret:V1IotSdkIntegrationTestPrivateKey-vNUQU8" -AWSMutualAuth_TodWorker_certificate="arn:aws:secretsmanager:us-east-1:123124136734:secret:V1IotSdkIntegrationTestCertificate-vTRwjE" +AWSMutualAuth_TodWorker_private_key="arn:aws:secretsmanager:us-east-1:180635532705:secret:ci/mqtt5/us/Mqtt5Prod/key-kqgyvf" +AWSMutualAuth_TodWorker_certificate="arn:aws:secretsmanager:us-east-1:180635532705:secret:ci/mqtt5/us/Mqtt5Prod/cert-VDI1Gd" AWSGGDiscovery_TodWorker_private_key="arn:aws:secretsmanager:us-east-1:123124136734:secret:V1IotSdkIntegrationTestGGDiscoveryPrivateKey-YHQI1F" AWSGGDiscovery_TodWorker_certificate="arn:aws:secretsmanager:us-east-1:123124136734:secret:V1IotSdkIntegrationTestGGDiscoveryCertificate-TwlAcS" @@ -82,11 +82,11 @@ else python ${RetrieveAWSKeys} ${AWSDRSName_certificate} > ${CREDENTIAL_DIR}certificate_drs.pem.crt python ${RetrieveAWSKeys} ${AWSDRSName_privatekey} > ${CREDENTIAL_DIR}privateKey_drs.pem.key elif [ "$1"x == "Websocket"x ]; then - ACCESS_KEY_ID_ARN=$(python ${RetrieveAWSKeys} ${AWSSecretForWebsocket_TodWorker_KeyId}) - ACCESS_SECRET_KEY_ARN=$(python ${RetrieveAWSKeys} ${AWSSecretForWebsocket_TodWorker_SecretKey}) + # ACCESS_KEY_ID_ARN=$(python ${RetrieveAWSKeys} ${AWSSecretForWebsocket_TodWorker_KeyId}) + # ACCESS_SECRET_KEY_ARN=$(python ${RetrieveAWSKeys} ${AWSSecretForWebsocket_TodWorker_SecretKey}) TestMode="Websocket" - export AWS_ACCESS_KEY_ID=${ACCESS_KEY_ID_ARN} - export AWS_SECRET_ACCESS_KEY=${ACCESS_SECRET_KEY_ARN} + # export AWS_ACCESS_KEY_ID=${ACCESS_KEY_ID_ARN} + # export AWS_SECRET_ACCESS_KEY=${ACCESS_SECRET_KEY_ARN} curl -s "${CA_CERT_URL}" > ${CA_CERT_PATH} echo -e "URL retrieved certificate data\n" elif [ "$1"x == "ALPN"x ]; then From f41536ba43d4c893ac5a8f4fe85286a0bdbfa02b Mon Sep 17 00:00:00 2001 From: Vera Xia Date: Fri, 15 Nov 2024 14:50:05 -0800 Subject: [PATCH 05/13] update host --- .../IntegrationTestAsyncAPIGeneralNotificationCallbacks.py | 4 ++-- .../IntegrationTests/TestToolLibrary/checkInManager.py | 4 +++- test-integration/run/run.sh | 5 ++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/test-integration/IntegrationTests/IntegrationTestAsyncAPIGeneralNotificationCallbacks.py b/test-integration/IntegrationTests/IntegrationTestAsyncAPIGeneralNotificationCallbacks.py index b69fdcd..152c48a 100644 --- a/test-integration/IntegrationTests/IntegrationTestAsyncAPIGeneralNotificationCallbacks.py +++ b/test-integration/IntegrationTests/IntegrationTestAsyncAPIGeneralNotificationCallbacks.py @@ -32,7 +32,6 @@ TOPIC = "topic/test/async_cb/" MESSAGE_PREFIX = "MagicMessage-" NUMBER_OF_PUBLISHES = 3 -HOST = "ajje7lpljulm4-ats.iot.us-east-1.amazonaws.com" ROOT_CA = "./test-integration/Credentials/rootCA.crt" CERT = "./test-integration/Credentials/certificate.pem.crt" KEY = "./test-integration/Credentials/privateKey.pem.key" @@ -102,9 +101,10 @@ def get_random_string(length): ############################################################################ # Main # # Check inputs -my_check_in_manager = checkInManager(1) +my_check_in_manager = checkInManager(2) my_check_in_manager.verify(sys.argv) mode = my_check_in_manager.mode +HOST = my_check_in_manager.host skip_when_match(ModeIsALPN(mode).And( Python2VersionLowerThan((2, 7, 10)).Or(Python3VersionLowerThan((3, 5, 0))) diff --git a/test-integration/IntegrationTests/TestToolLibrary/checkInManager.py b/test-integration/IntegrationTests/TestToolLibrary/checkInManager.py index 2faaa02..7115138 100644 --- a/test-integration/IntegrationTests/TestToolLibrary/checkInManager.py +++ b/test-integration/IntegrationTests/TestToolLibrary/checkInManager.py @@ -7,6 +7,7 @@ class checkInManager: def __init__(self, numberOfInputParameters): self._numberOfInputParameters = numberOfInputParameters self.mode = None + self.host = None self.customParameter = None def verify(self, args): @@ -14,5 +15,6 @@ def verify(self, args): if len(args) != self._numberOfInputParameters + 1: exit(4) self.mode = str(args[1]) + self.host = str(args[2]) if self._numberOfInputParameters + 1 > 2: - self.customParameter = int(args[2]) + self.customParameter = int(args[3]) diff --git a/test-integration/run/run.sh b/test-integration/run/run.sh index c241711..28b9008 100755 --- a/test-integration/run/run.sh +++ b/test-integration/run/run.sh @@ -33,6 +33,8 @@ # Define const USAGE="usage: run.sh " +AWSHost="arn:aws:secretsmanager:us-east-1:180635532705:secret:unit-test/endpoint-HSpeEu" + AWSMutualAuth_TodWorker_private_key="arn:aws:secretsmanager:us-east-1:180635532705:secret:ci/mqtt5/us/Mqtt5Prod/key-kqgyvf" AWSMutualAuth_TodWorker_certificate="arn:aws:secretsmanager:us-east-1:180635532705:secret:ci/mqtt5/us/Mqtt5Prod/cert-VDI1Gd" @@ -49,6 +51,7 @@ CREDENTIAL_DIR="./test-integration/Credentials/" TEST_DIR="./test-integration/IntegrationTests/" CA_CERT_URL="https://www.amazontrust.com/repository/AmazonRootCA1.pem" CA_CERT_PATH=${CREDENTIAL_DIR}rootCA.crt +Host=$(python ${RetrieveAWSKeys} ${AWSHost}) @@ -142,7 +145,7 @@ else "IntegrationTestJobsClient.py") Scale="" esac - python ${TEST_DIR}${file} ${TestMode} ${Scale} + python ${TEST_DIR}${file} ${TestMode} ${Host} ${Scale} currentTestStatus=$? echo "[SUB] Test: ${file} completed. Exiting with status: ${currentTestStatus}" if [ ${currentTestStatus} -ne 0 ]; then From aa8cbbaba20de8ce8a63139e52f32490eab246cd Mon Sep 17 00:00:00 2001 From: Vera Xia Date: Fri, 15 Nov 2024 15:07:38 -0800 Subject: [PATCH 06/13] test host --- .../IntegrationTestAutoReconnectResubscribe.py | 4 ++-- .../IntegrationTests/TestToolLibrary/checkInManager.py | 2 +- test-integration/run/run.sh | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/test-integration/IntegrationTests/IntegrationTestAutoReconnectResubscribe.py b/test-integration/IntegrationTests/IntegrationTestAutoReconnectResubscribe.py index 83b66c2..e6c1bee 100644 --- a/test-integration/IntegrationTests/IntegrationTestAutoReconnectResubscribe.py +++ b/test-integration/IntegrationTests/IntegrationTestAutoReconnectResubscribe.py @@ -135,14 +135,14 @@ def threadBRuntime(self, pyCoreClient, callback): ############################################################################ # Main # # Check inputs -myCheckInManager = checkInManager.checkInManager(1) +myCheckInManager = checkInManager.checkInManager(2) myCheckInManager.verify(sys.argv) -host = "ajje7lpljulm4-ats.iot.us-east-1.amazonaws.com" rootCA = "./test-integration/Credentials/rootCA.crt" certificate = "./test-integration/Credentials/certificate.pem.crt" privateKey = "./test-integration/Credentials/privateKey.pem.key" mode = myCheckInManager.mode +host = myCheckInManager.host skip_when_match(ModeIsALPN(mode).And( Python2VersionLowerThan((2, 7, 10)).Or(Python3VersionLowerThan((3, 5, 0))) diff --git a/test-integration/IntegrationTests/TestToolLibrary/checkInManager.py b/test-integration/IntegrationTests/TestToolLibrary/checkInManager.py index 7115138..aeeedd9 100644 --- a/test-integration/IntegrationTests/TestToolLibrary/checkInManager.py +++ b/test-integration/IntegrationTests/TestToolLibrary/checkInManager.py @@ -16,5 +16,5 @@ def verify(self, args): exit(4) self.mode = str(args[1]) self.host = str(args[2]) - if self._numberOfInputParameters + 1 > 2: + if self._numberOfInputParameters + 1 > 3: self.customParameter = int(args[3]) diff --git a/test-integration/run/run.sh b/test-integration/run/run.sh index 28b9008..1f06a6f 100755 --- a/test-integration/run/run.sh +++ b/test-integration/run/run.sh @@ -51,7 +51,8 @@ CREDENTIAL_DIR="./test-integration/Credentials/" TEST_DIR="./test-integration/IntegrationTests/" CA_CERT_URL="https://www.amazontrust.com/repository/AmazonRootCA1.pem" CA_CERT_PATH=${CREDENTIAL_DIR}rootCA.crt -Host=$(python ${RetrieveAWSKeys} ${AWSHost}) +TestHost=$(python ${RetrieveAWSKeys} ${AWSHost}) +echo ${TestHost} @@ -145,7 +146,7 @@ else "IntegrationTestJobsClient.py") Scale="" esac - python ${TEST_DIR}${file} ${TestMode} ${Host} ${Scale} + python ${TEST_DIR}${file} ${TestMode} ${TestHost} ${Scale} currentTestStatus=$? echo "[SUB] Test: ${file} completed. Exiting with status: ${currentTestStatus}" if [ ${currentTestStatus} -ne 0 ]; then From d129ff1a0178857a3b298a06d64fb941b885b141 Mon Sep 17 00:00:00 2001 From: Vera Xia Date: Fri, 15 Nov 2024 15:13:52 -0800 Subject: [PATCH 07/13] use a ci job role for test --- .github/workflows/ci.yml | 4 +-- .../workflows/handle-stale-discussions.yml | 29 ++++++++++--------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 95df595..ece4212 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ env: RUN: ${{ github.run_id }}-${{ github.run_number }} AWS_DEFAULT_REGION: us-east-1 CI_SDK_V1_ROLE: arn:aws:iam::123124136734:role/CI_SDK_V1_ROLE - CI_PUBSUB_ROLE: arn:aws:iam::180635532705:role/CI_PubSub_Role + CI_JOBS_ROLE: arn:aws:iam::180635532705:role/CI_Jobs_Role PACKAGE_NAME: aws-iot-device-sdk-python AWS_EC2_METADATA_DISABLED: true @@ -49,7 +49,7 @@ jobs: python-version: ${{ matrix.python-version }} - uses: aws-actions/configure-aws-credentials@v2 with: - role-to-assume: ${{ env.CI_PUBSUB_ROLE }} + role-to-assume: ${{ env.CI_JOBS_ROLE }} aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: Integration tests run: | diff --git a/.github/workflows/handle-stale-discussions.yml b/.github/workflows/handle-stale-discussions.yml index e92e660..4fbcd70 100644 --- a/.github/workflows/handle-stale-discussions.yml +++ b/.github/workflows/handle-stale-discussions.yml @@ -1,18 +1,19 @@ name: HandleStaleDiscussions on: -schedule: -- cron: '0 */4 * * *' -discussion_comment: -types: [created] + schedule: + - cron: '0 */4 * * *' + discussion_comment: + types: [created] jobs: -handle-stale-discussions: -name: Handle stale discussions -runs-on: ubuntu-latest -permissions: - discussions: write -steps: - - name: Stale discussions action - uses: aws-github-ops/handle-stale-discussions@v1 - env: - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} \ No newline at end of file + handle-stale-discussions: + name: Handle stale discussions + runs-on: ubuntu-latest + permissions: + discussions: write + steps: + - name: Stale discussions action + uses: aws-github-ops/handle-stale-discussions@v1 + env: + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + \ No newline at end of file From e9d0ecd5acea803708688491769d38c974aaa7e6 Mon Sep 17 00:00:00 2001 From: Vera Xia Date: Fri, 15 Nov 2024 15:24:55 -0800 Subject: [PATCH 08/13] update role permission --- .github/workflows/ci.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ece4212..195bf2d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,8 +9,7 @@ on: env: RUN: ${{ github.run_id }}-${{ github.run_number }} AWS_DEFAULT_REGION: us-east-1 - CI_SDK_V1_ROLE: arn:aws:iam::123124136734:role/CI_SDK_V1_ROLE - CI_JOBS_ROLE: arn:aws:iam::180635532705:role/CI_Jobs_Role + CI_SDK_V1_ROLE: arn:aws:iam::180635532705:role/CI_SDK_V1_ROLE PACKAGE_NAME: aws-iot-device-sdk-python AWS_EC2_METADATA_DISABLED: true @@ -49,7 +48,7 @@ jobs: python-version: ${{ matrix.python-version }} - uses: aws-actions/configure-aws-credentials@v2 with: - role-to-assume: ${{ env.CI_JOBS_ROLE }} + role-to-assume: ${{ env.CI_SDK_V1_ROLE }} aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: Integration tests run: | From 3543e3f593b988af4c064653b01e1fd75023ca55 Mon Sep 17 00:00:00 2001 From: Vera Xia Date: Fri, 15 Nov 2024 15:53:55 -0800 Subject: [PATCH 09/13] update tests to use host argument --- ...IntegrationTestAsyncAPIGeneralNotificationCallbacks.py | 4 ++-- .../IntegrationTests/IntegrationTestClientReusability.py | 8 ++++---- .../IntegrationTestConfigurablePublishMessageQueueing.py | 4 ++-- .../IntegrationTests/IntegrationTestJobsClient.py | 4 ++-- .../IntegrationTests/IntegrationTestMQTTConnection.py | 4 ++-- ...tegrationTestOfflineQueueingForSubscribeUnsubscribe.py | 6 +++--- .../IntegrationTests/IntegrationTestProgressiveBackoff.py | 4 ++-- .../IntegrationTests/IntegrationTestShadow.py | 4 ++-- test-integration/run/run.sh | 7 +++++-- 9 files changed, 24 insertions(+), 21 deletions(-) diff --git a/test-integration/IntegrationTests/IntegrationTestAsyncAPIGeneralNotificationCallbacks.py b/test-integration/IntegrationTests/IntegrationTestAsyncAPIGeneralNotificationCallbacks.py index 152c48a..577c5fa 100644 --- a/test-integration/IntegrationTests/IntegrationTestAsyncAPIGeneralNotificationCallbacks.py +++ b/test-integration/IntegrationTests/IntegrationTestAsyncAPIGeneralNotificationCallbacks.py @@ -104,7 +104,7 @@ def get_random_string(length): my_check_in_manager = checkInManager(2) my_check_in_manager.verify(sys.argv) mode = my_check_in_manager.mode -HOST = my_check_in_manager.host +host = my_check_in_manager.host skip_when_match(ModeIsALPN(mode).And( Python2VersionLowerThan((2, 7, 10)).Or(Python3VersionLowerThan((3, 5, 0))) @@ -115,7 +115,7 @@ def get_random_string(length): print("Connecting...") callback_manager = CallbackManager() sdk_mqtt_client = MQTTClientManager()\ - .create_nonconnected_mqtt_client(mode, CLIENT_ID, HOST, (ROOT_CA, CERT, KEY), callback_manager) + .create_nonconnected_mqtt_client(mode, CLIENT_ID, host, (ROOT_CA, CERT, KEY), callback_manager) sdk_mqtt_client.connectAsync(keepAliveIntervalSecond=1, ackCallback=callback_manager.connack) # Add callback print("Wait some time to make sure we are connected...") time.sleep(10) # 10 sec diff --git a/test-integration/IntegrationTests/IntegrationTestClientReusability.py b/test-integration/IntegrationTests/IntegrationTestClientReusability.py index f747e19..56e77b8 100644 --- a/test-integration/IntegrationTests/IntegrationTestClientReusability.py +++ b/test-integration/IntegrationTests/IntegrationTestClientReusability.py @@ -40,7 +40,6 @@ NUMBER_OF_MESSAGES_PER_LOOP = 3 NUMBER_OF_LOOPS = 3 SUB_WAIT_TIME_OUT_SEC = 20 -HOST = "ajje7lpljulm4-ats.iot.us-east-1.amazonaws.com" ROOT_CA = "./test-integration/Credentials/rootCA.crt" CERT = "./test-integration/Credentials/certificate.pem.crt" KEY = "./test-integration/Credentials/privateKey.pem.key" @@ -94,9 +93,10 @@ def verify(self): ############################################################################ # Main # -my_check_in_manager = checkInManager(1) +my_check_in_manager = checkInManager(2) my_check_in_manager.verify(sys.argv) mode = my_check_in_manager.mode +host = my_check_in_manager.host skip_when_match(ModeIsALPN(mode).And( Python2VersionLowerThan((2, 7, 10)).Or(Python3VersionLowerThan((3, 5, 0))) @@ -104,9 +104,9 @@ def verify(self): simple_thread_manager = simpleThreadManager() -client_pub = MQTTClientManager().create_nonconnected_mqtt_client(mode, CLIENT_ID_PUB, HOST, (ROOT_CA, CERT, KEY)) +client_pub = MQTTClientManager().create_nonconnected_mqtt_client(mode, CLIENT_ID_PUB, host, (ROOT_CA, CERT, KEY)) print("Client publisher initialized.") -client_sub = MQTTClientManager().create_nonconnected_mqtt_client(mode, CLIENT_ID_SUB, HOST, (ROOT_CA, CERT, KEY)) +client_sub = MQTTClientManager().create_nonconnected_mqtt_client(mode, CLIENT_ID_SUB, host, (ROOT_CA, CERT, KEY)) print("Client subscriber initialized.") client_twins = ClientTwins(client_pub, client_sub) print("Client twins initialized.") diff --git a/test-integration/IntegrationTests/IntegrationTestConfigurablePublishMessageQueueing.py b/test-integration/IntegrationTests/IntegrationTestConfigurablePublishMessageQueueing.py index d6bfdc5..0d78f4f 100644 --- a/test-integration/IntegrationTests/IntegrationTestConfigurablePublishMessageQueueing.py +++ b/test-integration/IntegrationTests/IntegrationTestConfigurablePublishMessageQueueing.py @@ -274,10 +274,10 @@ def performConfigurableOfflinePublishQueueTest(clientPub, clientSub): # Check inputs -myCheckInManager = checkInManager.checkInManager(1) +myCheckInManager = checkInManager.checkInManager(2) myCheckInManager.verify(sys.argv) -host = "ajje7lpljulm4-ats.iot.us-east-1.amazonaws.com" +host = myCheckInManager.host rootCA = "./test-integration/Credentials/rootCA.crt" certificate = "./test-integration/Credentials/certificate.pem.crt" privateKey = "./test-integration/Credentials/privateKey.pem.key" diff --git a/test-integration/IntegrationTests/IntegrationTestJobsClient.py b/test-integration/IntegrationTests/IntegrationTestJobsClient.py index 18d8aa5..3653725 100644 --- a/test-integration/IntegrationTests/IntegrationTestJobsClient.py +++ b/test-integration/IntegrationTests/IntegrationTestJobsClient.py @@ -154,10 +154,10 @@ def _test_send_response_confirm(self, sendResult): ############################################################################ # Main # # Check inputs -myCheckInManager = checkInManager.checkInManager(1) +myCheckInManager = checkInManager.checkInManager(2) myCheckInManager.verify(sys.argv) -host = "ajje7lpljulm4-ats.iot.us-east-1.amazonaws.com" +host = myCheckInManager.host rootCA = "./test-integration/Credentials/rootCA.crt" certificate = "./test-integration/Credentials/certificate.pem.crt" privateKey = "./test-integration/Credentials/privateKey.pem.key" diff --git a/test-integration/IntegrationTests/IntegrationTestMQTTConnection.py b/test-integration/IntegrationTests/IntegrationTestMQTTConnection.py index 252770f..9adc38c 100644 --- a/test-integration/IntegrationTests/IntegrationTestMQTTConnection.py +++ b/test-integration/IntegrationTests/IntegrationTestMQTTConnection.py @@ -84,10 +84,10 @@ def _performPublish(self, pyCoreClient, topic, qos, payload): ############################################################################ # Main # # Check inputs -myCheckInManager = checkInManager.checkInManager(2) +myCheckInManager = checkInManager.checkInManager(3) myCheckInManager.verify(sys.argv) -host = "ajje7lpljulm4-ats.iot.us-east-1.amazonaws.com" +host = myCheckInManager.host rootCA = "./test-integration/Credentials/rootCA.crt" certificate = "./test-integration/Credentials/certificate.pem.crt" privateKey = "./test-integration/Credentials/privateKey.pem.key" diff --git a/test-integration/IntegrationTests/IntegrationTestOfflineQueueingForSubscribeUnsubscribe.py b/test-integration/IntegrationTests/IntegrationTestOfflineQueueingForSubscribeUnsubscribe.py index c06847d..37c1862 100644 --- a/test-integration/IntegrationTests/IntegrationTestOfflineQueueingForSubscribeUnsubscribe.py +++ b/test-integration/IntegrationTests/IntegrationTestOfflineQueueingForSubscribeUnsubscribe.py @@ -47,7 +47,6 @@ def get_random_string(length): TOPIC_B = "topic/test/offline_sub_unsub/b" + get_random_string(4) MESSAGE_PREFIX = "MagicMessage-" NUMBER_OF_PUBLISHES = 3 -HOST = "ajje7lpljulm4-ats.iot.us-east-1.amazonaws.com" ROOT_CA = "./test-integration/Credentials/rootCA.crt" CERT = "./test-integration/Credentials/certificate.pem.crt" KEY = "./test-integration/Credentials/privateKey.pem.key" @@ -74,7 +73,7 @@ def __init__(self, mode): time.sleep(2) # Make sure the subscription is valid def _create_connected_client(self, id_prefix): - return MQTTClientManager().create_connected_mqtt_client(self.__mode, id_prefix, HOST, (ROOT_CA, CERT, KEY)) + return MQTTClientManager().create_connected_mqtt_client(self.__mode, id_prefix, host, (ROOT_CA, CERT, KEY)) def start(self): thread_client_sub_unsub = Thread(target=self._thread_client_sub_unsub_runtime) @@ -192,9 +191,10 @@ def verify(self): ############################################################################ # Main # # Check inputs -my_check_in_manager = checkInManager(1) +my_check_in_manager = checkInManager(2) my_check_in_manager.verify(sys.argv) mode = my_check_in_manager.mode +host = my_check_in_manager.host skip_when_match(ModeIsALPN(mode).And( Python2VersionLowerThan((2, 7, 10)).Or(Python3VersionLowerThan((3, 5, 0))) diff --git a/test-integration/IntegrationTests/IntegrationTestProgressiveBackoff.py b/test-integration/IntegrationTests/IntegrationTestProgressiveBackoff.py index cd7b7ec..fc937ef 100644 --- a/test-integration/IntegrationTests/IntegrationTestProgressiveBackoff.py +++ b/test-integration/IntegrationTests/IntegrationTestProgressiveBackoff.py @@ -220,11 +220,11 @@ def verifyBackoffTime(answerList, resultList): ############################################################################ # Main # # Check inputs -myCheckInManager = checkInManager.checkInManager(2) +myCheckInManager = checkInManager.checkInManager(3) myCheckInManager.verify(sys.argv) #host via describe-endpoint on this OdinMS: com.amazonaws.iot.device.sdk.credentials.testing.websocket -host = "ajje7lpljulm4-ats.iot.us-east-1.amazonaws.com" +host = myCheckInManager.host rootCA = "./test-integration/Credentials/rootCA.crt" certificate = "./test-integration/Credentials/certificate.pem.crt" privateKey = "./test-integration/Credentials/privateKey.pem.key" diff --git a/test-integration/IntegrationTests/IntegrationTestShadow.py b/test-integration/IntegrationTests/IntegrationTestShadow.py index 9e2c2a5..9b2d85a 100644 --- a/test-integration/IntegrationTests/IntegrationTestShadow.py +++ b/test-integration/IntegrationTests/IntegrationTestShadow.py @@ -150,10 +150,10 @@ def randomString(lengthOfString): ############################################################################ # Main # # Check inputs -myCheckInManager = checkInManager.checkInManager(2) +myCheckInManager = checkInManager.checkInManager(3) myCheckInManager.verify(sys.argv) -host = "ajje7lpljulm4-ats.iot.us-east-1.amazonaws.com" +host = myCheckInManager.host rootCA = "./test-integration/Credentials/rootCA.crt" certificate = "./test-integration/Credentials/certificate.pem.crt" privateKey = "./test-integration/Credentials/privateKey.pem.key" diff --git a/test-integration/run/run.sh b/test-integration/run/run.sh index 1f06a6f..f08fb73 100755 --- a/test-integration/run/run.sh +++ b/test-integration/run/run.sh @@ -119,10 +119,13 @@ else echo "***************************************************" for file in `ls ${TEST_DIR}` do - # if [ ${file}x == "IntegrationTestMQTTConnection.py"x ]; then + # SKIP discovery for now + if [ ${file}x == "IntegrationTestDiscovery.py"x ]; then + continue; + fi if [ ${file##*.}x == "py"x ]; then echo "[SUB] Running test: ${file}..." - + Scale=10 case "$file" in "IntegrationTestMQTTConnection.py") Scale=$2 From 14abcc4ea8a8dfa444ffba13d044bf78dd9ac4a5 Mon Sep 17 00:00:00 2001 From: Vera Xia Date: Tue, 19 Nov 2024 09:32:01 -0800 Subject: [PATCH 10/13] quick run discovery test --- test-integration/run/run.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test-integration/run/run.sh b/test-integration/run/run.sh index f08fb73..ba44292 100755 --- a/test-integration/run/run.sh +++ b/test-integration/run/run.sh @@ -119,10 +119,10 @@ else echo "***************************************************" for file in `ls ${TEST_DIR}` do - # SKIP discovery for now - if [ ${file}x == "IntegrationTestDiscovery.py"x ]; then - continue; - fi + # # SKIP discovery for now + # if [ ${file}x == "IntegrationTestDiscovery.py"x ]; then + # continue; + # fi if [ ${file##*.}x == "py"x ]; then echo "[SUB] Running test: ${file}..." From 221154244ddadf601cf0943dfa294f60ae583e1c Mon Sep 17 00:00:00 2001 From: Vera Xia Date: Wed, 20 Nov 2024 18:11:46 -0800 Subject: [PATCH 11/13] quick test for gg discovery --- .../IntegrationTestDiscovery.py | 17 +++++------ test-integration/run/run.sh | 29 ++++++++++--------- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/test-integration/IntegrationTests/IntegrationTestDiscovery.py b/test-integration/IntegrationTests/IntegrationTestDiscovery.py index 8f23aa9..0209119 100644 --- a/test-integration/IntegrationTests/IntegrationTestDiscovery.py +++ b/test-integration/IntegrationTests/IntegrationTestDiscovery.py @@ -8,7 +8,6 @@ from TestToolLibrary.skip import ModeIsWebSocket -HOST = "arc9d2oott9lj-ats.iot.us-east-1.amazonaws.com" # 003261610643 PORT = 8443 CA = "./test-integration/Credentials/rootCA.crt" CERT = "./test-integration/Credentials/certificate_drs.pem.crt" @@ -16,12 +15,12 @@ TIME_OUT_SEC = 30 # This is a pre-generated test data from DRS integration tests ID_PREFIX = "Id-" -GGC_ARN = "arn:aws:iot:us-east-1:003261610643:thing/DRS_GGC_0kegiNGA_0" +GGC_ARN = "arn:aws:iot:us-east-1:180635532705:thing/CI_Greengrass_Discovery_Thing" GGC_PORT_NUMBER_BASE = 8080 GGC_HOST_ADDRESS_PREFIX = "192.168.101." METADATA_PREFIX = "Description-" GROUP_ID = "627bf63d-ae64-4f58-a18c-80a44fcf4088" -THING_NAME = "DRS_GGAD_0kegiNGA_0" +THING_NAME = "CI_Greengrass_Discovery_Thing" EXPECTED_CA_CONTENT = "-----BEGIN CERTIFICATE-----\n" \ "MIIEFTCCAv2gAwIBAgIVAPZfc4GMLZPmXbnoaZm6jRDqDs4+MA0GCSqGSIb3DQEB\n" \ "CwUAMIGoMQswCQYDVQQGEwJVUzEYMBYGA1UECgwPQW1hem9uLmNvbSBJbmMuMRww\n" \ @@ -108,10 +107,14 @@ } ''' +my_check_in_manager = checkInManager(2) +my_check_in_manager.verify(sys.argv) +mode = my_check_in_manager.mode +host = my_check_in_manager.host def create_discovery_info_provider(): discovery_info_provider = DiscoveryInfoProvider() - discovery_info_provider.configureEndpoint(HOST, PORT) + discovery_info_provider.configureEndpoint(host, PORT) discovery_info_provider.configureCredentials(CA, CERT, KEY) discovery_info_provider.configureTimeout(TIME_OUT_SEC) return discovery_info_provider @@ -152,9 +155,8 @@ def _verify_ca_list(ca_list): def verify_all_cores(discovery_info): - print("Verifying \"getAllCores\"...") ggc_info_list = discovery_info.getAllCores() - assert len(ggc_info_list) == 1 + print("Verifying \"getAllCores\"... {0}".format(len(ggc_info_list))) _verify_ggc_info(ggc_info_list[0]) print("Pass!") @@ -196,9 +198,6 @@ def verify_group_object(discovery_info): ############################################################################ # Main # -my_check_in_manager = checkInManager(1) -my_check_in_manager.verify(sys.argv) -mode = my_check_in_manager.mode skip_when_match(ModeIsWebSocket(mode), "This test is not applicable for mode: %s. Skipping..." % mode) diff --git a/test-integration/run/run.sh b/test-integration/run/run.sh index ba44292..35b34c7 100755 --- a/test-integration/run/run.sh +++ b/test-integration/run/run.sh @@ -38,11 +38,18 @@ AWSHost="arn:aws:secretsmanager:us-east-1:180635532705:secret:unit-test/endpoint AWSMutualAuth_TodWorker_private_key="arn:aws:secretsmanager:us-east-1:180635532705:secret:ci/mqtt5/us/Mqtt5Prod/key-kqgyvf" AWSMutualAuth_TodWorker_certificate="arn:aws:secretsmanager:us-east-1:180635532705:secret:ci/mqtt5/us/Mqtt5Prod/cert-VDI1Gd" -AWSGGDiscovery_TodWorker_private_key="arn:aws:secretsmanager:us-east-1:123124136734:secret:V1IotSdkIntegrationTestGGDiscoveryPrivateKey-YHQI1F" -AWSGGDiscovery_TodWorker_certificate="arn:aws:secretsmanager:us-east-1:123124136734:secret:V1IotSdkIntegrationTestGGDiscoveryCertificate-TwlAcS" +# AWSGGDiscovery_TodWorker_private_key="arn:aws:secretsmanager:us-east-1:180635532705:secret:ci/greengrassv1/key-QEWWRI" +# AWSGGDiscovery_TodWorker_certificate="arn:aws:secretsmanager:us-east-1:180635532705:secret:ci/greengrassv1/cert-2GJc26" -AWSSecretForWebsocket_TodWorker_KeyId="arn:aws:secretsmanager:us-east-1:123124136734:secret:V1IotSdkIntegrationTestWebsocketAccessKeyId-1YdB9z" -AWSSecretForWebsocket_TodWorker_SecretKey="arn:aws:secretsmanager:us-east-1:123124136734:secret:V1IotSdkIntegrationTestWebsocketSecretAccessKey-MKTSaV" +# AWSGGDiscovery_TodWorker_private_key="arn:aws:secretsmanager:us-east-1:180635532705:secret:ci/GreengrassDiscovery/key-Ki81FY" +# AWSGGDiscovery_TodWorker_certificate="arn:aws:secretsmanager:us-east-1:180635532705:secret:ci/GreengrassDiscovery/cert-bxUN3i" + +AWSGGDiscovery_TodWorker_private_key="arn:aws:secretsmanager:us-east-1:180635532705:secret:ci/Greengrass/key-tHGj1k" +AWSGGDiscovery_TodWorker_certificate="arn:aws:secretsmanager:us-east-1:180635532705:secret:ci/Greengrass/cert-6RYeYf" + + +# AWSSecretForWebsocket_TodWorker_KeyId="arn:aws:secretsmanager:us-east-1:123124136734:secret:V1IotSdkIntegrationTestWebsocketAccessKeyId-1YdB9z" +# AWSSecretForWebsocket_TodWorker_SecretKey="arn:aws:secretsmanager:us-east-1:123124136734:secret:V1IotSdkIntegrationTestWebsocketSecretAccessKey-MKTSaV" SDKLocation="./AWSIoTPythonSDK" @@ -51,7 +58,7 @@ CREDENTIAL_DIR="./test-integration/Credentials/" TEST_DIR="./test-integration/IntegrationTests/" CA_CERT_URL="https://www.amazontrust.com/repository/AmazonRootCA1.pem" CA_CERT_PATH=${CREDENTIAL_DIR}rootCA.crt -TestHost=$(python ${RetrieveAWSKeys} ${AWSHost}) +TestHost=$(python3 ${RetrieveAWSKeys} ${AWSHost}) echo ${TestHost} @@ -86,11 +93,7 @@ else python ${RetrieveAWSKeys} ${AWSDRSName_certificate} > ${CREDENTIAL_DIR}certificate_drs.pem.crt python ${RetrieveAWSKeys} ${AWSDRSName_privatekey} > ${CREDENTIAL_DIR}privateKey_drs.pem.key elif [ "$1"x == "Websocket"x ]; then - # ACCESS_KEY_ID_ARN=$(python ${RetrieveAWSKeys} ${AWSSecretForWebsocket_TodWorker_KeyId}) - # ACCESS_SECRET_KEY_ARN=$(python ${RetrieveAWSKeys} ${AWSSecretForWebsocket_TodWorker_SecretKey}) TestMode="Websocket" - # export AWS_ACCESS_KEY_ID=${ACCESS_KEY_ID_ARN} - # export AWS_SECRET_ACCESS_KEY=${ACCESS_SECRET_KEY_ARN} curl -s "${CA_CERT_URL}" > ${CA_CERT_PATH} echo -e "URL retrieved certificate data\n" elif [ "$1"x == "ALPN"x ]; then @@ -119,10 +122,10 @@ else echo "***************************************************" for file in `ls ${TEST_DIR}` do - # # SKIP discovery for now - # if [ ${file}x == "IntegrationTestDiscovery.py"x ]; then - # continue; - # fi + # SKIP discovery for now + if [ ${file}x != "IntegrationTestDiscovery.py"x ]; then + continue; + fi if [ ${file##*.}x == "py"x ]; then echo "[SUB] Running test: ${file}..." From cc8b4aa1577ac58acc87dfcd7c0da8dfeb1cf1a1 Mon Sep 17 00:00:00 2001 From: Vera Xia Date: Thu, 21 Nov 2024 09:42:59 -0800 Subject: [PATCH 12/13] migrate gg discovery test --- .../IntegrationTestDiscovery.py | 7 +++-- test-integration/run/run.sh | 29 ++++++------------- 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/test-integration/IntegrationTests/IntegrationTestDiscovery.py b/test-integration/IntegrationTests/IntegrationTestDiscovery.py index 0209119..417ec3b 100644 --- a/test-integration/IntegrationTests/IntegrationTestDiscovery.py +++ b/test-integration/IntegrationTests/IntegrationTestDiscovery.py @@ -15,12 +15,12 @@ TIME_OUT_SEC = 30 # This is a pre-generated test data from DRS integration tests ID_PREFIX = "Id-" -GGC_ARN = "arn:aws:iot:us-east-1:180635532705:thing/CI_Greengrass_Discovery_Thing" +GGC_ARN = "arn:aws:iot:us-east-1:003261610643:thing/DRS_GGC_0kegiNGA_0" GGC_PORT_NUMBER_BASE = 8080 GGC_HOST_ADDRESS_PREFIX = "192.168.101." METADATA_PREFIX = "Description-" GROUP_ID = "627bf63d-ae64-4f58-a18c-80a44fcf4088" -THING_NAME = "CI_Greengrass_Discovery_Thing" +THING_NAME = "DRS_GGAD_0kegiNGA_0" EXPECTED_CA_CONTENT = "-----BEGIN CERTIFICATE-----\n" \ "MIIEFTCCAv2gAwIBAgIVAPZfc4GMLZPmXbnoaZm6jRDqDs4+MA0GCSqGSIb3DQEB\n" \ "CwUAMIGoMQswCQYDVQQGEwJVUzEYMBYGA1UECgwPQW1hem9uLmNvbSBJbmMuMRww\n" \ @@ -155,8 +155,9 @@ def _verify_ca_list(ca_list): def verify_all_cores(discovery_info): + print("Verifying \"getAllCores\"...") ggc_info_list = discovery_info.getAllCores() - print("Verifying \"getAllCores\"... {0}".format(len(ggc_info_list))) + assert len(ggc_info_list) == 1 _verify_ggc_info(ggc_info_list[0]) print("Pass!") diff --git a/test-integration/run/run.sh b/test-integration/run/run.sh index 35b34c7..8e23c91 100755 --- a/test-integration/run/run.sh +++ b/test-integration/run/run.sh @@ -33,23 +33,14 @@ # Define const USAGE="usage: run.sh " -AWSHost="arn:aws:secretsmanager:us-east-1:180635532705:secret:unit-test/endpoint-HSpeEu" +UnitTestHostArn="arn:aws:secretsmanager:us-east-1:180635532705:secret:unit-test/endpoint-HSpeEu" +GreenGrassHostArn="arn:aws:secretsmanager:us-east-1:180635532705:secret:ci/greengrassv1/endpoint-DgM00X" AWSMutualAuth_TodWorker_private_key="arn:aws:secretsmanager:us-east-1:180635532705:secret:ci/mqtt5/us/Mqtt5Prod/key-kqgyvf" AWSMutualAuth_TodWorker_certificate="arn:aws:secretsmanager:us-east-1:180635532705:secret:ci/mqtt5/us/Mqtt5Prod/cert-VDI1Gd" -# AWSGGDiscovery_TodWorker_private_key="arn:aws:secretsmanager:us-east-1:180635532705:secret:ci/greengrassv1/key-QEWWRI" -# AWSGGDiscovery_TodWorker_certificate="arn:aws:secretsmanager:us-east-1:180635532705:secret:ci/greengrassv1/cert-2GJc26" - -# AWSGGDiscovery_TodWorker_private_key="arn:aws:secretsmanager:us-east-1:180635532705:secret:ci/GreengrassDiscovery/key-Ki81FY" -# AWSGGDiscovery_TodWorker_certificate="arn:aws:secretsmanager:us-east-1:180635532705:secret:ci/GreengrassDiscovery/cert-bxUN3i" - -AWSGGDiscovery_TodWorker_private_key="arn:aws:secretsmanager:us-east-1:180635532705:secret:ci/Greengrass/key-tHGj1k" -AWSGGDiscovery_TodWorker_certificate="arn:aws:secretsmanager:us-east-1:180635532705:secret:ci/Greengrass/cert-6RYeYf" - - -# AWSSecretForWebsocket_TodWorker_KeyId="arn:aws:secretsmanager:us-east-1:123124136734:secret:V1IotSdkIntegrationTestWebsocketAccessKeyId-1YdB9z" -# AWSSecretForWebsocket_TodWorker_SecretKey="arn:aws:secretsmanager:us-east-1:123124136734:secret:V1IotSdkIntegrationTestWebsocketSecretAccessKey-MKTSaV" +AWSGGDiscovery_TodWorker_private_key="arn:aws:secretsmanager:us-east-1:180635532705:secret:V1IotSdkIntegrationTestGGDiscoveryPrivateKey-BsLvNP" +AWSGGDiscovery_TodWorker_certificate="arn:aws:secretsmanager:us-east-1:180635532705:secret:V1IotSdkIntegrationTestGGDiscoveryCertificate-DSwdhA" SDKLocation="./AWSIoTPythonSDK" @@ -58,8 +49,8 @@ CREDENTIAL_DIR="./test-integration/Credentials/" TEST_DIR="./test-integration/IntegrationTests/" CA_CERT_URL="https://www.amazontrust.com/repository/AmazonRootCA1.pem" CA_CERT_PATH=${CREDENTIAL_DIR}rootCA.crt -TestHost=$(python3 ${RetrieveAWSKeys} ${AWSHost}) -echo ${TestHost} +TestHost=$(python ${RetrieveAWSKeys} ${UnitTestHostArn}) +GreengrassHost=$(python ${RetrieveAWSKeys} ${GreenGrassHostArn}) @@ -122,14 +113,11 @@ else echo "***************************************************" for file in `ls ${TEST_DIR}` do - # SKIP discovery for now - if [ ${file}x != "IntegrationTestDiscovery.py"x ]; then - continue; - fi if [ ${file##*.}x == "py"x ]; then echo "[SUB] Running test: ${file}..." Scale=10 + Host=TestHost case "$file" in "IntegrationTestMQTTConnection.py") Scale=$2 ;; @@ -141,7 +129,8 @@ else ;; "IntegrationTestConfigurablePublishMessageQueueing.py") Scale="" ;; - "IntegrationTestDiscovery.py") Scale="" + "IntegrationTestDiscovery.py") Scale="" + Host=${GreengrassHost} ;; "IntegrationTestAsyncAPIGeneralNotificationCallbacks.py") Scale="" ;; From fad57a1f044e24c8fcb9c2bdb6067cb9a8f6c3f2 Mon Sep 17 00:00:00 2001 From: Vera Xia Date: Thu, 21 Nov 2024 10:03:57 -0800 Subject: [PATCH 13/13] more comments --- test-integration/IntegrationTests/IntegrationTestDiscovery.py | 1 + 1 file changed, 1 insertion(+) diff --git a/test-integration/IntegrationTests/IntegrationTestDiscovery.py b/test-integration/IntegrationTests/IntegrationTestDiscovery.py index 417ec3b..2fac25b 100644 --- a/test-integration/IntegrationTests/IntegrationTestDiscovery.py +++ b/test-integration/IntegrationTests/IntegrationTestDiscovery.py @@ -14,6 +14,7 @@ KEY = "./test-integration/Credentials/privateKey_drs.pem.key" TIME_OUT_SEC = 30 # This is a pre-generated test data from DRS integration tests +# The test resources point to account # 003261610643 ID_PREFIX = "Id-" GGC_ARN = "arn:aws:iot:us-east-1:003261610643:thing/DRS_GGC_0kegiNGA_0" GGC_PORT_NUMBER_BASE = 8080