From 14d14584b19da1142389ee79b61959493560f744 Mon Sep 17 00:00:00 2001 From: Vera Xia Date: Thu, 21 Sep 2023 19:03:59 -0700 Subject: [PATCH] Update Service Client Sample to Use Mqtt5 Client (#425) * update service client to use mqtt5 * update ci and identity sample * improve logs * setup client id for mqtt5 client * setup connectProperties * more service client notes * update readme --- .github/workflows/ci.yml | 12 +++++ .../ci_run_fleet_provisioning_mqtt5_cfg.json | 34 +++++++++++++ .github/workflows/ci_run_jobs_mqtt5_cfg.json | 30 +++++++++++ .../workflows/ci_run_shadow_mqtt5_cfg.json | 34 +++++++++++++ samples/node/fleet_provisioning/README.md | 50 ++++++++++++++++++ samples/node/fleet_provisioning/index.ts | 41 ++++++++++++--- samples/node/jobs/README.md | 50 ++++++++++++++++++ samples/node/jobs/index.ts | 34 ++++++++++--- samples/node/shadow/README.md | 51 +++++++++++++++++++ samples/node/shadow/index.ts | 25 ++++----- samples/util/cli_args.js | 5 +- 11 files changed, 340 insertions(+), 26 deletions(-) create mode 100644 .github/workflows/ci_run_fleet_provisioning_mqtt5_cfg.json create mode 100644 .github/workflows/ci_run_jobs_mqtt5_cfg.json create mode 100644 .github/workflows/ci_run_shadow_mqtt5_cfg.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 564eda14..a10a1489 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -245,6 +245,9 @@ jobs: - name: run Shadow sample run: | python3 ./aws-iot-device-sdk-js-v2/utils/run_sample_ci.py --file ./aws-iot-device-sdk-js-v2/.github/workflows/ci_run_shadow_cfg.json + - name: run Mqtt5 Shadow sample + run: | + python3 ./aws-iot-device-sdk-js-v2/utils/run_sample_ci.py --file ./aws-iot-device-sdk-js-v2/.github/workflows/ci_run_shadow_mqtt5_cfg.json - name: configure AWS credentials (Jobs) uses: aws-actions/configure-aws-credentials@v1 with: @@ -253,6 +256,9 @@ jobs: - name: run Jobs sample run: | python3 ./aws-iot-device-sdk-js-v2/utils/run_sample_ci.py --file ./aws-iot-device-sdk-js-v2/.github/workflows/ci_run_jobs_cfg.json + - name: run Mqtt5 Jobs sample + run: | + python3 ./aws-iot-device-sdk-js-v2/utils/run_sample_ci.py --file ./aws-iot-device-sdk-js-v2/.github/workflows/ci_run_jobs_mqtt5_cfg.json - name: configure AWS credentials (Fleet provisioning) uses: aws-actions/configure-aws-credentials@v1 with: @@ -264,6 +270,12 @@ jobs: Sample_UUID=$(python3 -c "import uuid; print (uuid.uuid4())") python3 ./aws-iot-device-sdk-js-v2/utils/run_sample_ci.py --file ./aws-iot-device-sdk-js-v2/.github/workflows/ci_run_fleet_provisioning_cfg.json --input_uuid ${Sample_UUID} python3 ./aws-iot-device-sdk-js-v2/utils/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 ./aws-iot-device-sdk-js-v2/utils/run_sample_ci.py --file ./aws-iot-device-sdk-js-v2/.github/workflows/ci_run_fleet_provisioning_mqtt5_cfg.json --input_uuid ${Sample_UUID} + python3 ./aws-iot-device-sdk-js-v2/utils/delete_iot_thing_ci.py --thing_name "Fleet_Thing_${Sample_UUID}" --region "us-east-1" - name: configure AWS credentials (MQTT5 PubSub) uses: aws-actions/configure-aws-credentials@v1 with: diff --git a/.github/workflows/ci_run_fleet_provisioning_mqtt5_cfg.json b/.github/workflows/ci_run_fleet_provisioning_mqtt5_cfg.json new file mode 100644 index 00000000..be670f92 --- /dev/null +++ b/.github/workflows/ci_run_fleet_provisioning_mqtt5_cfg.json @@ -0,0 +1,34 @@ +{ + "language": "Javascript", + "sample_file": "./aws-iot-device-sdk-js-v2/samples/node/fleet_provisioning", + "sample_region": "us-east-1", + "sample_main_class": "", + "arguments": [ + { + "name": "--endpoint", + "secret": "ci/endpoint" + }, + { + "name": "--cert", + "secret": "ci/FleetProvisioning/cert", + "filename": "tmp_certificate.pem" + }, + { + "name": "--key", + "secret": "ci/FleetProvisioning/key", + "filename": "tmp_key.pem" + }, + { + "name": "--template_name", + "data": "CI_FleetProvisioning_Template" + }, + { + "name": "--template_parameters", + "data": "{\"SerialNumber\":\"$INPUT_UUID\"}" + }, + { + "name": "--mqtt5", + "data": "true" + } + ] +} diff --git a/.github/workflows/ci_run_jobs_mqtt5_cfg.json b/.github/workflows/ci_run_jobs_mqtt5_cfg.json new file mode 100644 index 00000000..66db7a8c --- /dev/null +++ b/.github/workflows/ci_run_jobs_mqtt5_cfg.json @@ -0,0 +1,30 @@ +{ + "language": "Javascript", + "sample_file": "./aws-iot-device-sdk-js-v2/samples/node/jobs", + "sample_region": "us-east-1", + "sample_main_class": "", + "arguments": [ + { + "name": "--endpoint", + "secret": "ci/endpoint" + }, + { + "name": "--cert", + "secret": "ci/Jobs/cert", + "filename": "tmp_certificate.pem" + }, + { + "name": "--key", + "secret": "ci/Jobs/key", + "filename": "tmp_key.pem" + }, + { + "name": "--thing_name", + "data": "CI_Jobs_Thing" + }, + { + "name": "--mqtt5", + "data": "true" + } + ] +} diff --git a/.github/workflows/ci_run_shadow_mqtt5_cfg.json b/.github/workflows/ci_run_shadow_mqtt5_cfg.json new file mode 100644 index 00000000..49c16f68 --- /dev/null +++ b/.github/workflows/ci_run_shadow_mqtt5_cfg.json @@ -0,0 +1,34 @@ +{ + "language": "Javascript", + "sample_file": "./aws-iot-device-sdk-js-v2/samples/node/shadow", + "sample_region": "us-east-1", + "sample_main_class": "", + "arguments": [ + { + "name": "--endpoint", + "secret": "ci/endpoint" + }, + { + "name": "--cert", + "secret": "ci/Shadow/cert", + "filename": "tmp_certificate.pem" + }, + { + "name": "--key", + "secret": "ci/Shadow/key", + "filename": "tmp_key.pem" + }, + { + "name": "--thing_name", + "data": "CI_Shadow_Thing" + }, + { + "name": "--is_ci", + "data": "true" + }, + { + "name": "--mqtt5", + "data": "true" + } + ] +} diff --git a/samples/node/fleet_provisioning/README.md b/samples/node/fleet_provisioning/README.md index 927957bc..1372569f 100644 --- a/samples/node/fleet_provisioning/README.md +++ b/samples/node/fleet_provisioning/README.md @@ -79,6 +79,13 @@ npm install node ./index.js --endpoint --cert --key --template_name