Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
6042a8d
remove deprecated samples
sbSteveK Aug 15, 2025
e4a79f5
remove more samples and begin updating ci
sbSteveK Aug 15, 2025
fce9ad9
update mac ci
sbSteveK Aug 15, 2025
21361ef
update linux ci
sbSteveK Aug 15, 2025
486926b
more sample ci cleanup
sbSteveK Aug 15, 2025
52ed9e2
more sample culling
sbSteveK Aug 15, 2025
e6d375d
remove more mqtt3 samples
sbSteveK Aug 15, 2025
72bf681
remove unused roles
sbSteveK Aug 15, 2025
337355a
remove mqtt3 samples from codebuild smoketest
sbSteveK Aug 15, 2025
5b4bdf8
point CD and other areas to mqtt5 pubsub. Reinstate basic_discovery
sbSteveK Aug 18, 2025
8d380b8
remove --is_ci args from runner scripts
sbSteveK Aug 18, 2025
0a302fc
remove ci from mqtt5 pubsub
sbSteveK Aug 18, 2025
5c23074
forgot utils
sbSteveK Aug 18, 2025
ff8a813
restore old basic_discovery.py
sbSteveK Aug 18, 2025
029e88d
restore basic_discovery.md
sbSteveK Aug 18, 2025
3cfbabf
simplify arg parsing for pubsub
sbSteveK Aug 18, 2025
7561ef6
update custom auth sample
sbSteveK Aug 18, 2025
d5f5aa3
remove duplicate use_websockets
sbSteveK Aug 18, 2025
c8b1ed8
missed comma
sbSteveK Aug 18, 2025
df3c19d
comma again
sbSteveK Aug 18, 2025
2bb49a1
rename args
sbSteveK Aug 18, 2025
4c54985
input_custom_authorizer_name
sbSteveK Aug 18, 2025
b696d7e
is_ci remove
sbSteveK Aug 18, 2025
baa0c37
clientID
sbSteveK Aug 18, 2025
228e40a
use websockets is a toggle
sbSteveK Aug 18, 2025
3b69654
update samples
sbSteveK Aug 18, 2025
81d83dc
remove is_ci
sbSteveK Aug 18, 2025
85bd350
remove command line utils
sbSteveK Aug 18, 2025
45b4fcc
update fleet_provisioning test
sbSteveK Aug 19, 2025
0750ba1
remove utils dependency from remaining service tests
sbSteveK Aug 19, 2025
ac73022
remove utils from basic_discovery
sbSteveK Aug 19, 2025
bb3b98a
remove command_line_utils.py
sbSteveK Aug 19, 2025
5805cd7
samples-wide factoring start
sbSteveK Aug 19, 2025
f75b65e
simplify parser
sbSteveK Aug 19, 2025
13724e8
further formatting
sbSteveK Aug 19, 2025
391912e
Merge branch 'main' into sample-revamp
sbSteveK Aug 27, 2025
575774c
update README and FAQ
sbSteveK Aug 27, 2025
edf254e
PR fixes
sbSteveK Aug 27, 2025
353908a
try removing ci_run_greengrass_discovery_cfg to check if it's running
sbSteveK Aug 27, 2025
1d0fa5b
restore ci_run_greengrass_ipc_cfg
sbSteveK Aug 27, 2025
ea9e2d9
be holistic and also remove mqtt5 samples from ci
sbSteveK Aug 28, 2025
cb04f25
remove Device Advisor from CI
sbSteveK Aug 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove utils dependency from remaining service tests
  • Loading branch information
sbSteveK committed Aug 19, 2025
commit 0750ba1d464ab859f14d1d8c4395d7b5ac2e1c01
11 changes: 1 addition & 10 deletions servicetests/tests/FleetProvisioning/fleet_provisioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@
from awsiot import iotidentity, mqtt_connection_builder
from awsiot import mqtt5_client_builder
from concurrent.futures import Future
import sys
import threading
import time
import traceback
import json
# from utils.command_line_utils import CommandLineUtils
import sys, threading, time, traceback, json

