Skip to content

Commit 6b063b5

Browse files
authored
Run Greengrass samples in CI (#585)
- Add tests for Greengrass samples: IPC and discovery. - Add new CI job for Greengrass tests.
1 parent 8f60ff8 commit 6b063b5

34 files changed

+782
-120
lines changed

.github/workflows/ci.yml

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ env:
2929
CI_JOBS_ROLE: arn:aws:iam::180635532705:role/CI_Jobs_Role
3030
CI_FLEET_PROVISIONING_ROLE: arn:aws:iam::180635532705:role/service-role/CI_FleetProvisioning_Role
3131
CI_GREENGRASS_ROLE: arn:aws:iam::180635532705:role/CI_Greengrass_Role
32+
CI_GREENGRASS_INSTALLER_ROLE: arn:aws:iam::180635532705:role/CI_GreengrassInstaller_Role
3233
CI_DEVICE_ADVISOR: arn:aws:iam::180635532705:role/CI_DeviceAdvisor_Role
3334
CI_MQTT5_ROLE: arn:aws:iam::180635532705:role/CI_MQTT5_Role
3435
CI_BUILD_AND_TEST_ROLE: arn:aws:iam::180635532705:role/V2_SDK_Unit_Testing
@@ -393,14 +394,66 @@ jobs:
393394
Sample_UUID=$(python3 -c "import uuid; print (uuid.uuid4())")
394395
python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_mqtt5_fleet_provisioning_cfg.json --input_uuid ${Sample_UUID}
395396
python3 ${{ env.CI_UTILS_FOLDER }}/delete_iot_thing_ci.py --thing_name "Fleet_Thing_${Sample_UUID}" --region "us-east-1"
396-
- name: configure AWS credentials (Greengrass)
397+
398+
linux-greengrass-tests:
399+
runs-on: ubuntu-22.04
400+
permissions:
401+
id-token: write # This is required for requesting the JWT
402+
steps:
403+
- name: Setup environment
404+
run: |
405+
python3 -m pip install boto3
406+
- name: configure AWS credentials (containers)
397407
uses: aws-actions/configure-aws-credentials@v2
398408
with:
399-
role-to-assume: ${{ env.CI_GREENGRASS_ROLE }}
409+
role-to-assume: ${{ env.CI_BUILD_AND_TEST_ROLE }}
400410
aws-region: ${{ env.AWS_DEFAULT_REGION }}
401-
- name: run Greengrass Discovery sample
411+
- name: Build ${{ env.PACKAGE_NAME }}
412+
run: |
413+
python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder')"
414+
chmod a+x builder
415+
./builder build -p ${{ env.PACKAGE_NAME }}
416+
- name: Install Greengrass Development Kit
402417
run: |
403-
python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_greengrass_discovery_cfg.json
418+
python3 -m pip install awsiotsdk
419+
python3 -m pip install -U git+https://github.com/aws-greengrass/[email protected]
420+
- name: Configure AWS credentials (Greengrass)
421+
uses: aws-actions/configure-aws-credentials@v2
422+
with:
423+
role-to-assume: ${{ env.CI_GREENGRASS_INSTALLER_ROLE }}
424+
aws-region: ${{ env.AWS_DEFAULT_REGION }}
425+
- name: Build and run Greengrass basic discovery sample
426+
working-directory: ./aws-iot-device-sdk-python-v2/test/greengrass/basic_discovery
427+
run: |
428+
export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-python-v2/samples
429+
gdk component build
430+
gdk test-e2e build
431+
gdk test-e2e run
432+
- name: Show logs
433+
working-directory: ./aws-iot-device-sdk-python-v2/test/greengrass/basic_discovery
434+
# Print logs unconditionally to provide more details on Greengrass run even if the test failed.
435+
if: always()
436+
run: |
437+
echo "=== greengrass.log"
438+
cat testResults/gg*/greengrass.log
439+
echo "=== software.amazon.awssdk.sdk-gg-test-discovery.log"
440+
cat testResults/gg*/software.amazon.awssdk.sdk-gg-test-discovery.log
441+
- name: Build and run Greengrass IPC sample
442+
working-directory: ./aws-iot-device-sdk-python-v2/test/greengrass/ipc
443+
run: |
444+
gdk component build
445+
gdk test-e2e build
446+
gdk test-e2e run
447+
- name: Show logs
448+
working-directory: ./aws-iot-device-sdk-python-v2/test/greengrass/ipc
449+
# Print logs unconditionally to provide more details on Greengrass run even if the test failed.
450+
if: always()
451+
run: |
452+
echo "=== greengrass.log"
453+
cat testResults/gg*/greengrass.log
454+
echo "=== software.amazon.awssdk.sdk-gg-ipc.log"
455+
cat testResults/gg*/software.amazon.awssdk.sdk-gg-ipc.log
456+
404457
405458
# check that docs can still build
406459
check-docs:

.github/workflows/ci_run_basic_connect_cfg.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
"name": "--key",
1818
"secret": "ci/PubSub/key",
1919
"filename": "tmp_key.pem"
20+
},
21+
{
22+
"name": "--is_ci",
23+
"data": "true"
2024
}
2125
]
2226
}

