Skip to content

Commit

Permalink
update test DDTestRun script
Browse files Browse the repository at this point in the history
  • Loading branch information
xiazhvera committed Oct 18, 2023
1 parent 86bef21 commit b2627f6
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -422,10 +422,14 @@ jobs:
with:
role-to-assume: ${{ env.CI_DEVICE_DEFENDER }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: run DeviceDefemder
- 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
Expand Down
33 changes: 27 additions & 6 deletions devicedefender/script/DDTestRun.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
import os
import subprocess
import platform
import sys

# The script will create an IoT thing with a policy that allows it to run Device Defender, then runs the Device Defender sample
# Usage:
# - python DDTestRun.py : Test Device Defender with Mqtt3 Client
# - python DDTestRun.py mqtt5 : Test Device Defender with Mqtt5 Client

# On something other than Linux? Pass the test instantly since Device Defender is only supported on Linux
if platform.system() != "Linux":
Expand Down Expand Up @@ -37,6 +43,10 @@ def delete_thing_with_certi(thingName, certiId, certiArn):
thing_arn = None
client_made_thing = False
client_made_policy = False
use_mqtt5 = False
if len(sys.argv) > 0 and sys.argv[1] == "mqtt5":
use_mqtt5 = True
print("Run Device Defender using Mqtt5")

##############################################
# create a test thing
Expand Down Expand Up @@ -216,13 +226,24 @@ def delete_thing_with_certi(thingName, certiId, certiArn):
continue

print("[Device Defender]Info: Running sample (this should take ~60 seconds).")
# Run the sample:
exe_path = "build/samples/device_defender/basic_report/"
# If running locally, comment out the line above and uncomment the line below:
#exe_path = "samples/device_defender/basic_report/build/"

# Windows has a different build folder structure, but this ONLY runs on Linux currently so we do not need to worry about it
exe_path = os.path.join(exe_path, "basic-report")
if use_mqtt5 is "mqtt5":
# Run the sample:
exe_path = "build/samples/device_defender/basic_report/"
# If running locally, comment out the line above and uncomment the line below:
#exe_path = "samples/device_defender/basic_report/build/"

# Windows has a different build folder structure, but this ONLY runs on Linux currently so we do not need to worry about it
exe_path = os.path.join(exe_path, "basic-report")
else:
# Run the sample:
exe_path = "build/samples/device_defender/mqtt5_basic_report/"
# If running locally, comment out the line above and uncomment the line below:
#exe_path = "samples/device_defender/basic_report/build/"

# Windows has a different build folder structure, but this ONLY runs on Linux currently so we do not need to worry about it
exe_path = os.path.join(exe_path, "mqtt5-basic-report")

print("[Device Defender]Info: Start to run: " + exe_path)
# The Device Defender sample will take ~1 minute to run even if successful
# (since samples are sent every minute)
Expand Down

0 comments on commit b2627f6

Please sign in to comment.