-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
229 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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": "CPP", | ||
"runnable_file": "../build/servicetests/tests/fleet_provisioning", | ||
"runnable_region": "us-east-1", | ||
"runnable_main_class": "", | ||
"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 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": "CPP", | ||
"runnable_file": "../build/servicetests/tests/fleet_provisioning", | ||
"runnable_region": "us-east-1", | ||
"runnable_main_class": "", | ||
"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 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": "CPP", | ||
"runnable_file": "../build/servicetests/tests/fleet_provisioning", | ||
"runnable_region": "us-east-1", | ||
"runnable_main_class": "", | ||
"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 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": "CPP", | ||
"runnable_file": "../build/servicetests/tests/fleet_provisioning", | ||
"runnable_region": "us-east-1", | ||
"runnable_main_class": "", | ||
"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 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,50 @@ | ||
# 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( | ||
"--config-file", required=True, | ||
help="JSON file providing command-line arguments to a test") | ||
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( | ||
"--input-uuid", required=False, help="UUID for thing name. UUID will be generated if this option is omit") | ||
parsed_commands = argument_parser.parse_args() | ||
|
||
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. | ||
try: | ||
test_result = run_in_ci.setup_and_launch(parsed_commands.config_file, input_uuid) | ||
except Exception as e: | ||
print(f"ERROR: Failed to execute Fleet Provisioning test: {e}") | ||
test_result = -1 | ||
|
||
# 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. | ||
try: | ||
thing_name = parsed_commands.thing_name_prefix + input_uuid | ||
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 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,28 @@ | ||
cmake_minimum_required(VERSION 3.1) | ||
# note: cxx-17 requires cmake 3.8, cxx-20 requires cmake 3.12 | ||
project(fleet_provisioning CXX) | ||
|
||
file(GLOB SRC_FILES | ||
"*.cpp" | ||
"../../../samples/utils/CommandLineUtils.cpp" | ||
"../../../samples/utils/CommandLineUtils.h" | ||
) | ||
|
||
add_executable(${PROJECT_NAME} ${SRC_FILES}) | ||
|
||
set_target_properties(${PROJECT_NAME} PROPERTIES | ||
CXX_STANDARD 14) | ||
|
||
#set warnings | ||
if (MSVC) | ||
target_compile_options(${PROJECT_NAME} PRIVATE /W4 /WX) | ||
else () | ||
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wno-long-long -pedantic -Werror) | ||
endif () | ||
|
||
find_package(aws-crt-cpp REQUIRED) | ||
find_package(IotJobs-cpp REQUIRED) | ||
|
||
install(TARGETS ${PROJECT_NAME} DESTINATION bin) | ||
|
||
target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-crt-cpp AWS::IotJobs-cpp) |
This file contains 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,5 @@ | ||
|
||
int main(int argc, char * argv[]) | ||
{ | ||
return 0; | ||
} |