Skip to content

Commit e8fca89

Browse files
committed
add print_only mode for deployment test
1 parent 244e2df commit e8fca89

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

continuous-delivery/test_prod_pypi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ phases:
2020
- cd aws-iot-device-sdk-python
2121
- CURRENT_TAG_VERSION=$(git describe --tags | cut -f2 -dv)
2222
- python3 continuous-delivery/pip-install-with-retry.py --no-cache-dir --user AWSIoTPythonSDK==$CURRENT_TAG_VERSION
23-
- python3 samples/greengrass/basicDiscovery.py -e ${ENDPOINT} -c /tmp/certificate.pem -k /tmp/privatekey.pem -r /tmp/AmazonRootCA1.pem
23+
- python3 samples/greengrass/basicDiscovery.py -e ${ENDPOINT} -c /tmp/certificate.pem -k /tmp/privatekey.pem -r /tmp/AmazonRootCA1.pem --print_discover_resp_only
2424

2525
post_build:
2626
commands:

continuous-delivery/test_test_pypi.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ phases:
2222
# this is here because typing isn't in testpypi, so pull it from prod instead
2323
- python3 -m pip install typing
2424
- python3 continuous-delivery/pip-install-with-retry.py -i https://testpypi.python.org/simple --user AWSIoTPythonSDK-V1==$CURRENT_TAG_VERSION
25-
# The greengrass test failed for no discover the correct thing. However it is good enough to test if the AWSIoTPythonSDK installed successfully or not.
26-
- python3 samples/greengrass/basicDiscovery.py -e ${ENDPOINT} -c /tmp/certificate.pem -k /tmp/privatekey.pem -r /tmp/AmazonRootCA1.pem
25+
- python3 samples/greengrass/basicDiscovery.py -e ${ENDPOINT} -c /tmp/certificate.pem -k /tmp/privatekey.pem -r /tmp/AmazonRootCA1.pem --print_discover_resp_only
2726

2827
post_build:
2928
commands:

samples/greengrass/basicDiscovery.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ def customOnMessage(message):
4747
help="Operation modes: %s"%str(AllowedActions))
4848
parser.add_argument("-M", "--message", action="store", dest="message", default="Hello World!",
4949
help="Message to publish")
50+
#--print_discover_resp_only used for delopyment testing. The test run will return 0 as long as the SDK installed correctly.
51+
parser.add_argument("-p", "--print_discover_resp_only", action="store_true", dest="print_only", default=False)
5052

5153
args = parser.parse_args()
5254
host = args.host
@@ -56,6 +58,7 @@ def customOnMessage(message):
5658
clientId = args.thingName
5759
thingName = args.thingName
5860
topic = args.topic
61+
print_only = args.print_only
5962

6063
if args.mode not in AllowedActions:
6164
parser.error("Unknown --mode option %s. Must be one of %s" % (args.mode, str(AllowedActions)))
@@ -94,7 +97,7 @@ def customOnMessage(message):
9497
discoveryInfoProvider.configureCredentials(rootCAPath, certificatePath, privateKeyPath)
9598
discoveryInfoProvider.configureTimeout(10) # 10 sec
9699

97-
retryCount = MAX_DISCOVERY_RETRIES
100+
retryCount = MAX_DISCOVERY_RETRIES if not print_only else 1
98101
discovered = False
99102
groupCA = None
100103
coreInfo = None
@@ -136,6 +139,9 @@ def customOnMessage(message):
136139
backOffCore.backOff()
137140

138141
if not discovered:
142+
# With print_discover_resp_only flag, we only woud like to check if the API get called correctly.
143+
if print_only:
144+
sys.exit(0)
139145
print("Discovery failed after %d retries. Exiting...\n" % (MAX_DISCOVERY_RETRIES))
140146
sys.exit(-1)
141147

0 commit comments

Comments
 (0)