# - Overview -
# This sample uses the AWS IoT Fleet Provisioning to provision device using either the keys
Expand All @@ -25,10 +20,6 @@
# On startup, the script subscribes to topics based on the request type of either CSR or Keys
# publishes the request to corresponding topic and calls RegisterThing.

# cmdData is the arguments/input from the command line placed into a single struct for
# use in this sample. This handles all of the command line parsing, validating, etc.
# See the Utils/CommandLineUtils for more information.
# cmdData = CommandLineUtils.parse_sample_input_fleet_provisioning()
# --------------------------------- ARGUMENT PARSING -----------------------------------------
import argparse, uuid

Expand Down
89 changes: 57 additions & 32 deletions servicetests/tests/JobsExecution/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@
from awsiot import iotjobs, mqtt_connection_builder
from awsiot import mqtt5_client_builder
from concurrent.futures import Future
import sys
import threading
import time
import traceback
import time
from utils.command_line_utils import CommandLineUtils
import sys, threading, time, traceback, time

# - Overview -
# This sample uses the AWS IoT Jobs Service to get a list of pending jobs and
Expand Down Expand Up @@ -38,14 +33,44 @@
# Using globals to simplify sample code
is_sample_done = threading.Event()

# cmdData is the arguments/input from the command line placed into a single struct for
# use in this sample. This handles all of the command line parsing, validating, etc.
# See the Utils/CommandLineUtils for more information.
cmdData = CommandLineUtils.parse_sample_input_jobs()
# --------------------------------- ARGUMENT PARSING -----------------------------------------
import argparse, uuid

def parse_sample_input():
parser = argparse.ArgumentParser(
description="MQTT5 pub/sub sample (mTLS).",
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)

# Connection / TLS
parser.add_argument("--endpoint", required=True, dest="input_endpoint", help="IoT endpoint hostname")
parser.add_argument("--port", type=int, default=8883, dest="input_port", help="Port (8883 mTLS, 443 ALPN)")
parser.add_argument("--cert", required=True, dest="input_cert",
help="Path to the certificate file to use during mTLS connection establishment")
parser.add_argument("--key", required=True, dest="input_key",
help="Path to the private key file to use during mTLS connection establishment")
parser.add_argument("--ca_file", dest="input_ca", help="Path to optional CA bundle (PEM)")

# Proxy (optional)
parser.add_argument("--proxy-host", dest="input_proxy_host", help="HTTP proxy host")
parser.add_argument("--proxy-port", type=int, default=0, dest="input_proxy_port", help="HTTP proxy port")

# Misc
parser.add_argument("--client-id", dest="input_clientId",
default=f"test-{uuid.uuid4().hex[:8]}", help="Client ID")
parser.add_argument("--mqtt_version", type=int, default=0, dest="input_mqtt_version", help="MQTT Version")
parser.add_argument("--thing_name", required=True, dest="input_thing_name", help="The name assigned to your IoT Thing.")
parser.add_argument("--job_time", type=int, default=5, dest="input_job_time", help="Emulate working on a job by sleeping this many seconds (optional, default='5')")

return parser.parse_args()

args = parse_sample_input()

# --------------------------------- ARGUMENT PARSING END -----------------------------------------

mqtt_connection = None
jobs_client = None
jobs_thing_name = cmdData.input_thing_name
jobs_thing_name = args.input_thing_name
mqtt_qos = None

