From 3f51681d17051ef6bb1e478b71df2d4101b5ce8a Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Tue, 14 May 2024 15:26:37 -0700 Subject: [PATCH 01/79] Run example gg component --- tests/greengrass/sdk-gg-ipc/.gitignore | 10 ++ tests/greengrass/sdk-gg-ipc/gdk-config.json | 24 ++++ .../sdk-gg-ipc/gg-e2e-tests/pom.xml | 63 ++++++++ .../java/com/aws/greengrass/CustomSteps.java | 17 +++ .../greengrass/features/component.feature | 10 ++ .../features/confidenceTest.feature | 134 ++++++++++++++++++ tests/greengrass/sdk-gg-ipc/main.py | 8 ++ tests/greengrass/sdk-gg-ipc/recipe.yaml | 17 +++ 8 files changed, 283 insertions(+) create mode 100644 tests/greengrass/sdk-gg-ipc/.gitignore create mode 100644 tests/greengrass/sdk-gg-ipc/gdk-config.json create mode 100644 tests/greengrass/sdk-gg-ipc/gg-e2e-tests/pom.xml create mode 100644 tests/greengrass/sdk-gg-ipc/gg-e2e-tests/src/main/java/com/aws/greengrass/CustomSteps.java create mode 100644 tests/greengrass/sdk-gg-ipc/gg-e2e-tests/src/main/resources/greengrass/features/component.feature create mode 100644 tests/greengrass/sdk-gg-ipc/gg-e2e-tests/src/main/resources/greengrass/features/confidenceTest.feature create mode 100644 tests/greengrass/sdk-gg-ipc/main.py create mode 100644 tests/greengrass/sdk-gg-ipc/recipe.yaml diff --git a/tests/greengrass/sdk-gg-ipc/.gitignore b/tests/greengrass/sdk-gg-ipc/.gitignore new file mode 100644 index 000000000..029e222fa --- /dev/null +++ b/tests/greengrass/sdk-gg-ipc/.gitignore @@ -0,0 +1,10 @@ +*build/ +build +*dist/ +*.egg-info +*__pycache__ +*htmlcov/ +*.coverage +*.iml +*.DS_Store +*.eggs \ No newline at end of file diff --git a/tests/greengrass/sdk-gg-ipc/gdk-config.json b/tests/greengrass/sdk-gg-ipc/gdk-config.json new file mode 100644 index 000000000..da8f5ed13 --- /dev/null +++ b/tests/greengrass/sdk-gg-ipc/gdk-config.json @@ -0,0 +1,24 @@ +{ + "component": { + "software.amazon.awssdk.sdk-gg-ipc": { + "author": "iot-device-sdk", + "version": "NEXT_PATCH", + "build": { + "build_system": "zip", + "options": { + "zip_name": "" + } + }, + "publish": { + "bucket": "", + "region": "" + } + } + }, + "gdk_version": "1.3.0", + "test-e2e": { + "gtf_options": { + "tags": "testgg" + } + } +} diff --git a/tests/greengrass/sdk-gg-ipc/gg-e2e-tests/pom.xml b/tests/greengrass/sdk-gg-ipc/gg-e2e-tests/pom.xml new file mode 100644 index 000000000..460832fcb --- /dev/null +++ b/tests/greengrass/sdk-gg-ipc/gg-e2e-tests/pom.xml @@ -0,0 +1,63 @@ + + + 4.0.0 + + com.aws.greengrass + uat-features + jar + 1.0.0 + OTF + + + 1.2.0-SNAPSHOT + 1.8 + 1.8 + + + + + greengrass-common + greengrass common + + https://d2jrmugq4soldf.cloudfront.net/snapshots + + + + + + + com.aws.greengrass + aws-greengrass-testing-standalone + ${otf.version} + compile + + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.2 + + + package + + shade + + + + + + + com.aws.greengrass.testing.launcher.TestLauncher + + + + + + + + + diff --git a/tests/greengrass/sdk-gg-ipc/gg-e2e-tests/src/main/java/com/aws/greengrass/CustomSteps.java b/tests/greengrass/sdk-gg-ipc/gg-e2e-tests/src/main/java/com/aws/greengrass/CustomSteps.java new file mode 100644 index 000000000..b3808fedb --- /dev/null +++ b/tests/greengrass/sdk-gg-ipc/gg-e2e-tests/src/main/java/com/aws/greengrass/CustomSteps.java @@ -0,0 +1,17 @@ +package com.aws.greengrass; + +import io.cucumber.guice.ScenarioScoped; +import io.cucumber.java.en.And; + +/** + * Change this or create a file like this one to define custom steps to test functionality + * specific to your component + */ +@ScenarioScoped +public class CustomSteps { + + @And("I call my custom step") + public void customStep() { + System.out.println("My custom step was called "); + } +} \ No newline at end of file diff --git a/tests/greengrass/sdk-gg-ipc/gg-e2e-tests/src/main/resources/greengrass/features/component.feature b/tests/greengrass/sdk-gg-ipc/gg-e2e-tests/src/main/resources/greengrass/features/component.feature new file mode 100644 index 000000000..7e1a6f4e3 --- /dev/null +++ b/tests/greengrass/sdk-gg-ipc/gg-e2e-tests/src/main/resources/greengrass/features/component.feature @@ -0,0 +1,10 @@ +Feature: Testing features of Greengrassv2 IPC sample + @testgg + Scenario: As a developer, I can create a component and deploy it on my device + Given my device is registered as a Thing + And my device is running Greengrass + When I create a Greengrass deployment with components + | software.amazon.awssdk.sdk-gg-ipc | file:recipe.yaml | + And I deploy the Greengrass deployment configuration + Then the Greengrass deployment is COMPLETED on the device after 180 seconds + And I call my custom step diff --git a/tests/greengrass/sdk-gg-ipc/gg-e2e-tests/src/main/resources/greengrass/features/confidenceTest.feature b/tests/greengrass/sdk-gg-ipc/gg-e2e-tests/src/main/resources/greengrass/features/confidenceTest.feature new file mode 100644 index 000000000..37808c57a --- /dev/null +++ b/tests/greengrass/sdk-gg-ipc/gg-e2e-tests/src/main/resources/greengrass/features/confidenceTest.feature @@ -0,0 +1,134 @@ +Feature: Confidence Test Suite + + Background: + Given my device is registered as a Thing + And my device is running Greengrass + + @ConfidenceTest + Scenario: As a Developer, I can deploy GDK_COMPONENT_NAME to my device and see it is working as expected + When I create a Greengrass deployment with components + | GDK_COMPONENT_NAME | GDK_COMPONENT_RECIPE_FILE | + | aws.greengrass.Cli | LATEST | + And I deploy the Greengrass deployment configuration + Then the Greengrass deployment is COMPLETED on the device after 180 seconds + # Update component state accordingly. Possible states: {RUNNING, FINISHED, BROKEN, STOPPING} + And I verify the GDK_COMPONENT_NAME component is RUNNING using the greengrass-cli + + @ConfidenceTest + Scenario: As a Developer, I can deploy GDK_COMPONENT_NAME, stop it and start it again + When I create a Greengrass deployment with components + | GDK_COMPONENT_NAME | GDK_COMPONENT_RECIPE_FILE | + | aws.greengrass.Cli | LATEST | + And I deploy the Greengrass deployment configuration + Then the Greengrass deployment is COMPLETED on the device after 180 seconds + # Update component state accordingly. Possible states: {RUNNING, FINISHED, BROKEN, STOPPING} + Then I verify the GDK_COMPONENT_NAME component is RUNNING using the greengrass-cli + When I use greengrass-cli to stop the component GDK_COMPONENT_NAME + # Update component state accordingly. Possible states: {RUNNING, FINISHED, BROKEN, STOPPING} + Then I verify the GDK_COMPONENT_NAME component is FINISHED using the greengrass-cli + When I use greengrass-cli to restart the component GDK_COMPONENT_NAME + # Update component state accordingly. Possible states: {RUNNING, FINISHED, BROKEN, STOPPING} + Then I verify the GDK_COMPONENT_NAME component is RUNNING using the greengrass-cli + + @ConfidenceTest + Scenario: As a Developer, I can deploy GDK_COMPONENT_NAME and restart Greengrass to check if it is still working as expected + When I create a Greengrass deployment with components + | GDK_COMPONENT_NAME | GDK_COMPONENT_RECIPE_FILE | + | aws.greengrass.Cli | LATEST | + And I deploy the Greengrass deployment configuration + Then the Greengrass deployment is COMPLETED on the device after 180 seconds + # Update component state accordingly. Possible states: {RUNNING, FINISHED, BROKEN, STOPPING} + Then I verify the GDK_COMPONENT_NAME component is RUNNING using the greengrass-cli + When I restart Greengrass + Then I wait 5 seconds + # Update component state accordingly. Possible states: {RUNNING, FINISHED, BROKEN, STOPPING} + And I verify the GDK_COMPONENT_NAME component is RUNNING using the greengrass-cli + + @ConfidenceTest + Scenario: As a Developer, I can deploy GDK_COMPONENT_NAME and disable internet to check if component is working. Restore internet to check if component is still working + When I create a Greengrass deployment with components + | GDK_COMPONENT_NAME | GDK_COMPONENT_RECIPE_FILE | + | aws.greengrass.Cli | LATEST | + And I deploy the Greengrass deployment configuration + Then the Greengrass deployment is COMPLETED on the device after 180 seconds + # Update component state accordingly. Possible states: {RUNNING, FINISHED, BROKEN, STOPPING} + Then I verify the GDK_COMPONENT_NAME component is RUNNING using the greengrass-cli + When I set device network connectivity to OFFLINE + And I restart Greengrass + Then I wait 5 seconds + # Update component state accordingly. Possible states: {RUNNING, FINISHED, BROKEN, STOPPING} + Then I verify the GDK_COMPONENT_NAME component is RUNNING using the greengrass-cli + When I set device network connectivity to ONLINE + # Update component state accordingly. Possible states: {RUNNING, FINISHED, BROKEN, STOPPING} + Then I verify the GDK_COMPONENT_NAME component is RUNNING using the greengrass-cli + + @ConfidenceTest + Scenario: As a Developer, I can deploy GDK_COMPONENT_NAME to my device and see it is working as expected after an additional local deployment to change component configuration + When I create a Greengrass deployment with components + | GDK_COMPONENT_NAME | GDK_COMPONENT_RECIPE_FILE | + | aws.greengrass.Cli | LATEST | + And I deploy the Greengrass deployment configuration + Then the Greengrass deployment is COMPLETED on the device after 180 seconds + # Update component state accordingly. Possible states: {RUNNING, FINISHED, BROKEN, STOPPING}. + Then I verify the GDK_COMPONENT_NAME component is RUNNING using the greengrass-cli + # Update the MERGE deployment configuration with the intended key-value pairs. + And I update my local deployment configuration, setting the component GDK_COMPONENT_NAME configuration to: + """ + { + "MERGE": { + "configurationKey": "keyValue" + } + } + """ + Then the local Greengrass deployment is SUCCEEDED on the device after 120 seconds + # Update component state accordingly. Possible states: {RUNNING, FINISHED, BROKEN, STOPPING}. Additional verification steps may be added here too. + And I verify the GDK_COMPONENT_NAME component is RUNNING using the greengrass-cli + + @ConfidenceTest + Scenario: As a Developer, I can deploy GDK_COMPONENT_NAME to my device with configuration updates and see it is working as expected + When I create a Greengrass deployment with components + | GDK_COMPONENT_NAME | GDK_COMPONENT_RECIPE_FILE | + | aws.greengrass.Cli | LATEST | + # Update the MERGE deployment configuration with the intended key-value pairs. + And I update my Greengrass deployment configuration, setting the component GDK_COMPONENT_NAME configuration to: + """ + { + "MERGE": { + "configurationKey": "keyValue" + } + } + """ + And I deploy the Greengrass deployment configuration + Then the Greengrass deployment is COMPLETED on the device after 180 seconds + # Update component state accordingly. Possible states: {RUNNING, FINISHED, BROKEN, STOPPING}. Additional verification steps may be added here too. + Then I verify the GDK_COMPONENT_NAME component is RUNNING using the greengrass-cli + + @ConfidenceTest + Scenario: As a Developer, I can deploy GDK_COMPONENT_NAME to my device and verify device RAM has not increased by more than a specified threshold + # To extend the test case, record RAM usage statistic under a unique identifier, such as RAM1 here. + When I record the device's RAM usage statistic as RAM1 + And I create a Greengrass deployment with components + | GDK_COMPONENT_NAME | GDK_COMPONENT_RECIPE_FILE | + | aws.greengrass.Cli | LATEST | + And I deploy the Greengrass deployment configuration + Then the Greengrass deployment is COMPLETED on the device after 180 seconds + # Update component state accordingly. Possible states: {RUNNING, FINISHED, BROKEN, STOPPING} + Then I verify the GDK_COMPONENT_NAME component is RUNNING using the greengrass-cli + When I record the device's RAM usage statistic as RAM2 + # Update the intended threshold as needed, in MB. If extending the test case, use two unique identifiers recorded during previous steps. + Then the increase in the RAM usage from RAM1 to RAM2 is less than 1024 MB + + @ConfidenceTest + Scenario: As a Developer, I can deploy GDK_COMPONENT_NAME to my device and verify device CPU usage has not increased by more than a specified threshold + # To extend the test case, record CPU usage statistic under a unique identifier, such as CPU1 here. + When I record the device's CPU usage statistic as CPU1 + And I create a Greengrass deployment with components + | GDK_COMPONENT_NAME | GDK_COMPONENT_RECIPE_FILE | + | aws.greengrass.Cli | LATEST | + And I deploy the Greengrass deployment configuration + Then the Greengrass deployment is COMPLETED on the device after 180 seconds + # Update component state accordingly. Possible states: {RUNNING, FINISHED, BROKEN, STOPPING} + Then I verify the GDK_COMPONENT_NAME component is RUNNING using the greengrass-cli + When I record the device's CPU usage statistic as CPU2 + # Update the intended threshold as needed, as percent utilization. If extending the test case, use two unique identifiers recorded during previous steps. + Then the increase in the CPU usage from CPU1 to CPU2 is less than 25 percent \ No newline at end of file diff --git a/tests/greengrass/sdk-gg-ipc/main.py b/tests/greengrass/sdk-gg-ipc/main.py new file mode 100644 index 000000000..d236b968c --- /dev/null +++ b/tests/greengrass/sdk-gg-ipc/main.py @@ -0,0 +1,8 @@ +import sys + +def main(): + args = sys.argv[1:] + print("Hello {}".format(" ".join(args))) + +if __name__ == "__main__": + main() diff --git a/tests/greengrass/sdk-gg-ipc/recipe.yaml b/tests/greengrass/sdk-gg-ipc/recipe.yaml new file mode 100644 index 000000000..31d2a093e --- /dev/null +++ b/tests/greengrass/sdk-gg-ipc/recipe.yaml @@ -0,0 +1,17 @@ +--- +RecipeFormatVersion: "2020-01-25" +ComponentName: software.amazon.awssdk.sdk-gg-ipc +ComponentVersion: "1.0.0" +ComponentDescription: "This is test for the Greengrass IPC sample" +ComponentPublisher: "iot-device-sdk" +ComponentConfiguration: + DefaultConfiguration: + Message: "World" +Manifests: + - Platform: + os: all + Artifacts: + - URI: "file:main.py" + Lifecycle: + Run: | + python3 -u {artifacts:path}/main.py {configuration:/Message} From 45f7f1f54116ba754a80426c2a675aaf34db2a9d Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Tue, 14 May 2024 15:42:29 -0700 Subject: [PATCH 02/79] Check log file --- .../src/main/resources/greengrass/features/component.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/greengrass/sdk-gg-ipc/gg-e2e-tests/src/main/resources/greengrass/features/component.feature b/tests/greengrass/sdk-gg-ipc/gg-e2e-tests/src/main/resources/greengrass/features/component.feature index 7e1a6f4e3..8ccd00ccf 100644 --- a/tests/greengrass/sdk-gg-ipc/gg-e2e-tests/src/main/resources/greengrass/features/component.feature +++ b/tests/greengrass/sdk-gg-ipc/gg-e2e-tests/src/main/resources/greengrass/features/component.feature @@ -7,4 +7,4 @@ Feature: Testing features of Greengrassv2 IPC sample | software.amazon.awssdk.sdk-gg-ipc | file:recipe.yaml | And I deploy the Greengrass deployment configuration Then the Greengrass deployment is COMPLETED on the device after 180 seconds - And I call my custom step + And the software.amazon.awssdk.sdk-gg-ipc log on the device contains the line "Hello World" within 20 seconds From ea0cfc8eb63a1c26e7c3ac97e8964ffbba08785a Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Tue, 14 May 2024 15:46:41 -0700 Subject: [PATCH 03/79] Remove java extra test --- .../java/com/aws/greengrass/CustomSteps.java | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 tests/greengrass/sdk-gg-ipc/gg-e2e-tests/src/main/java/com/aws/greengrass/CustomSteps.java diff --git a/tests/greengrass/sdk-gg-ipc/gg-e2e-tests/src/main/java/com/aws/greengrass/CustomSteps.java b/tests/greengrass/sdk-gg-ipc/gg-e2e-tests/src/main/java/com/aws/greengrass/CustomSteps.java deleted file mode 100644 index b3808fedb..000000000 --- a/tests/greengrass/sdk-gg-ipc/gg-e2e-tests/src/main/java/com/aws/greengrass/CustomSteps.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.aws.greengrass; - -import io.cucumber.guice.ScenarioScoped; -import io.cucumber.java.en.And; - -/** - * Change this or create a file like this one to define custom steps to test functionality - * specific to your component - */ -@ScenarioScoped -public class CustomSteps { - - @And("I call my custom step") - public void customStep() { - System.out.println("My custom step was called "); - } -} \ No newline at end of file From 04f4034c3e6c149fd21672f0c30a746c051f0ce9 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Tue, 14 May 2024 16:29:43 -0700 Subject: [PATCH 04/79] Working with precompiled binary --- .../greengrass/features/component.feature | 2 +- .../features/confidenceTest.feature | 134 ------------------ tests/greengrass/sdk-gg-ipc/recipe.yaml | 16 ++- 3 files changed, 15 insertions(+), 137 deletions(-) delete mode 100644 tests/greengrass/sdk-gg-ipc/gg-e2e-tests/src/main/resources/greengrass/features/confidenceTest.feature diff --git a/tests/greengrass/sdk-gg-ipc/gg-e2e-tests/src/main/resources/greengrass/features/component.feature b/tests/greengrass/sdk-gg-ipc/gg-e2e-tests/src/main/resources/greengrass/features/component.feature index 8ccd00ccf..349ecca4f 100644 --- a/tests/greengrass/sdk-gg-ipc/gg-e2e-tests/src/main/resources/greengrass/features/component.feature +++ b/tests/greengrass/sdk-gg-ipc/gg-e2e-tests/src/main/resources/greengrass/features/component.feature @@ -7,4 +7,4 @@ Feature: Testing features of Greengrassv2 IPC sample | software.amazon.awssdk.sdk-gg-ipc | file:recipe.yaml | And I deploy the Greengrass deployment configuration Then the Greengrass deployment is COMPLETED on the device after 180 seconds - And the software.amazon.awssdk.sdk-gg-ipc log on the device contains the line "Hello World" within 20 seconds + And the software.amazon.awssdk.sdk-gg-ipc log on the device contains the line "Received payload: hello" within 5 seconds diff --git a/tests/greengrass/sdk-gg-ipc/gg-e2e-tests/src/main/resources/greengrass/features/confidenceTest.feature b/tests/greengrass/sdk-gg-ipc/gg-e2e-tests/src/main/resources/greengrass/features/confidenceTest.feature deleted file mode 100644 index 37808c57a..000000000 --- a/tests/greengrass/sdk-gg-ipc/gg-e2e-tests/src/main/resources/greengrass/features/confidenceTest.feature +++ /dev/null @@ -1,134 +0,0 @@ -Feature: Confidence Test Suite - - Background: - Given my device is registered as a Thing - And my device is running Greengrass - - @ConfidenceTest - Scenario: As a Developer, I can deploy GDK_COMPONENT_NAME to my device and see it is working as expected - When I create a Greengrass deployment with components - | GDK_COMPONENT_NAME | GDK_COMPONENT_RECIPE_FILE | - | aws.greengrass.Cli | LATEST | - And I deploy the Greengrass deployment configuration - Then the Greengrass deployment is COMPLETED on the device after 180 seconds - # Update component state accordingly. Possible states: {RUNNING, FINISHED, BROKEN, STOPPING} - And I verify the GDK_COMPONENT_NAME component is RUNNING using the greengrass-cli - - @ConfidenceTest - Scenario: As a Developer, I can deploy GDK_COMPONENT_NAME, stop it and start it again - When I create a Greengrass deployment with components - | GDK_COMPONENT_NAME | GDK_COMPONENT_RECIPE_FILE | - | aws.greengrass.Cli | LATEST | - And I deploy the Greengrass deployment configuration - Then the Greengrass deployment is COMPLETED on the device after 180 seconds - # Update component state accordingly. Possible states: {RUNNING, FINISHED, BROKEN, STOPPING} - Then I verify the GDK_COMPONENT_NAME component is RUNNING using the greengrass-cli - When I use greengrass-cli to stop the component GDK_COMPONENT_NAME - # Update component state accordingly. Possible states: {RUNNING, FINISHED, BROKEN, STOPPING} - Then I verify the GDK_COMPONENT_NAME component is FINISHED using the greengrass-cli - When I use greengrass-cli to restart the component GDK_COMPONENT_NAME - # Update component state accordingly. Possible states: {RUNNING, FINISHED, BROKEN, STOPPING} - Then I verify the GDK_COMPONENT_NAME component is RUNNING using the greengrass-cli - - @ConfidenceTest - Scenario: As a Developer, I can deploy GDK_COMPONENT_NAME and restart Greengrass to check if it is still working as expected - When I create a Greengrass deployment with components - | GDK_COMPONENT_NAME | GDK_COMPONENT_RECIPE_FILE | - | aws.greengrass.Cli | LATEST | - And I deploy the Greengrass deployment configuration - Then the Greengrass deployment is COMPLETED on the device after 180 seconds - # Update component state accordingly. Possible states: {RUNNING, FINISHED, BROKEN, STOPPING} - Then I verify the GDK_COMPONENT_NAME component is RUNNING using the greengrass-cli - When I restart Greengrass - Then I wait 5 seconds - # Update component state accordingly. Possible states: {RUNNING, FINISHED, BROKEN, STOPPING} - And I verify the GDK_COMPONENT_NAME component is RUNNING using the greengrass-cli - - @ConfidenceTest - Scenario: As a Developer, I can deploy GDK_COMPONENT_NAME and disable internet to check if component is working. Restore internet to check if component is still working - When I create a Greengrass deployment with components - | GDK_COMPONENT_NAME | GDK_COMPONENT_RECIPE_FILE | - | aws.greengrass.Cli | LATEST | - And I deploy the Greengrass deployment configuration - Then the Greengrass deployment is COMPLETED on the device after 180 seconds - # Update component state accordingly. Possible states: {RUNNING, FINISHED, BROKEN, STOPPING} - Then I verify the GDK_COMPONENT_NAME component is RUNNING using the greengrass-cli - When I set device network connectivity to OFFLINE - And I restart Greengrass - Then I wait 5 seconds - # Update component state accordingly. Possible states: {RUNNING, FINISHED, BROKEN, STOPPING} - Then I verify the GDK_COMPONENT_NAME component is RUNNING using the greengrass-cli - When I set device network connectivity to ONLINE - # Update component state accordingly. Possible states: {RUNNING, FINISHED, BROKEN, STOPPING} - Then I verify the GDK_COMPONENT_NAME component is RUNNING using the greengrass-cli - - @ConfidenceTest - Scenario: As a Developer, I can deploy GDK_COMPONENT_NAME to my device and see it is working as expected after an additional local deployment to change component configuration - When I create a Greengrass deployment with components - | GDK_COMPONENT_NAME | GDK_COMPONENT_RECIPE_FILE | - | aws.greengrass.Cli | LATEST | - And I deploy the Greengrass deployment configuration - Then the Greengrass deployment is COMPLETED on the device after 180 seconds - # Update component state accordingly. Possible states: {RUNNING, FINISHED, BROKEN, STOPPING}. - Then I verify the GDK_COMPONENT_NAME component is RUNNING using the greengrass-cli - # Update the MERGE deployment configuration with the intended key-value pairs. - And I update my local deployment configuration, setting the component GDK_COMPONENT_NAME configuration to: - """ - { - "MERGE": { - "configurationKey": "keyValue" - } - } - """ - Then the local Greengrass deployment is SUCCEEDED on the device after 120 seconds - # Update component state accordingly. Possible states: {RUNNING, FINISHED, BROKEN, STOPPING}. Additional verification steps may be added here too. - And I verify the GDK_COMPONENT_NAME component is RUNNING using the greengrass-cli - - @ConfidenceTest - Scenario: As a Developer, I can deploy GDK_COMPONENT_NAME to my device with configuration updates and see it is working as expected - When I create a Greengrass deployment with components - | GDK_COMPONENT_NAME | GDK_COMPONENT_RECIPE_FILE | - | aws.greengrass.Cli | LATEST | - # Update the MERGE deployment configuration with the intended key-value pairs. - And I update my Greengrass deployment configuration, setting the component GDK_COMPONENT_NAME configuration to: - """ - { - "MERGE": { - "configurationKey": "keyValue" - } - } - """ - And I deploy the Greengrass deployment configuration - Then the Greengrass deployment is COMPLETED on the device after 180 seconds - # Update component state accordingly. Possible states: {RUNNING, FINISHED, BROKEN, STOPPING}. Additional verification steps may be added here too. - Then I verify the GDK_COMPONENT_NAME component is RUNNING using the greengrass-cli - - @ConfidenceTest - Scenario: As a Developer, I can deploy GDK_COMPONENT_NAME to my device and verify device RAM has not increased by more than a specified threshold - # To extend the test case, record RAM usage statistic under a unique identifier, such as RAM1 here. - When I record the device's RAM usage statistic as RAM1 - And I create a Greengrass deployment with components - | GDK_COMPONENT_NAME | GDK_COMPONENT_RECIPE_FILE | - | aws.greengrass.Cli | LATEST | - And I deploy the Greengrass deployment configuration - Then the Greengrass deployment is COMPLETED on the device after 180 seconds - # Update component state accordingly. Possible states: {RUNNING, FINISHED, BROKEN, STOPPING} - Then I verify the GDK_COMPONENT_NAME component is RUNNING using the greengrass-cli - When I record the device's RAM usage statistic as RAM2 - # Update the intended threshold as needed, in MB. If extending the test case, use two unique identifiers recorded during previous steps. - Then the increase in the RAM usage from RAM1 to RAM2 is less than 1024 MB - - @ConfidenceTest - Scenario: As a Developer, I can deploy GDK_COMPONENT_NAME to my device and verify device CPU usage has not increased by more than a specified threshold - # To extend the test case, record CPU usage statistic under a unique identifier, such as CPU1 here. - When I record the device's CPU usage statistic as CPU1 - And I create a Greengrass deployment with components - | GDK_COMPONENT_NAME | GDK_COMPONENT_RECIPE_FILE | - | aws.greengrass.Cli | LATEST | - And I deploy the Greengrass deployment configuration - Then the Greengrass deployment is COMPLETED on the device after 180 seconds - # Update component state accordingly. Possible states: {RUNNING, FINISHED, BROKEN, STOPPING} - Then I verify the GDK_COMPONENT_NAME component is RUNNING using the greengrass-cli - When I record the device's CPU usage statistic as CPU2 - # Update the intended threshold as needed, as percent utilization. If extending the test case, use two unique identifiers recorded during previous steps. - Then the increase in the CPU usage from CPU1 to CPU2 is less than 25 percent \ No newline at end of file diff --git a/tests/greengrass/sdk-gg-ipc/recipe.yaml b/tests/greengrass/sdk-gg-ipc/recipe.yaml index 31d2a093e..b70e02911 100644 --- a/tests/greengrass/sdk-gg-ipc/recipe.yaml +++ b/tests/greengrass/sdk-gg-ipc/recipe.yaml @@ -6,12 +6,24 @@ ComponentDescription: "This is test for the Greengrass IPC sample" ComponentPublisher: "iot-device-sdk" ComponentConfiguration: DefaultConfiguration: + accessControl: + aws.greengrass.ipc.mqttproxy: + software.amazon.awssdk.sdk-gg-ipc:mqttproxy:1: + policyDescription: "Allows access to publish to all AWS IoT Core topics. For demonstration only - use best practices in a real application" + operations: + - aws.greengrass#PublishToIoTCore + - aws.greengrass#SubscribeToIoTCore + resources: + - "*" Message: "World" Manifests: - Platform: os: all Artifacts: - - URI: "file:main.py" + - URI: "file:greengrass-ipc" + Permission: + Read: ALL + Execute: ALL Lifecycle: Run: | - python3 -u {artifacts:path}/main.py {configuration:/Message} + {artifacts:path}/greengrass-ipc --topic test/mytopic --message hello From 8c3e59cf1a316f369e37bce4629ff116f2b4743f Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Wed, 15 May 2024 16:48:29 -0700 Subject: [PATCH 05/79] Use gg ipc sample --- tests/greengrass/sdk-gg-ipc/gdk-config.json | 6 ++---- tests/greengrass/sdk-gg-ipc/main.py | 8 -------- 2 files changed, 2 insertions(+), 12 deletions(-) delete mode 100644 tests/greengrass/sdk-gg-ipc/main.py diff --git a/tests/greengrass/sdk-gg-ipc/gdk-config.json b/tests/greengrass/sdk-gg-ipc/gdk-config.json index da8f5ed13..3c98d552b 100644 --- a/tests/greengrass/sdk-gg-ipc/gdk-config.json +++ b/tests/greengrass/sdk-gg-ipc/gdk-config.json @@ -4,10 +4,8 @@ "author": "iot-device-sdk", "version": "NEXT_PATCH", "build": { - "build_system": "zip", - "options": { - "zip_name": "" - } + "build_system": "custom", + "custom_build_command": ["cp", "../../../build/samples/greengrass/ipc/greengrass-ipc", "."] }, "publish": { "bucket": "", diff --git a/tests/greengrass/sdk-gg-ipc/main.py b/tests/greengrass/sdk-gg-ipc/main.py deleted file mode 100644 index d236b968c..000000000 --- a/tests/greengrass/sdk-gg-ipc/main.py +++ /dev/null @@ -1,8 +0,0 @@ -import sys - -def main(): - args = sys.argv[1:] - print("Hello {}".format(" ".join(args))) - -if __name__ == "__main__": - main() From 83ab3763abd5b23e2de42857841340e85da12203 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Thu, 16 May 2024 10:48:58 -0700 Subject: [PATCH 06/79] Setup gg ipc in sample dir --- .../greengrass/ipc}/gdk-config.json | 0 .../greengrass/ipc}/gg-e2e-tests/pom.xml | 0 .../resources/greengrass/features/component.feature | 0 samples/greengrass/ipc/main.cpp | 2 ++ .../sdk-gg-ipc => samples/greengrass/ipc}/recipe.yaml | 6 +++--- tests/greengrass/sdk-gg-ipc/.gitignore | 10 ---------- 6 files changed, 5 insertions(+), 13 deletions(-) rename {tests/greengrass/sdk-gg-ipc => samples/greengrass/ipc}/gdk-config.json (100%) rename {tests/greengrass/sdk-gg-ipc => samples/greengrass/ipc}/gg-e2e-tests/pom.xml (100%) rename {tests/greengrass/sdk-gg-ipc => samples/greengrass/ipc}/gg-e2e-tests/src/main/resources/greengrass/features/component.feature (100%) rename {tests/greengrass/sdk-gg-ipc => samples/greengrass/ipc}/recipe.yaml (74%) delete mode 100644 tests/greengrass/sdk-gg-ipc/.gitignore diff --git a/tests/greengrass/sdk-gg-ipc/gdk-config.json b/samples/greengrass/ipc/gdk-config.json similarity index 100% rename from tests/greengrass/sdk-gg-ipc/gdk-config.json rename to samples/greengrass/ipc/gdk-config.json diff --git a/tests/greengrass/sdk-gg-ipc/gg-e2e-tests/pom.xml b/samples/greengrass/ipc/gg-e2e-tests/pom.xml similarity index 100% rename from tests/greengrass/sdk-gg-ipc/gg-e2e-tests/pom.xml rename to samples/greengrass/ipc/gg-e2e-tests/pom.xml diff --git a/tests/greengrass/sdk-gg-ipc/gg-e2e-tests/src/main/resources/greengrass/features/component.feature b/samples/greengrass/ipc/gg-e2e-tests/src/main/resources/greengrass/features/component.feature similarity index 100% rename from tests/greengrass/sdk-gg-ipc/gg-e2e-tests/src/main/resources/greengrass/features/component.feature rename to samples/greengrass/ipc/gg-e2e-tests/src/main/resources/greengrass/features/component.feature diff --git a/samples/greengrass/ipc/main.cpp b/samples/greengrass/ipc/main.cpp index 86200f29d..d75eb89b1 100644 --- a/samples/greengrass/ipc/main.cpp +++ b/samples/greengrass/ipc/main.cpp @@ -29,6 +29,8 @@ int main(int argc, char *argv[]) */ Utils::cmdData cmdData = Utils::parseSampleInputGreengrassIPC(argc, argv, &apiHandle); + fprintf(stdout, "Running Greengrass IPC sample\n"); + /** * Create the default ClientBootstrap, which will create the default * EventLoopGroup (to process IO events) and HostResolver. diff --git a/tests/greengrass/sdk-gg-ipc/recipe.yaml b/samples/greengrass/ipc/recipe.yaml similarity index 74% rename from tests/greengrass/sdk-gg-ipc/recipe.yaml rename to samples/greengrass/ipc/recipe.yaml index b70e02911..9521febea 100644 --- a/tests/greengrass/sdk-gg-ipc/recipe.yaml +++ b/samples/greengrass/ipc/recipe.yaml @@ -9,12 +9,12 @@ ComponentConfiguration: accessControl: aws.greengrass.ipc.mqttproxy: software.amazon.awssdk.sdk-gg-ipc:mqttproxy:1: - policyDescription: "Allows access to publish to all AWS IoT Core topics. For demonstration only - use best practices in a real application" + policyDescription: "Allows access to publish and subscribe to a Greengrass IPC test topic" operations: - aws.greengrass#PublishToIoTCore - aws.greengrass#SubscribeToIoTCore resources: - - "*" + - "test/gg-ipc-topic" Message: "World" Manifests: - Platform: @@ -26,4 +26,4 @@ Manifests: Execute: ALL Lifecycle: Run: | - {artifacts:path}/greengrass-ipc --topic test/mytopic --message hello + {artifacts:path}/greengrass-ipc --topic test/gg-ipc-topic --message hello --is_ci diff --git a/tests/greengrass/sdk-gg-ipc/.gitignore b/tests/greengrass/sdk-gg-ipc/.gitignore deleted file mode 100644 index 029e222fa..000000000 --- a/tests/greengrass/sdk-gg-ipc/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -*build/ -build -*dist/ -*.egg-info -*__pycache__ -*htmlcov/ -*.coverage -*.iml -*.DS_Store -*.eggs \ No newline at end of file From 4054f8b7a3f64e8f610b8279eb9140776d76a706 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Thu, 16 May 2024 10:56:34 -0700 Subject: [PATCH 07/79] Fix policy --- samples/greengrass/ipc/recipe.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/greengrass/ipc/recipe.yaml b/samples/greengrass/ipc/recipe.yaml index 9521febea..e8e3e174d 100644 --- a/samples/greengrass/ipc/recipe.yaml +++ b/samples/greengrass/ipc/recipe.yaml @@ -14,7 +14,7 @@ ComponentConfiguration: - aws.greengrass#PublishToIoTCore - aws.greengrass#SubscribeToIoTCore resources: - - "test/gg-ipc-topic" + - "test/gg-ipc-topic*" Message: "World" Manifests: - Platform: From e320c16431c50c337855b44e34a7fed5d2c74eb8 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Thu, 16 May 2024 10:59:30 -0700 Subject: [PATCH 08/79] Add CI job --- .github/workflows/ci.yml | 1289 ++++++++++++++++++++------------------ 1 file changed, 662 insertions(+), 627 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 42bb8ac00..2d2b4c79c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,649 +37,684 @@ env: CI_X509_ROLE: arn:aws:iam::180635532705:role/CI_X509_Role CI_MQTT5_ROLE: arn:aws:iam::180635532705:role/CI_MQTT5_Role CI_GREENGRASS_ROLE: arn:aws:iam::180635532705:role/CI_Greengrass_Role + CI_GREENGRASS_INSTALLER_ROLE: arn:aws:iam::180635532705:role/CI_GreengrassInstaller_Role CI_JOBS_SERVICE_CLIENT_ROLE: arn:aws:iam::180635532705:role/CI_JobsServiceClient_Role CI_SHADOW_SERVICE_CLIENT_ROLE: arn:aws:iam::180635532705:role/CI_ShadowServiceClient_Role jobs: - linux-compat: - runs-on: ubuntu-latest - strategy: - matrix: - image: - - manylinux2014-x64 - - manylinux2014-x86 - - al2-x64 - - alpine-3.16-x64 - - alpine-3.16-x86 - - alpine-3.16-armv6 - - alpine-3.16-armv7 - - alpine-3.16-arm64 - permissions: - id-token: write # This is required for requesting the JWT - steps: - - name: configure AWS credentials (containers) - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ env.CI_IOT_CONTAINERS }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} - - name: Install qemu/docker - run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - - name: Build ${{ env.PACKAGE_NAME }} - run: | - aws s3 cp s3://aws-crt-test-stuff/ci/${{ env.BUILDER_VERSION }}/linux-container-ci.sh ./linux-container-ci.sh && chmod a+x ./linux-container-ci.sh - ./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-${{ matrix.image }} build -p ${{ env.PACKAGE_NAME }} - raspberry: - runs-on: ubuntu-20.04 # latest - strategy: - fail-fast: false - matrix: - image: - - raspbian-bullseye - permissions: - id-token: write # This is required for requesting the JWT - steps: - - name: configure AWS credentials (containers) - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ env.CI_IOT_CONTAINERS }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} - # set arm arch - - name: Install qemu/docker - run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - - name: Build ${{ env.PACKAGE_NAME }} - run: | - aws s3 cp s3://aws-crt-test-stuff/ci/${{ env.BUILDER_VERSION }}/linux-container-ci.sh ./linux-container-ci.sh && chmod a+x ./linux-container-ci.sh - ./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-${{ matrix.image }} build -p ${{ env.PACKAGE_NAME }} - linux-compiler-compat: - runs-on: ubuntu-latest - strategy: - matrix: - compiler: - - clang-3 - - clang-6 - - clang-8 - - clang-9 - - clang-10 - - clang-11 - - gcc-4.8 - - gcc-5 - - gcc-6 - - gcc-7 - - gcc-8 - permissions: - id-token: write # This is required for requesting the JWT - steps: - - name: configure AWS credentials (containers) - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ env.CI_IOT_CONTAINERS }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} - # We can't use the `uses: docker://image` version yet, GitHub lacks authentication for actions -> packages - - name: Build ${{ env.PACKAGE_NAME }} - run: | - aws s3 cp s3://aws-crt-test-stuff/ci/${{ env.BUILDER_VERSION }}/linux-container-ci.sh ./linux-container-ci.sh && chmod a+x ./linux-container-ci.sh - ./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-${{ env.LINUX_BASE_IMAGE }} build -p ${{ env.PACKAGE_NAME }} --compiler=${{ matrix.compiler }} - byo-crypto: - runs-on: ubuntu-latest - permissions: - id-token: write # This is required for requesting the JWT - steps: - - name: configure AWS credentials (containers) - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ env.CI_IOT_CONTAINERS }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} - # We can't use the `uses: docker://image` version yet, GitHub lacks authentication for actions -> packages - - name: Build ${{ env.PACKAGE_NAME }} - run: | - aws s3 cp s3://aws-crt-test-stuff/ci/${{ env.BUILDER_VERSION }}/linux-container-ci.sh ./linux-container-ci.sh && chmod a+x ./linux-container-ci.sh - ./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-${{ env.LINUX_BASE_IMAGE }} build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-DBYO_CRYPTO=ON --variant=skip_sample - linux-no-cpu-extensions: - runs-on: ubuntu-latest - permissions: - id-token: write # This is required for requesting the JWT - steps: - - name: configure AWS credentials (containers) - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ env.CI_IOT_CONTAINERS }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} - # We can't use the `uses: docker://image` version yet, GitHub lacks authentication for actions -> packages - - name: Build ${{ env.PACKAGE_NAME }} - run: | - aws s3 cp s3://aws-crt-test-stuff/ci/${{ env.BUILDER_VERSION }}/linux-container-ci.sh ./linux-container-ci.sh && chmod a+x ./linux-container-ci.sh - ./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-${{ env.LINUX_BASE_IMAGE }} build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-DUSE_CPU_EXTENSIONS=OFF - windows: - runs-on: windows-latest - permissions: - id-token: write # This is required for requesting the JWT - steps: - - name: Build ${{ env.PACKAGE_NAME }} + consumers - run: | - md ${{ env.CI_FOLDER }} - cd ${{ env.CI_FOLDER }} - python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz', 'builder.pyz')" - python builder.pyz build -p ${{ env.PACKAGE_NAME }} - - name: Running samples in CI setup - run: | - python -m pip install boto3 - - name: configure AWS credentials (PubSub) - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ env.CI_PUBSUB_ROLE }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} - - name: run MQTT3 PubSub sample - run: | - cd ${{ env.CI_FOLDER }} - python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_pubsub_windows_cfg.json - - name: run Windows Certificate Connect sample - run: | - cd ${{ env.CI_FOLDER }} - python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_windows_cert_connect_cfg.json - - name: configure AWS credentials (MQTT5) - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ env.CI_MQTT5_ROLE }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} - - name: run MQTT5 PubSub sample - run: | - cd ${{ env.CI_FOLDER }} - python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_mqtt5_pubsub_windows_cfg.json - - name: configure AWS credentials (Device Advisor) - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ env.CI_DEVICE_ADVISOR }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} - - name: run DeviceAdvisor - run: | - cd ${{ env.CI_FOLDER }}/aws-iot-device-sdk-cpp-v2 - python ./deviceadvisor/script/DATestRun.py - windows-vs14: - runs-on: windows-2019 # windows-2019 is last env with Visual Studio 2015 (v14.0) - strategy: - matrix: - arch: [Win32, x64] - fail-fast: false - permissions: - id-token: write # This is required for requesting the JWT - steps: - - name: Build ${{ env.PACKAGE_NAME }} + consumers - run: | - md ${{ env.CI_FOLDER }} - cd ${{ env.CI_FOLDER }} - python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')" - python builder.pyz build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-Tv140 --cmake-extra=-A${{ matrix.arch }} - - name: Running samples in CI setup - run: | - python -m pip install boto3 - - name: configure AWS credentials (PubSub) - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ env.CI_PUBSUB_ROLE }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} - - name: run MQTT3 PubSub sample - run: | - cd ${{ env.CI_FOLDER }} - python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_pubsub_windows_cfg.json - - name: run Windows Certificate Connect sample - run: | - cd ${{ env.CI_FOLDER }} - python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_windows_cert_connect_cfg.json - - name: configure AWS credentials (MQTT5) - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ env.CI_MQTT5_ROLE }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} - - name: run MQTT5 PubSub sample - run: | - cd ${{ env.CI_FOLDER }} - python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_mqtt5_pubsub_windows_cfg.json - - name: configure AWS credentials (Device Advisor) - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ env.CI_DEVICE_ADVISOR }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} - - name: run DeviceAdvisor - run: | - cd ${{ env.CI_FOLDER }}/aws-iot-device-sdk-cpp-v2 - python ./deviceadvisor/script/DATestRun.py - windows-no-cpu-extensions: - runs-on: windows-latest - permissions: - id-token: write # This is required for requesting the JWT - steps: - - name: Build ${{ env.PACKAGE_NAME }} + consumers - run: | - md ${{ env.CI_FOLDER }} - cd ${{ env.CI_FOLDER }} - python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz', 'builder.pyz')" - python builder.pyz build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-DUSE_CPU_EXTENSIONS=OFF - - name: Running samples in CI setup - run: | - python -m pip install boto3 - - name: configure AWS credentials (PubSub) - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ env.CI_PUBSUB_ROLE }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} - - name: run MQTT3 PubSub sample - run: | - cd ${{ env.CI_FOLDER }} - python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_pubsub_windows_cfg.json - - name: run Windows Certificate Connect sample - run: | - cd ${{ env.CI_FOLDER }} - python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_windows_cert_connect_cfg.json - - name: configure AWS credentials (MQTT5) - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ env.CI_MQTT5_ROLE }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} - - name: run MQTT5 PubSub sample - run: | - cd ${{ env.CI_FOLDER }} - python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_mqtt5_pubsub_windows_cfg.json - - name: configure AWS credentials (Device Advisor) - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ env.CI_DEVICE_ADVISOR }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} - - name: run DeviceAdvisor - run: | - cd ${{ env.CI_FOLDER }}/aws-iot-device-sdk-cpp-v2 - python ./deviceadvisor/script/DATestRun.py - windows-app-verifier: - runs-on: windows-2022 # latest - permissions: - id-token: write # This is required for requesting the JWT - steps: - - name: Build ${{ env.PACKAGE_NAME }} + consumers - run: | - md ${{ env.CI_FOLDER }} - cd ${{ env.CI_FOLDER }} - python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz', 'builder.pyz')" - python builder.pyz build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-DUSE_CPU_EXTENSIONS=OFF - - name: Running samples in CI setup - run: | - python -m pip install boto3 - - name: configure AWS credentials (CyclePubSub) - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ env.CI_CYCLEPUBSUB_ROLE }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} - - name: Run and check AppVerifier - run: | - cd ${{ env.CI_FOLDER }} - echo "Starting to run AppVerifier with cycle pub-sub sample" - python ${{ env.CI_UTILS_FOLDER }}/appverifier_launch_sample.py --sample_file ".\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\cycle_pub_sub\RelWithDebInfo\cycle-pub-sub.exe" --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/CyclePubSub/cert' --sample_secret_private_key 'ci/CyclePubSub/key' - windows-shared-lib: - runs-on: windows-latest - permissions: - id-token: write # This is required for requesting the JWT - steps: - - name: Build ${{ env.PACKAGE_NAME }} + consumers - run: | - md ${{ env.CI_FOLDER }} - cd ${{ env.CI_FOLDER }} - python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz', 'builder.pyz')" - python builder.pyz build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-DBUILD_SHARED_LIBS=ON + # linux-compat: + # runs-on: ubuntu-latest + # strategy: + # matrix: + # image: + # - manylinux2014-x64 + # - manylinux2014-x86 + # - al2-x64 + # - alpine-3.16-x64 + # - alpine-3.16-x86 + # - alpine-3.16-armv6 + # - alpine-3.16-armv7 + # - alpine-3.16-arm64 + # permissions: + # id-token: write # This is required for requesting the JWT + # steps: + # - name: configure AWS credentials (containers) + # uses: aws-actions/configure-aws-credentials@v2 + # with: + # role-to-assume: ${{ env.CI_IOT_CONTAINERS }} + # aws-region: ${{ env.AWS_DEFAULT_REGION }} + # - name: Install qemu/docker + # run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes + # - name: Build ${{ env.PACKAGE_NAME }} + # run: | + # aws s3 cp s3://aws-crt-test-stuff/ci/${{ env.BUILDER_VERSION }}/linux-container-ci.sh ./linux-container-ci.sh && chmod a+x ./linux-container-ci.sh + # ./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-${{ matrix.image }} build -p ${{ env.PACKAGE_NAME }} + # raspberry: + # runs-on: ubuntu-20.04 # latest + # strategy: + # fail-fast: false + # matrix: + # image: + # - raspbian-bullseye + # permissions: + # id-token: write # This is required for requesting the JWT + # steps: + # - name: configure AWS credentials (containers) + # uses: aws-actions/configure-aws-credentials@v2 + # with: + # role-to-assume: ${{ env.CI_IOT_CONTAINERS }} + # aws-region: ${{ env.AWS_DEFAULT_REGION }} + # # set arm arch + # - name: Install qemu/docker + # run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes + # - name: Build ${{ env.PACKAGE_NAME }} + # run: | + # aws s3 cp s3://aws-crt-test-stuff/ci/${{ env.BUILDER_VERSION }}/linux-container-ci.sh ./linux-container-ci.sh && chmod a+x ./linux-container-ci.sh + # ./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-${{ matrix.image }} build -p ${{ env.PACKAGE_NAME }} + # linux-compiler-compat: + # runs-on: ubuntu-latest + # strategy: + # matrix: + # compiler: + # - clang-3 + # - clang-6 + # - clang-8 + # - clang-9 + # - clang-10 + # - clang-11 + # - gcc-4.8 + # - gcc-5 + # - gcc-6 + # - gcc-7 + # - gcc-8 + # permissions: + # id-token: write # This is required for requesting the JWT + # steps: + # - name: configure AWS credentials (containers) + # uses: aws-actions/configure-aws-credentials@v2 + # with: + # role-to-assume: ${{ env.CI_IOT_CONTAINERS }} + # aws-region: ${{ env.AWS_DEFAULT_REGION }} + # # We can't use the `uses: docker://image` version yet, GitHub lacks authentication for actions -> packages + # - name: Build ${{ env.PACKAGE_NAME }} + # run: | + # aws s3 cp s3://aws-crt-test-stuff/ci/${{ env.BUILDER_VERSION }}/linux-container-ci.sh ./linux-container-ci.sh && chmod a+x ./linux-container-ci.sh + # ./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-${{ env.LINUX_BASE_IMAGE }} build -p ${{ env.PACKAGE_NAME }} --compiler=${{ matrix.compiler }} + # byo-crypto: + # runs-on: ubuntu-latest + # permissions: + # id-token: write # This is required for requesting the JWT + # steps: + # - name: configure AWS credentials (containers) + # uses: aws-actions/configure-aws-credentials@v2 + # with: + # role-to-assume: ${{ env.CI_IOT_CONTAINERS }} + # aws-region: ${{ env.AWS_DEFAULT_REGION }} + # # We can't use the `uses: docker://image` version yet, GitHub lacks authentication for actions -> packages + # - name: Build ${{ env.PACKAGE_NAME }} + # run: | + # aws s3 cp s3://aws-crt-test-stuff/ci/${{ env.BUILDER_VERSION }}/linux-container-ci.sh ./linux-container-ci.sh && chmod a+x ./linux-container-ci.sh + # ./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-${{ env.LINUX_BASE_IMAGE }} build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-DBYO_CRYPTO=ON --variant=skip_sample + # linux-no-cpu-extensions: + # runs-on: ubuntu-latest + # permissions: + # id-token: write # This is required for requesting the JWT + # steps: + # - name: configure AWS credentials (containers) + # uses: aws-actions/configure-aws-credentials@v2 + # with: + # role-to-assume: ${{ env.CI_IOT_CONTAINERS }} + # aws-region: ${{ env.AWS_DEFAULT_REGION }} + # # We can't use the `uses: docker://image` version yet, GitHub lacks authentication for actions -> packages + # - name: Build ${{ env.PACKAGE_NAME }} + # run: | + # aws s3 cp s3://aws-crt-test-stuff/ci/${{ env.BUILDER_VERSION }}/linux-container-ci.sh ./linux-container-ci.sh && chmod a+x ./linux-container-ci.sh + # ./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-${{ env.LINUX_BASE_IMAGE }} build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-DUSE_CPU_EXTENSIONS=OFF + # windows: + # runs-on: windows-latest + # permissions: + # id-token: write # This is required for requesting the JWT + # steps: + # - name: Build ${{ env.PACKAGE_NAME }} + consumers + # run: | + # md ${{ env.CI_FOLDER }} + # cd ${{ env.CI_FOLDER }} + # python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz', 'builder.pyz')" + # python builder.pyz build -p ${{ env.PACKAGE_NAME }} + # - name: Running samples in CI setup + # run: | + # python -m pip install boto3 + # - name: configure AWS credentials (PubSub) + # uses: aws-actions/configure-aws-credentials@v2 + # with: + # role-to-assume: ${{ env.CI_PUBSUB_ROLE }} + # aws-region: ${{ env.AWS_DEFAULT_REGION }} + # - name: run MQTT3 PubSub sample + # run: | + # cd ${{ env.CI_FOLDER }} + # python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_pubsub_windows_cfg.json + # - name: run Windows Certificate Connect sample + # run: | + # cd ${{ env.CI_FOLDER }} + # python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_windows_cert_connect_cfg.json + # - name: configure AWS credentials (MQTT5) + # uses: aws-actions/configure-aws-credentials@v2 + # with: + # role-to-assume: ${{ env.CI_MQTT5_ROLE }} + # aws-region: ${{ env.AWS_DEFAULT_REGION }} + # - name: run MQTT5 PubSub sample + # run: | + # cd ${{ env.CI_FOLDER }} + # python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_mqtt5_pubsub_windows_cfg.json + # - name: configure AWS credentials (Device Advisor) + # uses: aws-actions/configure-aws-credentials@v2 + # with: + # role-to-assume: ${{ env.CI_DEVICE_ADVISOR }} + # aws-region: ${{ env.AWS_DEFAULT_REGION }} + # - name: run DeviceAdvisor + # run: | + # cd ${{ env.CI_FOLDER }}/aws-iot-device-sdk-cpp-v2 + # python ./deviceadvisor/script/DATestRun.py + # windows-vs14: + # runs-on: windows-2019 # windows-2019 is last env with Visual Studio 2015 (v14.0) + # strategy: + # matrix: + # arch: [Win32, x64] + # fail-fast: false + # permissions: + # id-token: write # This is required for requesting the JWT + # steps: + # - name: Build ${{ env.PACKAGE_NAME }} + consumers + # run: | + # md ${{ env.CI_FOLDER }} + # cd ${{ env.CI_FOLDER }} + # python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')" + # python builder.pyz build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-Tv140 --cmake-extra=-A${{ matrix.arch }} + # - name: Running samples in CI setup + # run: | + # python -m pip install boto3 + # - name: configure AWS credentials (PubSub) + # uses: aws-actions/configure-aws-credentials@v2 + # with: + # role-to-assume: ${{ env.CI_PUBSUB_ROLE }} + # aws-region: ${{ env.AWS_DEFAULT_REGION }} + # - name: run MQTT3 PubSub sample + # run: | + # cd ${{ env.CI_FOLDER }} + # python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_pubsub_windows_cfg.json + # - name: run Windows Certificate Connect sample + # run: | + # cd ${{ env.CI_FOLDER }} + # python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_windows_cert_connect_cfg.json + # - name: configure AWS credentials (MQTT5) + # uses: aws-actions/configure-aws-credentials@v2 + # with: + # role-to-assume: ${{ env.CI_MQTT5_ROLE }} + # aws-region: ${{ env.AWS_DEFAULT_REGION }} + # - name: run MQTT5 PubSub sample + # run: | + # cd ${{ env.CI_FOLDER }} + # python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_mqtt5_pubsub_windows_cfg.json + # - name: configure AWS credentials (Device Advisor) + # uses: aws-actions/configure-aws-credentials@v2 + # with: + # role-to-assume: ${{ env.CI_DEVICE_ADVISOR }} + # aws-region: ${{ env.AWS_DEFAULT_REGION }} + # - name: run DeviceAdvisor + # run: | + # cd ${{ env.CI_FOLDER }}/aws-iot-device-sdk-cpp-v2 + # python ./deviceadvisor/script/DATestRun.py + # windows-no-cpu-extensions: + # runs-on: windows-latest + # permissions: + # id-token: write # This is required for requesting the JWT + # steps: + # - name: Build ${{ env.PACKAGE_NAME }} + consumers + # run: | + # md ${{ env.CI_FOLDER }} + # cd ${{ env.CI_FOLDER }} + # python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz', 'builder.pyz')" + # python builder.pyz build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-DUSE_CPU_EXTENSIONS=OFF + # - name: Running samples in CI setup + # run: | + # python -m pip install boto3 + # - name: configure AWS credentials (PubSub) + # uses: aws-actions/configure-aws-credentials@v2 + # with: + # role-to-assume: ${{ env.CI_PUBSUB_ROLE }} + # aws-region: ${{ env.AWS_DEFAULT_REGION }} + # - name: run MQTT3 PubSub sample + # run: | + # cd ${{ env.CI_FOLDER }} + # python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_pubsub_windows_cfg.json + # - name: run Windows Certificate Connect sample + # run: | + # cd ${{ env.CI_FOLDER }} + # python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_windows_cert_connect_cfg.json + # - name: configure AWS credentials (MQTT5) + # uses: aws-actions/configure-aws-credentials@v2 + # with: + # role-to-assume: ${{ env.CI_MQTT5_ROLE }} + # aws-region: ${{ env.AWS_DEFAULT_REGION }} + # - name: run MQTT5 PubSub sample + # run: | + # cd ${{ env.CI_FOLDER }} + # python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_mqtt5_pubsub_windows_cfg.json + # - name: configure AWS credentials (Device Advisor) + # uses: aws-actions/configure-aws-credentials@v2 + # with: + # role-to-assume: ${{ env.CI_DEVICE_ADVISOR }} + # aws-region: ${{ env.AWS_DEFAULT_REGION }} + # - name: run DeviceAdvisor + # run: | + # cd ${{ env.CI_FOLDER }}/aws-iot-device-sdk-cpp-v2 + # python ./deviceadvisor/script/DATestRun.py + # windows-app-verifier: + # runs-on: windows-2022 # latest + # permissions: + # id-token: write # This is required for requesting the JWT + # steps: + # - name: Build ${{ env.PACKAGE_NAME }} + consumers + # run: | + # md ${{ env.CI_FOLDER }} + # cd ${{ env.CI_FOLDER }} + # python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz', 'builder.pyz')" + # python builder.pyz build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-DUSE_CPU_EXTENSIONS=OFF + # - name: Running samples in CI setup + # run: | + # python -m pip install boto3 + # - name: configure AWS credentials (CyclePubSub) + # uses: aws-actions/configure-aws-credentials@v2 + # with: + # role-to-assume: ${{ env.CI_CYCLEPUBSUB_ROLE }} + # aws-region: ${{ env.AWS_DEFAULT_REGION }} + # - name: Run and check AppVerifier + # run: | + # cd ${{ env.CI_FOLDER }} + # echo "Starting to run AppVerifier with cycle pub-sub sample" + # python ${{ env.CI_UTILS_FOLDER }}/appverifier_launch_sample.py --sample_file ".\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\cycle_pub_sub\RelWithDebInfo\cycle-pub-sub.exe" --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/CyclePubSub/cert' --sample_secret_private_key 'ci/CyclePubSub/key' + # windows-shared-lib: + # runs-on: windows-latest + # permissions: + # id-token: write # This is required for requesting the JWT + # steps: + # - name: Build ${{ env.PACKAGE_NAME }} + consumers + # run: | + # md ${{ env.CI_FOLDER }} + # cd ${{ env.CI_FOLDER }} + # python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz', 'builder.pyz')" + # python builder.pyz build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-DBUILD_SHARED_LIBS=ON - osx: - runs-on: macos-latest - permissions: - id-token: write # This is required for requesting the JWT - security-events: write # This is required for pkcs12 sample to sign the key - steps: - - name: Build ${{ env.PACKAGE_NAME }} + consumers - run: | - python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz', 'builder')" - chmod a+x builder - ./builder build -p ${{ env.PACKAGE_NAME }} --spec=downstream - - name: Running samples in CI setup - run: | - python3 -m pip install boto3 - - name: configure AWS credentials (PubSub) - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ env.CI_PUBSUB_ROLE }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} - - name: run MQTT3 PubSub sample - run: | - python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_pubsub_cfg.json -# - name: run PKCS12 sample -# run: | -# aws s3 cp s3://iot-sdk-ci-bucket-us-east1/pkcs12_identity.p12 ./pkcs12_identity.p12 -# pkcs12_identity_name=$(aws secretsmanager get-secret-value --region us-east-1 --secret-id "ci/macos/pkcs12_identity" --query "SecretString" | cut -f2 -d":" | cut -f2 -d\") -# pkcs12_identity_password=$(aws secretsmanager get-secret-value --region us-east-1 --secret-id "ci/macos/pkcs12_identity_password" --query "SecretString" | cut -f2 -d":" | cut -f2 -d\") -# cert=$(aws secretsmanager get-secret-value --region us-east-1 --secret-id "ci/PubSub/cert" --query "SecretString" | cut -f2 -d":" | cut -f2 -d\") && echo -e "$cert" > /tmp/certificate.pem -# key=$(aws secretsmanager get-secret-value --region us-east-1 --secret-id "ci/PubSub/key" --query "SecretString" | cut -f2 -d":" | cut -f2 -d\") && echo -e "$key" > /tmp/privatekey.pem -# iot_pkcs12_password=$(aws secretsmanager get-secret-value --region us-east-1 --secret-id "ci/PubSub/key_pkcs12_password" --query "SecretString" | cut -f2 -d":" | cut -f2 -d\") -# openssl pkcs12 -export -in /tmp/certificate.pem -inkey /tmp/privatekey.pem -out ./iot_pkcs12_key.p12 -name PubSub_Thing_Alias -password pass:$iot_pkcs12_password -# security create-keychain -p test_password build.keychain -# security set-keychain-settings -lut 21600 build.keychain -# security default-keychain -s build.keychain -# security unlock-keychain -p test_password build.keychain -# security import pkcs12_identity.p12 -A -k build.keychain -f pkcs12 -P $pkcs12_identity_password -T /usr/bin/codesign -T /usr/bin/security -# security set-key-partition-list -S 'apple-tool:,apple:' -k test_password build.keychain -# /usr/bin/codesign --force -s $pkcs12_identity_name ./aws-iot-device-sdk-cpp-v2/build/samples/mqtt/pkcs12_connect/pkcs12-connect -v -# python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_pkcs12_connect_cfg.json - - name: configure AWS credentials (MQTT5) - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ env.CI_MQTT5_ROLE }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} - - name: run MQTT5 PubSub sample - run: | - python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_mqtt5_pubsub_cfg.json - - name: configure AWS credentials (Device Advisor) - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ env.CI_DEVICE_ADVISOR }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} - - name: run DeviceAdvisor - run: | - cd ./aws-iot-device-sdk-cpp-v2 - python3 ./deviceadvisor/script/DATestRun.py - # Not strictly needed, but allows us to run Device Advisor and PubSub on Linux without needing to run all samples - linux-github-actions: - runs-on: ubuntu-latest - strategy: - fail-fast: false - permissions: - id-token: write # This is required for requesting the JWT - steps: - - name: Build ${{ env.PACKAGE_NAME }} + consumers - run: | - python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')" - python builder.pyz build -p ${{ env.PACKAGE_NAME }} - - name: Running samples in CI setup - run: | - python3 -m pip install boto3 - - name: configure AWS credentials (PubSub) - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ env.CI_PUBSUB_ROLE }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} - - name: run MQTT3 PubSub sample - run: | - python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_pubsub_cfg.json - - name: configure AWS credentials (MQTT5) - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ env.CI_MQTT5_ROLE }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} - - name: run MQTT5 PubSub sample - run: | - python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_mqtt5_pubsub_cfg.json - - name: configure AWS credentials (Device Advisor) - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ env.CI_DEVICE_ADVISOR }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} - - name: run DeviceAdvisor - run: | - cd ./aws-iot-device-sdk-cpp-v2 - python3 ./deviceadvisor/script/DATestRun.py - - name: configure AWS credentials (Device Defender) - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ env.CI_DEVICE_DEFENDER }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} - - name: run DeviceDefender - run: | - cd ./aws-iot-device-sdk-cpp-v2 - python3 ./devicedefender/script/DDTestRun.py - - name: run Mqtt5 DeviceDefender - run: | - cd ./aws-iot-device-sdk-cpp-v2 - python3 ./devicedefender/script/DDTestRun.py mqtt5 - # Runs the samples and ensures that everything is working - linux-smoke-tests: + # osx: + # runs-on: macos-latest + # permissions: + # id-token: write # This is required for requesting the JWT + # security-events: write # This is required for pkcs12 sample to sign the key + # steps: + # - name: Build ${{ env.PACKAGE_NAME }} + consumers + # run: | + # python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz', 'builder')" + # chmod a+x builder + # ./builder build -p ${{ env.PACKAGE_NAME }} --spec=downstream + # - name: Running samples in CI setup + # run: | + # python3 -m pip install boto3 + # - name: configure AWS credentials (PubSub) + # uses: aws-actions/configure-aws-credentials@v2 + # with: + # role-to-assume: ${{ env.CI_PUBSUB_ROLE }} + # aws-region: ${{ env.AWS_DEFAULT_REGION }} + # - name: run MQTT3 PubSub sample + # run: | + # python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_pubsub_cfg.json +# # - name: run PKCS12 sample +# # run: | +# # aws s3 cp s3://iot-sdk-ci-bucket-us-east1/pkcs12_identity.p12 ./pkcs12_identity.p12 +# # pkcs12_identity_name=$(aws secretsmanager get-secret-value --region us-east-1 --secret-id "ci/macos/pkcs12_identity" --query "SecretString" | cut -f2 -d":" | cut -f2 -d\") +# # pkcs12_identity_password=$(aws secretsmanager get-secret-value --region us-east-1 --secret-id "ci/macos/pkcs12_identity_password" --query "SecretString" | cut -f2 -d":" | cut -f2 -d\") +# # cert=$(aws secretsmanager get-secret-value --region us-east-1 --secret-id "ci/PubSub/cert" --query "SecretString" | cut -f2 -d":" | cut -f2 -d\") && echo -e "$cert" > /tmp/certificate.pem +# # key=$(aws secretsmanager get-secret-value --region us-east-1 --secret-id "ci/PubSub/key" --query "SecretString" | cut -f2 -d":" | cut -f2 -d\") && echo -e "$key" > /tmp/privatekey.pem +# # iot_pkcs12_password=$(aws secretsmanager get-secret-value --region us-east-1 --secret-id "ci/PubSub/key_pkcs12_password" --query "SecretString" | cut -f2 -d":" | cut -f2 -d\") +# # openssl pkcs12 -export -in /tmp/certificate.pem -inkey /tmp/privatekey.pem -out ./iot_pkcs12_key.p12 -name PubSub_Thing_Alias -password pass:$iot_pkcs12_password +# # security create-keychain -p test_password build.keychain +# # security set-keychain-settings -lut 21600 build.keychain +# # security default-keychain -s build.keychain +# # security unlock-keychain -p test_password build.keychain +# # security import pkcs12_identity.p12 -A -k build.keychain -f pkcs12 -P $pkcs12_identity_password -T /usr/bin/codesign -T /usr/bin/security +# # security set-key-partition-list -S 'apple-tool:,apple:' -k test_password build.keychain +# # /usr/bin/codesign --force -s $pkcs12_identity_name ./aws-iot-device-sdk-cpp-v2/build/samples/mqtt/pkcs12_connect/pkcs12-connect -v +# # python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_pkcs12_connect_cfg.json + # - name: configure AWS credentials (MQTT5) + # uses: aws-actions/configure-aws-credentials@v2 + # with: + # role-to-assume: ${{ env.CI_MQTT5_ROLE }} + # aws-region: ${{ env.AWS_DEFAULT_REGION }} + # - name: run MQTT5 PubSub sample + # run: | + # python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_mqtt5_pubsub_cfg.json + # - name: configure AWS credentials (Device Advisor) + # uses: aws-actions/configure-aws-credentials@v2 + # with: + # role-to-assume: ${{ env.CI_DEVICE_ADVISOR }} + # aws-region: ${{ env.AWS_DEFAULT_REGION }} + # - name: run DeviceAdvisor + # run: | + # cd ./aws-iot-device-sdk-cpp-v2 + # python3 ./deviceadvisor/script/DATestRun.py + # # Not strictly needed, but allows us to run Device Advisor and PubSub on Linux without needing to run all samples + # linux-github-actions: + # runs-on: ubuntu-latest + # strategy: + # fail-fast: false + # permissions: + # id-token: write # This is required for requesting the JWT + # steps: + # - name: Build ${{ env.PACKAGE_NAME }} + consumers + # run: | + # python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')" + # python builder.pyz build -p ${{ env.PACKAGE_NAME }} + # - name: Running samples in CI setup + # run: | + # python3 -m pip install boto3 + # - name: configure AWS credentials (PubSub) + # uses: aws-actions/configure-aws-credentials@v2 + # with: + # role-to-assume: ${{ env.CI_PUBSUB_ROLE }} + # aws-region: ${{ env.AWS_DEFAULT_REGION }} + # - name: run MQTT3 PubSub sample + # run: | + # python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_pubsub_cfg.json + # - name: configure AWS credentials (MQTT5) + # uses: aws-actions/configure-aws-credentials@v2 + # with: + # role-to-assume: ${{ env.CI_MQTT5_ROLE }} + # aws-region: ${{ env.AWS_DEFAULT_REGION }} + # - name: run MQTT5 PubSub sample + # run: | + # python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_mqtt5_pubsub_cfg.json + # - name: configure AWS credentials (Device Advisor) + # uses: aws-actions/configure-aws-credentials@v2 + # with: + # role-to-assume: ${{ env.CI_DEVICE_ADVISOR }} + # aws-region: ${{ env.AWS_DEFAULT_REGION }} + # - name: run DeviceAdvisor + # run: | + # cd ./aws-iot-device-sdk-cpp-v2 + # python3 ./deviceadvisor/script/DATestRun.py + # - name: configure AWS credentials (Device Defender) + # uses: aws-actions/configure-aws-credentials@v2 + # with: + # role-to-assume: ${{ env.CI_DEVICE_DEFENDER }} + # aws-region: ${{ env.AWS_DEFAULT_REGION }} + # - name: run DeviceDefender + # run: | + # cd ./aws-iot-device-sdk-cpp-v2 + # python3 ./devicedefender/script/DDTestRun.py + # - name: run Mqtt5 DeviceDefender + # run: | + # cd ./aws-iot-device-sdk-cpp-v2 + # python3 ./devicedefender/script/DDTestRun.py mqtt5 + # # Runs the samples and ensures that everything is working + # linux-smoke-tests: + # runs-on: ubuntu-latest + # strategy: + # fail-fast: false + # permissions: + # id-token: write # This is required for requesting the JWT + # steps: + # - name: Setup C++ + # run: | + # sudo apt-get -qq update -y + # sudo apt-get -qq install -y build-essential + # sudo apt install cmake + # gcc --version + # cmake --version + # - name: Build ${{ env.PACKAGE_NAME }} + consumers + # run: | + # echo "Downloading source" + # git clone --recursive https://github.com/aws/aws-iot-device-sdk-cpp-v2.git --branch ${{ env.HEAD_REF || github.ref_name }} + # echo "Running builder" + # python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')" + # python builder.pyz build -p ${{ env.PACKAGE_NAME }} + # - name: Running samples in CI setup + # run: | + # python3 -m pip install boto3 + # sudo apt-get update -y + # sudo apt-get install softhsm -y + # softhsm2-util --version + + # - name: configure AWS credentials (Fleet provisioning) + # uses: aws-actions/configure-aws-credentials@v2 + # with: + # role-to-assume: ${{ env.CI_FLEET_PROVISIONING_ROLE }} + # aws-region: ${{ env.AWS_DEFAULT_REGION }} + # - name: run Fleet Provisioning service client test for MQTT311 + # working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests + # run: | + # export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils + # python3 ./test_cases/test_fleet_provisioning.py --config-file test_cases/mqtt3_fleet_provisioning_cfg.json --thing-name-prefix Fleet_Thing_ + # - name: run Fleet Provisioning service client test for MQTT5 + # working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests + # run: | + # export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils + # python3 ./test_cases/test_fleet_provisioning.py --config-file test_cases/mqtt5_fleet_provisioning_cfg.json --thing-name-prefix Fleet_Thing_ + # - name: run Fleet Provisioning with CSR service client test for MQTT311 + # working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests + # run: | + # export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils + # python3 ./test_cases/test_fleet_provisioning.py --config-file test_cases/mqtt3_fleet_provisioning_with_csr_cfg.json --thing-name-prefix Fleet_Thing_ + # - name: run Fleet Provisioning with CSR service client test for MQTT5 + # working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests + # run: | + # export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils + # python3 ./test_cases/test_fleet_provisioning.py --config-file test_cases/mqtt5_fleet_provisioning_with_csr_cfg.json --thing-name-prefix Fleet_Thing_ + + # - name: configure AWS credentials (Jobs) + # uses: aws-actions/configure-aws-credentials@v2 + # with: + # role-to-assume: ${{ env.CI_JOBS_SERVICE_CLIENT_ROLE }} + # aws-region: ${{ env.AWS_DEFAULT_REGION }} + # - name: run mqtt3 Jobs serviceTests + # working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests + # run: | + # export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils + # python3 ./test_cases/test_jobs_execution.py --config-file ${{ env.CI_SERVICE_TESTS_CFG_FOLDER }}/mqtt3_jobs_cfg.json + # - name: run mqtt5 Jobs serviceTests + # working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests + # run: | + # export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils + # python3 ./test_cases/test_jobs_execution.py --config-file ${{ env.CI_SERVICE_TESTS_CFG_FOLDER }}/mqtt5_jobs_cfg.json + # - name: configure AWS credentials (Shadow) + # uses: aws-actions/configure-aws-credentials@v2 + # with: + # role-to-assume: ${{ env.CI_SHADOW_SERVICE_CLIENT_ROLE }} + # aws-region: ${{ env.AWS_DEFAULT_REGION }} + # - name: run Shadow service client test for MQTT5 + # working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests + # run: | + # export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils + # python3 ./test_cases/test_shadow_update.py --config-file test_cases/mqtt5_shadow_cfg.json + # - name: run Shadow service client test for MQTT311 + # working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests + # run: | + # export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils + # python3 ./test_cases/test_shadow_update.py --config-file test_cases/mqtt3_shadow_cfg.json + # - name: run Named Shadow service client test for MQTT311 + # working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests + # run: | + # export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils + # python3 ./test_cases/test_shadow_update.py --config-file test_cases/mqtt3_named_shadow_cfg.json + # - name: run Named Shadow service client test for MQTT5 + # working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests + # run: | + # export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils + # python3 ./test_cases/test_shadow_update.py --config-file test_cases/mqtt5_named_shadow_cfg.json + # - name: configure AWS credentials (Connect and PubSub) + # uses: aws-actions/configure-aws-credentials@v2 + # with: + # role-to-assume: ${{ env.CI_PUBSUB_ROLE }} + # aws-region: ${{ env.AWS_DEFAULT_REGION }} + # - name: run Basic Connect sample + # run: | + # python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_basic_connect_cfg.json + # - name: run Websocket Connect sample + # run: | + # python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_websocket_connect_cfg.json + # - name: run MQTT3 PubSub sample + # run: | + # python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_pubsub_cfg.json + # - name: run PKCS11 Connect sample + # run: | + # mkdir -p /tmp/tokens + # export SOFTHSM2_CONF=/tmp/softhsm2.conf + # echo "directories.tokendir = /tmp/tokens" > /tmp/softhsm2.conf + # python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_pkcs11_connect_cfg.json + # - name: configure AWS credentials (MQTT5) + # uses: aws-actions/configure-aws-credentials@v2 + # with: + # role-to-assume: ${{ env.CI_MQTT5_ROLE }} + # aws-region: ${{ env.AWS_DEFAULT_REGION }} + # - name: run MQTT5 PubSub sample + # run: | + # python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_mqtt5_pubsub_cfg.json + # - name: run MQTT5 Shared Subscription sample + # run: | + # python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_mqtt5_shared_subscription_cfg.json + # - name: configure AWS credentials (Jobs) + # uses: aws-actions/configure-aws-credentials@v2 + # with: + # role-to-assume: ${{ env.CI_JOBS_ROLE }} + # aws-region: ${{ env.AWS_DEFAULT_REGION }} + # - name: run Jobs sample + # run: | + # python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_jobs_cfg.json + # - name: run Mqtt5 Jobs sample + # run: | + # python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_jobs_mqtt5_cfg.json + # - name: configure AWS credentials (Cognito) + # uses: aws-actions/configure-aws-credentials@v2 + # with: + # role-to-assume: ${{ env.CI_COGNITO_ROLE }} + # aws-region: ${{ env.AWS_DEFAULT_REGION }} + # - name: run CognitoConnect sample + # run: | + # python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_cognito_connect_cfg.json + # - name: configure AWS credentials (Custom Authorizer) + # uses: aws-actions/configure-aws-credentials@v2 + # with: + # role-to-assume: ${{ env.CI_CUSTOM_AUTHORIZER_ROLE }} + # aws-region: ${{ env.AWS_DEFAULT_REGION }} + # - name: run CustomAuthorizerConnect sample + # run: | + # python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_custom_authorizer_connect_cfg.json + # - name: configure AWS credentials (Shadow) + # uses: aws-actions/configure-aws-credentials@v2 + # with: + # role-to-assume: ${{ env.CI_SHADOW_ROLE }} + # aws-region: ${{ env.AWS_DEFAULT_REGION }} + # - name: run Shadow sample + # run: | + # python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_shadow_cfg.json + # - name: run Mqtt5 Shadow sample + # run: | + # python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_shadow_mqtt5_cfg.json + # - name: configure AWS credentials (Fleet provisioning) + # uses: aws-actions/configure-aws-credentials@v2 + # with: + # role-to-assume: ${{ env.CI_FLEET_PROVISIONING_ROLE }} + # aws-region: ${{ env.AWS_DEFAULT_REGION }} + # - name: run Fleet Provisioning sample + # run: | + # echo "Generating UUID for IoT thing" + # 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: run Mqtt5 Fleet Provisioning sample + # run: | + # echo "Generating UUID for IoT thing" + # 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_mqtt5_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 (Secure tunneling) + # uses: aws-actions/configure-aws-credentials@v2 + # with: + # role-to-assume: ${{ env.CI_SECURE_TUNNEL }} + # aws-region: ${{ env.AWS_DEFAULT_REGION }} + # # Secure Tunneling has special requirements, so it uses a different Python file + # - name: run Secure Tunneling sample + # run: | + # python3 ${{ env.CI_UTILS_FOLDER }}/run_secure_tunnel_ci.py --sample_file "./aws-iot-device-sdk-cpp-v2/build/samples/secure_tunneling/secure_tunnel/secure-tunnel" --sample_region ${{ env.AWS_DEFAULT_REGION }} + # - name: configure AWS credentials (X509) + # uses: aws-actions/configure-aws-credentials@v2 + # with: + # role-to-assume: ${{ env.CI_X509_ROLE }} + # aws-region: ${{ env.AWS_DEFAULT_REGION }} + # - name: run X509 sample + # run: | + # python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_x509_connect_cfg.json + # - name: configure AWS credentials (Greengrass) + # uses: aws-actions/configure-aws-credentials@v2 + # 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_cfg.json + + # Runs the Greengrass samples + linux-greengrass-tests: runs-on: ubuntu-latest strategy: fail-fast: false + matrix: + version: + - 17 permissions: id-token: write # This is required for requesting the JWT steps: - - name: Setup C++ - run: | - sudo apt-get -qq update -y - sudo apt-get -qq install -y build-essential - sudo apt install cmake - gcc --version - cmake --version - - name: Build ${{ env.PACKAGE_NAME }} + consumers - run: | - echo "Downloading source" - git clone --recursive https://github.com/aws/aws-iot-device-sdk-cpp-v2.git --branch ${{ env.HEAD_REF || github.ref_name }} - echo "Running builder" - python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')" - python builder.pyz build -p ${{ env.PACKAGE_NAME }} - - name: Running samples in CI setup - run: | - python3 -m pip install boto3 - sudo apt-get update -y - sudo apt-get install softhsm -y - softhsm2-util --version - - - name: configure AWS credentials (Fleet provisioning) - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ env.CI_FLEET_PROVISIONING_ROLE }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} - - name: run Fleet Provisioning service client test for MQTT311 - working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests - run: | - export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils - python3 ./test_cases/test_fleet_provisioning.py --config-file test_cases/mqtt3_fleet_provisioning_cfg.json --thing-name-prefix Fleet_Thing_ - - name: run Fleet Provisioning service client test for MQTT5 - working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests - run: | - export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils - python3 ./test_cases/test_fleet_provisioning.py --config-file test_cases/mqtt5_fleet_provisioning_cfg.json --thing-name-prefix Fleet_Thing_ - - name: run Fleet Provisioning with CSR service client test for MQTT311 - working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests - run: | - export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils - python3 ./test_cases/test_fleet_provisioning.py --config-file test_cases/mqtt3_fleet_provisioning_with_csr_cfg.json --thing-name-prefix Fleet_Thing_ - - name: run Fleet Provisioning with CSR service client test for MQTT5 - working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests - run: | - export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils - python3 ./test_cases/test_fleet_provisioning.py --config-file test_cases/mqtt5_fleet_provisioning_with_csr_cfg.json --thing-name-prefix Fleet_Thing_ - - - name: configure AWS credentials (Jobs) - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ env.CI_JOBS_SERVICE_CLIENT_ROLE }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} - - name: run mqtt3 Jobs serviceTests - working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests - run: | - export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils - python3 ./test_cases/test_jobs_execution.py --config-file ${{ env.CI_SERVICE_TESTS_CFG_FOLDER }}/mqtt3_jobs_cfg.json - - name: run mqtt5 Jobs serviceTests - working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests - run: | - export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils - python3 ./test_cases/test_jobs_execution.py --config-file ${{ env.CI_SERVICE_TESTS_CFG_FOLDER }}/mqtt5_jobs_cfg.json - - name: configure AWS credentials (Shadow) - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ env.CI_SHADOW_SERVICE_CLIENT_ROLE }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} - - name: run Shadow service client test for MQTT5 - working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests - run: | - export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils - python3 ./test_cases/test_shadow_update.py --config-file test_cases/mqtt5_shadow_cfg.json - - name: run Shadow service client test for MQTT311 - working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests - run: | - export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils - python3 ./test_cases/test_shadow_update.py --config-file test_cases/mqtt3_shadow_cfg.json - - name: run Named Shadow service client test for MQTT311 - working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests - run: | - export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils - python3 ./test_cases/test_shadow_update.py --config-file test_cases/mqtt3_named_shadow_cfg.json - - name: run Named Shadow service client test for MQTT5 - working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests - run: | - export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils - python3 ./test_cases/test_shadow_update.py --config-file test_cases/mqtt5_named_shadow_cfg.json - - name: configure AWS credentials (Connect and PubSub) - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ env.CI_PUBSUB_ROLE }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} - - name: run Basic Connect sample - run: | - python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_basic_connect_cfg.json - - name: run Websocket Connect sample - run: | - python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_websocket_connect_cfg.json - - name: run MQTT3 PubSub sample - run: | - python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_pubsub_cfg.json - - name: run PKCS11 Connect sample - run: | - mkdir -p /tmp/tokens - export SOFTHSM2_CONF=/tmp/softhsm2.conf - echo "directories.tokendir = /tmp/tokens" > /tmp/softhsm2.conf - python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_pkcs11_connect_cfg.json - - name: configure AWS credentials (MQTT5) - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ env.CI_MQTT5_ROLE }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} - - name: run MQTT5 PubSub sample - run: | - python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_mqtt5_pubsub_cfg.json - - name: run MQTT5 Shared Subscription sample - run: | - python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_mqtt5_shared_subscription_cfg.json - - name: configure AWS credentials (Jobs) - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ env.CI_JOBS_ROLE }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} - - name: run Jobs sample - run: | - python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_jobs_cfg.json - - name: run Mqtt5 Jobs sample - run: | - python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_jobs_mqtt5_cfg.json - - name: configure AWS credentials (Cognito) - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ env.CI_COGNITO_ROLE }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} - - name: run CognitoConnect sample - run: | - python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_cognito_connect_cfg.json - - name: configure AWS credentials (Custom Authorizer) - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ env.CI_CUSTOM_AUTHORIZER_ROLE }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} - - name: run CustomAuthorizerConnect sample - run: | - python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_custom_authorizer_connect_cfg.json - - name: configure AWS credentials (Shadow) - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ env.CI_SHADOW_ROLE }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} - - name: run Shadow sample - run: | - python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_shadow_cfg.json - - name: run Mqtt5 Shadow sample - run: | - python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_shadow_mqtt5_cfg.json - - name: configure AWS credentials (Fleet provisioning) - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ env.CI_FLEET_PROVISIONING_ROLE }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} - - name: run Fleet Provisioning sample - run: | - echo "Generating UUID for IoT thing" - 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: run Mqtt5 Fleet Provisioning sample - run: | - echo "Generating UUID for IoT thing" - 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_mqtt5_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 (Secure tunneling) - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ env.CI_SECURE_TUNNEL }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} - # Secure Tunneling has special requirements, so it uses a different Python file - - name: run Secure Tunneling sample - run: | - python3 ${{ env.CI_UTILS_FOLDER }}/run_secure_tunnel_ci.py --sample_file "./aws-iot-device-sdk-cpp-v2/build/samples/secure_tunneling/secure_tunnel/secure-tunnel" --sample_region ${{ env.AWS_DEFAULT_REGION }} - - name: configure AWS credentials (X509) - uses: aws-actions/configure-aws-credentials@v2 + - name: Checkout Sources + uses: actions/checkout@v2 + - name: Setup Java + uses: actions/setup-java@v2 with: - role-to-assume: ${{ env.CI_X509_ROLE }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} - - name: run X509 sample - run: | - python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_x509_connect_cfg.json + distribution: temurin + java-version: ${{ matrix.version }} + cache: maven - name: configure AWS credentials (Greengrass) uses: aws-actions/configure-aws-credentials@v2 with: - role-to-assume: ${{ env.CI_GREENGRASS_ROLE }} + role-to-assume: ${{ env.CI_GREENGRASS_INSTALLER_ROLE }} aws-region: ${{ env.AWS_DEFAULT_REGION }} - - name: run Greengrass Discovery sample + - name: Install Greengrass Development Kit run: | - 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: - runs-on: ubuntu-20.04 # latest - steps: - - uses: actions/checkout@v2 - with: - submodules: recursive - - name: Check docs + python3 -m pip install -U git+https://github.com/aws-greengrass/aws-greengrass-gdk-cli.git@v1.6 + - name: Running Greengrass IPC sample + working-directory: ./aws-iot-device-sdk-cpp-v2/samples/greengrass/ipc run: | - echo "Compiling and installing doxygen 1.8.20 from source" - sudo apt-get install -y llvm-11 llvm-11-dev clang-11 libclang-11-dev - git clone https://github.com/doxygen/doxygen.git -b Release_1_8_20 - cd doxygen - mkdir build - cd build - cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr .. - sudo make -j 4 - sudo make install - cd ../.. - echo "Finished compiling and installing Doxygen" - ./make-docs.py - check-submodules: - runs-on: ubuntu-latest - steps: - - name: Checkout Source - uses: actions/checkout@v2 - with: - submodules: true - fetch-depth: 0 - - name: Check Submodules - # note: using "@main" because "@${{env.BUILDER_VERSION}}" doesn't work - # https://github.com/actions/runner/issues/480 - uses: awslabs/aws-crt-builder/.github/actions/check-submodules@main + gdk component build + gdk test-e2e build + gdk test-e2e run - check-codegen-edits: - runs-on: ubuntu-20.04 # latest - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Check for edits to code-generated files - run: | - ./utils/check_codegen_edits.py + # # check that docs can still build + # check-docs: + # runs-on: ubuntu-20.04 # latest + # steps: + # - uses: actions/checkout@v2 + # with: + # submodules: recursive + # - name: Check docs + # run: | + # echo "Compiling and installing doxygen 1.8.20 from source" + # sudo apt-get install -y llvm-11 llvm-11-dev clang-11 libclang-11-dev + # git clone https://github.com/doxygen/doxygen.git -b Release_1_8_20 + # cd doxygen + # mkdir build + # cd build + # cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr .. + # sudo make -j 4 + # sudo make install + # cd ../.. + # echo "Finished compiling and installing Doxygen" + # ./make-docs.py + # check-submodules: + # runs-on: ubuntu-latest + # steps: + # - name: Checkout Source + # uses: actions/checkout@v2 + # with: + # submodules: true + # fetch-depth: 0 + # - name: Check Submodules + # # note: using "@main" because "@${{env.BUILDER_VERSION}}" doesn't work + # # https://github.com/actions/runner/issues/480 + # uses: awslabs/aws-crt-builder/.github/actions/check-submodules@main + + # check-codegen-edits: + # runs-on: ubuntu-20.04 # latest + # steps: + # - uses: actions/checkout@v2 + # with: + # fetch-depth: 0 + # - name: Check for edits to code-generated files + # run: | + # ./utils/check_codegen_edits.py From 44eb61cb219382dd88ac34cd43124cc53b7cd042 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Thu, 16 May 2024 11:01:19 -0700 Subject: [PATCH 09/79] Fix gdk version --- .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 2d2b4c79c..ec2eaa9c8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -667,7 +667,7 @@ jobs: aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: Install Greengrass Development Kit run: | - python3 -m pip install -U git+https://github.com/aws-greengrass/aws-greengrass-gdk-cli.git@v1.6 + python3 -m pip install -U git+https://github.com/aws-greengrass/aws-greengrass-gdk-cli.git@v1.6.2 - name: Running Greengrass IPC sample working-directory: ./aws-iot-device-sdk-cpp-v2/samples/greengrass/ipc run: | From 7cb8f76377b5e03df8b7148cb734c116bee54fc1 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Thu, 16 May 2024 11:05:08 -0700 Subject: [PATCH 10/79] Another working dir --- .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 ec2eaa9c8..00d93a36f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -669,7 +669,7 @@ jobs: run: | python3 -m pip install -U git+https://github.com/aws-greengrass/aws-greengrass-gdk-cli.git@v1.6.2 - name: Running Greengrass IPC sample - working-directory: ./aws-iot-device-sdk-cpp-v2/samples/greengrass/ipc + working-directory: ./samples/greengrass/ipc run: | gdk component build gdk test-e2e build From 40cdcff50105b5146496dbd05c58e8a225f67ae3 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Thu, 16 May 2024 11:06:41 -0700 Subject: [PATCH 11/79] Build sources --- .github/workflows/ci.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 00d93a36f..1c48845a2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -652,6 +652,20 @@ jobs: permissions: id-token: write # This is required for requesting the JWT steps: + - name: Setup C++ + run: | + sudo apt-get -qq update -y + sudo apt-get -qq install -y build-essential + sudo apt install cmake + gcc --version + cmake --version + - name: Build ${{ env.PACKAGE_NAME }} + consumers + run: | + echo "Downloading source" + git clone --recursive https://github.com/aws/aws-iot-device-sdk-cpp-v2.git --branch ${{ env.HEAD_REF || github.ref_name }} + echo "Running builder" + python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')" + python builder.pyz build -p ${{ env.PACKAGE_NAME }} - name: Checkout Sources uses: actions/checkout@v2 - name: Setup Java From 4ba3b9a39b1643b2f4b348fcf49f968b4a772ec2 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Thu, 16 May 2024 11:19:38 -0700 Subject: [PATCH 12/79] Add new builder variant for GG only --- .builder/actions/build_gg_samples.py | 30 ++++++++++++++++++++++++++++ builder.json | 6 ++++++ 2 files changed, 36 insertions(+) create mode 100644 .builder/actions/build_gg_samples.py diff --git a/.builder/actions/build_gg_samples.py b/.builder/actions/build_gg_samples.py new file mode 100644 index 000000000..c2ff6b443 --- /dev/null +++ b/.builder/actions/build_gg_samples.py @@ -0,0 +1,30 @@ +import Builder +import os +import sys +import argparse + + +class BuildGGSamples(Builder.Action): + def run(self, env): + # parse extra cmake configs + cmd_args = env.args + + steps = [] + samples = [ + 'samples/greengrass/ipc', + ] + + for sample_path in samples: + build_path = os.path.join('build', sample_path) + steps.append(['cmake', + f'-B{build_path}', + f'-H{sample_path}', + f'-DCMAKE_PREFIX_PATH={env.install_dir}', + '-DCMAKE_BUILD_TYPE=RelWithDebInfo']) + # append extra cmake configs + steps[-1].extend(cmd_args.cmake_extra) + steps.append(['cmake', + '--build', build_path, + '--config', 'RelWithDebInfo']) + + return Builder.Script(steps) diff --git a/builder.json b/builder.json index 2a014ee07..293a06351 100644 --- a/builder.json +++ b/builder.json @@ -28,6 +28,12 @@ "!build_steps": [ "build" ] + }, + "build_gg_samples_only": { + "!build_steps": [ + "build", + "build-gg-samples" + ] } } } From e71fcef3f05637db2a2fcd7fef6cf1a529f224db Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Thu, 16 May 2024 11:19:46 -0700 Subject: [PATCH 13/79] Debugging --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1c48845a2..ebb5304cc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -685,6 +685,7 @@ jobs: - name: Running Greengrass IPC sample working-directory: ./samples/greengrass/ipc run: | + tree ../../../ gdk component build gdk test-e2e build gdk test-e2e run From a6554ece60a1a8eb60fe57d090d1d30b9b64ca8a Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Thu, 16 May 2024 11:20:55 -0700 Subject: [PATCH 14/79] Temporary reconfig for builder --- builder.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builder.json b/builder.json index 293a06351..0b1cc8ebb 100644 --- a/builder.json +++ b/builder.json @@ -21,7 +21,7 @@ "_comment": "See .builder/actions/build_samples.py for definition of 'build-samples'", "build_steps": [ "build", - "build-samples" + "build-gg-samples" ], "variants" : { "skip_sample": { From 53306220e0506db20a1d712eba7ba2d7d4af83b4 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Thu, 16 May 2024 11:25:39 -0700 Subject: [PATCH 15/79] Fix path --- .github/workflows/ci.yml | 2 +- samples/greengrass/ipc/gdk-config.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ebb5304cc..fe7212895 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -685,7 +685,7 @@ jobs: - name: Running Greengrass IPC sample working-directory: ./samples/greengrass/ipc run: | - tree ../../../ + tree ../../../../ gdk component build gdk test-e2e build gdk test-e2e run diff --git a/samples/greengrass/ipc/gdk-config.json b/samples/greengrass/ipc/gdk-config.json index 3c98d552b..30bf54cdf 100644 --- a/samples/greengrass/ipc/gdk-config.json +++ b/samples/greengrass/ipc/gdk-config.json @@ -5,7 +5,7 @@ "version": "NEXT_PATCH", "build": { "build_system": "custom", - "custom_build_command": ["cp", "../../../build/samples/greengrass/ipc/greengrass-ipc", "."] + "custom_build_command": ["cp", "../../../../build/samples/greengrass/ipc/greengrass-ipc", "."] }, "publish": { "bucket": "", From 8c068dfd72adf6d0141dedb869ac56879f03323d Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Thu, 16 May 2024 11:31:11 -0700 Subject: [PATCH 16/79] More levels --- .github/workflows/ci.yml | 2 +- samples/greengrass/ipc/gdk-config.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fe7212895..dd7d0afb8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -685,7 +685,7 @@ jobs: - name: Running Greengrass IPC sample working-directory: ./samples/greengrass/ipc run: | - tree ../../../../ + tree ../../../../../ gdk component build gdk test-e2e build gdk test-e2e run diff --git a/samples/greengrass/ipc/gdk-config.json b/samples/greengrass/ipc/gdk-config.json index 30bf54cdf..ba4c667de 100644 --- a/samples/greengrass/ipc/gdk-config.json +++ b/samples/greengrass/ipc/gdk-config.json @@ -5,7 +5,7 @@ "version": "NEXT_PATCH", "build": { "build_system": "custom", - "custom_build_command": ["cp", "../../../../build/samples/greengrass/ipc/greengrass-ipc", "."] + "custom_build_command": ["cp", "../../../../../build/samples/greengrass/ipc/greengrass-ipc", "."] }, "publish": { "bucket": "", From b7424bb37a56baffb982498ead031e0609b82eb8 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Thu, 16 May 2024 11:44:22 -0700 Subject: [PATCH 17/79] fixup --- .github/workflows/ci.yml | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dd7d0afb8..d6dc87f32 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -659,6 +659,12 @@ jobs: sudo apt install cmake gcc --version cmake --version + - name: Setup Java + uses: actions/setup-java@v2 + with: + distribution: temurin + java-version: ${{ matrix.version }} + cache: maven - name: Build ${{ env.PACKAGE_NAME }} + consumers run: | echo "Downloading source" @@ -666,22 +672,17 @@ jobs: echo "Running builder" python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')" python builder.pyz build -p ${{ env.PACKAGE_NAME }} - - name: Checkout Sources - uses: actions/checkout@v2 - - name: Setup Java - uses: actions/setup-java@v2 - with: - distribution: temurin - java-version: ${{ matrix.version }} - cache: maven + - name: Install Greengrass Development Kit + run: | + python3 -m pip install -U git+https://github.com/aws-greengrass/aws-greengrass-gdk-cli.git@v1.6.2 - name: configure AWS credentials (Greengrass) uses: aws-actions/configure-aws-credentials@v2 with: role-to-assume: ${{ env.CI_GREENGRASS_INSTALLER_ROLE }} aws-region: ${{ env.AWS_DEFAULT_REGION }} - - name: Install Greengrass Development Kit + - name: Test path run: | - python3 -m pip install -U git+https://github.com/aws-greengrass/aws-greengrass-gdk-cli.git@v1.6.2 + ./aws-iot-device-sdk-cpp-v2/build/samples/greengrass/ipc/greengrass-ipc - name: Running Greengrass IPC sample working-directory: ./samples/greengrass/ipc run: | From b0746fec01819ed62e9973c71995b745d564fefe Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Thu, 16 May 2024 11:49:58 -0700 Subject: [PATCH 18/79] fixup --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d6dc87f32..67a12a97b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -659,6 +659,8 @@ jobs: sudo apt install cmake gcc --version cmake --version + - name: Checkout Sources + uses: actions/checkout@v2 - name: Setup Java uses: actions/setup-java@v2 with: From 15aa9dbd8606715ec7df2fadd5bffa80deb2d5a1 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Thu, 16 May 2024 12:03:24 -0700 Subject: [PATCH 19/79] Playing with CI --- .github/workflows/ci.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 67a12a97b..1649c13a2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -652,13 +652,6 @@ jobs: permissions: id-token: write # This is required for requesting the JWT steps: - - name: Setup C++ - run: | - sudo apt-get -qq update -y - sudo apt-get -qq install -y build-essential - sudo apt install cmake - gcc --version - cmake --version - name: Checkout Sources uses: actions/checkout@v2 - name: Setup Java @@ -667,6 +660,13 @@ jobs: distribution: temurin java-version: ${{ matrix.version }} cache: maven + - name: Setup C++ + run: | + sudo apt-get -qq update -y + sudo apt-get -qq install -y build-essential + sudo apt install cmake + gcc --version + cmake --version - name: Build ${{ env.PACKAGE_NAME }} + consumers run: | echo "Downloading source" From 3db24900b34fa0a870a3282374d1118a00b532fc Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Thu, 16 May 2024 12:07:54 -0700 Subject: [PATCH 20/79] Do not setup Java --- .github/workflows/ci.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1649c13a2..14f37ccef 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -652,14 +652,6 @@ jobs: permissions: id-token: write # This is required for requesting the JWT steps: - - name: Checkout Sources - uses: actions/checkout@v2 - - name: Setup Java - uses: actions/setup-java@v2 - with: - distribution: temurin - java-version: ${{ matrix.version }} - cache: maven - name: Setup C++ run: | sudo apt-get -qq update -y From 8917feb3cf756a243a285861add4aee2666dccab Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Thu, 16 May 2024 12:25:20 -0700 Subject: [PATCH 21/79] Remove test path --- .github/workflows/ci.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 14f37ccef..18ba4ae79 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -674,11 +674,8 @@ jobs: with: role-to-assume: ${{ env.CI_GREENGRASS_INSTALLER_ROLE }} aws-region: ${{ env.AWS_DEFAULT_REGION }} - - name: Test path - run: | - ./aws-iot-device-sdk-cpp-v2/build/samples/greengrass/ipc/greengrass-ipc - name: Running Greengrass IPC sample - working-directory: ./samples/greengrass/ipc + working-directory: ./aws-iot-device-sdk-cpp-v2/samples/greengrass/ipc run: | tree ../../../../../ gdk component build From 445f503dc4259b838b2cbc049d45ad233166ea50 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Thu, 16 May 2024 12:31:07 -0700 Subject: [PATCH 22/79] Fix path --- .github/workflows/ci.yml | 1 - samples/greengrass/ipc/gdk-config.json | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 18ba4ae79..23cd9e23a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -677,7 +677,6 @@ jobs: - name: Running Greengrass IPC sample working-directory: ./aws-iot-device-sdk-cpp-v2/samples/greengrass/ipc run: | - tree ../../../../../ gdk component build gdk test-e2e build gdk test-e2e run diff --git a/samples/greengrass/ipc/gdk-config.json b/samples/greengrass/ipc/gdk-config.json index ba4c667de..3c98d552b 100644 --- a/samples/greengrass/ipc/gdk-config.json +++ b/samples/greengrass/ipc/gdk-config.json @@ -5,7 +5,7 @@ "version": "NEXT_PATCH", "build": { "build_system": "custom", - "custom_build_command": ["cp", "../../../../../build/samples/greengrass/ipc/greengrass-ipc", "."] + "custom_build_command": ["cp", "../../../build/samples/greengrass/ipc/greengrass-ipc", "."] }, "publish": { "bucket": "", From 9366f3a51100cae07aea21fd99642f83a52c1e9a Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Tue, 21 May 2024 10:28:08 -0700 Subject: [PATCH 23/79] Run predefined gg core --- .github/workflows/ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 23cd9e23a..9dbeb83f1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -674,6 +674,11 @@ jobs: with: role-to-assume: ${{ env.CI_GREENGRASS_INSTALLER_ROLE }} aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: Install Greengrass core + curl -s https://d2s8p88vqu9w66.cloudfront.net/releases/greengrass-nucleus-latest.zip > greengrass-nucleus-latest.zip + unzip greengrass-nucleus-latest.zip -d GreengrassInstaller && rm greengrass-nucleus-latest.zip + java -jar ./GreengrassInstaller/lib/Greengrass.jar --version + sudo -E java -Droot="/greengrass/v2" -Dlog.store=FILE -jar ./GreengrassInstaller/lib/Greengrass.jar --aws-region us-east-1 --thing-name CI_GreengrassCore --thing-group-name CI_GreengrassCoreGroup --thing-policy-name GreengrassV2IoTThingPolicy --tes-role-name GreengrassV2TokenExchangeRole --tes-role-alias-name GreengrassCoreTokenExchangeRoleAlias --component-default-user ggc_user:ggc_group --provision true --setup-system-service true --deploy-dev-tools true - name: Running Greengrass IPC sample working-directory: ./aws-iot-device-sdk-cpp-v2/samples/greengrass/ipc run: | From 6e192fda6a752e090e71372d4ca080ab318d430a Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Tue, 21 May 2024 10:33:30 -0700 Subject: [PATCH 24/79] fixup --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9dbeb83f1..29600756f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -675,6 +675,7 @@ jobs: role-to-assume: ${{ env.CI_GREENGRASS_INSTALLER_ROLE }} aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: Install Greengrass core + run: | curl -s https://d2s8p88vqu9w66.cloudfront.net/releases/greengrass-nucleus-latest.zip > greengrass-nucleus-latest.zip unzip greengrass-nucleus-latest.zip -d GreengrassInstaller && rm greengrass-nucleus-latest.zip java -jar ./GreengrassInstaller/lib/Greengrass.jar --version From 3dccd484b5ef36d2b4a1e2cfceeb68f453e122d4 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Tue, 21 May 2024 10:39:54 -0700 Subject: [PATCH 25/79] Check gg core --- .github/workflows/ci.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 29600756f..e485175a5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -674,12 +674,12 @@ jobs: with: role-to-assume: ${{ env.CI_GREENGRASS_INSTALLER_ROLE }} aws-region: ${{ env.AWS_DEFAULT_REGION }} - - name: Install Greengrass core - run: | - curl -s https://d2s8p88vqu9w66.cloudfront.net/releases/greengrass-nucleus-latest.zip > greengrass-nucleus-latest.zip - unzip greengrass-nucleus-latest.zip -d GreengrassInstaller && rm greengrass-nucleus-latest.zip - java -jar ./GreengrassInstaller/lib/Greengrass.jar --version - sudo -E java -Droot="/greengrass/v2" -Dlog.store=FILE -jar ./GreengrassInstaller/lib/Greengrass.jar --aws-region us-east-1 --thing-name CI_GreengrassCore --thing-group-name CI_GreengrassCoreGroup --thing-policy-name GreengrassV2IoTThingPolicy --tes-role-name GreengrassV2TokenExchangeRole --tes-role-alias-name GreengrassCoreTokenExchangeRoleAlias --component-default-user ggc_user:ggc_group --provision true --setup-system-service true --deploy-dev-tools true + # - name: Install Greengrass core + # run: | + # curl -s https://d2s8p88vqu9w66.cloudfront.net/releases/greengrass-nucleus-latest.zip > greengrass-nucleus-latest.zip + # unzip greengrass-nucleus-latest.zip -d GreengrassInstaller && rm greengrass-nucleus-latest.zip + # java -jar ./GreengrassInstaller/lib/Greengrass.jar --version + # sudo -E java -Droot="/greengrass/v2" -Dlog.store=FILE -jar ./GreengrassInstaller/lib/Greengrass.jar --aws-region us-east-1 --thing-name CI_GreengrassCore --thing-group-name CI_GreengrassCoreGroup --thing-policy-name GreengrassV2IoTThingPolicy --tes-role-name GreengrassV2TokenExchangeRole --tes-role-alias-name GreengrassCoreTokenExchangeRoleAlias --component-default-user ggc_user:ggc_group --provision true --setup-system-service true --deploy-dev-tools true - name: Running Greengrass IPC sample working-directory: ./aws-iot-device-sdk-cpp-v2/samples/greengrass/ipc run: | From bd6d6c1f62be9a86c168e0af56a464ee07d7a6ff Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Tue, 21 May 2024 10:51:32 -0700 Subject: [PATCH 26/79] Use predefined gg core one more time --- .github/workflows/ci.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e485175a5..29600756f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -674,12 +674,12 @@ jobs: with: role-to-assume: ${{ env.CI_GREENGRASS_INSTALLER_ROLE }} aws-region: ${{ env.AWS_DEFAULT_REGION }} - # - name: Install Greengrass core - # run: | - # curl -s https://d2s8p88vqu9w66.cloudfront.net/releases/greengrass-nucleus-latest.zip > greengrass-nucleus-latest.zip - # unzip greengrass-nucleus-latest.zip -d GreengrassInstaller && rm greengrass-nucleus-latest.zip - # java -jar ./GreengrassInstaller/lib/Greengrass.jar --version - # sudo -E java -Droot="/greengrass/v2" -Dlog.store=FILE -jar ./GreengrassInstaller/lib/Greengrass.jar --aws-region us-east-1 --thing-name CI_GreengrassCore --thing-group-name CI_GreengrassCoreGroup --thing-policy-name GreengrassV2IoTThingPolicy --tes-role-name GreengrassV2TokenExchangeRole --tes-role-alias-name GreengrassCoreTokenExchangeRoleAlias --component-default-user ggc_user:ggc_group --provision true --setup-system-service true --deploy-dev-tools true + - name: Install Greengrass core + run: | + curl -s https://d2s8p88vqu9w66.cloudfront.net/releases/greengrass-nucleus-latest.zip > greengrass-nucleus-latest.zip + unzip greengrass-nucleus-latest.zip -d GreengrassInstaller && rm greengrass-nucleus-latest.zip + java -jar ./GreengrassInstaller/lib/Greengrass.jar --version + sudo -E java -Droot="/greengrass/v2" -Dlog.store=FILE -jar ./GreengrassInstaller/lib/Greengrass.jar --aws-region us-east-1 --thing-name CI_GreengrassCore --thing-group-name CI_GreengrassCoreGroup --thing-policy-name GreengrassV2IoTThingPolicy --tes-role-name GreengrassV2TokenExchangeRole --tes-role-alias-name GreengrassCoreTokenExchangeRoleAlias --component-default-user ggc_user:ggc_group --provision true --setup-system-service true --deploy-dev-tools true - name: Running Greengrass IPC sample working-directory: ./aws-iot-device-sdk-cpp-v2/samples/greengrass/ipc run: | From a2e530b8c2005a5dcf877ad84a5329e489815e73 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Tue, 21 May 2024 11:01:56 -0700 Subject: [PATCH 27/79] Try to remove gg core from recipe --- .../src/main/resources/greengrass/features/component.feature | 2 -- 1 file changed, 2 deletions(-) diff --git a/samples/greengrass/ipc/gg-e2e-tests/src/main/resources/greengrass/features/component.feature b/samples/greengrass/ipc/gg-e2e-tests/src/main/resources/greengrass/features/component.feature index 349ecca4f..eb2a01c54 100644 --- a/samples/greengrass/ipc/gg-e2e-tests/src/main/resources/greengrass/features/component.feature +++ b/samples/greengrass/ipc/gg-e2e-tests/src/main/resources/greengrass/features/component.feature @@ -1,8 +1,6 @@ Feature: Testing features of Greengrassv2 IPC sample @testgg Scenario: As a developer, I can create a component and deploy it on my device - Given my device is registered as a Thing - And my device is running Greengrass When I create a Greengrass deployment with components | software.amazon.awssdk.sdk-gg-ipc | file:recipe.yaml | And I deploy the Greengrass deployment configuration From 05c4d625681c29ca88986c32b4c26a57f022b866 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Tue, 21 May 2024 11:10:54 -0700 Subject: [PATCH 28/79] Add background --- .../src/main/resources/greengrass/features/component.feature | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/samples/greengrass/ipc/gg-e2e-tests/src/main/resources/greengrass/features/component.feature b/samples/greengrass/ipc/gg-e2e-tests/src/main/resources/greengrass/features/component.feature index eb2a01c54..c47edc521 100644 --- a/samples/greengrass/ipc/gg-e2e-tests/src/main/resources/greengrass/features/component.feature +++ b/samples/greengrass/ipc/gg-e2e-tests/src/main/resources/greengrass/features/component.feature @@ -1,4 +1,9 @@ Feature: Testing features of Greengrassv2 IPC sample + + Background: + Given my device is registered as a Thing + And my device is running Greengrass + @testgg Scenario: As a developer, I can create a component and deploy it on my device When I create a Greengrass deployment with components From ee02511808caaafa47aff989cb21d7db1ed98ef6 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Tue, 21 May 2024 11:19:28 -0700 Subject: [PATCH 29/79] Echo gg core thing --- samples/greengrass/ipc/recipe.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/samples/greengrass/ipc/recipe.yaml b/samples/greengrass/ipc/recipe.yaml index e8e3e174d..4918a20b6 100644 --- a/samples/greengrass/ipc/recipe.yaml +++ b/samples/greengrass/ipc/recipe.yaml @@ -26,4 +26,5 @@ Manifests: Execute: ALL Lifecycle: Run: | + echo "GG core:" {iot:thingName} {artifacts:path}/greengrass-ipc --topic test/gg-ipc-topic --message hello --is_ci From ea00deb84d950bfe2d2527f33b0336ee45f4791a Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Tue, 21 May 2024 11:44:22 -0700 Subject: [PATCH 30/79] Roll back gg core creation --- .../main/resources/greengrass/features/component.feature | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/samples/greengrass/ipc/gg-e2e-tests/src/main/resources/greengrass/features/component.feature b/samples/greengrass/ipc/gg-e2e-tests/src/main/resources/greengrass/features/component.feature index c47edc521..52fdeee2b 100644 --- a/samples/greengrass/ipc/gg-e2e-tests/src/main/resources/greengrass/features/component.feature +++ b/samples/greengrass/ipc/gg-e2e-tests/src/main/resources/greengrass/features/component.feature @@ -1,11 +1,9 @@ Feature: Testing features of Greengrassv2 IPC sample - Background: - Given my device is registered as a Thing - And my device is running Greengrass - @testgg Scenario: As a developer, I can create a component and deploy it on my device + Given my device is registered as a Thing + And my device is running Greengrass When I create a Greengrass deployment with components | software.amazon.awssdk.sdk-gg-ipc | file:recipe.yaml | And I deploy the Greengrass deployment configuration From ddebc7d3b7c21a55a10b0d615d71f6f2a778a454 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Tue, 21 May 2024 11:45:28 -0700 Subject: [PATCH 31/79] Increase timeout --- .../src/main/resources/greengrass/features/component.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/greengrass/ipc/gg-e2e-tests/src/main/resources/greengrass/features/component.feature b/samples/greengrass/ipc/gg-e2e-tests/src/main/resources/greengrass/features/component.feature index 52fdeee2b..815331ad0 100644 --- a/samples/greengrass/ipc/gg-e2e-tests/src/main/resources/greengrass/features/component.feature +++ b/samples/greengrass/ipc/gg-e2e-tests/src/main/resources/greengrass/features/component.feature @@ -8,4 +8,4 @@ Feature: Testing features of Greengrassv2 IPC sample | software.amazon.awssdk.sdk-gg-ipc | file:recipe.yaml | And I deploy the Greengrass deployment configuration Then the Greengrass deployment is COMPLETED on the device after 180 seconds - And the software.amazon.awssdk.sdk-gg-ipc log on the device contains the line "Received payload: hello" within 5 seconds + And the software.amazon.awssdk.sdk-gg-ipc log on the device contains the line "Received payload: hello" within 20 seconds From 9dde71f87e40153bef9a5c85bfa7b85611e822f7 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Tue, 21 May 2024 11:47:12 -0700 Subject: [PATCH 32/79] Print test logs --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 29600756f..58c3508e2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -686,6 +686,10 @@ jobs: gdk component build gdk test-e2e build gdk test-e2e run + echo "Test logs" + echo "========" + cat testResults/gg*/software.amazon.awssdk.sdk-gg-ipc.log + echo "========" # # check that docs can still build # check-docs: From 9ad99afe7b2ab389aa1c0961bf8b5d0c24e84dfe Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Tue, 21 May 2024 11:51:21 -0700 Subject: [PATCH 33/79] Remove installing gg core --- .github/workflows/ci.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 58c3508e2..b952bb040 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -674,12 +674,6 @@ jobs: with: role-to-assume: ${{ env.CI_GREENGRASS_INSTALLER_ROLE }} aws-region: ${{ env.AWS_DEFAULT_REGION }} - - name: Install Greengrass core - run: | - curl -s https://d2s8p88vqu9w66.cloudfront.net/releases/greengrass-nucleus-latest.zip > greengrass-nucleus-latest.zip - unzip greengrass-nucleus-latest.zip -d GreengrassInstaller && rm greengrass-nucleus-latest.zip - java -jar ./GreengrassInstaller/lib/Greengrass.jar --version - sudo -E java -Droot="/greengrass/v2" -Dlog.store=FILE -jar ./GreengrassInstaller/lib/Greengrass.jar --aws-region us-east-1 --thing-name CI_GreengrassCore --thing-group-name CI_GreengrassCoreGroup --thing-policy-name GreengrassV2IoTThingPolicy --tes-role-name GreengrassV2TokenExchangeRole --tes-role-alias-name GreengrassCoreTokenExchangeRoleAlias --component-default-user ggc_user:ggc_group --provision true --setup-system-service true --deploy-dev-tools true - name: Running Greengrass IPC sample working-directory: ./aws-iot-device-sdk-cpp-v2/samples/greengrass/ipc run: | From 687259f96fa68e5b1992d8ffeb0d28e5f98224b1 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Tue, 21 May 2024 13:25:28 -0700 Subject: [PATCH 34/79] Run test using run_in_ci --- samples/greengrass/ipc/recipe.yaml | 2 +- utils/run_in_ci.py | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/samples/greengrass/ipc/recipe.yaml b/samples/greengrass/ipc/recipe.yaml index 4918a20b6..210c3d815 100644 --- a/samples/greengrass/ipc/recipe.yaml +++ b/samples/greengrass/ipc/recipe.yaml @@ -27,4 +27,4 @@ Manifests: Lifecycle: Run: | echo "GG core:" {iot:thingName} - {artifacts:path}/greengrass-ipc --topic test/gg-ipc-topic --message hello --is_ci + python3 ../../../utils/run_in_ci.py --runnable_dir {artifacts:path} --file ci_run_ipc_cfg.json diff --git a/utils/run_in_ci.py b/utils/run_in_ci.py index a999d2def..d7400d264 100644 --- a/utils/run_in_ci.py +++ b/utils/run_in_ci.py @@ -242,7 +242,7 @@ def cleanup_runnable(): return -1 -def launch_runnable(): +def launch_runnable(runnable_dir): global config_json global config_json_arguments_list @@ -254,6 +254,7 @@ def launch_runnable(): print("Launching runnable...") + runnable_file = os.path.join(runnable_dir, config_json['runnable_file']) # Java if (config_json['language'] == "Java"): @@ -266,7 +267,7 @@ def launch_runnable(): arguments = ["mvn", "compile", "exec:java"] arguments.append("-pl") - arguments.append(config_json['runnable_file']) + arguments.append(runnable_file) arguments.append("-Dexec.mainClass=" + config_json['runnable_main_class']) arguments.append("-Daws.crt.ci=True") @@ -279,7 +280,7 @@ def launch_runnable(): # C++ elif (config_json['language'] == "CPP"): runnable_return = subprocess.run( - args=config_json_arguments_list, executable=config_json['runnable_file']) + args=config_json_arguments_list, executable=runnable_file) exit_code = runnable_return.returncode elif (config_json['language'] == "Python"): @@ -287,11 +288,11 @@ def launch_runnable(): config_json_arguments_list.append("True") runnable_return = subprocess.run( - args=[sys.executable, config_json['runnable_file']] + config_json_arguments_list) + args=[sys.executable, runnable_file] + config_json_arguments_list) exit_code = runnable_return.returncode elif (config_json['language'] == "Javascript"): - os.chdir(config_json['runnable_file']) + os.chdir(runnable_file) config_json_arguments_list.append("--is_ci") config_json_arguments_list.append("true") @@ -328,14 +329,14 @@ def launch_runnable(): return exit_code -def setup_and_launch(file, input_uuid=None): +def setup_and_launch(file, input_uuid=None, runnable_dir=''): setup_result = setup_runnable(file, input_uuid) if setup_result != 0: print("Setting up runnable failed") return setup_result print("About to launch runnable...") - return launch_runnable() + return launch_runnable(runnable_dir) def main(): @@ -344,13 +345,16 @@ def main(): argument_parser.add_argument("--file", required=True, help="Configuration file to pull CI data from") argument_parser.add_argument("--input_uuid", required=False, help="UUID data to replace '$INPUT_UUID' with. Only works in Data field") + argument_parser.add_argument("--runnable_dir", required=False, default='', + help="Directory where runnable_file is located") parsed_commands = argument_parser.parse_args() file = parsed_commands.file input_uuid = parsed_commands.input_uuid + runnable_dir = parsed_commands.runnable_dir print(f"Starting to launch runnable: config {file}; input UUID: {input_uuid}") - test_result = setup_and_launch(file, input_uuid) + test_result = setup_and_launch(file, input_uuid, runnable_dir) sys.exit(test_result) From da6094c402ca89fa19619aac371ee2b6af390f2f Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Tue, 21 May 2024 14:40:15 -0700 Subject: [PATCH 35/79] fixup --- samples/greengrass/ipc/ci_run_ipc_cfg.json | 21 +++++++++++++++++++++ samples/greengrass/ipc/copy_files.sh | 2 ++ samples/greengrass/ipc/gdk-config.json | 2 +- samples/greengrass/ipc/recipe.yaml | 4 +++- 4 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 samples/greengrass/ipc/ci_run_ipc_cfg.json create mode 100644 samples/greengrass/ipc/copy_files.sh diff --git a/samples/greengrass/ipc/ci_run_ipc_cfg.json b/samples/greengrass/ipc/ci_run_ipc_cfg.json new file mode 100644 index 000000000..11f95a1bb --- /dev/null +++ b/samples/greengrass/ipc/ci_run_ipc_cfg.json @@ -0,0 +1,21 @@ +{ + "language": "CPP", + "runnable_file": "greengrass-ipc", + "runnable_region": "us-east-1", + "runnable_main_class": "", + "arguments": [ + { + "name": "--topic", + "data": "test/gg-ipc-topic" + }, + { + "name": "--message", + "data": "hello" + }, + { + "name": "--is_ci", + "data": "true" + } + + ] +} diff --git a/samples/greengrass/ipc/copy_files.sh b/samples/greengrass/ipc/copy_files.sh new file mode 100644 index 000000000..d4b7dce1e --- /dev/null +++ b/samples/greengrass/ipc/copy_files.sh @@ -0,0 +1,2 @@ +cp ../../../build/samples/greengrass/ipc/greengrass-ipc . +cp ../../../utils/run_in_ci.py . diff --git a/samples/greengrass/ipc/gdk-config.json b/samples/greengrass/ipc/gdk-config.json index 3c98d552b..92222370e 100644 --- a/samples/greengrass/ipc/gdk-config.json +++ b/samples/greengrass/ipc/gdk-config.json @@ -5,7 +5,7 @@ "version": "NEXT_PATCH", "build": { "build_system": "custom", - "custom_build_command": ["cp", "../../../build/samples/greengrass/ipc/greengrass-ipc", "."] + "custom_build_command": ["bash", "copy_files.sh"] }, "publish": { "bucket": "", diff --git a/samples/greengrass/ipc/recipe.yaml b/samples/greengrass/ipc/recipe.yaml index 210c3d815..1c0c19858 100644 --- a/samples/greengrass/ipc/recipe.yaml +++ b/samples/greengrass/ipc/recipe.yaml @@ -24,7 +24,9 @@ Manifests: Permission: Read: ALL Execute: ALL + - URI: "file:run_in_ci.py" + - URI: "file:ci_run_ipc_cfg.json" Lifecycle: Run: | echo "GG core:" {iot:thingName} - python3 ../../../utils/run_in_ci.py --runnable_dir {artifacts:path} --file ci_run_ipc_cfg.json + python3 {artifacts:path}/run_in_ci.py --runnable_dir {artifacts:path} --file {artifacts:path}/ci_run_ipc_cfg.json From 0ecdc8749067490e44b37a56098c5515e3249af9 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Tue, 21 May 2024 15:11:15 -0700 Subject: [PATCH 36/79] Add basic discovery to CI --- .../basic_discovery/ci_run_discovery_cfg.json | 38 ++++++++++ .../greengrass/basic_discovery/copy_files.sh | 2 + .../basic_discovery/gdk-config.json | 22 ++++++ .../basic_discovery/gg-e2e-tests/pom.xml | 63 +++++++++++++++++ .../greengrass/features/component.feature | 70 +++++++++++++++++++ samples/greengrass/basic_discovery/main.cpp | 1 + .../greengrass/basic_discovery/recipe.yaml | 32 +++++++++ 7 files changed, 228 insertions(+) create mode 100644 samples/greengrass/basic_discovery/ci_run_discovery_cfg.json create mode 100644 samples/greengrass/basic_discovery/copy_files.sh create mode 100644 samples/greengrass/basic_discovery/gdk-config.json create mode 100644 samples/greengrass/basic_discovery/gg-e2e-tests/pom.xml create mode 100644 samples/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature create mode 100644 samples/greengrass/basic_discovery/recipe.yaml diff --git a/samples/greengrass/basic_discovery/ci_run_discovery_cfg.json b/samples/greengrass/basic_discovery/ci_run_discovery_cfg.json new file mode 100644 index 000000000..cb75909a1 --- /dev/null +++ b/samples/greengrass/basic_discovery/ci_run_discovery_cfg.json @@ -0,0 +1,38 @@ +{ + "language": "CPP", + "runnable_file": "basic-discovery", + "runnable_region": "us-east-1", + "runnable_main_class": "", + "arguments": [ + { + "name": "--cert", + "secret": "ci/PubSub/cert", + "filename": "tmp_certificate.pem" + }, + { + "name": "--key", + "secret": "ci/PubSub/key", + "filename": "tmp_key.pem" + }, + { + "name": "--thing_name", + "data": "CI_PubSub_Thing" + }, + { + "name": "--region", + "data": "us-east-1" + }, + { + "name": "--message", + "data": "hello" + }, + { + "name": "--print_discover_resp_only", + "data": "true" + }, + { + "name": "--is_ci", + "data": "true" + } + ] +} diff --git a/samples/greengrass/basic_discovery/copy_files.sh b/samples/greengrass/basic_discovery/copy_files.sh new file mode 100644 index 000000000..6b78d939a --- /dev/null +++ b/samples/greengrass/basic_discovery/copy_files.sh @@ -0,0 +1,2 @@ +cp ../../../build/samples/greengrass/basic_discovery/basic-discovery . +cp ../../../utils/run_in_ci.py . diff --git a/samples/greengrass/basic_discovery/gdk-config.json b/samples/greengrass/basic_discovery/gdk-config.json new file mode 100644 index 000000000..92222370e --- /dev/null +++ b/samples/greengrass/basic_discovery/gdk-config.json @@ -0,0 +1,22 @@ +{ + "component": { + "software.amazon.awssdk.sdk-gg-ipc": { + "author": "iot-device-sdk", + "version": "NEXT_PATCH", + "build": { + "build_system": "custom", + "custom_build_command": ["bash", "copy_files.sh"] + }, + "publish": { + "bucket": "", + "region": "" + } + } + }, + "gdk_version": "1.3.0", + "test-e2e": { + "gtf_options": { + "tags": "testgg" + } + } +} diff --git a/samples/greengrass/basic_discovery/gg-e2e-tests/pom.xml b/samples/greengrass/basic_discovery/gg-e2e-tests/pom.xml new file mode 100644 index 000000000..460832fcb --- /dev/null +++ b/samples/greengrass/basic_discovery/gg-e2e-tests/pom.xml @@ -0,0 +1,63 @@ + + + 4.0.0 + + com.aws.greengrass + uat-features + jar + 1.0.0 + OTF + + + 1.2.0-SNAPSHOT + 1.8 + 1.8 + + + + + greengrass-common + greengrass common + + https://d2jrmugq4soldf.cloudfront.net/snapshots + + + + + + + com.aws.greengrass + aws-greengrass-testing-standalone + ${otf.version} + compile + + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.2 + + + package + + shade + + + + + + + com.aws.greengrass.testing.launcher.TestLauncher + + + + + + + + + diff --git a/samples/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature b/samples/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature new file mode 100644 index 000000000..a7ba8bee5 --- /dev/null +++ b/samples/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature @@ -0,0 +1,70 @@ +Feature: Testing features of Greengrassv2 IPC sample + + @testgg + Scenario: As a developer, I can create a component and deploy it on my device + Given my device is registered as a Thing + And my device is running Greengrass + When I create a Greengrass deployment with components + | aws.greengrass.clientdevices.Auth | LATEST | + | aws.greengrass.clientdevices.mqtt.Moquette | LATEST | + | aws.greengrass.clientdevices.mqtt.Bridge | LATEST | + | aws.greengrass.clientdevices.IPDetector | LATEST | + | software.amazon.awssdk.sdk-gg-ipc | file:recipe.yaml | + When I update my Greengrass deployment configuration, setting the component aws.greengrass.clientdevices.Auth configuration to: + """ + { + "MERGE": { + "deviceGroups": { + "formatVersion": "2021-03-05", + "definitions": { + "MyPermissiveDeviceGroup": { + "selectionRule": "thingName: *", + "policyName": "MyPermissivePolicy" + } + }, + "policies": { + "MyPermissivePolicy": { + "AllowAll": { + "statementDescription": "Allow client devices to perform all actions.", + "operations": [ + "*" + ], + "resources": [ + "*" + ] + } + } + } + } + } + } + """ + When I update my Greengrass deployment configuration, setting the component aws.greengrass.clientdevices.mqtt.Bridge configuration to: + """ + { + "MERGE": { + "mqttTopicMapping": { + "ClientDeviceHelloWorld": { + "topic": "clients/+/hello/world", + "source": "LocalMqtt", + "target": "IotCore" + }, + "ClientDeviceEvents": { + "topic": "clients/+/detections", + "targetTopicPrefix": "events/input/", + "source": "LocalMqtt", + "target": "Pubsub" + }, + "ClientDeviceCloudStatusUpdate": { + "topic": "clients/+/status", + "targetTopicPrefix": "$aws/rules/StatusUpdateRule/", + "source": "LocalMqtt", + "target": "IotCore" + } + } + } + } + """ + And I deploy the Greengrass deployment configuration + Then the Greengrass deployment is COMPLETED on the device after 120 seconds + And the software.amazon.awssdk.sdk-gg-ipc log on the device contains the line "Received payload: hello" within 20 seconds diff --git a/samples/greengrass/basic_discovery/main.cpp b/samples/greengrass/basic_discovery/main.cpp index a8a7cbb6b..f9e5ceec4 100644 --- a/samples/greengrass/basic_discovery/main.cpp +++ b/samples/greengrass/basic_discovery/main.cpp @@ -98,6 +98,7 @@ int main(int argc, char *argv[]) discoveryClient->Discover( cmdData.input_thingName, [&](DiscoverResponse *response, int error, int httpResponseCode) { + fprintf(stdout, "Discovery completed with error code %d; http code %d\n", error, httpResponseCode); if (!error && response->GGGroups) { // Print the discovery response information and then exit. Does not use the discovery info. diff --git a/samples/greengrass/basic_discovery/recipe.yaml b/samples/greengrass/basic_discovery/recipe.yaml new file mode 100644 index 000000000..a60b31c5e --- /dev/null +++ b/samples/greengrass/basic_discovery/recipe.yaml @@ -0,0 +1,32 @@ +--- +RecipeFormatVersion: "2020-01-25" +ComponentName: software.amazon.awssdk.sdk-gg-ipc +ComponentVersion: "1.0.0" +ComponentDescription: "This is test for the Greengrass IPC sample" +ComponentPublisher: "iot-device-sdk" +ComponentConfiguration: + DefaultConfiguration: + accessControl: + aws.greengrass.ipc.mqttproxy: + software.amazon.awssdk.sdk-gg-ipc:mqttproxy:1: + policyDescription: "Allows access to publish and subscribe to a Greengrass IPC test topic" + operations: + - aws.greengrass#PublishToIoTCore + - aws.greengrass#SubscribeToIoTCore + resources: + - "*" + Message: "World" +Manifests: + - Platform: + os: all + Artifacts: + - URI: "file:basic-discovery" + Permission: + Read: ALL + Execute: ALL + - URI: "file:run_in_ci.py" + - URI: "file:ci_run_discovery_cfg.json" + Lifecycle: + Run: | + echo "GG core:" {iot:thingName} + python3 {artifacts:path}/run_in_ci.py --runnable_dir {artifacts:path} --file {artifacts:path}/ci_run_discovery_cfg.json From 7747ff976d1a5f642e985d129983ba3cdf496f72 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Tue, 21 May 2024 15:16:56 -0700 Subject: [PATCH 37/79] Enable gg discovery in CI --- .github/workflows/ci.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b952bb040..f4c4d92f9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -674,6 +674,16 @@ jobs: with: role-to-assume: ${{ env.CI_GREENGRASS_INSTALLER_ROLE }} aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: Running Greengrass basic discovery sample + working-directory: ./aws-iot-device-sdk-cpp-v2/samples/greengrass/basic_discovery + run: | + gdk component build + gdk test-e2e build + gdk test-e2e run + echo "Test logs" + echo "========" + cat testResults/gg*/software.amazon.awssdk.sdk-gg-ipc.log + echo "========" - name: Running Greengrass IPC sample working-directory: ./aws-iot-device-sdk-cpp-v2/samples/greengrass/ipc run: | From 39d5db7ff541193dfc56b9015ffb43c9d0d16f96 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Tue, 21 May 2024 15:53:57 -0700 Subject: [PATCH 38/79] Fix discovery CI --- .builder/actions/build_gg_samples.py | 1 + samples/greengrass/basic_discovery/gdk-config.json | 2 +- .../main/resources/greengrass/features/component.feature | 6 +++--- samples/greengrass/basic_discovery/recipe.yaml | 6 +++--- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.builder/actions/build_gg_samples.py b/.builder/actions/build_gg_samples.py index c2ff6b443..0413a09a9 100644 --- a/.builder/actions/build_gg_samples.py +++ b/.builder/actions/build_gg_samples.py @@ -12,6 +12,7 @@ def run(self, env): steps = [] samples = [ 'samples/greengrass/ipc', + 'samples/greengrass/basic_discovery', ] for sample_path in samples: diff --git a/samples/greengrass/basic_discovery/gdk-config.json b/samples/greengrass/basic_discovery/gdk-config.json index 92222370e..27552d10c 100644 --- a/samples/greengrass/basic_discovery/gdk-config.json +++ b/samples/greengrass/basic_discovery/gdk-config.json @@ -1,6 +1,6 @@ { "component": { - "software.amazon.awssdk.sdk-gg-ipc": { + "software.amazon.awssdk.sdk-gg-discovery": { "author": "iot-device-sdk", "version": "NEXT_PATCH", "build": { diff --git a/samples/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature b/samples/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature index a7ba8bee5..3b08280ef 100644 --- a/samples/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature +++ b/samples/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature @@ -1,4 +1,4 @@ -Feature: Testing features of Greengrassv2 IPC sample +Feature: Testing features of Greengrassv2 basic discovery sample @testgg Scenario: As a developer, I can create a component and deploy it on my device @@ -9,7 +9,7 @@ Feature: Testing features of Greengrassv2 IPC sample | aws.greengrass.clientdevices.mqtt.Moquette | LATEST | | aws.greengrass.clientdevices.mqtt.Bridge | LATEST | | aws.greengrass.clientdevices.IPDetector | LATEST | - | software.amazon.awssdk.sdk-gg-ipc | file:recipe.yaml | + | software.amazon.awssdk.sdk-gg-discovery | file:recipe.yaml | When I update my Greengrass deployment configuration, setting the component aws.greengrass.clientdevices.Auth configuration to: """ { @@ -67,4 +67,4 @@ Feature: Testing features of Greengrassv2 IPC sample """ And I deploy the Greengrass deployment configuration Then the Greengrass deployment is COMPLETED on the device after 120 seconds - And the software.amazon.awssdk.sdk-gg-ipc log on the device contains the line "Received payload: hello" within 20 seconds + And the software.amazon.awssdk.sdk-gg-discovery log on the device contains the line "Discovery completed with error code" within 20 seconds diff --git a/samples/greengrass/basic_discovery/recipe.yaml b/samples/greengrass/basic_discovery/recipe.yaml index a60b31c5e..320465798 100644 --- a/samples/greengrass/basic_discovery/recipe.yaml +++ b/samples/greengrass/basic_discovery/recipe.yaml @@ -1,14 +1,14 @@ --- RecipeFormatVersion: "2020-01-25" -ComponentName: software.amazon.awssdk.sdk-gg-ipc +ComponentName: software.amazon.awssdk.sdk-gg-discovery ComponentVersion: "1.0.0" -ComponentDescription: "This is test for the Greengrass IPC sample" +ComponentDescription: "This is test for the Greengrass basic discovery sample" ComponentPublisher: "iot-device-sdk" ComponentConfiguration: DefaultConfiguration: accessControl: aws.greengrass.ipc.mqttproxy: - software.amazon.awssdk.sdk-gg-ipc:mqttproxy:1: + software.amazon.awssdk.sdk-gg-discovery:mqttproxy:1: policyDescription: "Allows access to publish and subscribe to a Greengrass IPC test topic" operations: - aws.greengrass#PublishToIoTCore From d876163c355e944b6eef8801041edb1f1ac827a9 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Tue, 21 May 2024 16:06:52 -0700 Subject: [PATCH 39/79] fixup --- .github/workflows/ci.yml | 13 ++++++++----- .../resources/greengrass/features/component.feature | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f4c4d92f9..6a6b91d99 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -680,9 +680,12 @@ jobs: gdk component build gdk test-e2e build gdk test-e2e run - echo "Test logs" - echo "========" - cat testResults/gg*/software.amazon.awssdk.sdk-gg-ipc.log + - name: Show logs + echo "Logs" + echo "======== greengrass.log" + cat testResults/gg*/greengrass.log + echo "======== software.amazon.awssdk.sdk-gg-discovery.log" + cat testResults/gg*/software.amazon.awssdk.sdk-gg-discovery.log echo "========" - name: Running Greengrass IPC sample working-directory: ./aws-iot-device-sdk-cpp-v2/samples/greengrass/ipc @@ -690,8 +693,8 @@ jobs: gdk component build gdk test-e2e build gdk test-e2e run - echo "Test logs" - echo "========" + echo "Logs" + echo "======== software.amazon.awssdk.sdk-gg-ipc.log" cat testResults/gg*/software.amazon.awssdk.sdk-gg-ipc.log echo "========" diff --git a/samples/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature b/samples/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature index 3b08280ef..8ecbaf4bb 100644 --- a/samples/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature +++ b/samples/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature @@ -66,5 +66,5 @@ Feature: Testing features of Greengrassv2 basic discovery sample } """ And I deploy the Greengrass deployment configuration - Then the Greengrass deployment is COMPLETED on the device after 120 seconds + Then the Greengrass deployment is COMPLETED on the device after 180 seconds And the software.amazon.awssdk.sdk-gg-discovery log on the device contains the line "Discovery completed with error code" within 20 seconds From 91a73bb266835a035ba7fc814015163bfb647b66 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Tue, 21 May 2024 16:08:57 -0700 Subject: [PATCH 40/79] fixup --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6a6b91d99..085996a64 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -681,6 +681,9 @@ jobs: gdk test-e2e build gdk test-e2e run - name: Show logs + working-directory: ./aws-iot-device-sdk-cpp-v2/samples/greengrass/basic_discovery + if: always() + run: | echo "Logs" echo "======== greengrass.log" cat testResults/gg*/greengrass.log From 18732329ff234201e7435a4b4de3dfeaf4178ec8 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Tue, 21 May 2024 16:20:46 -0700 Subject: [PATCH 41/79] Show associated devices --- .../src/main/resources/greengrass/features/component.feature | 2 +- samples/greengrass/basic_discovery/recipe.yaml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/samples/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature b/samples/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature index 8ecbaf4bb..3b08280ef 100644 --- a/samples/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature +++ b/samples/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature @@ -66,5 +66,5 @@ Feature: Testing features of Greengrassv2 basic discovery sample } """ And I deploy the Greengrass deployment configuration - Then the Greengrass deployment is COMPLETED on the device after 180 seconds + Then the Greengrass deployment is COMPLETED on the device after 120 seconds And the software.amazon.awssdk.sdk-gg-discovery log on the device contains the line "Discovery completed with error code" within 20 seconds diff --git a/samples/greengrass/basic_discovery/recipe.yaml b/samples/greengrass/basic_discovery/recipe.yaml index 320465798..674ba7bff 100644 --- a/samples/greengrass/basic_discovery/recipe.yaml +++ b/samples/greengrass/basic_discovery/recipe.yaml @@ -29,4 +29,5 @@ Manifests: Lifecycle: Run: | echo "GG core:" {iot:thingName} + aws greengrassv2 list-client-devices-associated-with-core-device --core-device-thing-name {iot:thingName} python3 {artifacts:path}/run_in_ci.py --runnable_dir {artifacts:path} --file {artifacts:path}/ci_run_discovery_cfg.json From b4247776d662f40ac11c5a2ed6a2efe965f52d85 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Tue, 21 May 2024 16:31:15 -0700 Subject: [PATCH 42/79] Associate device with gg core --- samples/greengrass/basic_discovery/recipe.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/samples/greengrass/basic_discovery/recipe.yaml b/samples/greengrass/basic_discovery/recipe.yaml index 674ba7bff..2dff9f724 100644 --- a/samples/greengrass/basic_discovery/recipe.yaml +++ b/samples/greengrass/basic_discovery/recipe.yaml @@ -29,5 +29,6 @@ Manifests: Lifecycle: Run: | echo "GG core:" {iot:thingName} + aws greengrassv2 batch-associate-client-device-with-core-device --core-device-thing-name {iot:thingName} --entries thingName=CI_PubSub_Thing aws greengrassv2 list-client-devices-associated-with-core-device --core-device-thing-name {iot:thingName} python3 {artifacts:path}/run_in_ci.py --runnable_dir {artifacts:path} --file {artifacts:path}/ci_run_discovery_cfg.json From fb8eb8845004ff03cf7386e2732cb1991c3b9b13 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Tue, 21 May 2024 16:47:33 -0700 Subject: [PATCH 43/79] Use startup --- samples/greengrass/basic_discovery/recipe.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/samples/greengrass/basic_discovery/recipe.yaml b/samples/greengrass/basic_discovery/recipe.yaml index 2dff9f724..1616c6dc4 100644 --- a/samples/greengrass/basic_discovery/recipe.yaml +++ b/samples/greengrass/basic_discovery/recipe.yaml @@ -27,8 +27,9 @@ Manifests: - URI: "file:run_in_ci.py" - URI: "file:ci_run_discovery_cfg.json" Lifecycle: - Run: | + Startup: | echo "GG core:" {iot:thingName} aws greengrassv2 batch-associate-client-device-with-core-device --core-device-thing-name {iot:thingName} --entries thingName=CI_PubSub_Thing aws greengrassv2 list-client-devices-associated-with-core-device --core-device-thing-name {iot:thingName} + Run: | python3 {artifacts:path}/run_in_ci.py --runnable_dir {artifacts:path} --file {artifacts:path}/ci_run_discovery_cfg.json From 2522862fcc6fd4568f9a3326421f913645390c42 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Tue, 21 May 2024 16:55:57 -0700 Subject: [PATCH 44/79] fixup --- samples/greengrass/basic_discovery/recipe.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/greengrass/basic_discovery/recipe.yaml b/samples/greengrass/basic_discovery/recipe.yaml index 1616c6dc4..37cd26552 100644 --- a/samples/greengrass/basic_discovery/recipe.yaml +++ b/samples/greengrass/basic_discovery/recipe.yaml @@ -27,7 +27,7 @@ Manifests: - URI: "file:run_in_ci.py" - URI: "file:ci_run_discovery_cfg.json" Lifecycle: - Startup: | + Install: | echo "GG core:" {iot:thingName} aws greengrassv2 batch-associate-client-device-with-core-device --core-device-thing-name {iot:thingName} --entries thingName=CI_PubSub_Thing aws greengrassv2 list-client-devices-associated-with-core-device --core-device-thing-name {iot:thingName} From 0d96bb5d7d845f297ae8ab25d3fc8671ca2095bd Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Tue, 21 May 2024 17:03:49 -0700 Subject: [PATCH 45/79] Add sleep --- samples/greengrass/basic_discovery/recipe.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/samples/greengrass/basic_discovery/recipe.yaml b/samples/greengrass/basic_discovery/recipe.yaml index 37cd26552..42953348e 100644 --- a/samples/greengrass/basic_discovery/recipe.yaml +++ b/samples/greengrass/basic_discovery/recipe.yaml @@ -32,4 +32,5 @@ Manifests: aws greengrassv2 batch-associate-client-device-with-core-device --core-device-thing-name {iot:thingName} --entries thingName=CI_PubSub_Thing aws greengrassv2 list-client-devices-associated-with-core-device --core-device-thing-name {iot:thingName} Run: | + sleep 60 python3 {artifacts:path}/run_in_ci.py --runnable_dir {artifacts:path} --file {artifacts:path}/ci_run_discovery_cfg.json From 4e9f540929718de0a6ec8eb93c410bebe30bfbf5 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Tue, 21 May 2024 17:11:30 -0700 Subject: [PATCH 46/79] fixup --- .../src/main/resources/greengrass/features/component.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature b/samples/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature index 3b08280ef..5795e812e 100644 --- a/samples/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature +++ b/samples/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature @@ -67,4 +67,4 @@ Feature: Testing features of Greengrassv2 basic discovery sample """ And I deploy the Greengrass deployment configuration Then the Greengrass deployment is COMPLETED on the device after 120 seconds - And the software.amazon.awssdk.sdk-gg-discovery log on the device contains the line "Discovery completed with error code" within 20 seconds + And the software.amazon.awssdk.sdk-gg-discovery log on the device contains the line "Discovery completed with error code" within 80 seconds From 2380aa3e77f77c0cdfa7dcb966e6831bd9998957 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Wed, 22 May 2024 09:11:35 -0700 Subject: [PATCH 47/79] Try without print_discover_resp_only flag --- samples/greengrass/basic_discovery/ci_run_discovery_cfg.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/samples/greengrass/basic_discovery/ci_run_discovery_cfg.json b/samples/greengrass/basic_discovery/ci_run_discovery_cfg.json index cb75909a1..a7492aa2a 100644 --- a/samples/greengrass/basic_discovery/ci_run_discovery_cfg.json +++ b/samples/greengrass/basic_discovery/ci_run_discovery_cfg.json @@ -26,10 +26,6 @@ "name": "--message", "data": "hello" }, - { - "name": "--print_discover_resp_only", - "data": "true" - }, { "name": "--is_ci", "data": "true" From e706dae342b5d2d514637fbb963af30dd7e691b4 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Wed, 22 May 2024 09:19:19 -0700 Subject: [PATCH 48/79] Revert --- samples/greengrass/basic_discovery/ci_run_discovery_cfg.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/samples/greengrass/basic_discovery/ci_run_discovery_cfg.json b/samples/greengrass/basic_discovery/ci_run_discovery_cfg.json index a7492aa2a..cb75909a1 100644 --- a/samples/greengrass/basic_discovery/ci_run_discovery_cfg.json +++ b/samples/greengrass/basic_discovery/ci_run_discovery_cfg.json @@ -26,6 +26,10 @@ "name": "--message", "data": "hello" }, + { + "name": "--print_discover_resp_only", + "data": "true" + }, { "name": "--is_ci", "data": "true" From 2d14cba2b2dcdd2f3a8acfcedd450fdda24582a3 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Wed, 22 May 2024 09:26:33 -0700 Subject: [PATCH 49/79] Try topic --- samples/greengrass/basic_discovery/ci_run_discovery_cfg.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/greengrass/basic_discovery/ci_run_discovery_cfg.json b/samples/greengrass/basic_discovery/ci_run_discovery_cfg.json index cb75909a1..65a01004f 100644 --- a/samples/greengrass/basic_discovery/ci_run_discovery_cfg.json +++ b/samples/greengrass/basic_discovery/ci_run_discovery_cfg.json @@ -27,8 +27,8 @@ "data": "hello" }, { - "name": "--print_discover_resp_only", - "data": "true" + "name": "--topic", + "data": "clients/CI_PubSub_Thing/hello/world" }, { "name": "--is_ci", From d85cb69120818f3c5464251c25382dc6fe881864 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Wed, 22 May 2024 16:40:18 -0700 Subject: [PATCH 50/79] Add component for discovery --- .../greengrass/basic_discovery/copy_files.sh | 2 - .../basic_discovery/gdk-config.json | 2 +- .../greengrass/features/component.feature | 20 +- .../basic_discovery/hello_world_subscriber.py | 41 +++ samples/greengrass/basic_discovery/main.cpp | 278 ++++++++++-------- .../greengrass/basic_discovery/recipe.yaml | 30 +- 6 files changed, 224 insertions(+), 149 deletions(-) create mode 100644 samples/greengrass/basic_discovery/hello_world_subscriber.py diff --git a/samples/greengrass/basic_discovery/copy_files.sh b/samples/greengrass/basic_discovery/copy_files.sh index 6b78d939a..e69de29bb 100644 --- a/samples/greengrass/basic_discovery/copy_files.sh +++ b/samples/greengrass/basic_discovery/copy_files.sh @@ -1,2 +0,0 @@ -cp ../../../build/samples/greengrass/basic_discovery/basic-discovery . -cp ../../../utils/run_in_ci.py . diff --git a/samples/greengrass/basic_discovery/gdk-config.json b/samples/greengrass/basic_discovery/gdk-config.json index 27552d10c..142fbcd0b 100644 --- a/samples/greengrass/basic_discovery/gdk-config.json +++ b/samples/greengrass/basic_discovery/gdk-config.json @@ -1,6 +1,6 @@ { "component": { - "software.amazon.awssdk.sdk-gg-discovery": { + "software.amazon.awssdk.sdk-gg-test-discovery": { "author": "iot-device-sdk", "version": "NEXT_PATCH", "build": { diff --git a/samples/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature b/samples/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature index 5795e812e..e77bdf1c6 100644 --- a/samples/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature +++ b/samples/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature @@ -5,11 +5,11 @@ Feature: Testing features of Greengrassv2 basic discovery sample Given my device is registered as a Thing And my device is running Greengrass When I create a Greengrass deployment with components - | aws.greengrass.clientdevices.Auth | LATEST | - | aws.greengrass.clientdevices.mqtt.Moquette | LATEST | - | aws.greengrass.clientdevices.mqtt.Bridge | LATEST | - | aws.greengrass.clientdevices.IPDetector | LATEST | - | software.amazon.awssdk.sdk-gg-discovery | file:recipe.yaml | + | aws.greengrass.clientdevices.Auth | LATEST | + | aws.greengrass.clientdevices.mqtt.Moquette | LATEST | + | aws.greengrass.clientdevices.mqtt.Bridge | LATEST | + | aws.greengrass.clientdevices.IPDetector | LATEST | + | software.amazon.awssdk.sdk-gg-test-subscriber | file:recipe.yaml | When I update my Greengrass deployment configuration, setting the component aws.greengrass.clientdevices.Auth configuration to: """ { @@ -44,11 +44,16 @@ Feature: Testing features of Greengrassv2 basic discovery sample { "MERGE": { "mqttTopicMapping": { - "ClientDeviceHelloWorld": { + "HelloWorldCoreMapping": { "topic": "clients/+/hello/world", "source": "LocalMqtt", "target": "IotCore" }, + "HelloWorldPubsubMapping": { + "topic": "clients/+/hello/world", + "source": "LocalMqtt", + "target": "Pubsub" + }, "ClientDeviceEvents": { "topic": "clients/+/detections", "targetTopicPrefix": "events/input/", @@ -67,4 +72,5 @@ Feature: Testing features of Greengrassv2 basic discovery sample """ And I deploy the Greengrass deployment configuration Then the Greengrass deployment is COMPLETED on the device after 120 seconds - And the software.amazon.awssdk.sdk-gg-discovery log on the device contains the line "Discovery completed with error code" within 80 seconds + And the software.amazon.awssdk.sdk-gg-test-subscriber log on the device contains the line "Successfully subscribed to topic" within 80 seconds + And the software.amazon.awssdk.sdk-gg-test-subscriber log on the device contains the line "Received new message" within 100 seconds diff --git a/samples/greengrass/basic_discovery/hello_world_subscriber.py b/samples/greengrass/basic_discovery/hello_world_subscriber.py new file mode 100644 index 000000000..77fd7fb2d --- /dev/null +++ b/samples/greengrass/basic_discovery/hello_world_subscriber.py @@ -0,0 +1,41 @@ +import sys +import time +import traceback + +from awsiot.greengrasscoreipc.clientv2 import GreengrassCoreIPCClientV2 + +CLIENT_DEVICE_HELLO_WORLD_TOPIC = 'clients/+/hello/world' +TIMEOUT = 10 + + +def on_hello_world_message(event): + try: + message = str(event.binary_message.message, 'utf-8') + print('Received new message: %s' % message) + except: + traceback.print_exc() + + +try: + ipc_client = GreengrassCoreIPCClientV2() + + # SubscribeToTopic returns a tuple with the response and the operation. + _, operation = ipc_client.subscribe_to_topic( + topic=CLIENT_DEVICE_HELLO_WORLD_TOPIC, on_stream_event=on_hello_world_message) + print('Successfully subscribed to topic: %s' % + CLIENT_DEVICE_HELLO_WORLD_TOPIC) + + # Keep the main thread alive, or the process will exit. + try: + cnt = 0 + while cnt < 6: + time.sleep(10) + cnt = cnt + 1 + except InterruptedError: + print('Subscribe interrupted.') + + operation.close() +except Exception: + print('Exception occurred when using IPC.', file=sys.stderr) + traceback.print_exc() + exit(1) diff --git a/samples/greengrass/basic_discovery/main.cpp b/samples/greengrass/basic_discovery/main.cpp index f9e5ceec4..bb01e985a 100644 --- a/samples/greengrass/basic_discovery/main.cpp +++ b/samples/greengrass/basic_discovery/main.cpp @@ -19,6 +19,101 @@ using namespace Aws::Crt; using namespace Aws::Discovery; +std::shared_ptr getMqttConnection( + Aws::Iot::MqttClient &mqttClient, + DiscoverResponse *response, + Utils::cmdData &cmdData, + std::promise &shutdownCompletedPromise) +{ + std::shared_ptr connection; + + for (const auto &groupToUse : *response->GGGroups) + { + for (const auto &connectivityInfo : *groupToUse.Cores->at(0).Connectivity) + { + fprintf( + stdout, + "Connecting to group %s with thing arn %s, using endpoint %s:%d\n", + groupToUse.GGGroupId->c_str(), + groupToUse.Cores->at(0).ThingArn->c_str(), + connectivityInfo.HostAddress->c_str(), + (int)connectivityInfo.Port.value()); + + connection = mqttClient.NewConnection( + Aws::Iot::MqttClientConnectionConfigBuilder(cmdData.input_cert.c_str(), cmdData.input_key.c_str()) + .WithCertificateAuthority(ByteCursorFromCString(groupToUse.CAs->at(0).c_str())) + .WithPortOverride(connectivityInfo.Port.value()) + .WithEndpoint(connectivityInfo.HostAddress.value()) + .WithTcpConnectTimeout(3000) + .Build()); + + if (!connection) + { + fprintf(stderr, "Connection setup failed with error %s", ErrorDebugString(mqttClient.LastError())); + continue; + } + + std::promise connectPromise; + + connection->OnConnectionCompleted = [&connectPromise, connectivityInfo, groupToUse]( + Mqtt::MqttConnection & /*connection*/, + int errorCode, + Mqtt::ReturnCode /*returnCode*/, + bool /*sessionPresent*/) + { + if (!errorCode) + { + fprintf( + stdout, + "Connected to group %s, using connection to %s:%d\n", + groupToUse.GGGroupId->c_str(), + connectivityInfo.HostAddress->c_str(), + (int)connectivityInfo.Port.value()); + connectPromise.set_value(true); + } + else + { + fprintf( + stderr, + "Error connecting to group %s, using connection to %s:%d\n", + groupToUse.GGGroupId->c_str(), + connectivityInfo.HostAddress->c_str(), + (int)connectivityInfo.Port.value()); + fprintf(stderr, "Error: %s\n", aws_error_debug_str(errorCode)); + connectPromise.set_value(false); + } + }; + + connection->OnConnectionInterrupted = [](Mqtt::MqttConnection &, int errorCode) + { fprintf(stderr, "Connection interrupted with error %s\n", aws_error_debug_str(errorCode)); }; + + connection->OnConnectionResumed = + [](Mqtt::MqttConnection & /*connection*/, Mqtt::ReturnCode /*connectCode*/, bool /*sessionPresent*/) + { fprintf(stdout, "Connection resumed\n"); }; + + connection->OnDisconnect = [&](Mqtt::MqttConnection & /*connection*/) + { + fprintf(stdout, "Connection disconnected. Shutting Down.....\n"); + shutdownCompletedPromise.set_value(); + }; + + if (!connection->Connect(cmdData.input_thingName.c_str(), false)) + { + fprintf(stderr, "Connect failed with error %s\n", aws_error_debug_str(aws_last_error())); + continue; + } + + auto connectFuture = connectPromise.get_future(); + + if (connectFuture.get()) + { + return connection; + } + } + } + return nullptr; +} + int main(int argc, char *argv[]) { /************************ Setup ****************************/ @@ -97,13 +192,15 @@ int main(int argc, char *argv[]) std::promise shutdownCompletedPromise; discoveryClient->Discover( - cmdData.input_thingName, [&](DiscoverResponse *response, int error, int httpResponseCode) { + cmdData.input_thingName, + [&](DiscoverResponse *response, int error, int httpResponseCode) + { fprintf(stdout, "Discovery completed with error code %d; http code %d\n", error, httpResponseCode); if (!error && response->GGGroups) { // Print the discovery response information and then exit. Does not use the discovery info. // (unless in CI, in which case just note it was successful and exit) - if (cmdData.input_PrintDiscoverRespOnly == true) + if (cmdData.input_PrintDiscoverRespOnly) { // Print the discovery response information and then exit (unless in CI, in which case just note it // was successful) @@ -140,117 +237,14 @@ int main(int argc, char *argv[]) exit(0); } - auto groupToUse = std::move(response->GGGroups->at(0)); - auto connectivityInfo = groupToUse.Cores->at(0).Connectivity->at(0); - - fprintf( - stdout, - "Connecting to group %s with thing arn %s, using endpoint %s:%d\n", - groupToUse.GGGroupId->c_str(), - groupToUse.Cores->at(0).ThingArn->c_str(), - connectivityInfo.HostAddress->c_str(), - (int)connectivityInfo.Port.value()); - - connection = mqttClient.NewConnection( - Aws::Iot::MqttClientConnectionConfigBuilder(cmdData.input_cert.c_str(), cmdData.input_key.c_str()) - .WithCertificateAuthority(ByteCursorFromCString(groupToUse.CAs->at(0).c_str())) - .WithPortOverride(connectivityInfo.Port.value()) - .WithEndpoint(connectivityInfo.HostAddress.value()) - .Build()); - - if (!connection) + connection = getMqttConnection(mqttClient, response, cmdData, shutdownCompletedPromise); + if (connection) { - fprintf(stderr, "Connection setup failed with error %s", ErrorDebugString(mqttClient.LastError())); - exit(-1); + connectionFinishedPromise.set_value(); } - - connection->OnConnectionCompleted = [&, connectivityInfo, groupToUse]( - Mqtt::MqttConnection &conn, - int errorCode, - Mqtt::ReturnCode /*returnCode*/, - bool /*sessionPresent*/) { - if (!errorCode) - { - fprintf( - stdout, - "Connected to group %s, using connection to %s:%d\n", - groupToUse.GGGroupId->c_str(), - connectivityInfo.HostAddress->c_str(), - (int)connectivityInfo.Port.value()); - - if (cmdData.input_mode == "both" || cmdData.input_mode == "subscribe") - { - auto onMessage = [&](Mqtt::MqttConnection & /*connection*/, - const String &receivedOnTopic, - const ByteBuf &payload, - bool /*dup*/, - Mqtt::QOS /*qos*/, - bool /*retain*/) { - fprintf(stdout, "Publish received on topic %s\n", receivedOnTopic.c_str()); - fprintf(stdout, "Message: \n"); - fwrite(payload.buffer, 1, payload.len, stdout); - fprintf(stdout, "\n"); - }; - - auto onSubAck = [&](Mqtt::MqttConnection & /*connection*/, - uint16_t /*packetId*/, - const String &topic, - Mqtt::QOS /*qos*/, - int errorCode) { - if (!errorCode) - { - fprintf(stdout, "Successfully subscribed to %s\n", topic.c_str()); - connectionFinishedPromise.set_value(); - } - else - { - fprintf( - stderr, - "Failed to subscribe to %s with error %s. Exiting\n", - topic.c_str(), - aws_error_debug_str(errorCode)); - exit(-1); - } - }; - - conn.Subscribe(cmdData.input_topic.c_str(), AWS_MQTT_QOS_AT_MOST_ONCE, onMessage, onSubAck); - } - else - { - connectionFinishedPromise.set_value(); - } - } - else - { - fprintf( - stderr, - "Error connecting to group %s, using connection to %s:%d\n", - groupToUse.GGGroupId->c_str(), - connectivityInfo.HostAddress->c_str(), - (int)connectivityInfo.Port.value()); - fprintf(stderr, "Error: %s\n", aws_error_debug_str(errorCode)); - exit(-1); - } - }; - - connection->OnConnectionInterrupted = [](Mqtt::MqttConnection &, int errorCode) { - fprintf(stderr, "Connection interrupted with error %s\n", aws_error_debug_str(errorCode)); - }; - - connection->OnConnectionResumed = [](Mqtt::MqttConnection & /*connection*/, - Mqtt::ReturnCode /*connectCode*/, - bool /*sessionPresent*/) { - fprintf(stdout, "Connection resumed\n"); - }; - - connection->OnDisconnect = [&](Mqtt::MqttConnection & /*connection*/) { - fprintf(stdout, "Connection disconnected. Shutting Down.....\n"); - shutdownCompletedPromise.set_value(); - }; - - if (!connection->Connect(cmdData.input_thingName.c_str(), false)) + else { - fprintf(stderr, "Connect failed with error %s\n", aws_error_debug_str(aws_last_error())); + fprintf(stderr, "All connection attempts failed\n"); exit(-1); } } @@ -264,17 +258,56 @@ int main(int argc, char *argv[]) exit(-1); } }); + + connectionFinishedPromise.get_future().wait(); + + if (cmdData.input_mode == "both" || cmdData.input_mode == "subscribe") { - connectionFinishedPromise.get_future().wait(); + auto onMessage = [&](Mqtt::MqttConnection & /*connection*/, + const String &receivedOnTopic, + const ByteBuf &payload, + bool /*dup*/, + Mqtt::QOS /*qos*/, + bool /*retain*/) + { + fprintf(stdout, "Publish received on topic %s\n", receivedOnTopic.c_str()); + fprintf(stdout, "Message: \n"); + fwrite(payload.buffer, 1, payload.len, stdout); + fprintf(stdout, "\n"); + }; + + auto onSubAck = [&](Mqtt::MqttConnection & /*connection*/, + uint16_t /*packetId*/, + const String &topic, + Mqtt::QOS /*qos*/, + int errorCode) + { + if (!errorCode) + { + fprintf(stdout, "Successfully subscribed to %s\n", topic.c_str()); + } + else + { + fprintf( + stderr, + "Failed to subscribe to %s with error %s. Exiting\n", + topic.c_str(), + aws_error_debug_str(errorCode)); + exit(-1); + } + }; + + connection->Subscribe(cmdData.input_topic.c_str(), AWS_MQTT_QOS_AT_MOST_ONCE, onMessage, onSubAck); } + // TODO Wait for subscription success. - bool first_input = true; - while (true) + int cnt = 0; + while (++cnt < 20) { - String input = ""; + String input; if (cmdData.input_mode == "both" || cmdData.input_mode == "publish") { - if (cmdData.input_message == "") + if (cmdData.input_message.empty()) { fprintf( stdout, @@ -284,13 +317,9 @@ int main(int argc, char *argv[]) std::getline(std::cin, input); cmdData.input_message = input; } - else if (first_input == false) - { - fprintf(stdout, "Enter a new message or enter 'exit' or 'quit' to exit the program.\n"); - std::getline(std::cin, input); - cmdData.input_message = input; + else { + input = cmdData.input_message; } - first_input = false; } else { @@ -300,7 +329,7 @@ int main(int argc, char *argv[]) if (input == "exit" || input == "quit") { - fprintf(stdout, "Exiting..."); + fprintf(stdout, "Exiting...\n"); break; } @@ -309,7 +338,8 @@ int main(int argc, char *argv[]) ByteBuf payload = ByteBufNewCopy(DefaultAllocator(), (const uint8_t *)input.data(), input.length()); ByteBuf *payloadPtr = &payload; - auto onPublishComplete = [payloadPtr](Mqtt::MqttConnection &, uint16_t packetId, int errorCode) { + auto onPublishComplete = [payloadPtr](Mqtt::MqttConnection &, uint16_t packetId, int errorCode) + { aws_byte_buf_clean_up(payloadPtr); if (packetId) @@ -324,6 +354,8 @@ int main(int argc, char *argv[]) connection->Publish( cmdData.input_topic.c_str(), AWS_MQTT_QOS_AT_MOST_ONCE, false, payload, onPublishComplete); } + + std::this_thread::sleep_for(std::chrono::seconds(1)); } connection->Disconnect(); diff --git a/samples/greengrass/basic_discovery/recipe.yaml b/samples/greengrass/basic_discovery/recipe.yaml index 42953348e..170280637 100644 --- a/samples/greengrass/basic_discovery/recipe.yaml +++ b/samples/greengrass/basic_discovery/recipe.yaml @@ -1,36 +1,34 @@ --- RecipeFormatVersion: "2020-01-25" -ComponentName: software.amazon.awssdk.sdk-gg-discovery +ComponentName: software.amazon.awssdk.sdk-gg-test-subscriber ComponentVersion: "1.0.0" ComponentDescription: "This is test for the Greengrass basic discovery sample" ComponentPublisher: "iot-device-sdk" ComponentConfiguration: DefaultConfiguration: accessControl: - aws.greengrass.ipc.mqttproxy: - software.amazon.awssdk.sdk-gg-discovery:mqttproxy:1: - policyDescription: "Allows access to publish and subscribe to a Greengrass IPC test topic" + aws.greengrass.ipc.pubsub: + software.amazon.awssdk.sdk-gg-test-subscriber:pubsub:1: + policyDescription: "Allows access to subscribe to a Greengrass IPC test topic" operations: - - aws.greengrass#PublishToIoTCore - - aws.greengrass#SubscribeToIoTCore + - aws.greengrass#SubscribeToTopic resources: - "*" - Message: "World" Manifests: - Platform: os: all Artifacts: - - URI: "file:basic-discovery" - Permission: - Read: ALL - Execute: ALL - - URI: "file:run_in_ci.py" - - URI: "file:ci_run_discovery_cfg.json" + - URI: "file:hello_world_subscriber.py" Lifecycle: Install: | echo "GG core:" {iot:thingName} - aws greengrassv2 batch-associate-client-device-with-core-device --core-device-thing-name {iot:thingName} --entries thingName=CI_PubSub_Thing + aws greengrassv2 batch-associate-client-device-with-core-device --core-device-thing-name {iot:thingName} --entries thingName=laptop_test_0001 aws greengrassv2 list-client-devices-associated-with-core-device --core-device-thing-name {iot:thingName} Run: | - sleep 60 - python3 {artifacts:path}/run_in_ci.py --runnable_dir {artifacts:path} --file {artifacts:path}/ci_run_discovery_cfg.json + python3 -u {artifacts:path}/hello_world_subscriber.py + Shutdown: | + echo "Shutdown step" + aws greengrassv2 batch-disassociate-client-device-from-core-device --core-device-thing-name {iot:thingName} --entries thingName=laptop_test_0001 + Recover: | + echo "Recover step" + aws greengrassv2 batch-disassociate-client-device-from-core-device --core-device-thing-name {iot:thingName} --entries thingName=laptop_test_0001 From a4e9c45fd112e35738d3ca4755448db9422e59c3 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Fri, 24 May 2024 13:15:59 -0700 Subject: [PATCH 51/79] Run discovery within component --- .../basic_discovery/ci_run_discovery_cfg.json | 4 ++++ .../greengrass/basic_discovery/copy_files.sh | 2 ++ .../basic_discovery/gdk-config.json | 4 ++-- .../greengrass/features/component.feature | 14 ++++++------- .../basic_discovery/hello_world_subscriber.py | 2 ++ .../greengrass/basic_discovery/recipe.yaml | 21 +++++++++++++------ 6 files changed, 32 insertions(+), 15 deletions(-) diff --git a/samples/greengrass/basic_discovery/ci_run_discovery_cfg.json b/samples/greengrass/basic_discovery/ci_run_discovery_cfg.json index 65a01004f..cc81dd2d3 100644 --- a/samples/greengrass/basic_discovery/ci_run_discovery_cfg.json +++ b/samples/greengrass/basic_discovery/ci_run_discovery_cfg.json @@ -30,6 +30,10 @@ "name": "--topic", "data": "clients/CI_PubSub_Thing/hello/world" }, + { + "name": "--mode", + "data": "publish" + }, { "name": "--is_ci", "data": "true" diff --git a/samples/greengrass/basic_discovery/copy_files.sh b/samples/greengrass/basic_discovery/copy_files.sh index e69de29bb..6b78d939a 100644 --- a/samples/greengrass/basic_discovery/copy_files.sh +++ b/samples/greengrass/basic_discovery/copy_files.sh @@ -0,0 +1,2 @@ +cp ../../../build/samples/greengrass/basic_discovery/basic-discovery . +cp ../../../utils/run_in_ci.py . diff --git a/samples/greengrass/basic_discovery/gdk-config.json b/samples/greengrass/basic_discovery/gdk-config.json index 142fbcd0b..468e794eb 100644 --- a/samples/greengrass/basic_discovery/gdk-config.json +++ b/samples/greengrass/basic_discovery/gdk-config.json @@ -8,8 +8,8 @@ "custom_build_command": ["bash", "copy_files.sh"] }, "publish": { - "bucket": "", - "region": "" + "bucket": "iot-sdk-ci-bucket-us-east-1", + "region": "us-east-1" } } }, diff --git a/samples/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature b/samples/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature index e77bdf1c6..520977c3f 100644 --- a/samples/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature +++ b/samples/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature @@ -5,11 +5,11 @@ Feature: Testing features of Greengrassv2 basic discovery sample Given my device is registered as a Thing And my device is running Greengrass When I create a Greengrass deployment with components - | aws.greengrass.clientdevices.Auth | LATEST | - | aws.greengrass.clientdevices.mqtt.Moquette | LATEST | - | aws.greengrass.clientdevices.mqtt.Bridge | LATEST | - | aws.greengrass.clientdevices.IPDetector | LATEST | - | software.amazon.awssdk.sdk-gg-test-subscriber | file:recipe.yaml | + | aws.greengrass.clientdevices.Auth | LATEST | + | aws.greengrass.clientdevices.mqtt.Moquette | LATEST | + | aws.greengrass.clientdevices.mqtt.Bridge | LATEST | + | aws.greengrass.clientdevices.IPDetector | LATEST | + | software.amazon.awssdk.sdk-gg-test-discovery | file:recipe.yaml | When I update my Greengrass deployment configuration, setting the component aws.greengrass.clientdevices.Auth configuration to: """ { @@ -72,5 +72,5 @@ Feature: Testing features of Greengrassv2 basic discovery sample """ And I deploy the Greengrass deployment configuration Then the Greengrass deployment is COMPLETED on the device after 120 seconds - And the software.amazon.awssdk.sdk-gg-test-subscriber log on the device contains the line "Successfully subscribed to topic" within 80 seconds - And the software.amazon.awssdk.sdk-gg-test-subscriber log on the device contains the line "Received new message" within 100 seconds + And the software.amazon.awssdk.sdk-gg-test-discovery log on the device contains the line "Successfully subscribed to topic" within 80 seconds + And the software.amazon.awssdk.sdk-gg-test-discovery log on the device contains the line "Received new message" within 100 seconds diff --git a/samples/greengrass/basic_discovery/hello_world_subscriber.py b/samples/greengrass/basic_discovery/hello_world_subscriber.py index 77fd7fb2d..b69d24a49 100644 --- a/samples/greengrass/basic_discovery/hello_world_subscriber.py +++ b/samples/greengrass/basic_discovery/hello_world_subscriber.py @@ -39,3 +39,5 @@ def on_hello_world_message(event): print('Exception occurred when using IPC.', file=sys.stderr) traceback.print_exc() exit(1) + +print("Subscriber done") diff --git a/samples/greengrass/basic_discovery/recipe.yaml b/samples/greengrass/basic_discovery/recipe.yaml index 170280637..c7a34e9bd 100644 --- a/samples/greengrass/basic_discovery/recipe.yaml +++ b/samples/greengrass/basic_discovery/recipe.yaml @@ -1,6 +1,6 @@ --- RecipeFormatVersion: "2020-01-25" -ComponentName: software.amazon.awssdk.sdk-gg-test-subscriber +ComponentName: software.amazon.awssdk.sdk-gg-test-discovery ComponentVersion: "1.0.0" ComponentDescription: "This is test for the Greengrass basic discovery sample" ComponentPublisher: "iot-device-sdk" @@ -8,7 +8,7 @@ ComponentConfiguration: DefaultConfiguration: accessControl: aws.greengrass.ipc.pubsub: - software.amazon.awssdk.sdk-gg-test-subscriber:pubsub:1: + software.amazon.awssdk.sdk-gg-test-discovery:pubsub:1: policyDescription: "Allows access to subscribe to a Greengrass IPC test topic" operations: - aws.greengrass#SubscribeToTopic @@ -19,16 +19,25 @@ Manifests: os: all Artifacts: - URI: "file:hello_world_subscriber.py" + - URI: "file:basic-discovery" + Permission: + Read: ALL + Execute: ALL Lifecycle: Install: | echo "GG core:" {iot:thingName} - aws greengrassv2 batch-associate-client-device-with-core-device --core-device-thing-name {iot:thingName} --entries thingName=laptop_test_0001 + aws greengrassv2 batch-associate-client-device-with-core-device --core-device-thing-name {iot:thingName} --entries thingName=CI_PubSub_Thing aws greengrassv2 list-client-devices-associated-with-core-device --core-device-thing-name {iot:thingName} Run: | - python3 -u {artifacts:path}/hello_world_subscriber.py + echo "starting subscriber" + python3 -u {artifacts:path}/hello_world_subscriber.py & + echo "continuing ..." + sleep 10 + echo "starting discovery" + python3 {artifacts:path}/run_in_ci.py --runnable_dir {artifacts:path} --file {artifacts:path}/ci_run_discovery_cfg.json Shutdown: | echo "Shutdown step" - aws greengrassv2 batch-disassociate-client-device-from-core-device --core-device-thing-name {iot:thingName} --entries thingName=laptop_test_0001 + aws greengrassv2 batch-disassociate-client-device-from-core-device --core-device-thing-name {iot:thingName} --entries thingName=CI_PubSub_Thing Recover: | echo "Recover step" - aws greengrassv2 batch-disassociate-client-device-from-core-device --core-device-thing-name {iot:thingName} --entries thingName=laptop_test_0001 + aws greengrassv2 batch-disassociate-client-device-from-core-device --core-device-thing-name {iot:thingName} --entries thingName=CI_PubSub_Thing From f901fccf8624ae0e089feb1a6b880d81e4b9c21d Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Fri, 24 May 2024 13:17:53 -0700 Subject: [PATCH 52/79] format --- samples/greengrass/basic_discovery/main.cpp | 33 +++++++++------------ 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/samples/greengrass/basic_discovery/main.cpp b/samples/greengrass/basic_discovery/main.cpp index bb01e985a..74f7fa883 100644 --- a/samples/greengrass/basic_discovery/main.cpp +++ b/samples/greengrass/basic_discovery/main.cpp @@ -59,8 +59,7 @@ std::shared_ptr getMqttConnection( Mqtt::MqttConnection & /*connection*/, int errorCode, Mqtt::ReturnCode /*returnCode*/, - bool /*sessionPresent*/) - { + bool /*sessionPresent*/) { if (!errorCode) { fprintf( @@ -84,15 +83,15 @@ std::shared_ptr getMqttConnection( } }; - connection->OnConnectionInterrupted = [](Mqtt::MqttConnection &, int errorCode) - { fprintf(stderr, "Connection interrupted with error %s\n", aws_error_debug_str(errorCode)); }; + connection->OnConnectionInterrupted = [](Mqtt::MqttConnection &, int errorCode) { + fprintf(stderr, "Connection interrupted with error %s\n", aws_error_debug_str(errorCode)); + }; - connection->OnConnectionResumed = - [](Mqtt::MqttConnection & /*connection*/, Mqtt::ReturnCode /*connectCode*/, bool /*sessionPresent*/) - { fprintf(stdout, "Connection resumed\n"); }; + connection->OnConnectionResumed = [](Mqtt::MqttConnection & /*connection*/, + Mqtt::ReturnCode /*connectCode*/, + bool /*sessionPresent*/) { fprintf(stdout, "Connection resumed\n"); }; - connection->OnDisconnect = [&](Mqtt::MqttConnection & /*connection*/) - { + connection->OnDisconnect = [&](Mqtt::MqttConnection & /*connection*/) { fprintf(stdout, "Connection disconnected. Shutting Down.....\n"); shutdownCompletedPromise.set_value(); }; @@ -192,9 +191,7 @@ int main(int argc, char *argv[]) std::promise shutdownCompletedPromise; discoveryClient->Discover( - cmdData.input_thingName, - [&](DiscoverResponse *response, int error, int httpResponseCode) - { + cmdData.input_thingName, [&](DiscoverResponse *response, int error, int httpResponseCode) { fprintf(stdout, "Discovery completed with error code %d; http code %d\n", error, httpResponseCode); if (!error && response->GGGroups) { @@ -268,8 +265,7 @@ int main(int argc, char *argv[]) const ByteBuf &payload, bool /*dup*/, Mqtt::QOS /*qos*/, - bool /*retain*/) - { + bool /*retain*/) { fprintf(stdout, "Publish received on topic %s\n", receivedOnTopic.c_str()); fprintf(stdout, "Message: \n"); fwrite(payload.buffer, 1, payload.len, stdout); @@ -280,8 +276,7 @@ int main(int argc, char *argv[]) uint16_t /*packetId*/, const String &topic, Mqtt::QOS /*qos*/, - int errorCode) - { + int errorCode) { if (!errorCode) { fprintf(stdout, "Successfully subscribed to %s\n", topic.c_str()); @@ -317,7 +312,8 @@ int main(int argc, char *argv[]) std::getline(std::cin, input); cmdData.input_message = input; } - else { + else + { input = cmdData.input_message; } } @@ -338,8 +334,7 @@ int main(int argc, char *argv[]) ByteBuf payload = ByteBufNewCopy(DefaultAllocator(), (const uint8_t *)input.data(), input.length()); ByteBuf *payloadPtr = &payload; - auto onPublishComplete = [payloadPtr](Mqtt::MqttConnection &, uint16_t packetId, int errorCode) - { + auto onPublishComplete = [payloadPtr](Mqtt::MqttConnection &, uint16_t packetId, int errorCode) { aws_byte_buf_clean_up(payloadPtr); if (packetId) From bb46c89130d08a4dfca4c34b173e0b1cb5ee2c49 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Fri, 24 May 2024 13:22:56 -0700 Subject: [PATCH 53/79] Missing include --- samples/greengrass/basic_discovery/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/samples/greengrass/basic_discovery/main.cpp b/samples/greengrass/basic_discovery/main.cpp index 74f7fa883..7f0319412 100644 --- a/samples/greengrass/basic_discovery/main.cpp +++ b/samples/greengrass/basic_discovery/main.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include "../../utils/CommandLineUtils.h" From c52ee9649160ebe7be9ce89872fb9ccd7ac67b92 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Fri, 24 May 2024 13:41:43 -0700 Subject: [PATCH 54/79] Add artifact --- samples/greengrass/basic_discovery/recipe.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/samples/greengrass/basic_discovery/recipe.yaml b/samples/greengrass/basic_discovery/recipe.yaml index c7a34e9bd..7190ba66e 100644 --- a/samples/greengrass/basic_discovery/recipe.yaml +++ b/samples/greengrass/basic_discovery/recipe.yaml @@ -19,6 +19,7 @@ Manifests: os: all Artifacts: - URI: "file:hello_world_subscriber.py" + - URI: "file:run_in_ci.py" - URI: "file:basic-discovery" Permission: Read: ALL From c1a602ba5a3cb7d6f759bd0514e67ceff58f68cf Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Fri, 24 May 2024 13:50:54 -0700 Subject: [PATCH 55/79] Add config to artifacts --- samples/greengrass/basic_discovery/recipe.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/samples/greengrass/basic_discovery/recipe.yaml b/samples/greengrass/basic_discovery/recipe.yaml index 7190ba66e..73763f560 100644 --- a/samples/greengrass/basic_discovery/recipe.yaml +++ b/samples/greengrass/basic_discovery/recipe.yaml @@ -20,6 +20,7 @@ Manifests: Artifacts: - URI: "file:hello_world_subscriber.py" - URI: "file:run_in_ci.py" + - URI: "file:ci_run_discovery_cfg.json" - URI: "file:basic-discovery" Permission: Read: ALL From 2ab1aca4e4448f1941c0869c29738886e864c45f Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Fri, 24 May 2024 14:05:11 -0700 Subject: [PATCH 56/79] Fix log filename --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 085996a64..6a65595ae 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -687,8 +687,8 @@ jobs: echo "Logs" echo "======== greengrass.log" cat testResults/gg*/greengrass.log - echo "======== software.amazon.awssdk.sdk-gg-discovery.log" - cat testResults/gg*/software.amazon.awssdk.sdk-gg-discovery.log + echo "======== software.amazon.awssdk.sdk-gg-test-discovery.log" + cat testResults/gg*/software.amazon.awssdk.sdk-gg-test-discovery.log echo "========" - name: Running Greengrass IPC sample working-directory: ./aws-iot-device-sdk-cpp-v2/samples/greengrass/ipc From b83e05fef20451823ccc391a4cb2802704fd335a Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Fri, 24 May 2024 14:31:23 -0700 Subject: [PATCH 57/79] Install awsiotsdk --- .github/workflows/ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6a65595ae..dfe4862ad 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -668,13 +668,14 @@ jobs: python builder.pyz build -p ${{ env.PACKAGE_NAME }} - name: Install Greengrass Development Kit run: | + python3 -m pip install awsiotsdk python3 -m pip install -U git+https://github.com/aws-greengrass/aws-greengrass-gdk-cli.git@v1.6.2 - - name: configure AWS credentials (Greengrass) + - name: Configure AWS credentials (Greengrass) uses: aws-actions/configure-aws-credentials@v2 with: role-to-assume: ${{ env.CI_GREENGRASS_INSTALLER_ROLE }} aws-region: ${{ env.AWS_DEFAULT_REGION }} - - name: Running Greengrass basic discovery sample + - name: Build and run Greengrass basic discovery sample working-directory: ./aws-iot-device-sdk-cpp-v2/samples/greengrass/basic_discovery run: | gdk component build From 01865d9b9ff054204348963e8fe0111422cd259b Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Fri, 24 May 2024 14:40:51 -0700 Subject: [PATCH 58/79] Add print message --- samples/greengrass/basic_discovery/main.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/samples/greengrass/basic_discovery/main.cpp b/samples/greengrass/basic_discovery/main.cpp index 7f0319412..21376133e 100644 --- a/samples/greengrass/basic_discovery/main.cpp +++ b/samples/greengrass/basic_discovery/main.cpp @@ -183,6 +183,8 @@ int main(int argc, char *argv[]) /************************ Run the sample ****************************/ + fprintf(stdout, "Starting discovery\n"); + auto discoveryClient = DiscoveryClient::CreateClient(clientConfig); Aws::Iot::MqttClient mqttClient; From 98b6f9e4989319a6cedfd3af89e16af33bdbecda Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Fri, 24 May 2024 14:55:49 -0700 Subject: [PATCH 59/79] Fix log message --- samples/greengrass/basic_discovery/main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/samples/greengrass/basic_discovery/main.cpp b/samples/greengrass/basic_discovery/main.cpp index 21376133e..780587867 100644 --- a/samples/greengrass/basic_discovery/main.cpp +++ b/samples/greengrass/basic_discovery/main.cpp @@ -75,8 +75,9 @@ std::shared_ptr getMqttConnection( { fprintf( stderr, - "Error connecting to group %s, using connection to %s:%d\n", + "Error connecting to group %s (thing %s) using connection to %s:%d\n", groupToUse.GGGroupId->c_str(), + groupToUse.Cores->at(0).ThingArn->c_str(), connectivityInfo.HostAddress->c_str(), (int)connectivityInfo.Port.value()); fprintf(stderr, "Error: %s\n", aws_error_debug_str(errorCode)); From f0cea9e69e9cc25f1ccda439452bd189243a0a8d Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Fri, 24 May 2024 15:23:07 -0700 Subject: [PATCH 60/79] Use more suitable thing --- .../greengrass/basic_discovery/ci_run_discovery_cfg.json | 8 ++++---- samples/greengrass/basic_discovery/recipe.yaml | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/samples/greengrass/basic_discovery/ci_run_discovery_cfg.json b/samples/greengrass/basic_discovery/ci_run_discovery_cfg.json index cc81dd2d3..d61295932 100644 --- a/samples/greengrass/basic_discovery/ci_run_discovery_cfg.json +++ b/samples/greengrass/basic_discovery/ci_run_discovery_cfg.json @@ -6,17 +6,17 @@ "arguments": [ { "name": "--cert", - "secret": "ci/PubSub/cert", + "secret": "ci/Greengrass/cert", "filename": "tmp_certificate.pem" }, { "name": "--key", - "secret": "ci/PubSub/key", + "secret": "ci/Greengrass/key", "filename": "tmp_key.pem" }, { "name": "--thing_name", - "data": "CI_PubSub_Thing" + "data": "CI_GreenGrass_Thing" }, { "name": "--region", @@ -28,7 +28,7 @@ }, { "name": "--topic", - "data": "clients/CI_PubSub_Thing/hello/world" + "data": "clients/CI_GreenGrass_Thing/hello/world" }, { "name": "--mode", diff --git a/samples/greengrass/basic_discovery/recipe.yaml b/samples/greengrass/basic_discovery/recipe.yaml index 73763f560..bae1106d9 100644 --- a/samples/greengrass/basic_discovery/recipe.yaml +++ b/samples/greengrass/basic_discovery/recipe.yaml @@ -28,7 +28,7 @@ Manifests: Lifecycle: Install: | echo "GG core:" {iot:thingName} - aws greengrassv2 batch-associate-client-device-with-core-device --core-device-thing-name {iot:thingName} --entries thingName=CI_PubSub_Thing + aws greengrassv2 batch-associate-client-device-with-core-device --core-device-thing-name {iot:thingName} --entries thingName=CI_GreenGrass_Thing aws greengrassv2 list-client-devices-associated-with-core-device --core-device-thing-name {iot:thingName} Run: | echo "starting subscriber" @@ -39,7 +39,7 @@ Manifests: python3 {artifacts:path}/run_in_ci.py --runnable_dir {artifacts:path} --file {artifacts:path}/ci_run_discovery_cfg.json Shutdown: | echo "Shutdown step" - aws greengrassv2 batch-disassociate-client-device-from-core-device --core-device-thing-name {iot:thingName} --entries thingName=CI_PubSub_Thing + aws greengrassv2 batch-disassociate-client-device-from-core-device --core-device-thing-name {iot:thingName} --entries thingName=CI_GreenGrass_Thing Recover: | echo "Recover step" - aws greengrassv2 batch-disassociate-client-device-from-core-device --core-device-thing-name {iot:thingName} --entries thingName=CI_PubSub_Thing + aws greengrassv2 batch-disassociate-client-device-from-core-device --core-device-thing-name {iot:thingName} --entries thingName=CI_GreenGrass_Thing From ed1449c4972d24e75ac50eeeff0d4231e20c428c Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Mon, 27 May 2024 14:06:54 -0700 Subject: [PATCH 61/79] fixup --- .../greengrass/basic_discovery/ci_run_discovery_cfg.json | 8 ++++---- .../main/resources/greengrass/features/component.feature | 6 +++--- samples/greengrass/basic_discovery/main.cpp | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/samples/greengrass/basic_discovery/ci_run_discovery_cfg.json b/samples/greengrass/basic_discovery/ci_run_discovery_cfg.json index d61295932..ed7a0f702 100644 --- a/samples/greengrass/basic_discovery/ci_run_discovery_cfg.json +++ b/samples/greengrass/basic_discovery/ci_run_discovery_cfg.json @@ -6,17 +6,17 @@ "arguments": [ { "name": "--cert", - "secret": "ci/Greengrass/cert", + "secret": "ci/Greengrass_Discovery/cert", "filename": "tmp_certificate.pem" }, { "name": "--key", - "secret": "ci/Greengrass/key", + "secret": "ci/Greengrass_Discovery/key", "filename": "tmp_key.pem" }, { "name": "--thing_name", - "data": "CI_GreenGrass_Thing" + "data": "CI_Greengrass_Discovery_Thing" }, { "name": "--region", @@ -28,7 +28,7 @@ }, { "name": "--topic", - "data": "clients/CI_GreenGrass_Thing/hello/world" + "data": "clients/CI_Greengrass_Discovery_Thing/hello/world" }, { "name": "--mode", diff --git a/samples/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature b/samples/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature index 520977c3f..5f4d9f057 100644 --- a/samples/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature +++ b/samples/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature @@ -71,6 +71,6 @@ Feature: Testing features of Greengrassv2 basic discovery sample } """ And I deploy the Greengrass deployment configuration - Then the Greengrass deployment is COMPLETED on the device after 120 seconds - And the software.amazon.awssdk.sdk-gg-test-discovery log on the device contains the line "Successfully subscribed to topic" within 80 seconds - And the software.amazon.awssdk.sdk-gg-test-discovery log on the device contains the line "Received new message" within 100 seconds + Then the Greengrass deployment is COMPLETED on the device after 180 seconds + And the software.amazon.awssdk.sdk-gg-test-discovery log on the device contains the line "Successfully subscribed to topic" within 120 seconds + And the software.amazon.awssdk.sdk-gg-test-discovery log on the device contains the line "Received new message" within 140 seconds diff --git a/samples/greengrass/basic_discovery/main.cpp b/samples/greengrass/basic_discovery/main.cpp index 780587867..83bed5b50 100644 --- a/samples/greengrass/basic_discovery/main.cpp +++ b/samples/greengrass/basic_discovery/main.cpp @@ -301,7 +301,7 @@ int main(int argc, char *argv[]) // TODO Wait for subscription success. int cnt = 0; - while (++cnt < 20) + while (++cnt < 10) { String input; if (cmdData.input_mode == "both" || cmdData.input_mode == "publish") From 0d2516a1fc60603b667f2a0575dd3be171184b1e Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Mon, 27 May 2024 15:35:05 -0700 Subject: [PATCH 62/79] fixup --- .../greengrass/features/component.feature | 18 +---- .../basic_discovery/hello_world_subscriber.py | 66 +++++++++++-------- samples/greengrass/basic_discovery/main.cpp | 5 +- .../greengrass/basic_discovery/recipe.yaml | 5 +- 4 files changed, 48 insertions(+), 46 deletions(-) diff --git a/samples/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature b/samples/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature index 5f4d9f057..a8b128a1a 100644 --- a/samples/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature +++ b/samples/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature @@ -45,32 +45,20 @@ Feature: Testing features of Greengrassv2 basic discovery sample "MERGE": { "mqttTopicMapping": { "HelloWorldCoreMapping": { - "topic": "clients/+/hello/world", + "topic": "clients/+/hello/world/+", "source": "LocalMqtt", "target": "IotCore" }, "HelloWorldPubsubMapping": { - "topic": "clients/+/hello/world", + "topic": "clients/+/hello/world/+", "source": "LocalMqtt", "target": "Pubsub" - }, - "ClientDeviceEvents": { - "topic": "clients/+/detections", - "targetTopicPrefix": "events/input/", - "source": "LocalMqtt", - "target": "Pubsub" - }, - "ClientDeviceCloudStatusUpdate": { - "topic": "clients/+/status", - "targetTopicPrefix": "$aws/rules/StatusUpdateRule/", - "source": "LocalMqtt", - "target": "IotCore" } } } } """ And I deploy the Greengrass deployment configuration - Then the Greengrass deployment is COMPLETED on the device after 180 seconds + Then the Greengrass deployment is COMPLETED on the device after 150 seconds And the software.amazon.awssdk.sdk-gg-test-discovery log on the device contains the line "Successfully subscribed to topic" within 120 seconds And the software.amazon.awssdk.sdk-gg-test-discovery log on the device contains the line "Received new message" within 140 seconds diff --git a/samples/greengrass/basic_discovery/hello_world_subscriber.py b/samples/greengrass/basic_discovery/hello_world_subscriber.py index b69d24a49..44fd99b71 100644 --- a/samples/greengrass/basic_discovery/hello_world_subscriber.py +++ b/samples/greengrass/basic_discovery/hello_world_subscriber.py @@ -1,43 +1,55 @@ +import argparse import sys import time import traceback +import uuid from awsiot.greengrasscoreipc.clientv2 import GreengrassCoreIPCClientV2 -CLIENT_DEVICE_HELLO_WORLD_TOPIC = 'clients/+/hello/world' -TIMEOUT = 10 - -def on_hello_world_message(event): +def on_message(event): try: + print('Topic: {}'.format(event.binary_message.context.topic)) message = str(event.binary_message.message, 'utf-8') - print('Received new message: %s' % message) + print('Received new message: {}'.format(message)) except: traceback.print_exc() -try: - ipc_client = GreengrassCoreIPCClientV2() +def main(): + argument_parser = argparse.ArgumentParser( + description="Run Greengrass subscriber component") + argument_parser.add_argument( + "--input_uuid", required=False, help="UUID for unique topic name. UUID will be generated if this option is omit") + parsed_commands = argument_parser.parse_args() - # SubscribeToTopic returns a tuple with the response and the operation. - _, operation = ipc_client.subscribe_to_topic( - topic=CLIENT_DEVICE_HELLO_WORLD_TOPIC, on_stream_event=on_hello_world_message) - print('Successfully subscribed to topic: %s' % - CLIENT_DEVICE_HELLO_WORLD_TOPIC) + input_uuid = parsed_commands.input_uuid if parsed_commands.input_uuid else str(uuid.uuid4()) - # Keep the main thread alive, or the process will exit. try: - cnt = 0 - while cnt < 6: - time.sleep(10) - cnt = cnt + 1 - except InterruptedError: - print('Subscribe interrupted.') - - operation.close() -except Exception: - print('Exception occurred when using IPC.', file=sys.stderr) - traceback.print_exc() - exit(1) - -print("Subscriber done") + ipc_client = GreengrassCoreIPCClientV2() + + client_device_hello_world_topic = 'clients/+/hello/world/{}'.format(input_uuid) + + # SubscribeToTopic returns a tuple with the response and the operation. + _, operation = ipc_client.subscribe_to_topic( + topic=client_device_hello_world_topic, on_stream_event=on_message) + print('Successfully subscribed to topic: {}'.format(client_device_hello_world_topic)) + + # Keep the main thread alive, or the process will exit. + try: + while True: + time.sleep(10) + except InterruptedError: + print('Subscribe interrupted.') + + operation.close() + except Exception: + print('Exception occurred when using IPC.', file=sys.stderr) + traceback.print_exc() + exit(1) + + print("Subscriber done") + + +if __name__ == "__main__": + main() diff --git a/samples/greengrass/basic_discovery/main.cpp b/samples/greengrass/basic_discovery/main.cpp index 83bed5b50..860720902 100644 --- a/samples/greengrass/basic_discovery/main.cpp +++ b/samples/greengrass/basic_discovery/main.cpp @@ -301,7 +301,7 @@ int main(int argc, char *argv[]) // TODO Wait for subscription success. int cnt = 0; - while (++cnt < 10) + while (++cnt < 3) { String input; if (cmdData.input_mode == "both" || cmdData.input_mode == "publish") @@ -350,8 +350,9 @@ int main(int argc, char *argv[]) fprintf(stdout, "Operation failed with error %s\n", aws_error_debug_str(errorCode)); } }; + fprintf(stdout, "Publishing to topic %s\n", cmdData.input_topic.c_str()); connection->Publish( - cmdData.input_topic.c_str(), AWS_MQTT_QOS_AT_MOST_ONCE, false, payload, onPublishComplete); + cmdData.input_topic.c_str(), AWS_MQTT_QOS_AT_LEAST_ONCE, false, payload, onPublishComplete); } std::this_thread::sleep_for(std::chrono::seconds(1)); diff --git a/samples/greengrass/basic_discovery/recipe.yaml b/samples/greengrass/basic_discovery/recipe.yaml index bae1106d9..e3ac935da 100644 --- a/samples/greengrass/basic_discovery/recipe.yaml +++ b/samples/greengrass/basic_discovery/recipe.yaml @@ -31,12 +31,13 @@ Manifests: aws greengrassv2 batch-associate-client-device-with-core-device --core-device-thing-name {iot:thingName} --entries thingName=CI_GreenGrass_Thing aws greengrassv2 list-client-devices-associated-with-core-device --core-device-thing-name {iot:thingName} Run: | + UUID=$(python3 -c "import uuid; print (uuid.uuid4())") echo "starting subscriber" - python3 -u {artifacts:path}/hello_world_subscriber.py & + python3 -u {artifacts:path}/hello_world_subscriber.py --input_uuid ${UUID} & echo "continuing ..." sleep 10 echo "starting discovery" - python3 {artifacts:path}/run_in_ci.py --runnable_dir {artifacts:path} --file {artifacts:path}/ci_run_discovery_cfg.json + python3 {artifacts:path}/run_in_ci.py --runnable_dir {artifacts:path} --input_uuid ${UUID} --file {artifacts:path}/ci_run_discovery_cfg.local.json Shutdown: | echo "Shutdown step" aws greengrassv2 batch-disassociate-client-device-from-core-device --core-device-thing-name {iot:thingName} --entries thingName=CI_GreenGrass_Thing From 336408cdbd957564407561de43d64c6f9c179371 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Mon, 27 May 2024 15:37:51 -0700 Subject: [PATCH 63/79] fixup --- samples/greengrass/basic_discovery/recipe.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/samples/greengrass/basic_discovery/recipe.yaml b/samples/greengrass/basic_discovery/recipe.yaml index e3ac935da..c2e4f4e69 100644 --- a/samples/greengrass/basic_discovery/recipe.yaml +++ b/samples/greengrass/basic_discovery/recipe.yaml @@ -12,6 +12,15 @@ ComponentConfiguration: policyDescription: "Allows access to subscribe to a Greengrass IPC test topic" operations: - aws.greengrass#SubscribeToTopic + - aws.greengrass#PublishToTopic + resources: + - "*" + aws.greengrass.ipc.mqttproxy: + software.amazon.awssdk.sdk-gg-test-discovery:mqttproxy:1: + policyDescription: "Allows access to publish and subscribe to a Greengrass IPC test topic" + operations: + - aws.greengrass#PublishToIoTCore + - aws.greengrass#SubscribeToIoTCore resources: - "*" Manifests: From fa154669e002fea4905e63eedc8419084b95bac3 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Tue, 28 May 2024 11:40:29 -0700 Subject: [PATCH 64/79] Use the right thing --- .../basic_discovery/ci_run_discovery_cfg.json | 10 +++------- samples/greengrass/basic_discovery/recipe.yaml | 16 ++++------------ 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/samples/greengrass/basic_discovery/ci_run_discovery_cfg.json b/samples/greengrass/basic_discovery/ci_run_discovery_cfg.json index ed7a0f702..257924ffe 100644 --- a/samples/greengrass/basic_discovery/ci_run_discovery_cfg.json +++ b/samples/greengrass/basic_discovery/ci_run_discovery_cfg.json @@ -6,12 +6,12 @@ "arguments": [ { "name": "--cert", - "secret": "ci/Greengrass_Discovery/cert", + "secret": "ci/GreengrassDiscovery/cert", "filename": "tmp_certificate.pem" }, { "name": "--key", - "secret": "ci/Greengrass_Discovery/key", + "secret": "ci/GreengrassDiscovery/key", "filename": "tmp_key.pem" }, { @@ -28,15 +28,11 @@ }, { "name": "--topic", - "data": "clients/CI_Greengrass_Discovery_Thing/hello/world" + "data": "clients/CI_Greengrass_Discovery_Thing/hello/world/$INPUT_UUID" }, { "name": "--mode", "data": "publish" - }, - { - "name": "--is_ci", - "data": "true" } ] } diff --git a/samples/greengrass/basic_discovery/recipe.yaml b/samples/greengrass/basic_discovery/recipe.yaml index c2e4f4e69..96495a6cd 100644 --- a/samples/greengrass/basic_discovery/recipe.yaml +++ b/samples/greengrass/basic_discovery/recipe.yaml @@ -15,14 +15,6 @@ ComponentConfiguration: - aws.greengrass#PublishToTopic resources: - "*" - aws.greengrass.ipc.mqttproxy: - software.amazon.awssdk.sdk-gg-test-discovery:mqttproxy:1: - policyDescription: "Allows access to publish and subscribe to a Greengrass IPC test topic" - operations: - - aws.greengrass#PublishToIoTCore - - aws.greengrass#SubscribeToIoTCore - resources: - - "*" Manifests: - Platform: os: all @@ -37,7 +29,7 @@ Manifests: Lifecycle: Install: | echo "GG core:" {iot:thingName} - aws greengrassv2 batch-associate-client-device-with-core-device --core-device-thing-name {iot:thingName} --entries thingName=CI_GreenGrass_Thing + aws greengrassv2 batch-associate-client-device-with-core-device --core-device-thing-name {iot:thingName} --entries thingName=CI_Greengrass_Discovery_Thing aws greengrassv2 list-client-devices-associated-with-core-device --core-device-thing-name {iot:thingName} Run: | UUID=$(python3 -c "import uuid; print (uuid.uuid4())") @@ -46,10 +38,10 @@ Manifests: echo "continuing ..." sleep 10 echo "starting discovery" - python3 {artifacts:path}/run_in_ci.py --runnable_dir {artifacts:path} --input_uuid ${UUID} --file {artifacts:path}/ci_run_discovery_cfg.local.json + python3 {artifacts:path}/run_in_ci.py --runnable_dir {artifacts:path} --input_uuid ${UUID} --file {artifacts:path}/ci_run_discovery_cfg.json Shutdown: | echo "Shutdown step" - aws greengrassv2 batch-disassociate-client-device-from-core-device --core-device-thing-name {iot:thingName} --entries thingName=CI_GreenGrass_Thing + aws greengrassv2 batch-disassociate-client-device-from-core-device --core-device-thing-name {iot:thingName} --entries thingName=CI_Greengrass_Discovery_Thing Recover: | echo "Recover step" - aws greengrassv2 batch-disassociate-client-device-from-core-device --core-device-thing-name {iot:thingName} --entries thingName=CI_GreenGrass_Thing + aws greengrassv2 batch-disassociate-client-device-from-core-device --core-device-thing-name {iot:thingName} --entries thingName=CI_Greengrass_Discovery_Thing From 73a379c5ed8d2bdf23def05592e90ed90efc71a4 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Tue, 28 May 2024 14:14:13 -0700 Subject: [PATCH 65/79] Enable all CI jobs --- .github/workflows/ci.yml | 1274 +++++++++++++++++++------------------- builder.json | 2 +- 2 files changed, 638 insertions(+), 638 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dfe4862ad..49c17ec5f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,604 +42,604 @@ env: CI_SHADOW_SERVICE_CLIENT_ROLE: arn:aws:iam::180635532705:role/CI_ShadowServiceClient_Role jobs: - # linux-compat: - # runs-on: ubuntu-latest - # strategy: - # matrix: - # image: - # - manylinux2014-x64 - # - manylinux2014-x86 - # - al2-x64 - # - alpine-3.16-x64 - # - alpine-3.16-x86 - # - alpine-3.16-armv6 - # - alpine-3.16-armv7 - # - alpine-3.16-arm64 - # permissions: - # id-token: write # This is required for requesting the JWT - # steps: - # - name: configure AWS credentials (containers) - # uses: aws-actions/configure-aws-credentials@v2 - # with: - # role-to-assume: ${{ env.CI_IOT_CONTAINERS }} - # aws-region: ${{ env.AWS_DEFAULT_REGION }} - # - name: Install qemu/docker - # run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - # - name: Build ${{ env.PACKAGE_NAME }} - # run: | - # aws s3 cp s3://aws-crt-test-stuff/ci/${{ env.BUILDER_VERSION }}/linux-container-ci.sh ./linux-container-ci.sh && chmod a+x ./linux-container-ci.sh - # ./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-${{ matrix.image }} build -p ${{ env.PACKAGE_NAME }} - # raspberry: - # runs-on: ubuntu-20.04 # latest - # strategy: - # fail-fast: false - # matrix: - # image: - # - raspbian-bullseye - # permissions: - # id-token: write # This is required for requesting the JWT - # steps: - # - name: configure AWS credentials (containers) - # uses: aws-actions/configure-aws-credentials@v2 - # with: - # role-to-assume: ${{ env.CI_IOT_CONTAINERS }} - # aws-region: ${{ env.AWS_DEFAULT_REGION }} - # # set arm arch - # - name: Install qemu/docker - # run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - # - name: Build ${{ env.PACKAGE_NAME }} - # run: | - # aws s3 cp s3://aws-crt-test-stuff/ci/${{ env.BUILDER_VERSION }}/linux-container-ci.sh ./linux-container-ci.sh && chmod a+x ./linux-container-ci.sh - # ./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-${{ matrix.image }} build -p ${{ env.PACKAGE_NAME }} - # linux-compiler-compat: - # runs-on: ubuntu-latest - # strategy: - # matrix: - # compiler: - # - clang-3 - # - clang-6 - # - clang-8 - # - clang-9 - # - clang-10 - # - clang-11 - # - gcc-4.8 - # - gcc-5 - # - gcc-6 - # - gcc-7 - # - gcc-8 - # permissions: - # id-token: write # This is required for requesting the JWT - # steps: - # - name: configure AWS credentials (containers) - # uses: aws-actions/configure-aws-credentials@v2 - # with: - # role-to-assume: ${{ env.CI_IOT_CONTAINERS }} - # aws-region: ${{ env.AWS_DEFAULT_REGION }} - # # We can't use the `uses: docker://image` version yet, GitHub lacks authentication for actions -> packages - # - name: Build ${{ env.PACKAGE_NAME }} - # run: | - # aws s3 cp s3://aws-crt-test-stuff/ci/${{ env.BUILDER_VERSION }}/linux-container-ci.sh ./linux-container-ci.sh && chmod a+x ./linux-container-ci.sh - # ./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-${{ env.LINUX_BASE_IMAGE }} build -p ${{ env.PACKAGE_NAME }} --compiler=${{ matrix.compiler }} - # byo-crypto: - # runs-on: ubuntu-latest - # permissions: - # id-token: write # This is required for requesting the JWT - # steps: - # - name: configure AWS credentials (containers) - # uses: aws-actions/configure-aws-credentials@v2 - # with: - # role-to-assume: ${{ env.CI_IOT_CONTAINERS }} - # aws-region: ${{ env.AWS_DEFAULT_REGION }} - # # We can't use the `uses: docker://image` version yet, GitHub lacks authentication for actions -> packages - # - name: Build ${{ env.PACKAGE_NAME }} - # run: | - # aws s3 cp s3://aws-crt-test-stuff/ci/${{ env.BUILDER_VERSION }}/linux-container-ci.sh ./linux-container-ci.sh && chmod a+x ./linux-container-ci.sh - # ./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-${{ env.LINUX_BASE_IMAGE }} build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-DBYO_CRYPTO=ON --variant=skip_sample - # linux-no-cpu-extensions: - # runs-on: ubuntu-latest - # permissions: - # id-token: write # This is required for requesting the JWT - # steps: - # - name: configure AWS credentials (containers) - # uses: aws-actions/configure-aws-credentials@v2 - # with: - # role-to-assume: ${{ env.CI_IOT_CONTAINERS }} - # aws-region: ${{ env.AWS_DEFAULT_REGION }} - # # We can't use the `uses: docker://image` version yet, GitHub lacks authentication for actions -> packages - # - name: Build ${{ env.PACKAGE_NAME }} - # run: | - # aws s3 cp s3://aws-crt-test-stuff/ci/${{ env.BUILDER_VERSION }}/linux-container-ci.sh ./linux-container-ci.sh && chmod a+x ./linux-container-ci.sh - # ./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-${{ env.LINUX_BASE_IMAGE }} build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-DUSE_CPU_EXTENSIONS=OFF - # windows: - # runs-on: windows-latest - # permissions: - # id-token: write # This is required for requesting the JWT - # steps: - # - name: Build ${{ env.PACKAGE_NAME }} + consumers - # run: | - # md ${{ env.CI_FOLDER }} - # cd ${{ env.CI_FOLDER }} - # python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz', 'builder.pyz')" - # python builder.pyz build -p ${{ env.PACKAGE_NAME }} - # - name: Running samples in CI setup - # run: | - # python -m pip install boto3 - # - name: configure AWS credentials (PubSub) - # uses: aws-actions/configure-aws-credentials@v2 - # with: - # role-to-assume: ${{ env.CI_PUBSUB_ROLE }} - # aws-region: ${{ env.AWS_DEFAULT_REGION }} - # - name: run MQTT3 PubSub sample - # run: | - # cd ${{ env.CI_FOLDER }} - # python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_pubsub_windows_cfg.json - # - name: run Windows Certificate Connect sample - # run: | - # cd ${{ env.CI_FOLDER }} - # python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_windows_cert_connect_cfg.json - # - name: configure AWS credentials (MQTT5) - # uses: aws-actions/configure-aws-credentials@v2 - # with: - # role-to-assume: ${{ env.CI_MQTT5_ROLE }} - # aws-region: ${{ env.AWS_DEFAULT_REGION }} - # - name: run MQTT5 PubSub sample - # run: | - # cd ${{ env.CI_FOLDER }} - # python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_mqtt5_pubsub_windows_cfg.json - # - name: configure AWS credentials (Device Advisor) - # uses: aws-actions/configure-aws-credentials@v2 - # with: - # role-to-assume: ${{ env.CI_DEVICE_ADVISOR }} - # aws-region: ${{ env.AWS_DEFAULT_REGION }} - # - name: run DeviceAdvisor - # run: | - # cd ${{ env.CI_FOLDER }}/aws-iot-device-sdk-cpp-v2 - # python ./deviceadvisor/script/DATestRun.py - # windows-vs14: - # runs-on: windows-2019 # windows-2019 is last env with Visual Studio 2015 (v14.0) - # strategy: - # matrix: - # arch: [Win32, x64] - # fail-fast: false - # permissions: - # id-token: write # This is required for requesting the JWT - # steps: - # - name: Build ${{ env.PACKAGE_NAME }} + consumers - # run: | - # md ${{ env.CI_FOLDER }} - # cd ${{ env.CI_FOLDER }} - # python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')" - # python builder.pyz build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-Tv140 --cmake-extra=-A${{ matrix.arch }} - # - name: Running samples in CI setup - # run: | - # python -m pip install boto3 - # - name: configure AWS credentials (PubSub) - # uses: aws-actions/configure-aws-credentials@v2 - # with: - # role-to-assume: ${{ env.CI_PUBSUB_ROLE }} - # aws-region: ${{ env.AWS_DEFAULT_REGION }} - # - name: run MQTT3 PubSub sample - # run: | - # cd ${{ env.CI_FOLDER }} - # python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_pubsub_windows_cfg.json - # - name: run Windows Certificate Connect sample - # run: | - # cd ${{ env.CI_FOLDER }} - # python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_windows_cert_connect_cfg.json - # - name: configure AWS credentials (MQTT5) - # uses: aws-actions/configure-aws-credentials@v2 - # with: - # role-to-assume: ${{ env.CI_MQTT5_ROLE }} - # aws-region: ${{ env.AWS_DEFAULT_REGION }} - # - name: run MQTT5 PubSub sample - # run: | - # cd ${{ env.CI_FOLDER }} - # python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_mqtt5_pubsub_windows_cfg.json - # - name: configure AWS credentials (Device Advisor) - # uses: aws-actions/configure-aws-credentials@v2 - # with: - # role-to-assume: ${{ env.CI_DEVICE_ADVISOR }} - # aws-region: ${{ env.AWS_DEFAULT_REGION }} - # - name: run DeviceAdvisor - # run: | - # cd ${{ env.CI_FOLDER }}/aws-iot-device-sdk-cpp-v2 - # python ./deviceadvisor/script/DATestRun.py - # windows-no-cpu-extensions: - # runs-on: windows-latest - # permissions: - # id-token: write # This is required for requesting the JWT - # steps: - # - name: Build ${{ env.PACKAGE_NAME }} + consumers - # run: | - # md ${{ env.CI_FOLDER }} - # cd ${{ env.CI_FOLDER }} - # python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz', 'builder.pyz')" - # python builder.pyz build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-DUSE_CPU_EXTENSIONS=OFF - # - name: Running samples in CI setup - # run: | - # python -m pip install boto3 - # - name: configure AWS credentials (PubSub) - # uses: aws-actions/configure-aws-credentials@v2 - # with: - # role-to-assume: ${{ env.CI_PUBSUB_ROLE }} - # aws-region: ${{ env.AWS_DEFAULT_REGION }} - # - name: run MQTT3 PubSub sample - # run: | - # cd ${{ env.CI_FOLDER }} - # python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_pubsub_windows_cfg.json - # - name: run Windows Certificate Connect sample - # run: | - # cd ${{ env.CI_FOLDER }} - # python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_windows_cert_connect_cfg.json - # - name: configure AWS credentials (MQTT5) - # uses: aws-actions/configure-aws-credentials@v2 - # with: - # role-to-assume: ${{ env.CI_MQTT5_ROLE }} - # aws-region: ${{ env.AWS_DEFAULT_REGION }} - # - name: run MQTT5 PubSub sample - # run: | - # cd ${{ env.CI_FOLDER }} - # python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_mqtt5_pubsub_windows_cfg.json - # - name: configure AWS credentials (Device Advisor) - # uses: aws-actions/configure-aws-credentials@v2 - # with: - # role-to-assume: ${{ env.CI_DEVICE_ADVISOR }} - # aws-region: ${{ env.AWS_DEFAULT_REGION }} - # - name: run DeviceAdvisor - # run: | - # cd ${{ env.CI_FOLDER }}/aws-iot-device-sdk-cpp-v2 - # python ./deviceadvisor/script/DATestRun.py - # windows-app-verifier: - # runs-on: windows-2022 # latest - # permissions: - # id-token: write # This is required for requesting the JWT - # steps: - # - name: Build ${{ env.PACKAGE_NAME }} + consumers - # run: | - # md ${{ env.CI_FOLDER }} - # cd ${{ env.CI_FOLDER }} - # python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz', 'builder.pyz')" - # python builder.pyz build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-DUSE_CPU_EXTENSIONS=OFF - # - name: Running samples in CI setup - # run: | - # python -m pip install boto3 - # - name: configure AWS credentials (CyclePubSub) - # uses: aws-actions/configure-aws-credentials@v2 - # with: - # role-to-assume: ${{ env.CI_CYCLEPUBSUB_ROLE }} - # aws-region: ${{ env.AWS_DEFAULT_REGION }} - # - name: Run and check AppVerifier - # run: | - # cd ${{ env.CI_FOLDER }} - # echo "Starting to run AppVerifier with cycle pub-sub sample" - # python ${{ env.CI_UTILS_FOLDER }}/appverifier_launch_sample.py --sample_file ".\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\cycle_pub_sub\RelWithDebInfo\cycle-pub-sub.exe" --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/CyclePubSub/cert' --sample_secret_private_key 'ci/CyclePubSub/key' - # windows-shared-lib: - # runs-on: windows-latest - # permissions: - # id-token: write # This is required for requesting the JWT - # steps: - # - name: Build ${{ env.PACKAGE_NAME }} + consumers - # run: | - # md ${{ env.CI_FOLDER }} - # cd ${{ env.CI_FOLDER }} - # python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz', 'builder.pyz')" - # python builder.pyz build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-DBUILD_SHARED_LIBS=ON + linux-compat: + runs-on: ubuntu-latest + strategy: + matrix: + image: + - manylinux2014-x64 + - manylinux2014-x86 + - al2-x64 + - alpine-3.16-x64 + - alpine-3.16-x86 + - alpine-3.16-armv6 + - alpine-3.16-armv7 + - alpine-3.16-arm64 + permissions: + id-token: write # This is required for requesting the JWT + steps: + - name: configure AWS credentials (containers) + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.CI_IOT_CONTAINERS }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: Install qemu/docker + run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes + - name: Build ${{ env.PACKAGE_NAME }} + run: | + aws s3 cp s3://aws-crt-test-stuff/ci/${{ env.BUILDER_VERSION }}/linux-container-ci.sh ./linux-container-ci.sh && chmod a+x ./linux-container-ci.sh + ./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-${{ matrix.image }} build -p ${{ env.PACKAGE_NAME }} + raspberry: + runs-on: ubuntu-20.04 # latest + strategy: + fail-fast: false + matrix: + image: + - raspbian-bullseye + permissions: + id-token: write # This is required for requesting the JWT + steps: + - name: configure AWS credentials (containers) + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.CI_IOT_CONTAINERS }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + # set arm arch + - name: Install qemu/docker + run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes + - name: Build ${{ env.PACKAGE_NAME }} + run: | + aws s3 cp s3://aws-crt-test-stuff/ci/${{ env.BUILDER_VERSION }}/linux-container-ci.sh ./linux-container-ci.sh && chmod a+x ./linux-container-ci.sh + ./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-${{ matrix.image }} build -p ${{ env.PACKAGE_NAME }} + linux-compiler-compat: + runs-on: ubuntu-latest + strategy: + matrix: + compiler: + - clang-3 + - clang-6 + - clang-8 + - clang-9 + - clang-10 + - clang-11 + - gcc-4.8 + - gcc-5 + - gcc-6 + - gcc-7 + - gcc-8 + permissions: + id-token: write # This is required for requesting the JWT + steps: + - name: configure AWS credentials (containers) + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.CI_IOT_CONTAINERS }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + # We can't use the `uses: docker://image` version yet, GitHub lacks authentication for actions -> packages + - name: Build ${{ env.PACKAGE_NAME }} + run: | + aws s3 cp s3://aws-crt-test-stuff/ci/${{ env.BUILDER_VERSION }}/linux-container-ci.sh ./linux-container-ci.sh && chmod a+x ./linux-container-ci.sh + ./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-${{ env.LINUX_BASE_IMAGE }} build -p ${{ env.PACKAGE_NAME }} --compiler=${{ matrix.compiler }} + byo-crypto: + runs-on: ubuntu-latest + permissions: + id-token: write # This is required for requesting the JWT + steps: + - name: configure AWS credentials (containers) + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.CI_IOT_CONTAINERS }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + # We can't use the `uses: docker://image` version yet, GitHub lacks authentication for actions -> packages + - name: Build ${{ env.PACKAGE_NAME }} + run: | + aws s3 cp s3://aws-crt-test-stuff/ci/${{ env.BUILDER_VERSION }}/linux-container-ci.sh ./linux-container-ci.sh && chmod a+x ./linux-container-ci.sh + ./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-${{ env.LINUX_BASE_IMAGE }} build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-DBYO_CRYPTO=ON --variant=skip_sample + linux-no-cpu-extensions: + runs-on: ubuntu-latest + permissions: + id-token: write # This is required for requesting the JWT + steps: + - name: configure AWS credentials (containers) + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.CI_IOT_CONTAINERS }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + # We can't use the `uses: docker://image` version yet, GitHub lacks authentication for actions -> packages + - name: Build ${{ env.PACKAGE_NAME }} + run: | + aws s3 cp s3://aws-crt-test-stuff/ci/${{ env.BUILDER_VERSION }}/linux-container-ci.sh ./linux-container-ci.sh && chmod a+x ./linux-container-ci.sh + ./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-${{ env.LINUX_BASE_IMAGE }} build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-DUSE_CPU_EXTENSIONS=OFF + windows: + runs-on: windows-latest + permissions: + id-token: write # This is required for requesting the JWT + steps: + - name: Build ${{ env.PACKAGE_NAME }} + consumers + run: | + md ${{ env.CI_FOLDER }} + cd ${{ env.CI_FOLDER }} + python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz', 'builder.pyz')" + python builder.pyz build -p ${{ env.PACKAGE_NAME }} + - name: Running samples in CI setup + run: | + python -m pip install boto3 + - name: configure AWS credentials (PubSub) + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.CI_PUBSUB_ROLE }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run MQTT3 PubSub sample + run: | + cd ${{ env.CI_FOLDER }} + python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_pubsub_windows_cfg.json + - name: run Windows Certificate Connect sample + run: | + cd ${{ env.CI_FOLDER }} + python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_windows_cert_connect_cfg.json + - name: configure AWS credentials (MQTT5) + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.CI_MQTT5_ROLE }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run MQTT5 PubSub sample + run: | + cd ${{ env.CI_FOLDER }} + python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_mqtt5_pubsub_windows_cfg.json + - name: configure AWS credentials (Device Advisor) + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.CI_DEVICE_ADVISOR }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run DeviceAdvisor + run: | + cd ${{ env.CI_FOLDER }}/aws-iot-device-sdk-cpp-v2 + python ./deviceadvisor/script/DATestRun.py + windows-vs14: + runs-on: windows-2019 # windows-2019 is last env with Visual Studio 2015 (v14.0) + strategy: + matrix: + arch: [Win32, x64] + fail-fast: false + permissions: + id-token: write # This is required for requesting the JWT + steps: + - name: Build ${{ env.PACKAGE_NAME }} + consumers + run: | + md ${{ env.CI_FOLDER }} + cd ${{ env.CI_FOLDER }} + python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')" + python builder.pyz build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-Tv140 --cmake-extra=-A${{ matrix.arch }} + - name: Running samples in CI setup + run: | + python -m pip install boto3 + - name: configure AWS credentials (PubSub) + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.CI_PUBSUB_ROLE }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run MQTT3 PubSub sample + run: | + cd ${{ env.CI_FOLDER }} + python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_pubsub_windows_cfg.json + - name: run Windows Certificate Connect sample + run: | + cd ${{ env.CI_FOLDER }} + python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_windows_cert_connect_cfg.json + - name: configure AWS credentials (MQTT5) + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.CI_MQTT5_ROLE }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run MQTT5 PubSub sample + run: | + cd ${{ env.CI_FOLDER }} + python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_mqtt5_pubsub_windows_cfg.json + - name: configure AWS credentials (Device Advisor) + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.CI_DEVICE_ADVISOR }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run DeviceAdvisor + run: | + cd ${{ env.CI_FOLDER }}/aws-iot-device-sdk-cpp-v2 + python ./deviceadvisor/script/DATestRun.py + windows-no-cpu-extensions: + runs-on: windows-latest + permissions: + id-token: write # This is required for requesting the JWT + steps: + - name: Build ${{ env.PACKAGE_NAME }} + consumers + run: | + md ${{ env.CI_FOLDER }} + cd ${{ env.CI_FOLDER }} + python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz', 'builder.pyz')" + python builder.pyz build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-DUSE_CPU_EXTENSIONS=OFF + - name: Running samples in CI setup + run: | + python -m pip install boto3 + - name: configure AWS credentials (PubSub) + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.CI_PUBSUB_ROLE }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run MQTT3 PubSub sample + run: | + cd ${{ env.CI_FOLDER }} + python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_pubsub_windows_cfg.json + - name: run Windows Certificate Connect sample + run: | + cd ${{ env.CI_FOLDER }} + python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_windows_cert_connect_cfg.json + - name: configure AWS credentials (MQTT5) + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.CI_MQTT5_ROLE }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run MQTT5 PubSub sample + run: | + cd ${{ env.CI_FOLDER }} + python ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_mqtt5_pubsub_windows_cfg.json + - name: configure AWS credentials (Device Advisor) + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.CI_DEVICE_ADVISOR }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run DeviceAdvisor + run: | + cd ${{ env.CI_FOLDER }}/aws-iot-device-sdk-cpp-v2 + python ./deviceadvisor/script/DATestRun.py + windows-app-verifier: + runs-on: windows-2022 # latest + permissions: + id-token: write # This is required for requesting the JWT + steps: + - name: Build ${{ env.PACKAGE_NAME }} + consumers + run: | + md ${{ env.CI_FOLDER }} + cd ${{ env.CI_FOLDER }} + python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz', 'builder.pyz')" + python builder.pyz build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-DUSE_CPU_EXTENSIONS=OFF + - name: Running samples in CI setup + run: | + python -m pip install boto3 + - name: configure AWS credentials (CyclePubSub) + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.CI_CYCLEPUBSUB_ROLE }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: Run and check AppVerifier + run: | + cd ${{ env.CI_FOLDER }} + echo "Starting to run AppVerifier with cycle pub-sub sample" + python ${{ env.CI_UTILS_FOLDER }}/appverifier_launch_sample.py --sample_file ".\aws-iot-device-sdk-cpp-v2\build\samples\pub_sub\cycle_pub_sub\RelWithDebInfo\cycle-pub-sub.exe" --sample_secret_endpoint 'ci/endpoint' --sample_secret_certificate 'ci/CyclePubSub/cert' --sample_secret_private_key 'ci/CyclePubSub/key' + windows-shared-lib: + runs-on: windows-latest + permissions: + id-token: write # This is required for requesting the JWT + steps: + - name: Build ${{ env.PACKAGE_NAME }} + consumers + run: | + md ${{ env.CI_FOLDER }} + cd ${{ env.CI_FOLDER }} + python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz', 'builder.pyz')" + python builder.pyz build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-DBUILD_SHARED_LIBS=ON - # osx: - # runs-on: macos-latest - # permissions: - # id-token: write # This is required for requesting the JWT - # security-events: write # This is required for pkcs12 sample to sign the key - # steps: - # - name: Build ${{ env.PACKAGE_NAME }} + consumers - # run: | - # python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz', 'builder')" - # chmod a+x builder - # ./builder build -p ${{ env.PACKAGE_NAME }} --spec=downstream - # - name: Running samples in CI setup - # run: | - # python3 -m pip install boto3 - # - name: configure AWS credentials (PubSub) - # uses: aws-actions/configure-aws-credentials@v2 - # with: - # role-to-assume: ${{ env.CI_PUBSUB_ROLE }} - # aws-region: ${{ env.AWS_DEFAULT_REGION }} - # - name: run MQTT3 PubSub sample - # run: | - # python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_pubsub_cfg.json -# # - name: run PKCS12 sample -# # run: | -# # aws s3 cp s3://iot-sdk-ci-bucket-us-east1/pkcs12_identity.p12 ./pkcs12_identity.p12 -# # pkcs12_identity_name=$(aws secretsmanager get-secret-value --region us-east-1 --secret-id "ci/macos/pkcs12_identity" --query "SecretString" | cut -f2 -d":" | cut -f2 -d\") -# # pkcs12_identity_password=$(aws secretsmanager get-secret-value --region us-east-1 --secret-id "ci/macos/pkcs12_identity_password" --query "SecretString" | cut -f2 -d":" | cut -f2 -d\") -# # cert=$(aws secretsmanager get-secret-value --region us-east-1 --secret-id "ci/PubSub/cert" --query "SecretString" | cut -f2 -d":" | cut -f2 -d\") && echo -e "$cert" > /tmp/certificate.pem -# # key=$(aws secretsmanager get-secret-value --region us-east-1 --secret-id "ci/PubSub/key" --query "SecretString" | cut -f2 -d":" | cut -f2 -d\") && echo -e "$key" > /tmp/privatekey.pem -# # iot_pkcs12_password=$(aws secretsmanager get-secret-value --region us-east-1 --secret-id "ci/PubSub/key_pkcs12_password" --query "SecretString" | cut -f2 -d":" | cut -f2 -d\") -# # openssl pkcs12 -export -in /tmp/certificate.pem -inkey /tmp/privatekey.pem -out ./iot_pkcs12_key.p12 -name PubSub_Thing_Alias -password pass:$iot_pkcs12_password -# # security create-keychain -p test_password build.keychain -# # security set-keychain-settings -lut 21600 build.keychain -# # security default-keychain -s build.keychain -# # security unlock-keychain -p test_password build.keychain -# # security import pkcs12_identity.p12 -A -k build.keychain -f pkcs12 -P $pkcs12_identity_password -T /usr/bin/codesign -T /usr/bin/security -# # security set-key-partition-list -S 'apple-tool:,apple:' -k test_password build.keychain -# # /usr/bin/codesign --force -s $pkcs12_identity_name ./aws-iot-device-sdk-cpp-v2/build/samples/mqtt/pkcs12_connect/pkcs12-connect -v -# # python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_pkcs12_connect_cfg.json - # - name: configure AWS credentials (MQTT5) - # uses: aws-actions/configure-aws-credentials@v2 - # with: - # role-to-assume: ${{ env.CI_MQTT5_ROLE }} - # aws-region: ${{ env.AWS_DEFAULT_REGION }} - # - name: run MQTT5 PubSub sample - # run: | - # python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_mqtt5_pubsub_cfg.json - # - name: configure AWS credentials (Device Advisor) - # uses: aws-actions/configure-aws-credentials@v2 - # with: - # role-to-assume: ${{ env.CI_DEVICE_ADVISOR }} - # aws-region: ${{ env.AWS_DEFAULT_REGION }} - # - name: run DeviceAdvisor - # run: | - # cd ./aws-iot-device-sdk-cpp-v2 - # python3 ./deviceadvisor/script/DATestRun.py - # # Not strictly needed, but allows us to run Device Advisor and PubSub on Linux without needing to run all samples - # linux-github-actions: - # runs-on: ubuntu-latest - # strategy: - # fail-fast: false - # permissions: - # id-token: write # This is required for requesting the JWT - # steps: - # - name: Build ${{ env.PACKAGE_NAME }} + consumers - # run: | - # python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')" - # python builder.pyz build -p ${{ env.PACKAGE_NAME }} - # - name: Running samples in CI setup - # run: | - # python3 -m pip install boto3 - # - name: configure AWS credentials (PubSub) - # uses: aws-actions/configure-aws-credentials@v2 - # with: - # role-to-assume: ${{ env.CI_PUBSUB_ROLE }} - # aws-region: ${{ env.AWS_DEFAULT_REGION }} - # - name: run MQTT3 PubSub sample - # run: | - # python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_pubsub_cfg.json - # - name: configure AWS credentials (MQTT5) - # uses: aws-actions/configure-aws-credentials@v2 - # with: - # role-to-assume: ${{ env.CI_MQTT5_ROLE }} - # aws-region: ${{ env.AWS_DEFAULT_REGION }} - # - name: run MQTT5 PubSub sample - # run: | - # python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_mqtt5_pubsub_cfg.json - # - name: configure AWS credentials (Device Advisor) - # uses: aws-actions/configure-aws-credentials@v2 - # with: - # role-to-assume: ${{ env.CI_DEVICE_ADVISOR }} - # aws-region: ${{ env.AWS_DEFAULT_REGION }} - # - name: run DeviceAdvisor - # run: | - # cd ./aws-iot-device-sdk-cpp-v2 - # python3 ./deviceadvisor/script/DATestRun.py - # - name: configure AWS credentials (Device Defender) - # uses: aws-actions/configure-aws-credentials@v2 - # with: - # role-to-assume: ${{ env.CI_DEVICE_DEFENDER }} - # aws-region: ${{ env.AWS_DEFAULT_REGION }} - # - name: run DeviceDefender - # run: | - # cd ./aws-iot-device-sdk-cpp-v2 - # python3 ./devicedefender/script/DDTestRun.py - # - name: run Mqtt5 DeviceDefender - # run: | - # cd ./aws-iot-device-sdk-cpp-v2 - # python3 ./devicedefender/script/DDTestRun.py mqtt5 - # # Runs the samples and ensures that everything is working - # linux-smoke-tests: - # runs-on: ubuntu-latest - # strategy: - # fail-fast: false - # permissions: - # id-token: write # This is required for requesting the JWT - # steps: - # - name: Setup C++ - # run: | - # sudo apt-get -qq update -y - # sudo apt-get -qq install -y build-essential - # sudo apt install cmake - # gcc --version - # cmake --version - # - name: Build ${{ env.PACKAGE_NAME }} + consumers - # run: | - # echo "Downloading source" - # git clone --recursive https://github.com/aws/aws-iot-device-sdk-cpp-v2.git --branch ${{ env.HEAD_REF || github.ref_name }} - # echo "Running builder" - # python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')" - # python builder.pyz build -p ${{ env.PACKAGE_NAME }} - # - name: Running samples in CI setup - # run: | - # python3 -m pip install boto3 - # sudo apt-get update -y - # sudo apt-get install softhsm -y - # softhsm2-util --version + osx: + runs-on: macos-latest + permissions: + id-token: write # This is required for requesting the JWT + security-events: write # This is required for pkcs12 sample to sign the key + steps: + - name: Build ${{ env.PACKAGE_NAME }} + consumers + run: | + python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz', 'builder')" + chmod a+x builder + ./builder build -p ${{ env.PACKAGE_NAME }} --spec=downstream + - name: Running samples in CI setup + run: | + python3 -m pip install boto3 + - name: configure AWS credentials (PubSub) + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.CI_PUBSUB_ROLE }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run MQTT3 PubSub sample + run: | + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_pubsub_cfg.json +# - name: run PKCS12 sample +# run: | +# aws s3 cp s3://iot-sdk-ci-bucket-us-east1/pkcs12_identity.p12 ./pkcs12_identity.p12 +# pkcs12_identity_name=$(aws secretsmanager get-secret-value --region us-east-1 --secret-id "ci/macos/pkcs12_identity" --query "SecretString" | cut -f2 -d":" | cut -f2 -d\") +# pkcs12_identity_password=$(aws secretsmanager get-secret-value --region us-east-1 --secret-id "ci/macos/pkcs12_identity_password" --query "SecretString" | cut -f2 -d":" | cut -f2 -d\") +# cert=$(aws secretsmanager get-secret-value --region us-east-1 --secret-id "ci/PubSub/cert" --query "SecretString" | cut -f2 -d":" | cut -f2 -d\") && echo -e "$cert" > /tmp/certificate.pem +# key=$(aws secretsmanager get-secret-value --region us-east-1 --secret-id "ci/PubSub/key" --query "SecretString" | cut -f2 -d":" | cut -f2 -d\") && echo -e "$key" > /tmp/privatekey.pem +# iot_pkcs12_password=$(aws secretsmanager get-secret-value --region us-east-1 --secret-id "ci/PubSub/key_pkcs12_password" --query "SecretString" | cut -f2 -d":" | cut -f2 -d\") +# openssl pkcs12 -export -in /tmp/certificate.pem -inkey /tmp/privatekey.pem -out ./iot_pkcs12_key.p12 -name PubSub_Thing_Alias -password pass:$iot_pkcs12_password +# security create-keychain -p test_password build.keychain +# security set-keychain-settings -lut 21600 build.keychain +# security default-keychain -s build.keychain +# security unlock-keychain -p test_password build.keychain +# security import pkcs12_identity.p12 -A -k build.keychain -f pkcs12 -P $pkcs12_identity_password -T /usr/bin/codesign -T /usr/bin/security +# security set-key-partition-list -S 'apple-tool:,apple:' -k test_password build.keychain +# /usr/bin/codesign --force -s $pkcs12_identity_name ./aws-iot-device-sdk-cpp-v2/build/samples/mqtt/pkcs12_connect/pkcs12-connect -v +# python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_pkcs12_connect_cfg.json + - name: configure AWS credentials (MQTT5) + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.CI_MQTT5_ROLE }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run MQTT5 PubSub sample + run: | + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_mqtt5_pubsub_cfg.json + - name: configure AWS credentials (Device Advisor) + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.CI_DEVICE_ADVISOR }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run DeviceAdvisor + run: | + cd ./aws-iot-device-sdk-cpp-v2 + python3 ./deviceadvisor/script/DATestRun.py + # Not strictly needed, but allows us to run Device Advisor and PubSub on Linux without needing to run all samples + linux-github-actions: + runs-on: ubuntu-latest + strategy: + fail-fast: false + permissions: + id-token: write # This is required for requesting the JWT + steps: + - name: Build ${{ env.PACKAGE_NAME }} + consumers + run: | + python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')" + python builder.pyz build -p ${{ env.PACKAGE_NAME }} + - name: Running samples in CI setup + run: | + python3 -m pip install boto3 + - name: configure AWS credentials (PubSub) + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.CI_PUBSUB_ROLE }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run MQTT3 PubSub sample + run: | + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_pubsub_cfg.json + - name: configure AWS credentials (MQTT5) + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.CI_MQTT5_ROLE }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run MQTT5 PubSub sample + run: | + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_mqtt5_pubsub_cfg.json + - name: configure AWS credentials (Device Advisor) + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.CI_DEVICE_ADVISOR }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run DeviceAdvisor + run: | + cd ./aws-iot-device-sdk-cpp-v2 + python3 ./deviceadvisor/script/DATestRun.py + - name: configure AWS credentials (Device Defender) + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.CI_DEVICE_DEFENDER }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run DeviceDefender + run: | + cd ./aws-iot-device-sdk-cpp-v2 + python3 ./devicedefender/script/DDTestRun.py + - name: run Mqtt5 DeviceDefender + run: | + cd ./aws-iot-device-sdk-cpp-v2 + python3 ./devicedefender/script/DDTestRun.py mqtt5 + # Runs the samples and ensures that everything is working + linux-smoke-tests: + runs-on: ubuntu-latest + strategy: + fail-fast: false + permissions: + id-token: write # This is required for requesting the JWT + steps: + - name: Setup C++ + run: | + sudo apt-get -qq update -y + sudo apt-get -qq install -y build-essential + sudo apt install cmake + gcc --version + cmake --version + - name: Build ${{ env.PACKAGE_NAME }} + consumers + run: | + echo "Downloading source" + git clone --recursive https://github.com/aws/aws-iot-device-sdk-cpp-v2.git --branch ${{ env.HEAD_REF || github.ref_name }} + echo "Running builder" + python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')" + python builder.pyz build -p ${{ env.PACKAGE_NAME }} + - name: Running samples in CI setup + run: | + python3 -m pip install boto3 + sudo apt-get update -y + sudo apt-get install softhsm -y + softhsm2-util --version - # - name: configure AWS credentials (Fleet provisioning) - # uses: aws-actions/configure-aws-credentials@v2 - # with: - # role-to-assume: ${{ env.CI_FLEET_PROVISIONING_ROLE }} - # aws-region: ${{ env.AWS_DEFAULT_REGION }} - # - name: run Fleet Provisioning service client test for MQTT311 - # working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests - # run: | - # export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils - # python3 ./test_cases/test_fleet_provisioning.py --config-file test_cases/mqtt3_fleet_provisioning_cfg.json --thing-name-prefix Fleet_Thing_ - # - name: run Fleet Provisioning service client test for MQTT5 - # working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests - # run: | - # export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils - # python3 ./test_cases/test_fleet_provisioning.py --config-file test_cases/mqtt5_fleet_provisioning_cfg.json --thing-name-prefix Fleet_Thing_ - # - name: run Fleet Provisioning with CSR service client test for MQTT311 - # working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests - # run: | - # export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils - # python3 ./test_cases/test_fleet_provisioning.py --config-file test_cases/mqtt3_fleet_provisioning_with_csr_cfg.json --thing-name-prefix Fleet_Thing_ - # - name: run Fleet Provisioning with CSR service client test for MQTT5 - # working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests - # run: | - # export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils - # python3 ./test_cases/test_fleet_provisioning.py --config-file test_cases/mqtt5_fleet_provisioning_with_csr_cfg.json --thing-name-prefix Fleet_Thing_ + - name: configure AWS credentials (Fleet provisioning) + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.CI_FLEET_PROVISIONING_ROLE }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run Fleet Provisioning service client test for MQTT311 + working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests + run: | + export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils + python3 ./test_cases/test_fleet_provisioning.py --config-file test_cases/mqtt3_fleet_provisioning_cfg.json --thing-name-prefix Fleet_Thing_ + - name: run Fleet Provisioning service client test for MQTT5 + working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests + run: | + export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils + python3 ./test_cases/test_fleet_provisioning.py --config-file test_cases/mqtt5_fleet_provisioning_cfg.json --thing-name-prefix Fleet_Thing_ + - name: run Fleet Provisioning with CSR service client test for MQTT311 + working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests + run: | + export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils + python3 ./test_cases/test_fleet_provisioning.py --config-file test_cases/mqtt3_fleet_provisioning_with_csr_cfg.json --thing-name-prefix Fleet_Thing_ + - name: run Fleet Provisioning with CSR service client test for MQTT5 + working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests + run: | + export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils + python3 ./test_cases/test_fleet_provisioning.py --config-file test_cases/mqtt5_fleet_provisioning_with_csr_cfg.json --thing-name-prefix Fleet_Thing_ - # - name: configure AWS credentials (Jobs) - # uses: aws-actions/configure-aws-credentials@v2 - # with: - # role-to-assume: ${{ env.CI_JOBS_SERVICE_CLIENT_ROLE }} - # aws-region: ${{ env.AWS_DEFAULT_REGION }} - # - name: run mqtt3 Jobs serviceTests - # working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests - # run: | - # export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils - # python3 ./test_cases/test_jobs_execution.py --config-file ${{ env.CI_SERVICE_TESTS_CFG_FOLDER }}/mqtt3_jobs_cfg.json - # - name: run mqtt5 Jobs serviceTests - # working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests - # run: | - # export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils - # python3 ./test_cases/test_jobs_execution.py --config-file ${{ env.CI_SERVICE_TESTS_CFG_FOLDER }}/mqtt5_jobs_cfg.json - # - name: configure AWS credentials (Shadow) - # uses: aws-actions/configure-aws-credentials@v2 - # with: - # role-to-assume: ${{ env.CI_SHADOW_SERVICE_CLIENT_ROLE }} - # aws-region: ${{ env.AWS_DEFAULT_REGION }} - # - name: run Shadow service client test for MQTT5 - # working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests - # run: | - # export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils - # python3 ./test_cases/test_shadow_update.py --config-file test_cases/mqtt5_shadow_cfg.json - # - name: run Shadow service client test for MQTT311 - # working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests - # run: | - # export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils - # python3 ./test_cases/test_shadow_update.py --config-file test_cases/mqtt3_shadow_cfg.json - # - name: run Named Shadow service client test for MQTT311 - # working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests - # run: | - # export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils - # python3 ./test_cases/test_shadow_update.py --config-file test_cases/mqtt3_named_shadow_cfg.json - # - name: run Named Shadow service client test for MQTT5 - # working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests - # run: | - # export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils - # python3 ./test_cases/test_shadow_update.py --config-file test_cases/mqtt5_named_shadow_cfg.json - # - name: configure AWS credentials (Connect and PubSub) - # uses: aws-actions/configure-aws-credentials@v2 - # with: - # role-to-assume: ${{ env.CI_PUBSUB_ROLE }} - # aws-region: ${{ env.AWS_DEFAULT_REGION }} - # - name: run Basic Connect sample - # run: | - # python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_basic_connect_cfg.json - # - name: run Websocket Connect sample - # run: | - # python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_websocket_connect_cfg.json - # - name: run MQTT3 PubSub sample - # run: | - # python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_pubsub_cfg.json - # - name: run PKCS11 Connect sample - # run: | - # mkdir -p /tmp/tokens - # export SOFTHSM2_CONF=/tmp/softhsm2.conf - # echo "directories.tokendir = /tmp/tokens" > /tmp/softhsm2.conf - # python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_pkcs11_connect_cfg.json - # - name: configure AWS credentials (MQTT5) - # uses: aws-actions/configure-aws-credentials@v2 - # with: - # role-to-assume: ${{ env.CI_MQTT5_ROLE }} - # aws-region: ${{ env.AWS_DEFAULT_REGION }} - # - name: run MQTT5 PubSub sample - # run: | - # python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_mqtt5_pubsub_cfg.json - # - name: run MQTT5 Shared Subscription sample - # run: | - # python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_mqtt5_shared_subscription_cfg.json - # - name: configure AWS credentials (Jobs) - # uses: aws-actions/configure-aws-credentials@v2 - # with: - # role-to-assume: ${{ env.CI_JOBS_ROLE }} - # aws-region: ${{ env.AWS_DEFAULT_REGION }} - # - name: run Jobs sample - # run: | - # python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_jobs_cfg.json - # - name: run Mqtt5 Jobs sample - # run: | - # python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_jobs_mqtt5_cfg.json - # - name: configure AWS credentials (Cognito) - # uses: aws-actions/configure-aws-credentials@v2 - # with: - # role-to-assume: ${{ env.CI_COGNITO_ROLE }} - # aws-region: ${{ env.AWS_DEFAULT_REGION }} - # - name: run CognitoConnect sample - # run: | - # python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_cognito_connect_cfg.json - # - name: configure AWS credentials (Custom Authorizer) - # uses: aws-actions/configure-aws-credentials@v2 - # with: - # role-to-assume: ${{ env.CI_CUSTOM_AUTHORIZER_ROLE }} - # aws-region: ${{ env.AWS_DEFAULT_REGION }} - # - name: run CustomAuthorizerConnect sample - # run: | - # python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_custom_authorizer_connect_cfg.json - # - name: configure AWS credentials (Shadow) - # uses: aws-actions/configure-aws-credentials@v2 - # with: - # role-to-assume: ${{ env.CI_SHADOW_ROLE }} - # aws-region: ${{ env.AWS_DEFAULT_REGION }} - # - name: run Shadow sample - # run: | - # python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_shadow_cfg.json - # - name: run Mqtt5 Shadow sample - # run: | - # python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_shadow_mqtt5_cfg.json - # - name: configure AWS credentials (Fleet provisioning) - # uses: aws-actions/configure-aws-credentials@v2 - # with: - # role-to-assume: ${{ env.CI_FLEET_PROVISIONING_ROLE }} - # aws-region: ${{ env.AWS_DEFAULT_REGION }} - # - name: run Fleet Provisioning sample - # run: | - # echo "Generating UUID for IoT thing" - # 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: run Mqtt5 Fleet Provisioning sample - # run: | - # echo "Generating UUID for IoT thing" - # 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_mqtt5_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 (Secure tunneling) - # uses: aws-actions/configure-aws-credentials@v2 - # with: - # role-to-assume: ${{ env.CI_SECURE_TUNNEL }} - # aws-region: ${{ env.AWS_DEFAULT_REGION }} - # # Secure Tunneling has special requirements, so it uses a different Python file - # - name: run Secure Tunneling sample - # run: | - # python3 ${{ env.CI_UTILS_FOLDER }}/run_secure_tunnel_ci.py --sample_file "./aws-iot-device-sdk-cpp-v2/build/samples/secure_tunneling/secure_tunnel/secure-tunnel" --sample_region ${{ env.AWS_DEFAULT_REGION }} - # - name: configure AWS credentials (X509) - # uses: aws-actions/configure-aws-credentials@v2 - # with: - # role-to-assume: ${{ env.CI_X509_ROLE }} - # aws-region: ${{ env.AWS_DEFAULT_REGION }} - # - name: run X509 sample - # run: | - # python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_x509_connect_cfg.json - # - name: configure AWS credentials (Greengrass) - # uses: aws-actions/configure-aws-credentials@v2 - # 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_cfg.json + - name: configure AWS credentials (Jobs) + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.CI_JOBS_SERVICE_CLIENT_ROLE }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run mqtt3 Jobs serviceTests + working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests + run: | + export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils + python3 ./test_cases/test_jobs_execution.py --config-file ${{ env.CI_SERVICE_TESTS_CFG_FOLDER }}/mqtt3_jobs_cfg.json + - name: run mqtt5 Jobs serviceTests + working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests + run: | + export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils + python3 ./test_cases/test_jobs_execution.py --config-file ${{ env.CI_SERVICE_TESTS_CFG_FOLDER }}/mqtt5_jobs_cfg.json + - name: configure AWS credentials (Shadow) + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.CI_SHADOW_SERVICE_CLIENT_ROLE }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run Shadow service client test for MQTT5 + working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests + run: | + export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils + python3 ./test_cases/test_shadow_update.py --config-file test_cases/mqtt5_shadow_cfg.json + - name: run Shadow service client test for MQTT311 + working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests + run: | + export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils + python3 ./test_cases/test_shadow_update.py --config-file test_cases/mqtt3_shadow_cfg.json + - name: run Named Shadow service client test for MQTT311 + working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests + run: | + export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils + python3 ./test_cases/test_shadow_update.py --config-file test_cases/mqtt3_named_shadow_cfg.json + - name: run Named Shadow service client test for MQTT5 + working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests + run: | + export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils + python3 ./test_cases/test_shadow_update.py --config-file test_cases/mqtt5_named_shadow_cfg.json + - name: configure AWS credentials (Connect and PubSub) + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.CI_PUBSUB_ROLE }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run Basic Connect sample + run: | + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_basic_connect_cfg.json + - name: run Websocket Connect sample + run: | + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_websocket_connect_cfg.json + - name: run MQTT3 PubSub sample + run: | + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_pubsub_cfg.json + - name: run PKCS11 Connect sample + run: | + mkdir -p /tmp/tokens + export SOFTHSM2_CONF=/tmp/softhsm2.conf + echo "directories.tokendir = /tmp/tokens" > /tmp/softhsm2.conf + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_pkcs11_connect_cfg.json + - name: configure AWS credentials (MQTT5) + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.CI_MQTT5_ROLE }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run MQTT5 PubSub sample + run: | + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_mqtt5_pubsub_cfg.json + - name: run MQTT5 Shared Subscription sample + run: | + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_mqtt5_shared_subscription_cfg.json + - name: configure AWS credentials (Jobs) + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.CI_JOBS_ROLE }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run Jobs sample + run: | + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_jobs_cfg.json + - name: run Mqtt5 Jobs sample + run: | + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_jobs_mqtt5_cfg.json + - name: configure AWS credentials (Cognito) + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.CI_COGNITO_ROLE }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run CognitoConnect sample + run: | + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_cognito_connect_cfg.json + - name: configure AWS credentials (Custom Authorizer) + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.CI_CUSTOM_AUTHORIZER_ROLE }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run CustomAuthorizerConnect sample + run: | + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_custom_authorizer_connect_cfg.json + - name: configure AWS credentials (Shadow) + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.CI_SHADOW_ROLE }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run Shadow sample + run: | + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_shadow_cfg.json + - name: run Mqtt5 Shadow sample + run: | + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_shadow_mqtt5_cfg.json + - name: configure AWS credentials (Fleet provisioning) + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.CI_FLEET_PROVISIONING_ROLE }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run Fleet Provisioning sample + run: | + echo "Generating UUID for IoT thing" + 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: run Mqtt5 Fleet Provisioning sample + run: | + echo "Generating UUID for IoT thing" + 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_mqtt5_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 (Secure tunneling) + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.CI_SECURE_TUNNEL }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + # Secure Tunneling has special requirements, so it uses a different Python file + - name: run Secure Tunneling sample + run: | + python3 ${{ env.CI_UTILS_FOLDER }}/run_secure_tunnel_ci.py --sample_file "./aws-iot-device-sdk-cpp-v2/build/samples/secure_tunneling/secure_tunnel/secure-tunnel" --sample_region ${{ env.AWS_DEFAULT_REGION }} + - name: configure AWS credentials (X509) + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.CI_X509_ROLE }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run X509 sample + run: | + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_x509_connect_cfg.json + - name: configure AWS credentials (Greengrass) + uses: aws-actions/configure-aws-credentials@v2 + 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_cfg.json # Runs the Greengrass samples linux-greengrass-tests: @@ -702,46 +702,46 @@ jobs: cat testResults/gg*/software.amazon.awssdk.sdk-gg-ipc.log echo "========" - # # check that docs can still build - # check-docs: - # runs-on: ubuntu-20.04 # latest - # steps: - # - uses: actions/checkout@v2 - # with: - # submodules: recursive - # - name: Check docs - # run: | - # echo "Compiling and installing doxygen 1.8.20 from source" - # sudo apt-get install -y llvm-11 llvm-11-dev clang-11 libclang-11-dev - # git clone https://github.com/doxygen/doxygen.git -b Release_1_8_20 - # cd doxygen - # mkdir build - # cd build - # cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr .. - # sudo make -j 4 - # sudo make install - # cd ../.. - # echo "Finished compiling and installing Doxygen" - # ./make-docs.py - # check-submodules: - # runs-on: ubuntu-latest - # steps: - # - name: Checkout Source - # uses: actions/checkout@v2 - # with: - # submodules: true - # fetch-depth: 0 - # - name: Check Submodules - # # note: using "@main" because "@${{env.BUILDER_VERSION}}" doesn't work - # # https://github.com/actions/runner/issues/480 - # uses: awslabs/aws-crt-builder/.github/actions/check-submodules@main + # check that docs can still build + check-docs: + runs-on: ubuntu-20.04 # latest + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + - name: Check docs + run: | + echo "Compiling and installing doxygen 1.8.20 from source" + sudo apt-get install -y llvm-11 llvm-11-dev clang-11 libclang-11-dev + git clone https://github.com/doxygen/doxygen.git -b Release_1_8_20 + cd doxygen + mkdir build + cd build + cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr .. + sudo make -j 4 + sudo make install + cd ../.. + echo "Finished compiling and installing Doxygen" + ./make-docs.py + check-submodules: + runs-on: ubuntu-latest + steps: + - name: Checkout Source + uses: actions/checkout@v2 + with: + submodules: true + fetch-depth: 0 + - name: Check Submodules + # note: using "@main" because "@${{env.BUILDER_VERSION}}" doesn't work + # https://github.com/actions/runner/issues/480 + uses: awslabs/aws-crt-builder/.github/actions/check-submodules@main - # check-codegen-edits: - # runs-on: ubuntu-20.04 # latest - # steps: - # - uses: actions/checkout@v2 - # with: - # fetch-depth: 0 - # - name: Check for edits to code-generated files - # run: | - # ./utils/check_codegen_edits.py + check-codegen-edits: + runs-on: ubuntu-20.04 # latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Check for edits to code-generated files + run: | + ./utils/check_codegen_edits.py diff --git a/builder.json b/builder.json index 0b1cc8ebb..293a06351 100644 --- a/builder.json +++ b/builder.json @@ -21,7 +21,7 @@ "_comment": "See .builder/actions/build_samples.py for definition of 'build-samples'", "build_steps": [ "build", - "build-gg-samples" + "build-samples" ], "variants" : { "skip_sample": { From 1543e0a5ad26fb52608fec20e4734f0a1cdbc404 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Tue, 28 May 2024 14:31:11 -0700 Subject: [PATCH 66/79] Build only GG samples in GG CI job --- .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 49c17ec5f..a66fd3f2a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -665,7 +665,7 @@ jobs: git clone --recursive https://github.com/aws/aws-iot-device-sdk-cpp-v2.git --branch ${{ env.HEAD_REF || github.ref_name }} echo "Running builder" python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')" - python builder.pyz build -p ${{ env.PACKAGE_NAME }} + python builder.pyz build -p ${{ env.PACKAGE_NAME }} --variant build_gg_samples_only - name: Install Greengrass Development Kit run: | python3 -m pip install awsiotsdk From 79650eabcf09e11276994351f8cd1e7bbfa09417 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Tue, 28 May 2024 14:43:04 -0700 Subject: [PATCH 67/79] Add comments --- .builder/actions/build_gg_samples.py | 10 ++++++++-- .builder/actions/build_samples.py | 9 ++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.builder/actions/build_gg_samples.py b/.builder/actions/build_gg_samples.py index 0413a09a9..69284a7a3 100644 --- a/.builder/actions/build_gg_samples.py +++ b/.builder/actions/build_gg_samples.py @@ -1,10 +1,16 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0. + import Builder import os -import sys -import argparse class BuildGGSamples(Builder.Action): + """ + Defines a custom build step for Greengrass samples. + It's used via builder.json config file in the project root directory. + """ + def run(self, env): # parse extra cmake configs cmd_args = env.args diff --git a/.builder/actions/build_samples.py b/.builder/actions/build_samples.py index d007b769d..79475011b 100644 --- a/.builder/actions/build_samples.py +++ b/.builder/actions/build_samples.py @@ -1,10 +1,17 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0. + import Builder import os import sys -import argparse class BuildSamples(Builder.Action): + """ + Defines a custom build step for samples and tests. + It's used via builder.json config file in the project root directory. + """ + def run(self, env): # parse extra cmake configs cmd_args = env.args From 4a10bff230eae53790ee900f4d8f968348046b6d Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Tue, 28 May 2024 14:43:13 -0700 Subject: [PATCH 68/79] Increase timeouts --- .../main/resources/greengrass/features/component.feature | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature b/samples/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature index a8b128a1a..dd235c3e0 100644 --- a/samples/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature +++ b/samples/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature @@ -59,6 +59,6 @@ Feature: Testing features of Greengrassv2 basic discovery sample } """ And I deploy the Greengrass deployment configuration - Then the Greengrass deployment is COMPLETED on the device after 150 seconds - And the software.amazon.awssdk.sdk-gg-test-discovery log on the device contains the line "Successfully subscribed to topic" within 120 seconds - And the software.amazon.awssdk.sdk-gg-test-discovery log on the device contains the line "Received new message" within 140 seconds + Then the Greengrass deployment is COMPLETED on the device after 300 seconds + And the software.amazon.awssdk.sdk-gg-test-discovery log on the device contains the line "Successfully subscribed to topic" within 180 seconds + And the software.amazon.awssdk.sdk-gg-test-discovery log on the device contains the line "Received new message" within 240 seconds From 0c4f49d35c670d8602dad7de433f273952315dd8 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Tue, 28 May 2024 15:28:19 -0700 Subject: [PATCH 69/79] Move CI config to github dir --- .../ci_run_greengrass_discovery_cfg.json | 27 +++++++------ .../basic_discovery/ci_run_discovery_cfg.json | 38 ------------------- 2 files changed, 13 insertions(+), 52 deletions(-) delete mode 100644 samples/greengrass/basic_discovery/ci_run_discovery_cfg.json diff --git a/.github/workflows/ci_run_greengrass_discovery_cfg.json b/.github/workflows/ci_run_greengrass_discovery_cfg.json index b60d8106f..257924ffe 100644 --- a/.github/workflows/ci_run_greengrass_discovery_cfg.json +++ b/.github/workflows/ci_run_greengrass_discovery_cfg.json @@ -1,39 +1,38 @@ { "language": "CPP", - "sample_file": "./aws-iot-device-sdk-cpp-v2/build/samples/greengrass/basic_discovery/basic-discovery", - "sample_region": "us-east-1", - "sample_main_class": "", + "runnable_file": "basic-discovery", + "runnable_region": "us-east-1", + "runnable_main_class": "", "arguments": [ { "name": "--cert", - "secret": "ci/Greengrass/cert", + "secret": "ci/GreengrassDiscovery/cert", "filename": "tmp_certificate.pem" }, { "name": "--key", - "secret": "ci/Greengrass/key", + "secret": "ci/GreengrassDiscovery/key", "filename": "tmp_key.pem" }, { - "name": "--ca_file", - "secret": "ci/Greengrass/ca", - "filename": "tmp_ca.pem" + "name": "--thing_name", + "data": "CI_Greengrass_Discovery_Thing" }, { "name": "--region", "data": "us-east-1" }, { - "name": "--thing_name", - "data": "CI_GreenGrass_Thing" + "name": "--message", + "data": "hello" }, { - "name": "--is_ci", - "data": "true" + "name": "--topic", + "data": "clients/CI_Greengrass_Discovery_Thing/hello/world/$INPUT_UUID" }, { - "name": "--print_discover_resp_only", - "data": "" + "name": "--mode", + "data": "publish" } ] } diff --git a/samples/greengrass/basic_discovery/ci_run_discovery_cfg.json b/samples/greengrass/basic_discovery/ci_run_discovery_cfg.json deleted file mode 100644 index 257924ffe..000000000 --- a/samples/greengrass/basic_discovery/ci_run_discovery_cfg.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "language": "CPP", - "runnable_file": "basic-discovery", - "runnable_region": "us-east-1", - "runnable_main_class": "", - "arguments": [ - { - "name": "--cert", - "secret": "ci/GreengrassDiscovery/cert", - "filename": "tmp_certificate.pem" - }, - { - "name": "--key", - "secret": "ci/GreengrassDiscovery/key", - "filename": "tmp_key.pem" - }, - { - "name": "--thing_name", - "data": "CI_Greengrass_Discovery_Thing" - }, - { - "name": "--region", - "data": "us-east-1" - }, - { - "name": "--message", - "data": "hello" - }, - { - "name": "--topic", - "data": "clients/CI_Greengrass_Discovery_Thing/hello/world/$INPUT_UUID" - }, - { - "name": "--mode", - "data": "publish" - } - ] -} From 18bf7d70972124ecfc2911bece660d77f7045b99 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Tue, 28 May 2024 16:08:57 -0700 Subject: [PATCH 70/79] Move test into a separate dir --- .../greengrass/basic_discovery/copy_files.sh | 1 + .../greengrass/basic_discovery/gdk-config.json | 0 .../greengrass/basic_discovery/gg-e2e-tests/pom.xml | 0 .../resources/greengrass/features/component.feature | 1 + .../basic_discovery/hello_world_subscriber.py | 0 .../greengrass/basic_discovery/recipe.yaml | 13 ++++++------- 6 files changed, 8 insertions(+), 7 deletions(-) rename {samples => tests}/greengrass/basic_discovery/copy_files.sh (60%) rename {samples => tests}/greengrass/basic_discovery/gdk-config.json (100%) rename {samples => tests}/greengrass/basic_discovery/gg-e2e-tests/pom.xml (100%) rename {samples => tests}/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature (94%) rename {samples => tests}/greengrass/basic_discovery/hello_world_subscriber.py (100%) rename {samples => tests}/greengrass/basic_discovery/recipe.yaml (86%) diff --git a/samples/greengrass/basic_discovery/copy_files.sh b/tests/greengrass/basic_discovery/copy_files.sh similarity index 60% rename from samples/greengrass/basic_discovery/copy_files.sh rename to tests/greengrass/basic_discovery/copy_files.sh index 6b78d939a..525c767b2 100644 --- a/samples/greengrass/basic_discovery/copy_files.sh +++ b/tests/greengrass/basic_discovery/copy_files.sh @@ -1,2 +1,3 @@ cp ../../../build/samples/greengrass/basic_discovery/basic-discovery . cp ../../../utils/run_in_ci.py . +cp ../../../.github/workflows/ci_run_greengrass_discovery_cfg.json . diff --git a/samples/greengrass/basic_discovery/gdk-config.json b/tests/greengrass/basic_discovery/gdk-config.json similarity index 100% rename from samples/greengrass/basic_discovery/gdk-config.json rename to tests/greengrass/basic_discovery/gdk-config.json diff --git a/samples/greengrass/basic_discovery/gg-e2e-tests/pom.xml b/tests/greengrass/basic_discovery/gg-e2e-tests/pom.xml similarity index 100% rename from samples/greengrass/basic_discovery/gg-e2e-tests/pom.xml rename to tests/greengrass/basic_discovery/gg-e2e-tests/pom.xml diff --git a/samples/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature b/tests/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature similarity index 94% rename from samples/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature rename to tests/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature index dd235c3e0..330960d25 100644 --- a/samples/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature +++ b/tests/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature @@ -62,3 +62,4 @@ Feature: Testing features of Greengrassv2 basic discovery sample Then the Greengrass deployment is COMPLETED on the device after 300 seconds And the software.amazon.awssdk.sdk-gg-test-discovery log on the device contains the line "Successfully subscribed to topic" within 180 seconds And the software.amazon.awssdk.sdk-gg-test-discovery log on the device contains the line "Received new message" within 240 seconds + And the software.amazon.awssdk.sdk-gg-test-discovery log on the device contains the line "disassociating CI_Greengrass_Discovery_Thing" within 260 seconds diff --git a/samples/greengrass/basic_discovery/hello_world_subscriber.py b/tests/greengrass/basic_discovery/hello_world_subscriber.py similarity index 100% rename from samples/greengrass/basic_discovery/hello_world_subscriber.py rename to tests/greengrass/basic_discovery/hello_world_subscriber.py diff --git a/samples/greengrass/basic_discovery/recipe.yaml b/tests/greengrass/basic_discovery/recipe.yaml similarity index 86% rename from samples/greengrass/basic_discovery/recipe.yaml rename to tests/greengrass/basic_discovery/recipe.yaml index 96495a6cd..34e0745d5 100644 --- a/samples/greengrass/basic_discovery/recipe.yaml +++ b/tests/greengrass/basic_discovery/recipe.yaml @@ -21,7 +21,7 @@ Manifests: Artifacts: - URI: "file:hello_world_subscriber.py" - URI: "file:run_in_ci.py" - - URI: "file:ci_run_discovery_cfg.json" + - URI: "file:ci_run_greengrass_discovery_cfg.json" - URI: "file:basic-discovery" Permission: Read: ALL @@ -33,15 +33,14 @@ Manifests: aws greengrassv2 list-client-devices-associated-with-core-device --core-device-thing-name {iot:thingName} Run: | UUID=$(python3 -c "import uuid; print (uuid.uuid4())") - echo "starting subscriber" + echo "Starting subscriber" python3 -u {artifacts:path}/hello_world_subscriber.py --input_uuid ${UUID} & - echo "continuing ..." sleep 10 - echo "starting discovery" - python3 {artifacts:path}/run_in_ci.py --runnable_dir {artifacts:path} --input_uuid ${UUID} --file {artifacts:path}/ci_run_discovery_cfg.json + echo "Starting discovery" + python3 {artifacts:path}/run_in_ci.py --runnable_dir {artifacts:path} --input_uuid ${UUID} --file {artifacts:path}/ci_run_greengrass_discovery_cfg.json Shutdown: | - echo "Shutdown step" + echo "Shutdown: disassociating CI_Greengrass_Discovery_Thing" aws greengrassv2 batch-disassociate-client-device-from-core-device --core-device-thing-name {iot:thingName} --entries thingName=CI_Greengrass_Discovery_Thing Recover: | - echo "Recover step" + echo "Recover: disassociating CI_Greengrass_Discovery_Thing" aws greengrassv2 batch-disassociate-client-device-from-core-device --core-device-thing-name {iot:thingName} --entries thingName=CI_Greengrass_Discovery_Thing From c46fc2323c122e44e692c3582d32017ba4d96f8f Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Tue, 28 May 2024 16:16:08 -0700 Subject: [PATCH 71/79] Move ipc test into a separate dir --- .github/workflows/ci.yml | 6 +++--- .../workflows/ci_run_greengrass_ipc_cfg.json | 0 {samples => tests}/greengrass/ipc/copy_files.sh | 1 + {samples => tests}/greengrass/ipc/gdk-config.json | 0 {samples => tests}/greengrass/ipc/gg-e2e-tests/pom.xml | 0 .../main/resources/greengrass/features/component.feature | 0 {samples => tests}/greengrass/ipc/recipe.yaml | 4 ++-- 7 files changed, 6 insertions(+), 5 deletions(-) rename samples/greengrass/ipc/ci_run_ipc_cfg.json => .github/workflows/ci_run_greengrass_ipc_cfg.json (100%) rename {samples => tests}/greengrass/ipc/copy_files.sh (59%) rename {samples => tests}/greengrass/ipc/gdk-config.json (100%) rename {samples => tests}/greengrass/ipc/gg-e2e-tests/pom.xml (100%) rename {samples => tests}/greengrass/ipc/gg-e2e-tests/src/main/resources/greengrass/features/component.feature (100%) rename {samples => tests}/greengrass/ipc/recipe.yaml (89%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a66fd3f2a..c49cd2013 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -676,13 +676,13 @@ jobs: role-to-assume: ${{ env.CI_GREENGRASS_INSTALLER_ROLE }} aws-region: ${{ env.AWS_DEFAULT_REGION }} - name: Build and run Greengrass basic discovery sample - working-directory: ./aws-iot-device-sdk-cpp-v2/samples/greengrass/basic_discovery + working-directory: ./aws-iot-device-sdk-cpp-v2/tests/greengrass/basic_discovery run: | gdk component build gdk test-e2e build gdk test-e2e run - name: Show logs - working-directory: ./aws-iot-device-sdk-cpp-v2/samples/greengrass/basic_discovery + working-directory: ./aws-iot-device-sdk-cpp-v2/tests/greengrass/basic_discovery if: always() run: | echo "Logs" @@ -692,7 +692,7 @@ jobs: cat testResults/gg*/software.amazon.awssdk.sdk-gg-test-discovery.log echo "========" - name: Running Greengrass IPC sample - working-directory: ./aws-iot-device-sdk-cpp-v2/samples/greengrass/ipc + working-directory: ./aws-iot-device-sdk-cpp-v2/tests/greengrass/ipc run: | gdk component build gdk test-e2e build diff --git a/samples/greengrass/ipc/ci_run_ipc_cfg.json b/.github/workflows/ci_run_greengrass_ipc_cfg.json similarity index 100% rename from samples/greengrass/ipc/ci_run_ipc_cfg.json rename to .github/workflows/ci_run_greengrass_ipc_cfg.json diff --git a/samples/greengrass/ipc/copy_files.sh b/tests/greengrass/ipc/copy_files.sh similarity index 59% rename from samples/greengrass/ipc/copy_files.sh rename to tests/greengrass/ipc/copy_files.sh index d4b7dce1e..1e22ce09a 100644 --- a/samples/greengrass/ipc/copy_files.sh +++ b/tests/greengrass/ipc/copy_files.sh @@ -1,2 +1,3 @@ cp ../../../build/samples/greengrass/ipc/greengrass-ipc . cp ../../../utils/run_in_ci.py . +cp ../../../.github/workflows/ci_run_greengrass_ipc_cfg.json . diff --git a/samples/greengrass/ipc/gdk-config.json b/tests/greengrass/ipc/gdk-config.json similarity index 100% rename from samples/greengrass/ipc/gdk-config.json rename to tests/greengrass/ipc/gdk-config.json diff --git a/samples/greengrass/ipc/gg-e2e-tests/pom.xml b/tests/greengrass/ipc/gg-e2e-tests/pom.xml similarity index 100% rename from samples/greengrass/ipc/gg-e2e-tests/pom.xml rename to tests/greengrass/ipc/gg-e2e-tests/pom.xml diff --git a/samples/greengrass/ipc/gg-e2e-tests/src/main/resources/greengrass/features/component.feature b/tests/greengrass/ipc/gg-e2e-tests/src/main/resources/greengrass/features/component.feature similarity index 100% rename from samples/greengrass/ipc/gg-e2e-tests/src/main/resources/greengrass/features/component.feature rename to tests/greengrass/ipc/gg-e2e-tests/src/main/resources/greengrass/features/component.feature diff --git a/samples/greengrass/ipc/recipe.yaml b/tests/greengrass/ipc/recipe.yaml similarity index 89% rename from samples/greengrass/ipc/recipe.yaml rename to tests/greengrass/ipc/recipe.yaml index 1c0c19858..004915886 100644 --- a/samples/greengrass/ipc/recipe.yaml +++ b/tests/greengrass/ipc/recipe.yaml @@ -25,8 +25,8 @@ Manifests: Read: ALL Execute: ALL - URI: "file:run_in_ci.py" - - URI: "file:ci_run_ipc_cfg.json" + - URI: "file:ci_run_greengrass_ipc_cfg.json" Lifecycle: Run: | echo "GG core:" {iot:thingName} - python3 {artifacts:path}/run_in_ci.py --runnable_dir {artifacts:path} --file {artifacts:path}/ci_run_ipc_cfg.json + python3 {artifacts:path}/run_in_ci.py --runnable_dir {artifacts:path} --file {artifacts:path}/ci_run_greengrass_ipc_cfg.json From b929c2dd3f72703696890460093e3fbda0f130e2 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Tue, 28 May 2024 16:19:27 -0700 Subject: [PATCH 72/79] fixup --- samples/greengrass/basic_discovery/main.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/samples/greengrass/basic_discovery/main.cpp b/samples/greengrass/basic_discovery/main.cpp index 860720902..e7959d2b6 100644 --- a/samples/greengrass/basic_discovery/main.cpp +++ b/samples/greengrass/basic_discovery/main.cpp @@ -298,7 +298,6 @@ int main(int argc, char *argv[]) connection->Subscribe(cmdData.input_topic.c_str(), AWS_MQTT_QOS_AT_MOST_ONCE, onMessage, onSubAck); } - // TODO Wait for subscription success. int cnt = 0; while (++cnt < 3) From a1fc3cf034ca34c983743e6241af3f9b9079a35d Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Tue, 28 May 2024 16:56:59 -0700 Subject: [PATCH 73/79] fixup --- .../src/main/resources/greengrass/features/component.feature | 2 +- tests/greengrass/basic_discovery/recipe.yaml | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature b/tests/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature index 330960d25..3d613ceb6 100644 --- a/tests/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature +++ b/tests/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature @@ -62,4 +62,4 @@ Feature: Testing features of Greengrassv2 basic discovery sample Then the Greengrass deployment is COMPLETED on the device after 300 seconds And the software.amazon.awssdk.sdk-gg-test-discovery log on the device contains the line "Successfully subscribed to topic" within 180 seconds And the software.amazon.awssdk.sdk-gg-test-discovery log on the device contains the line "Received new message" within 240 seconds - And the software.amazon.awssdk.sdk-gg-test-discovery log on the device contains the line "disassociating CI_Greengrass_Discovery_Thing" within 260 seconds + And the software.amazon.awssdk.sdk-gg-test-discovery log on the device contains the line "disassociated CI_Greengrass_Discovery_Thing" within 260 seconds diff --git a/tests/greengrass/basic_discovery/recipe.yaml b/tests/greengrass/basic_discovery/recipe.yaml index 34e0745d5..d8f55732f 100644 --- a/tests/greengrass/basic_discovery/recipe.yaml +++ b/tests/greengrass/basic_discovery/recipe.yaml @@ -38,6 +38,8 @@ Manifests: sleep 10 echo "Starting discovery" python3 {artifacts:path}/run_in_ci.py --runnable_dir {artifacts:path} --input_uuid ${UUID} --file {artifacts:path}/ci_run_greengrass_discovery_cfg.json + aws greengrassv2 batch-disassociate-client-device-from-core-device --core-device-thing-name {iot:thingName} --entries thingName=CI_Greengrass_Discovery_Thing + echo "Run: disassociated CI_Greengrass_Discovery_Thing" Shutdown: | echo "Shutdown: disassociating CI_Greengrass_Discovery_Thing" aws greengrassv2 batch-disassociate-client-device-from-core-device --core-device-thing-name {iot:thingName} --entries thingName=CI_Greengrass_Discovery_Thing From dc75a9b1fd7feb25724710d3d2da86aa5aadda81 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Tue, 28 May 2024 17:04:30 -0700 Subject: [PATCH 74/79] Disable old sample run --- .github/workflows/ci.yml | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c49cd2013..7a08af84e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -632,14 +632,6 @@ jobs: - name: run X509 sample run: | python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_x509_connect_cfg.json - - name: configure AWS credentials (Greengrass) - uses: aws-actions/configure-aws-credentials@v2 - 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_cfg.json # Runs the Greengrass samples linux-greengrass-tests: @@ -683,6 +675,7 @@ jobs: gdk test-e2e run - name: Show logs working-directory: ./aws-iot-device-sdk-cpp-v2/tests/greengrass/basic_discovery + # Print logs unconditionally to provide more details on Greengrass run even if the test failed. if: always() run: | echo "Logs" @@ -691,7 +684,7 @@ jobs: echo "======== software.amazon.awssdk.sdk-gg-test-discovery.log" cat testResults/gg*/software.amazon.awssdk.sdk-gg-test-discovery.log echo "========" - - name: Running Greengrass IPC sample + - name: Build and run Greengrass IPC sample working-directory: ./aws-iot-device-sdk-cpp-v2/tests/greengrass/ipc run: | gdk component build From a89837c53a60ea696a87c01a27b2cf51694108cb Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Wed, 29 May 2024 14:00:53 -0700 Subject: [PATCH 75/79] Add readmes, review policies --- .github/workflows/ci.yml | 17 ++++--- tests/greengrass/basic_discovery/README.md | 44 +++++++++++++++++++ .../greengrass/features/component.feature | 23 +++++++--- tests/greengrass/ipc/README.md | 43 ++++++++++++++++++ 4 files changed, 113 insertions(+), 14 deletions(-) create mode 100644 tests/greengrass/basic_discovery/README.md create mode 100644 tests/greengrass/ipc/README.md diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7a08af84e..b4ad83a35 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -678,22 +678,25 @@ jobs: # Print logs unconditionally to provide more details on Greengrass run even if the test failed. if: always() run: | - echo "Logs" - echo "======== greengrass.log" + echo "=== greengrass.log" cat testResults/gg*/greengrass.log - echo "======== software.amazon.awssdk.sdk-gg-test-discovery.log" + echo "=== software.amazon.awssdk.sdk-gg-test-discovery.log" cat testResults/gg*/software.amazon.awssdk.sdk-gg-test-discovery.log - echo "========" - name: Build and run Greengrass IPC sample working-directory: ./aws-iot-device-sdk-cpp-v2/tests/greengrass/ipc run: | gdk component build gdk test-e2e build gdk test-e2e run - echo "Logs" - echo "======== software.amazon.awssdk.sdk-gg-ipc.log" + - name: Show logs + working-directory: ./aws-iot-device-sdk-cpp-v2/tests/greengrass/ipc + # Print logs unconditionally to provide more details on Greengrass run even if the test failed. + if: always() + run: | + echo "=== greengrass.log" + cat testResults/gg*/greengrass.log + echo "=== software.amazon.awssdk.sdk-gg-ipc.log" cat testResults/gg*/software.amazon.awssdk.sdk-gg-ipc.log - echo "========" # check that docs can still build check-docs: diff --git a/tests/greengrass/basic_discovery/README.md b/tests/greengrass/basic_discovery/README.md new file mode 100644 index 000000000..77f1c5753 --- /dev/null +++ b/tests/greengrass/basic_discovery/README.md @@ -0,0 +1,44 @@ +# Test for Greengrass Discovery Sample + +Greengrass discovery test runs using [Greengrass Development Kit Command-Line Interface](https://docs.aws.amazon.com/greengrass/v2/developerguide/greengrass-development-kit-cli.html) (GDK CLI). + +### Greengrass discovery component + +For Greengrass discovery sample to work, a Greengrass component subscribed to a particular topic is required. +The following files defines this custom component: + +- [gdk-config.json](./gdk-config.json) - `gdk` reads this file to build and publish component. +- [copy_files.sh](./copy_files.sh) - utility to copy all required files for `gdk` to be able to build the component. +- [recipe.yaml](./recipe.yaml) - defines a component's details, dependencies, artifacts, and lifecycles. +- [hello_world_subscriber.py](./hello_world_subscriber.py) - a simple Greengrass client that subscribes to a given topic using Greengrass IPC. + +### How the test runs + +The first step is to build GreengrassV2 component artifacts and recipes from its source code: + +```shell +gdk component build +``` + +Then the following command builds the testing module: + +```shell +gdk test-e2e build +``` + +Finally, the test can run: + +```shell +gdk test-e2e run +``` + +The test behavior is defined in the [component.feature](./gg-e2e-tests/src/main/resources/greengrass/features/component.feature) +config file using a domain-specific language called [Gherkin](https://docs.aws.amazon.com/greengrass/v2/developerguide/gg-testing-framework.html). + +The test spins up Greengrass core, installs and configures Greengrass component dependencies (including the custom +Greengrass component described in the previous section). After everything is set up, it performs checks. They are defined +at the very bottom of the file and basically grep a log file for specific messages. + +On completion, the test creates log files in `testResult` directory with the run details. The component's logs are stored +in `testResult/gg-/software.amazon.awssdk.sdk-gg-test-discovery.log` file. Though, if error occurred before +the component started its execution, this file might be absent. diff --git a/tests/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature b/tests/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature index 3d613ceb6..fb6d21d46 100644 --- a/tests/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature +++ b/tests/greengrass/basic_discovery/gg-e2e-tests/src/main/resources/greengrass/features/component.feature @@ -17,21 +17,30 @@ Feature: Testing features of Greengrassv2 basic discovery sample "deviceGroups": { "formatVersion": "2021-03-05", "definitions": { - "MyPermissiveDeviceGroup": { - "selectionRule": "thingName: *", - "policyName": "MyPermissivePolicy" + "MyDeviceGroup": { + "selectionRule": "thingName: CI_Greengrass_Discovery_Thing", + "policyName": "MyRestrictivePolicy" } }, "policies": { - "MyPermissivePolicy": { - "AllowAll": { - "statementDescription": "Allow client devices to perform all actions.", + "MyRestrictivePolicy": { + "AllowConnect": { + "statementDescription": "Allow client devices to connect.", "operations": [ - "*" + "mqtt:connect" ], "resources": [ "*" ] + }, + "AllowPublish": { + "statementDescription": "Allow client devices to publish on topic.", + "operations": [ + "mqtt:publish" + ], + "resources": [ + "*clients/*/hello/world/*" + ] } } } diff --git a/tests/greengrass/ipc/README.md b/tests/greengrass/ipc/README.md new file mode 100644 index 000000000..415195d68 --- /dev/null +++ b/tests/greengrass/ipc/README.md @@ -0,0 +1,43 @@ +# Test for Greengrass IPC Sample + +Greengrass IPC test runs using [Greengrass Development Kit Command-Line Interface](https://docs.aws.amazon.com/greengrass/v2/developerguide/greengrass-development-kit-cli.html) (GDK CLI). + +### Greengrass IPC component + +For Greengrass IPC sample to work, it should be deployed as a Greengrass component. +The following files defines this component: + +- [gdk-config.json](./gdk-config.json) - `gdk` reads this file to build and publish component. +- [copy_files.sh](./copy_files.sh) - utility to copy all required files for `gdk` to be able to build the component. +- [recipe.yaml](./recipe.yaml) - defines a component's details, dependencies, artifacts, and lifecycles. + +### How the test runs + +The first step is to build GreengrassV2 component artifacts and recipes from its source code: + +```shell +gdk component build +``` + +Then the following command builds the testing module: + +```shell +gdk test-e2e build +``` + +Finally, the test can run: + +```shell +gdk test-e2e run +``` + +The test behavior is defined in the [component.feature](./gg-e2e-tests/src/main/resources/greengrass/features/component.feature) +config file using a domain-specific language called [Gherkin](https://docs.aws.amazon.com/greengrass/v2/developerguide/gg-testing-framework.html). + +The test spins up Greengrass core, installs and configures Greengrass component dependencies (including the custom +Greengrass component described in the previous section). After everything is set up, it performs checks. They are defined +at the very bottom of the file and basically grep a log file for specific messages. + +On completion, the test creates log files in `testResult` directory with the run details. The component's logs are stored +in `testResult/gg-/software.amazon.awssdk.sdk-gg-ipc.log` file. Though, if error occurred before the +component started its execution, this file might be absent. From 168271d510553796a460ed86b5d5b16f170c5fd1 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Wed, 29 May 2024 14:14:25 -0700 Subject: [PATCH 76/79] Restrict policy --- tests/greengrass/basic_discovery/recipe.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/greengrass/basic_discovery/recipe.yaml b/tests/greengrass/basic_discovery/recipe.yaml index d8f55732f..271423fcf 100644 --- a/tests/greengrass/basic_discovery/recipe.yaml +++ b/tests/greengrass/basic_discovery/recipe.yaml @@ -14,7 +14,7 @@ ComponentConfiguration: - aws.greengrass#SubscribeToTopic - aws.greengrass#PublishToTopic resources: - - "*" + - "clients/*/hello/world/*" Manifests: - Platform: os: all From 62c45057f0b002073078a8e68703e60d236a794d Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Mon, 3 Jun 2024 13:54:02 -0700 Subject: [PATCH 77/79] Get input from file --- .../ci_run_greengrass_discovery_cfg.json | 7 +-- samples/greengrass/basic_discovery/main.cpp | 14 ++--- tests/greengrass/basic_discovery/messages.txt | 2 + tests/greengrass/basic_discovery/recipe.yaml | 1 + utils/run_in_ci.py | 56 +++++++++++++++---- 5 files changed, 58 insertions(+), 22 deletions(-) create mode 100644 tests/greengrass/basic_discovery/messages.txt diff --git a/.github/workflows/ci_run_greengrass_discovery_cfg.json b/.github/workflows/ci_run_greengrass_discovery_cfg.json index 257924ffe..b89c1240d 100644 --- a/.github/workflows/ci_run_greengrass_discovery_cfg.json +++ b/.github/workflows/ci_run_greengrass_discovery_cfg.json @@ -22,10 +22,6 @@ "name": "--region", "data": "us-east-1" }, - { - "name": "--message", - "data": "hello" - }, { "name": "--topic", "data": "clients/CI_Greengrass_Discovery_Thing/hello/world/$INPUT_UUID" @@ -34,5 +30,6 @@ "name": "--mode", "data": "publish" } - ] + ], + "stdin_file": "messages.txt" } diff --git a/samples/greengrass/basic_discovery/main.cpp b/samples/greengrass/basic_discovery/main.cpp index e7959d2b6..ae39f5c9a 100644 --- a/samples/greengrass/basic_discovery/main.cpp +++ b/samples/greengrass/basic_discovery/main.cpp @@ -299,8 +299,8 @@ int main(int argc, char *argv[]) connection->Subscribe(cmdData.input_topic.c_str(), AWS_MQTT_QOS_AT_MOST_ONCE, onMessage, onSubAck); } - int cnt = 0; - while (++cnt < 3) + bool first_input = true; + while (true) { String input; if (cmdData.input_mode == "both" || cmdData.input_mode == "publish") @@ -315,10 +315,13 @@ int main(int argc, char *argv[]) std::getline(std::cin, input); cmdData.input_message = input; } - else + else if (!first_input) { - input = cmdData.input_message; + fprintf(stdout, "Enter a new message or enter 'exit' or 'quit' to exit the program.\n"); + std::getline(std::cin, input); + cmdData.input_message = input; } + first_input = false; } else { @@ -349,12 +352,9 @@ int main(int argc, char *argv[]) fprintf(stdout, "Operation failed with error %s\n", aws_error_debug_str(errorCode)); } }; - fprintf(stdout, "Publishing to topic %s\n", cmdData.input_topic.c_str()); connection->Publish( cmdData.input_topic.c_str(), AWS_MQTT_QOS_AT_LEAST_ONCE, false, payload, onPublishComplete); } - - std::this_thread::sleep_for(std::chrono::seconds(1)); } connection->Disconnect(); diff --git a/tests/greengrass/basic_discovery/messages.txt b/tests/greengrass/basic_discovery/messages.txt new file mode 100644 index 000000000..d5727f718 --- /dev/null +++ b/tests/greengrass/basic_discovery/messages.txt @@ -0,0 +1,2 @@ +hello +exit diff --git a/tests/greengrass/basic_discovery/recipe.yaml b/tests/greengrass/basic_discovery/recipe.yaml index 271423fcf..b7a019bcb 100644 --- a/tests/greengrass/basic_discovery/recipe.yaml +++ b/tests/greengrass/basic_discovery/recipe.yaml @@ -22,6 +22,7 @@ Manifests: - URI: "file:hello_world_subscriber.py" - URI: "file:run_in_ci.py" - URI: "file:ci_run_greengrass_discovery_cfg.json" + - URI: "file:messages.txt" - URI: "file:basic-discovery" Permission: Read: ALL diff --git a/utils/run_in_ci.py b/utils/run_in_ci.py index d7400d264..bd4b9d2ef 100644 --- a/utils/run_in_ci.py +++ b/utils/run_in_ci.py @@ -147,7 +147,18 @@ def make_windows_pfx_file(certificate_file_path, private_key_path, pfx_file_path # Import the PFX into the Windows Certificate Store # (Passing '$mypwd' is required even though it is empty and our certificate has no password. It fails CI otherwise) - import_pfx_arguments = ["powershell.exe", "Import-PfxCertificate", "-FilePath", pfx_file_path, "-CertStoreLocation", "Cert:\\" + pfx_certificate_store_location, "-Password", "$mypwd"] + import_pfx_arguments = [ + "powershell.exe", + # Powershell 7.3 introduced an issue where launching powershell from cmd would not set PSModulePath correctly. + # As a workaround, we set `PSModulePath` to empty so powershell would automatically reset the PSModulePath to default. + # More details: https://github.com/PowerShell/PowerShell/issues/18530 + "$env:PSModulePath = '';", + "Import-PfxCertificate", + "-FilePath", pfx_file_path, + "-CertStoreLocation", + "Cert:\\" + pfx_certificate_store_location, + "-Password", + "$mypwd"] import_pfx_run = subprocess.run(args=import_pfx_arguments, shell=True, stdout=subprocess.PIPE) if (import_pfx_run.returncode != 0): print ("ERROR: Could not import PFX certificate into Windows store!") @@ -250,14 +261,19 @@ def launch_runnable(runnable_dir): print("No configuration JSON file data found!") return -1 + # Prepare data for runnable's STDIN + subprocess_stdin = None + if "stdin_file" in config_json: + stdin_file = os.path.join(runnable_dir, config_json['stdin_file']) + with open(stdin_file, "rb") as file: + subprocess_stdin = file.read() + exit_code = 0 print("Launching runnable...") - runnable_file = os.path.join(runnable_dir, config_json['runnable_file']) # Java if (config_json['language'] == "Java"): - # Flatten arguments down into a single string arguments_as_string = "" for i in range(0, len(config_json_arguments_list)): @@ -267,20 +283,40 @@ def launch_runnable(runnable_dir): arguments = ["mvn", "compile", "exec:java"] arguments.append("-pl") - arguments.append(runnable_file) + arguments.append(config_json['runnable_file']) arguments.append("-Dexec.mainClass=" + config_json['runnable_main_class']) arguments.append("-Daws.crt.ci=True") # We have to do this as a string, unfortunately, due to how -Dexec.args= works... argument_string = subprocess.list2cmdline(arguments) + " -Dexec.args=\"" + arguments_as_string + "\"" print(f"Running cmd: {argument_string}") - runnable_return = subprocess.run(argument_string, shell=True) + runnable_return = subprocess.run(argument_string, input=subprocess_stdin, shell=True) + exit_code = runnable_return.returncode + + elif (config_json['language'] == "Java JAR"): + # Flatten arguments down into a single string + arguments_as_string = "" + for i in range(0, len(config_json_arguments_list)): + arguments_as_string += str(config_json_arguments_list[i]) + if (i+1 < len(config_json_arguments_list)): + arguments_as_string += " " + + runnable_file = os.path.join(runnable_dir, config_json['runnable_file']) + + arguments = ["java"] + arguments.append("-Daws.crt.ci=True") + arguments.append("-jar") + arguments.append(runnable_file) + + argument_string = subprocess.list2cmdline(arguments) + " " + arguments_as_string + print(f"Running cmd: {argument_string}") + runnable_return = subprocess.run(argument_string, input=subprocess_stdin, shell=True) exit_code = runnable_return.returncode # C++ elif (config_json['language'] == "CPP"): - runnable_return = subprocess.run( - args=config_json_arguments_list, executable=runnable_file) + runnable_file = os.path.join(runnable_dir, config_json['runnable_file']) + runnable_return = subprocess.run(args=config_json_arguments_list, input=subprocess_stdin, executable=runnable_file) exit_code = runnable_return.returncode elif (config_json['language'] == "Python"): @@ -288,11 +324,11 @@ def launch_runnable(runnable_dir): config_json_arguments_list.append("True") runnable_return = subprocess.run( - args=[sys.executable, runnable_file] + config_json_arguments_list) + args=[sys.executable, config_json['runnable_file']] + config_json_arguments_list, input=subprocess_stdin) exit_code = runnable_return.returncode elif (config_json['language'] == "Javascript"): - os.chdir(runnable_file) + os.chdir(config_json['runnable_file']) config_json_arguments_list.append("--is_ci") config_json_arguments_list.append("true") @@ -318,7 +354,7 @@ def launch_runnable(runnable_dir): args=arguments + config_json_arguments_list, shell=True) else: runnable_return_two = subprocess.run( - args=arguments + config_json_arguments_list) + args=arguments + config_json_arguments_list, input=subprocess_stdin) if (runnable_return_two != None): exit_code = runnable_return_two.returncode From bc2750033a66f68f4e776410005718721eb92a16 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Mon, 3 Jun 2024 14:21:17 -0700 Subject: [PATCH 78/79] CLean CI config --- .github/workflows/ci.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 44f8280b5..8eed8015f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -646,11 +646,6 @@ jobs: # Runs the Greengrass samples linux-greengrass-tests: runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - version: - - 17 permissions: id-token: write # This is required for requesting the JWT steps: From 0506505fa5af0f3798b5b2ed1be69824772d8221 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Wed, 5 Jun 2024 13:36:11 -0700 Subject: [PATCH 79/79] Sync run_in_in_ci.py --- utils/run_in_ci.py | 181 ++++++++++++++++++++++++--------------------- 1 file changed, 95 insertions(+), 86 deletions(-) diff --git a/utils/run_in_ci.py b/utils/run_in_ci.py index bd4b9d2ef..d8d284a6b 100644 --- a/utils/run_in_ci.py +++ b/utils/run_in_ci.py @@ -33,7 +33,8 @@ def setup_json_arguments_list(file, input_uuid=None): for argument in config_json['arguments']: # Add the name of the argument - config_json_arguments_list.append(argument['name']) + if( 'name' in argument): + config_json_arguments_list.append(argument['name']) # Based on the data present, we need to process and add the data differently try: @@ -227,7 +228,8 @@ def cleanup_runnable(): global config_json_arguments_list for argument in config_json['arguments']: - config_json_arguments_list.append(argument['name']) + if( 'name' in argument): + config_json_arguments_list.append(argument['name']) # Based on the data present, we need to process and add the data differently try: @@ -270,96 +272,103 @@ def launch_runnable(runnable_dir): exit_code = 0 + runnable_timeout = None + if ('timeout' in config_json): + runnable_timeout = config_json['timeout'] + print("Launching runnable...") - # Java - if (config_json['language'] == "Java"): - # Flatten arguments down into a single string - arguments_as_string = "" - for i in range(0, len(config_json_arguments_list)): - arguments_as_string += str(config_json_arguments_list[i]) - if (i+1 < len(config_json_arguments_list)): - arguments_as_string += " " - - arguments = ["mvn", "compile", "exec:java"] - arguments.append("-pl") - arguments.append(config_json['runnable_file']) - arguments.append("-Dexec.mainClass=" + config_json['runnable_main_class']) - arguments.append("-Daws.crt.ci=True") - - # We have to do this as a string, unfortunately, due to how -Dexec.args= works... - argument_string = subprocess.list2cmdline(arguments) + " -Dexec.args=\"" + arguments_as_string + "\"" - print(f"Running cmd: {argument_string}") - runnable_return = subprocess.run(argument_string, input=subprocess_stdin, shell=True) - exit_code = runnable_return.returncode - - elif (config_json['language'] == "Java JAR"): - # Flatten arguments down into a single string - arguments_as_string = "" - for i in range(0, len(config_json_arguments_list)): - arguments_as_string += str(config_json_arguments_list[i]) - if (i+1 < len(config_json_arguments_list)): - arguments_as_string += " " - - runnable_file = os.path.join(runnable_dir, config_json['runnable_file']) - - arguments = ["java"] - arguments.append("-Daws.crt.ci=True") - arguments.append("-jar") - arguments.append(runnable_file) - - argument_string = subprocess.list2cmdline(arguments) + " " + arguments_as_string - print(f"Running cmd: {argument_string}") - runnable_return = subprocess.run(argument_string, input=subprocess_stdin, shell=True) - exit_code = runnable_return.returncode - - # C++ - elif (config_json['language'] == "CPP"): - runnable_file = os.path.join(runnable_dir, config_json['runnable_file']) - runnable_return = subprocess.run(args=config_json_arguments_list, input=subprocess_stdin, executable=runnable_file) - exit_code = runnable_return.returncode - - elif (config_json['language'] == "Python"): - config_json_arguments_list.append("--is_ci") - config_json_arguments_list.append("True") - - runnable_return = subprocess.run( - args=[sys.executable, config_json['runnable_file']] + config_json_arguments_list, input=subprocess_stdin) - exit_code = runnable_return.returncode - - elif (config_json['language'] == "Javascript"): - os.chdir(config_json['runnable_file']) - - config_json_arguments_list.append("--is_ci") - config_json_arguments_list.append("true") - - runnable_return_one = None - if sys.platform == "win32" or sys.platform == "cygwin": - runnable_return_one = subprocess.run(args=["npm", "install"], shell=True) - else: - runnable_return_one = subprocess.run(args=["npm", "install"]) + try: + # Java + if (config_json['language'] == "Java"): + # Flatten arguments down into a single string + arguments_as_string = "" + for i in range(0, len(config_json_arguments_list)): + arguments_as_string += str(config_json_arguments_list[i]) + if (i+1 < len(config_json_arguments_list)): + arguments_as_string += " " + + arguments = ["mvn", "compile", "exec:java"] + arguments.append("-pl") + arguments.append(config_json['runnable_file']) + arguments.append("-Dexec.mainClass=" + config_json['runnable_main_class']) + arguments.append("-Daws.crt.ci=True") + + # We have to do this as a string, unfortunately, due to how -Dexec.args= works... + argument_string = subprocess.list2cmdline(arguments) + " -Dexec.args=\"" + arguments_as_string + "\"" + print(f"Running cmd: {argument_string}") + runnable_return = subprocess.run(argument_string, input=subprocess_stdin, timeout=runnable_timeout, shell=True) + exit_code = runnable_return.returncode + + elif (config_json['language'] == "Java JAR"): + # Flatten arguments down into a single string + arguments_as_string = "" + for i in range(0, len(config_json_arguments_list)): + arguments_as_string += str(config_json_arguments_list[i]) + if (i+1 < len(config_json_arguments_list)): + arguments_as_string += " " + + runnable_file = os.path.join(runnable_dir, config_json['runnable_file']) + + arguments = ["java"] + arguments.append("-Daws.crt.ci=True") + arguments.append("-jar") + arguments.append(runnable_file) + + argument_string = subprocess.list2cmdline(arguments) + " " + arguments_as_string + print(f"Running cmd: {argument_string}") + runnable_return = subprocess.run(argument_string, input=subprocess_stdin, timeout=runnable_timeout, shell=True) + exit_code = runnable_return.returncode + + # C++ + elif (config_json['language'] == "CPP"): + runnable_file = os.path.join(runnable_dir, config_json['runnable_file']) + runnable_return = subprocess.run(args=config_json_arguments_list, input=subprocess_stdin, timeout=runnable_timeout, executable=runnable_file) + exit_code = runnable_return.returncode + + elif (config_json['language'] == "Python"): + runnable_file = os.path.join(runnable_dir, config_json['runnable_file']) + runnable_return = subprocess.run( + args=[sys.executable, runnable_file] + config_json_arguments_list, input=subprocess_stdin, timeout=runnable_timeout) + exit_code = runnable_return.returncode + + elif (config_json['language'] == "Javascript"): + os.chdir(config_json['runnable_file']) + + config_json_arguments_list.append("--is_ci") + config_json_arguments_list.append("true") + + runnable_return_one = None + if not 'skip_install' in config_json: + if sys.platform == "win32" or sys.platform == "cygwin": + runnable_return_one = subprocess.run(args=["npm", "install"], shell=True, timeout=runnable_timeout) + else: + runnable_return_one = subprocess.run(args=["npm", "install"], timeout=runnable_timeout) - if (runnable_return_one == None or runnable_return_one.returncode != 0): - exit_code = runnable_return_one.returncode - else: - runnable_return_two = None - arguments = [] - if 'node_cmd' in config_json: - arguments = config_json['node_cmd'].split(" ") + if not 'skip_install' in config_json and (runnable_return_one == None or runnable_return_one.returncode != 0): + exit_code = runnable_return_one.returncode else: - arguments = ["node", "dist/index.js"] + runnable_return_two = None + arguments = [] + if 'node_cmd' in config_json: + arguments = config_json['node_cmd'].split(" ") + else: + arguments = ["node", "dist/index.js"] - if sys.platform == "win32" or sys.platform == "cygwin": - runnable_return_two = subprocess.run( - args=arguments + config_json_arguments_list, shell=True) - else: - runnable_return_two = subprocess.run( - args=arguments + config_json_arguments_list, input=subprocess_stdin) + if sys.platform == "win32" or sys.platform == "cygwin": + runnable_return_two = subprocess.run( + args=arguments + config_json_arguments_list, shell=True, check=True, timeout=runnable_timeout) + else: + runnable_return_two = subprocess.run( + args=arguments + config_json_arguments_list, input=subprocess_stdin, timeout=runnable_timeout) - if (runnable_return_two != None): - exit_code = runnable_return_two.returncode - else: - exit_code = 1 + if (runnable_return_two != None): + exit_code = runnable_return_two.returncode + else: + exit_code = 1 + except subprocess.CalledProcessError as e: + print(e.output) + exit_code = 1 cleanup_runnable() return exit_code