From 5b5fc876c05c015cac88b5216baf6bd7db962f8c Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Mon, 5 Jun 2023 16:23:31 -0400 Subject: [PATCH 1/9] Run Greengrass Basic Discovery in CI --- .github/workflows/ci.yml | 9 +++++ .../ci_run_greengrass_discovery_cfg.json | 39 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 .github/workflows/ci_run_greengrass_discovery_cfg.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9b14cc2c..baa79fed 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,6 +28,7 @@ env: CI_SHADOW_ROLE: arn:aws:iam::180635532705:role/CI_Shadow_Role CI_JOBS_ROLE: arn:aws:iam::180635532705:role/CI_Jobs_Role CI_FLEET_PROVISIONING_ROLE: arn:aws:iam::180635532705:role/service-role/CI_FleetProvisioning_Role + CI_GREENGRASS_ROLE: arn:aws:iam::180635532705:role/CI_Greengrass_Role CI_DEVICE_ADVISOR: arn:aws:iam::180635532705:role/CI_DeviceAdvisor_Role CI_MQTT5_ROLE: arn:aws:iam::180635532705:role/CI_MQTT5_Role CI_BUILD_AND_TEST_ROLE: arn:aws:iam::180635532705:role/V2_SDK_Unit_Testing @@ -297,6 +298,14 @@ jobs: Sample_UUID=$(python3 -c "import uuid; print (uuid.uuid4())") python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_fleet_provisioning_cfg.json --input_uuid ${Sample_UUID} python3 ${{ env.CI_UTILS_FOLDER }}/delete_iot_thing_ci.py --thing_name "Fleet_Thing_${Sample_UUID}" --region "us-east-1" + - name: configure AWS credentials (Greengrass) + uses: aws-actions/configure-aws-credentials@v1 + with: + role-to-assume: ${{ env.CI_GREENGRASS_ROLE }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run Greengrass Discovery sample + run: | + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_greengrass_discovery.json # check that docs can still build check-docs: diff --git a/.github/workflows/ci_run_greengrass_discovery_cfg.json b/.github/workflows/ci_run_greengrass_discovery_cfg.json new file mode 100644 index 00000000..d2e10f31 --- /dev/null +++ b/.github/workflows/ci_run_greengrass_discovery_cfg.json @@ -0,0 +1,39 @@ +{ + "language": "Python", + "sample_file": "./aws-iot-device-sdk-python-v2/samples/basic_discovery.py", + "sample_region": "us-east-1", + "sample_main_class": "", + "arguments": [ + { + "name": "--endpoint", + "secret": "ci/endpoint" + }, + { + "name": "--cert", + "secret": "ci/Greengrass/cert", + "filename": "tmp_certificate.pem" + }, + { + "name": "--key", + "secret": "ci/Greengrass/key", + "filename": "tmp_key.pem" + }, + { + "name": "--ca_file", + "secret": "ci/Greengrass/ca", + "filename": "tmp_key.pem" + }, + { + "name": "--region", + "data": "us-east-1" + }, + { + "name": "--thing_name", + "data": "CI_GreenGrass_Thing" + }, + { + "name": "--print_discovery_resp_only", + "data": "true" + } + ] +} From 0ea1847bfaa3b01065e9f0430ce9cf8db400e882 Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Mon, 5 Jun 2023 16:27:26 -0400 Subject: [PATCH 2/9] Fix filepath --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index baa79fed..19f6adcf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -305,7 +305,7 @@ jobs: aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: run Greengrass Discovery sample run: | - python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_greengrass_discovery.json + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_greengrass_discovery_cfg.json # check that docs can still build check-docs: From 786933eaf17938836ecb0335bd230d590fbe16a0 Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Mon, 5 Jun 2023 16:32:48 -0400 Subject: [PATCH 3/9] Remove the endpoint argument --- .github/workflows/ci_run_greengrass_discovery_cfg.json | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/ci_run_greengrass_discovery_cfg.json b/.github/workflows/ci_run_greengrass_discovery_cfg.json index d2e10f31..13f1cec9 100644 --- a/.github/workflows/ci_run_greengrass_discovery_cfg.json +++ b/.github/workflows/ci_run_greengrass_discovery_cfg.json @@ -4,10 +4,6 @@ "sample_region": "us-east-1", "sample_main_class": "", "arguments": [ - { - "name": "--endpoint", - "secret": "ci/endpoint" - }, { "name": "--cert", "secret": "ci/Greengrass/cert", @@ -33,7 +29,7 @@ }, { "name": "--print_discovery_resp_only", - "data": "true" + "data": "" } ] } From de7754395034cc38b34b5c151af275e90dfca212 Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Mon, 5 Jun 2023 16:38:01 -0400 Subject: [PATCH 4/9] Discover, not discovery --- .github/workflows/ci_run_greengrass_discovery_cfg.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_run_greengrass_discovery_cfg.json b/.github/workflows/ci_run_greengrass_discovery_cfg.json index 13f1cec9..abb8483d 100644 --- a/.github/workflows/ci_run_greengrass_discovery_cfg.json +++ b/.github/workflows/ci_run_greengrass_discovery_cfg.json @@ -28,7 +28,7 @@ "data": "CI_GreenGrass_Thing" }, { - "name": "--print_discovery_resp_only", + "name": "--print_discover_resp_only", "data": "" } ] From 2972e7d0a7f86d59d642c555546343eac8059ddd Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Mon, 5 Jun 2023 16:44:56 -0400 Subject: [PATCH 5/9] Properly ignore empty data --- utils/run_sample_ci.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/utils/run_sample_ci.py b/utils/run_sample_ci.py index fb6dc6ef..512d6fe2 100644 --- a/utils/run_sample_ci.py +++ b/utils/run_sample_ci.py @@ -83,7 +83,8 @@ def setup_json_arguments_list(parsed_commands): if isinstance(tmp_value, str) and 'input_uuid' in parsed_commands: if ("$INPUT_UUID" in tmp_value): tmp_value = tmp_value.replace("$INPUT_UUID", parsed_commands.input_uuid) - config_json_arguments_list.append(tmp_value) + if (tmp_value != None and tmp_value != ""): + config_json_arguments_list.append(tmp_value) # None of the above? Just print an error else: From 2d9e13976df50539b672c226141db0b26788f28e Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Mon, 5 Jun 2023 16:48:25 -0400 Subject: [PATCH 6/9] Fix CA file copy-paste --- .github/workflows/ci_run_greengrass_discovery_cfg.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_run_greengrass_discovery_cfg.json b/.github/workflows/ci_run_greengrass_discovery_cfg.json index abb8483d..8d9a247d 100644 --- a/.github/workflows/ci_run_greengrass_discovery_cfg.json +++ b/.github/workflows/ci_run_greengrass_discovery_cfg.json @@ -17,7 +17,7 @@ { "name": "--ca_file", "secret": "ci/Greengrass/ca", - "filename": "tmp_key.pem" + "filename": "tmp_ca.pem" }, { "name": "--region", From 63ddaffad25233682903b7364962bc1a518e16b2 Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Tue, 6 Jun 2023 09:35:41 -0400 Subject: [PATCH 7/9] Try using a test Greengrass Device --- .github/workflows/ci_run_greengrass_discovery_cfg.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_run_greengrass_discovery_cfg.json b/.github/workflows/ci_run_greengrass_discovery_cfg.json index 8d9a247d..21ccda5c 100644 --- a/.github/workflows/ci_run_greengrass_discovery_cfg.json +++ b/.github/workflows/ci_run_greengrass_discovery_cfg.json @@ -25,7 +25,7 @@ }, { "name": "--thing_name", - "data": "CI_GreenGrass_Thing" + "data": "CI_GreenGrass_Thing_Test" }, { "name": "--print_discover_resp_only", From 47b03f5d0bf43e34f4a23d7137b33316d2686966 Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Tue, 6 Jun 2023 11:53:53 -0400 Subject: [PATCH 8/9] This should work now, I think --- .github/workflows/ci_run_greengrass_discovery_cfg.json | 6 +++++- samples/basic_discovery.py | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci_run_greengrass_discovery_cfg.json b/.github/workflows/ci_run_greengrass_discovery_cfg.json index 21ccda5c..5e67b26c 100644 --- a/.github/workflows/ci_run_greengrass_discovery_cfg.json +++ b/.github/workflows/ci_run_greengrass_discovery_cfg.json @@ -25,7 +25,11 @@ }, { "name": "--thing_name", - "data": "CI_GreenGrass_Thing_Test" + "data": "CI_GreenGrass_Thing" + }, + { + "name": "--is_ci", + "data": "true" }, { "name": "--print_discover_resp_only", diff --git a/samples/basic_discovery.py b/samples/basic_discovery.py index 02b5eeec..5aecd0da 100644 --- a/samples/basic_discovery.py +++ b/samples/basic_discovery.py @@ -37,7 +37,11 @@ resp_future = discovery_client.discover(cmdData.input_thing_name) discover_response = resp_future.result() -print(discover_response) +if (cmdData.input_is_ci): + print("Received a greengrass discovery result! Not showing result in CI currently.") +else: + print(discover_response) + if (cmdData.input_print_discovery_resp_only): exit(0) From 26f9129f68a49ac3ca2fbb395a5bc66b323a8473 Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Tue, 6 Jun 2023 14:40:14 -0400 Subject: [PATCH 9/9] Trivial change to make sure CI still works --- samples/basic_discovery.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/basic_discovery.py b/samples/basic_discovery.py index 5aecd0da..63a69d72 100644 --- a/samples/basic_discovery.py +++ b/samples/basic_discovery.py @@ -38,7 +38,7 @@ discover_response = resp_future.result() if (cmdData.input_is_ci): - print("Received a greengrass discovery result! Not showing result in CI currently.") + print("Received a greengrass discovery result! Not showing result in CI for possible data sensitivity.") else: print(discover_response)