# MQTT5 specific
Expand Down Expand Up @@ -75,7 +100,7 @@ def exit(msg_or_exception):
if not locked_data.disconnect_called:
print("Disconnecting...")
locked_data.disconnect_called = True
if cmdData.input_mqtt_version == 5:
if args.input_mqtt_version == 5:
mqtt5_client.stop()
else:
future = mqtt_connection.disconnect()
Expand Down Expand Up @@ -213,7 +238,7 @@ def on_start_next_pending_job_execution_rejected(rejected):
def job_thread_fn(job_id, job_document):
try:
print("Starting local work on job...")
time.sleep(cmdData.input_job_time)
time.sleep(args.input_job_time)
print("Done working on job.")

print("Publishing request to update job status to SUCCEEDED...")
Expand Down Expand Up @@ -272,27 +297,27 @@ def on_lifecycle_stopped(lifecycle_stopped_data: mqtt5.LifecycleStoppedData):
# Create the proxy options if the data is present in cmdData

proxy_options = None
if cmdData.input_proxy_host is not None and cmdData.input_proxy_port != 0:
if args.input_proxy_host is not None and args.input_proxy_port != 0:
proxy_options = http.HttpProxyOptions(
host_name=cmdData.input_proxy_host,
port=cmdData.input_proxy_port)
host_name=args.input_proxy_host,
port=args.input_proxy_port)

if cmdData.input_mqtt_version == 5:
if args.input_mqtt_version == 5:
mqtt_qos = mqtt5.QoS.AT_LEAST_ONCE
# Create a mqtt5 connection from the command line data
mqtt5_client = mqtt5_client_builder.mtls_from_path(
endpoint=cmdData.input_endpoint,
port=cmdData.input_port,
cert_filepath=cmdData.input_cert,
pri_key_filepath=cmdData.input_key,
ca_filepath=cmdData.input_ca,
client_id=cmdData.input_clientId,
endpoint=args.input_endpoint,
port=args.input_port,
cert_filepath=args.input_cert,
pri_key_filepath=args.input_key,
ca_filepath=args.input_ca,
client_id=args.input_clientId,
clean_session=False,
keep_alive_secs=30,
http_proxy_options=proxy_options,
on_lifecycle_connection_success=on_lifecycle_connection_success,
on_lifecycle_stopped=on_lifecycle_stopped)
print(f"Connecting to {cmdData.input_endpoint} with client ID '{cmdData.input_clientId}' with MQTT5...")
print(f"Connecting to {args.input_endpoint} with client ID '{args.input_clientId}' with MQTT5...")

mqtt5_client.start()

Expand All @@ -304,21 +329,21 @@ def on_lifecycle_stopped(lifecycle_stopped_data: mqtt5.LifecycleStoppedData):
# mqtt5_client before its fully connected will simply be queued.
# But this sample waits here so it's obvious when a connection
# fails or succeeds.
elif cmdData.input_mqtt_version == 3:
elif args.input_mqtt_version == 3:
mqtt_qos = mqtt.QoS.AT_LEAST_ONCE
# Create a MQTT connection from the command line data
mqtt_connection = mqtt_connection_builder.mtls_from_path(
endpoint=cmdData.input_endpoint,
port=cmdData.input_port,
cert_filepath=cmdData.input_cert,
pri_key_filepath=cmdData.input_key,
ca_filepath=cmdData.input_ca,
client_id=cmdData.input_clientId,
endpoint=args.input_endpoint,
port=args.input_port,
cert_filepath=args.input_cert,
pri_key_filepath=args.input_key,
ca_filepath=args.input_ca,
client_id=args.input_clientId,
clean_session=False,
keep_alive_secs=30,
http_proxy_options=proxy_options)

print(f"Connecting to {cmdData.input_endpoint} with client ID '{cmdData.input_clientId}' with MQTT3...")
print(f"Connecting to {args.input_endpoint} with client ID '{args.input_clientId}' with MQTT3...")

connected_future = mqtt_connection.connect()

Expand Down
100 changes: 65 additions & 35 deletions servicetests/tests/ShadowUpdate/shadow_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@
from awscrt import mqtt, mqtt5, http
from awsiot import iotshadow, mqtt_connection_builder, mqtt5_client_builder
from concurrent.futures import Future
import sys
import threading
import traceback
import sys, threading, traceback
from uuid import uuid4
from utils.command_line_utils import CommandLineUtils