.github/workflows/ci_run_cognito_connect_cfg.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
{
1616
"name": "--cognito_identity",
1717
"secret": "ci/Cognito/identity_id"
18+
},
19+
{
20+
"name": "--is_ci",
21+
"data": "true"
1822
}
1923
]
2024
}

.github/workflows/ci_run_custom_authorizer_connect_cfg.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
{
1616
"name": "--custom_auth_password",
1717
"secret": "ci/CustomAuthorizer/password"
18+
},
19+
{
20+
"name": "--is_ci",
21+
"data": "true"
1822
}
1923
]
2024
}

.github/workflows/ci_run_fleet_provisioning_cfg.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
{
2626
"name": "--template_parameters",
2727
"data": "{\"SerialNumber\":\"$INPUT_UUID\"}"
28+
},
29+
{
30+
"name": "--is_ci",
31+
"data": "true"
2832
}
2933
]
3034
}
Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,34 @@
11
{
22
"language": "Python",
3-
"sample_file": "./aws-iot-device-sdk-python-v2/samples/basic_discovery.py",
4-
"sample_region": "us-east-1",
5-
"sample_main_class": "",
3+
"runnable_file": "basic_discovery.py",
4+
"runnable_region": "us-east-1",
5+
"runnable_main_class": "",
66
"arguments": [
77
{
88
"name": "--cert",
9-
"secret": "ci/Greengrass/cert",
9+
"secret": "ci/GreengrassDiscovery/cert",
1010
"filename": "tmp_certificate.pem"
1111
},
1212
{
1313
"name": "--key",
14-
"secret": "ci/Greengrass/key",
14+
"secret": "ci/GreengrassDiscovery/key",
1515
"filename": "tmp_key.pem"
1616
},
1717
{
18-
"name": "--ca_file",
19-
"secret": "ci/Greengrass/ca",
20-
"filename": "tmp_ca.pem"
18+
"name": "--thing_name",
19+
"data": "CI_Greengrass_Discovery_Thing"
2120
},
2221
{
2322
"name": "--region",
2423
"data": "us-east-1"
2524
},
2625
{
27-
"name": "--thing_name",
28-
"data": "CI_GreenGrass_Thing"
29-
},
30-
{
31-
"name": "--is_ci",
32-
"data": "true"
26+
"name": "--topic",
27+
"data": "clients/CI_Greengrass_Discovery_Thing/hello/world/$INPUT_UUID"
3328
},
3429
{
35-
"name": "--print_discover_resp_only",
36-
"data": ""
30+
"name": "--mode",
31+
"data": "publish"
3732
}
3833
]
3934
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"language": "Python",
3+
"runnable_file": "ipc_greengrass.py",
4+
"runnable_region": "us-east-1",
5+
"runnable_main_class": "",
6+
"arguments": [
7+
{
8+
"name": "--topic",
9+
"data": "test/gg-ipc-topic"
10+
},
11+
{
12+
"name": "--message",
13+
"data": "hello"
14+
},
15+
{
16+
"name": "--is_ci",
17+
"data": "true"
18+
}
19+
]
20+
}

.github/workflows/ci_run_jobs_cfg.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
{
2222
"name": "--thing_name",
2323
"data": "CI_Jobs_Thing"
24+
},
25+
{
26+
"name": "--is_ci",
27+
"data": "true"
2428
}
2529
]
2630
}

.github/workflows/ci_run_mqtt5_custom_authorizer_cfg.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
{
1616
"name": "--custom_auth_password",
1717
"secret": "ci/CustomAuthorizer/password"
18+
},
19+
{
20+
"name": "--is_ci",
21+
"data": "true"
1822
}
1923
]
2024
}

.github/workflows/ci_run_mqtt5_custom_authorizer_websockets_cfg.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
{
2020
"name": "--use_websockets",
2121
"data": "true"
22+
},
23+
{
24+
"name": "--is_ci",
25+
"data": "true"
2226
}
2327
]
2428
}

0 commit comments

Comments
 (0)