-
Notifications
You must be signed in to change notification settings - Fork 75
Implement fleet provisioning test #501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
3d2f290
Implemented fleet provisioning test
sfodagain b6a19ee
Merge branch 'main' into add-fleet-provisioning-test
sfod 9c7b40c
Merge branch 'main' into add-fleet-provisioning-test
sfod 378a351
Move deleting thing to separate module
sfodagain 0c6fc93
Fix error message
sfodagain 6ca2256
Cleanup code
sfodagain f10641b
Fix log message
sfodagain 7a74ae8
fixup
sfodagain 0e1a11f
fixup
sfodagain 5e1306e
Mqtt3 and mqtt5 fleet provisioning
sfodagain 912e098
Working version
sfodagain 8a5c6ea
Fix CI
sfodagain f2fec2a
wip
sfodagain 8ee50d2
wip
sfodagain 21ea38a
Merge branch 'main' into add-fleet-provisioning-test
sfodagain c5f377d
Simplify test
sfodagain e1bd1d8
FIx CI
sfodagain b1098dd
FIx CI
sfodagain da04c2b
Reorganize service tests
sfodagain 111b98e
Fix CI
sfodagain c10b373
Fix CI
sfodagain c8ab0aa
Fix CI
sfodagain 953941e
Use cmdutils from samples
sfodagain 711f786
Fix CI
sfodagain e3b4ef4
Merge branch 'main' into add-fleet-provisioning-test
sfodagain 9117603
Experiment
sfodagain 77fb38b
Experiment
sfodagain fda955b
Revert experiment
sfodagain 5138b1c
Extract connection creation
sfodagain b222b3f
CLen code
sfodagain a1369b5
Clean code
sfodagain d2615ba
Move main function
sfodagain bf6f3ad
cleanup
sfodagain c23d7bb
cleanup
sfodagain 4444d01
Add CSR
sfodagain ba2d494
Fix CI
sfodagain c76ec17
Use exceptions
sfodagain 18f70b7
Fix deleting thing
sfodagain File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -185,3 +185,6 @@ bin/ | |
|
||
# docs are updated automatically by .github/workflows/docs.yml | ||
docs/ | ||
|
||
# Python cache | ||
__pycache__ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>software.amazon.awssdk.iotdevicesdk</groupId> | ||
<artifactId>ServiceClientTests</artifactId> | ||
<packaging>pom</packaging> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>software.amazon.awssdk.iotdevicesdk</groupId> | ||
<artifactId>aws-iot-device-sdk</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
</dependency> | ||
</dependencies> | ||
<modules> | ||
<module>tests/FleetProvisioning</module> | ||
</modules> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>versions-maven-plugin</artifactId> | ||
<version>2.7</version> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"language": "Java", | ||
"runnable_file": "tests/FleetProvisioning", | ||
"runnable_region": "us-east-1", | ||
"runnable_main_class": "fleetProvisioning.FleetProvisioning", | ||
"arguments": [ | ||
{ | ||
"name": "--mqtt_version", | ||
"data": 3 | ||
}, | ||
{ | ||
"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}" | ||
} | ||
] | ||
} |
39 changes: 39 additions & 0 deletions
39
servicetests/test_cases/mqtt3_fleet_provisioning_with_csr_cfg.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"language": "Java", | ||
"runnable_file": "tests/FleetProvisioning", | ||
"runnable_region": "us-east-1", | ||
"runnable_main_class": "fleetProvisioning.FleetProvisioning", | ||
"arguments": [ | ||
{ | ||
"name": "--mqtt_version", | ||
"data": 3 | ||
}, | ||
{ | ||
"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": "--csr", | ||
"secret": "ci/FleetProvisioning/csr", | ||
"filename": "tmp_csr.pem" | ||
}, | ||
{ | ||
"name": "--template_name", | ||
"data": "CI_FleetProvisioning_Template" | ||
}, | ||
{ | ||
"name": "--template_parameters", | ||
"data": "{SerialNumber:$INPUT_UUID}" | ||
} | ||
] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"language": "Java", | ||
"runnable_file": "tests/FleetProvisioning", | ||
"runnable_region": "us-east-1", | ||
"runnable_main_class": "fleetProvisioning.FleetProvisioning", | ||
"arguments": [ | ||
{ | ||
"name": "--mqtt_version", | ||
"data": 5 | ||
}, | ||
{ | ||
"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}" | ||
} | ||
] | ||
} |
39 changes: 39 additions & 0 deletions
39
servicetests/test_cases/mqtt5_fleet_provisioning_with_csr_cfg.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"language": "Java", | ||
"runnable_file": "tests/FleetProvisioning", | ||
"runnable_region": "us-east-1", | ||
"runnable_main_class": "fleetProvisioning.FleetProvisioning", | ||
"arguments": [ | ||
{ | ||
"name": "--mqtt_version", | ||
"data": 5 | ||
}, | ||
{ | ||
"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": "--csr", | ||
"secret": "ci/FleetProvisioning/csr", | ||
"filename": "tmp_csr.pem" | ||
}, | ||
{ | ||
"name": "--template_name", | ||
"data": "CI_FleetProvisioning_Template" | ||
}, | ||
{ | ||
"name": "--template_parameters", | ||
"data": "{SerialNumber:$INPUT_UUID}" | ||
} | ||
] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0. | ||
|
||
import argparse | ||
import uuid | ||
import os | ||
import sys | ||
import run_in_ci | ||
import ci_iot_thing | ||
|
||
|
||
def main(): | ||
argument_parser = argparse.ArgumentParser( | ||
description="Run Fleet Provisioning test in CI") | ||
argument_parser.add_argument( | ||
"--input-uuid", required=False, help="UUID for thing name. UUID will be generated if this option is omit") | ||
argument_parser.add_argument( | ||
"--thing-name-prefix", required=False, default="", | ||
help="Prefix for a thing name, should be the same that Fleet Provisioning template uses") | ||
argument_parser.add_argument( | ||
"--region", required=False, default="us-east-1", help="The name of the region to use") | ||
argument_parser.add_argument( | ||
"--mqtt-version", required=True, choices=[3, 5], type=int, help="MQTT protocol version to use") | ||
argument_parser.add_argument( | ||
"--use-csr", required=False, default=False, action='store_true', help="Create certificate from CSR") | ||
parsed_commands = argument_parser.parse_args() | ||
|
||
current_path = os.path.dirname(os.path.realpath(__file__)) | ||
cfg_file_mqtt_version = "mqtt3_" if parsed_commands.mqtt_version == 3 else "mqtt5_" | ||
cfg_file_csr = "with_csr_" if parsed_commands.use_csr else "" | ||
cfg_file = os.path.join(current_path, cfg_file_mqtt_version + "fleet_provisioning_" + cfg_file_csr + "cfg.json") | ||
input_uuid = parsed_commands.input_uuid if parsed_commands.input_uuid else str(uuid.uuid4()) | ||
|
||
# Perform fleet provisioning. If it's successful, a newly created thing should appear. | ||
test_result = run_in_ci.setup_and_launch(cfg_file, input_uuid) | ||
|
||
# Delete a thing created by fleet provisioning. If this fails, we assume that's because fleet provisioning failed to | ||
# create a thing. | ||
# NOTE We want to try to delete thing even if test was unsuccessful. | ||
thing_name = parsed_commands.thing_name_prefix + input_uuid | ||
try: | ||
delete_result = ci_iot_thing.delete_iot_thing(thing_name, parsed_commands.region) | ||
except Exception as e: | ||
print(f"ERROR: Failed to delete thing: {e}") | ||
test_result = -1 | ||
|
||
if test_result != 0: | ||
sys.exit(-1) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>software.amazon.awssdk.iotdevicesdk</groupId> | ||
<artifactId>FleetProvisioningServiceTest</artifactId> | ||
<packaging>jar</packaging> | ||
<version>1.0-SNAPSHOT</version> | ||
<name>${project.groupId}:${project.artifactId}</name> | ||
<description>Java bindings for the AWS IoT Core Service</description> | ||
<url>https://github.com/awslabs/aws-iot-device-sdk-java-v2</url> | ||
<properties> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>software.amazon.awssdk.iotdevicesdk</groupId> | ||
<artifactId>aws-iot-device-sdk</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>build-helper-maven-plugin</artifactId> | ||
<version>3.2.0</version> | ||
<executions> | ||
<execution> | ||
<id>add-source</id> | ||
<phase>generate-sources</phase> | ||
<goals> | ||
<goal>add-source</goal> | ||
</goals> | ||
<configuration> | ||
<sources> | ||
<source>../../../samples/Utils/CommandLineUtils</source> | ||
<source>../Utils/MqttClientConnectionWrapper</source> | ||
<source>../ServiceTestLifecycleEvents</source> | ||
</sources> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As for a test purpose, we should run the tests for all possible platform instead just on ubuntu-latest.
This might not apply to Java here, while for other SDKs, if we use crt-builder to build the SDK, then we could directly use the
build.json
script to setup the test for each CI build. You can refer to Python SDK for an example: https://github.com/aws/aws-iot-device-sdk-python-v2/blob/fa4f4ad921748d6377827548b2663d1249cbdedb/builder.json#L90There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I enabled service client tests for one platform only, because we already test builder and connection methods on all platforms. But if you think it might be useful to run these tests on multiple platforms, I can place them near DeviceAdvisor tests.