# - Overview -
# This sample uses the AWS IoT Device Shadow Service to keep a property in
Expand All @@ -27,16 +24,49 @@
# initial state. The Test subscribes to modified events from the server,
# which are sent when a property's value changes

# cmdData is the arguments/input from the command line placed into a single struct for
# use in this sample. This handles all of the command line parsing, validating, etc.
# See the Utils/CommandLineUtils for more information.
cmdData = CommandLineUtils.parse_sample_input_shadow()
# --------------------------------- ARGUMENT PARSING -----------------------------------------
import argparse, uuid

def parse_sample_input():
parser = argparse.ArgumentParser(
description="MQTT5 pub/sub sample (mTLS).",
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)

# Connection / TLS
parser.add_argument("--endpoint", required=True, dest="input_endpoint", help="IoT endpoint hostname")
parser.add_argument("--port", type=int, default=8883, dest="input_port", help="Port (8883 mTLS, 443 ALPN)")
parser.add_argument("--cert", required=True, dest="input_cert",
help="Path to the certificate file to use during mTLS connection establishment")
parser.add_argument("--key", required=True, dest="input_key",
help="Path to the private key file to use during mTLS connection establishment")
parser.add_argument("--ca_file", dest="input_ca", help="Path to optional CA bundle (PEM)")

# Proxy (optional)
parser.add_argument("--proxy-host", dest="input_proxy_host", help="HTTP proxy host")
parser.add_argument("--proxy-port", type=int, default=0, dest="input_proxy_port", help="HTTP proxy port")

# Misc
parser.add_argument("--client-id", dest="input_clientId",
default=f"test-{uuid.uuid4().hex[:8]}", help="Client ID")
parser.add_argument("--mqtt_version", type=int, default=0, dest="input_mqtt_version", help="MQTT Version")
parser.add_argument("--thing_name", required=True, dest="input_thing_name", help="The name assigned to your IoT Thing.")
parser.add_argument("--shadow_property", dest="input_shadow_property", default="",
help="The name of the shadow property you want to change (optional, default=''")
parser.add_argument("--shadow_value", dest="input_shadow_value", help="The desired value of the shadow property you want to set (optional)")
parser.add_argument("--shadow_name", dest="input_shadow_name", default="", help="Shadow name (optional, default='')")

return parser.parse_args()

args = parse_sample_input()

# --------------------------------- ARGUMENT PARSING END -----------------------------------------

# Using globals to simplify sample code
is_sample_done = threading.Event()
mqtt_connection = None
shadow_thing_name = cmdData.input_thing_name
shadow_property = cmdData.input_shadow_property
shadow_thing_name = args.input_thing_name
shadow_property = args.input_shadow_property
mqtt_qos = None

# MQTT5 specific
Expand Down Expand Up @@ -67,7 +97,7 @@ def exit(msg_or_exception):
with locked_data.lock:
if not locked_data.disconnect_called:
locked_data.disconnect_called = True
if cmdData.input_mqtt_version == 5:
if args.input_mqtt_version == 5:
print("Stop the client...")
mqtt5_client.stop()
else:
Expand Down Expand Up @@ -211,7 +241,7 @@ def on_lifecycle_stopped(lifecycle_stopped_data: mqtt5.LifecycleStoppedData):
def update_named_shadow():
print("Updating named shadow")
# named shadow here
named_shadow = cmdData.input_shadow_name
named_shadow = args.input_shadow_name
try:
# Subscribe to necessary topics.
# Note that is **is** important to wait for "accepted/rejected" subscriptions
Expand Down Expand Up @@ -272,8 +302,8 @@ def update_named_shadow():
subscribe_future.result()

state=iotshadow.ShadowState(
reported={shadow_property: cmdData.input_shadow_value},
desired={shadow_property: cmdData.input_shadow_value},
reported={shadow_property: args.input_shadow_value},
desired={shadow_property: args.input_shadow_value},
token=token)

update_thing_update_future = shadow_client.publish_update_named_shadow(request = iotshadow.UpdateNamedShadowRequest
Expand Down Expand Up @@ -347,8 +377,8 @@ def update_shadow():
subscribe_future.result()

state=iotshadow.ShadowState(
reported={shadow_property: cmdData.input_shadow_value},
desired={shadow_property: cmdData.input_shadow_value},
reported={shadow_property: args.input_shadow_value},
desired={shadow_property: args.input_shadow_value},
token=token)

update_thing_update_future = shadow_client.publish_update_shadow(request = iotshadow.UpdateShadowRequest
Expand All @@ -362,27 +392,27 @@ def update_shadow():
if __name__ == '__main__':
# Create the proxy options if the data is present in cmdData
proxy_options = None
if cmdData.input_proxy_host is not None and cmdData.input_proxy_port != 0:
if args.input_proxy_host is not None and args.input_proxy_port != 0:
proxy_options = http.HttpProxyOptions(
host_name=cmdData.input_proxy_host,
port=cmdData.input_proxy_port)
host_name=args.input_proxy_host,
port=args.input_proxy_port)

if cmdData.input_mqtt_version == 5:
if args.input_mqtt_version == 5:
mqtt_qos = mqtt5.QoS.AT_LEAST_ONCE
# Create a mqtt5 connection from the command line data
mqtt5_client = mqtt5_client_builder.mtls_from_path(
endpoint=cmdData.input_endpoint,
port=cmdData.input_port,
cert_filepath=cmdData.input_cert,
pri_key_filepath=cmdData.input_key,
ca_filepath=cmdData.input_ca,
client_id=cmdData.input_clientId,
endpoint=args.input_endpoint,
port=args.input_port,
cert_filepath=args.input_cert,
pri_key_filepath=args.input_key,
ca_filepath=args.input_ca,
client_id=args.input_clientId,
clean_session=False,
keep_alive_secs=30,
http_proxy_options=proxy_options,
on_lifecycle_connection_success=on_lifecycle_connection_success,
on_lifecycle_stopped=on_lifecycle_stopped)
print(f"Connecting to {cmdData.input_endpoint} with client ID '{cmdData.input_clientId}' with MQTT5...")
print(f"Connecting to {args.input_endpoint} with client ID '{args.input_clientId}' with MQTT5...")

mqtt5_client.start()

Expand All @@ -394,16 +424,16 @@ def update_shadow():
# mqtt5_client before its fully connected will simply be queued.
# But this sample waits here so it's obvious when a connection
# fails or succeeds.
elif cmdData.input_mqtt_version == 3:
elif args.input_mqtt_version == 3:
mqtt_qos = mqtt.QoS.AT_LEAST_ONCE
# Create a MQTT connection from the command line data
mqtt_connection = mqtt_connection_builder.mtls_from_path(
endpoint=cmdData.input_endpoint,
port=cmdData.input_port,
cert_filepath=cmdData.input_cert,
pri_key_filepath=cmdData.input_key,
ca_filepath=cmdData.input_ca,
client_id=cmdData.input_clientId,
endpoint=args.input_endpoint,
port=args.input_port,
cert_filepath=args.input_cert,
pri_key_filepath=args.input_key,
ca_filepath=args.input_ca,
client_id=args.input_clientId,
clean_session=False,
keep_alive_secs=30,
http_proxy_options=proxy_options)
Expand All @@ -424,7 +454,7 @@ def update_shadow():

print("Connected!")

if not cmdData.input_shadow_name:
if not args.input_shadow_name:
update_shadow()
else:
update_named_shadow()
Expand Down
Loading