Skip to content

Commit 5ef8702

Browse files
authored
Shadow Update tests for CI (#660)
* add some futures resets * Update service tests * Fix commit review * fix syntax error * Shadow update tests * servicetests/tests/ShadowUpdate/CMakeLists.txt servicetests/tests/ShadowUpdate/main.cpp * clang format * clang format * clang format * clang format * Fix yml file * fix pythong path * Fix config * Fix core dump * add some prints * fix parse function * Add future waiting * fix * deleting shadow client * Fix * fix * add sleep * value on object * program type * Comments update * clang format * clang format * clang format * clang format * check updated shadow * update named shadow * Fix * fix * remove commented code * Fix * fix * Fix * Fix * change execution order * add extra policy * Fix python arg * do not delete thing * fix syntax * change lambda passing * lambda out of scope arguments * Fix * Add disconnect callback * remove print statements * add print * add print statement * fix * Fix * Fix print * Fix * Fix warning * checkout job execution main
1 parent f6f289a commit 5ef8702

File tree

15 files changed

+852
-6
lines changed

15 files changed

+852
-6
lines changed

.builder/actions/build_samples.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ def run(self, env):
5353

5454
servicetests = [
5555
'servicetests/tests/JobsExecution/',
56-
'servicetests/tests/FleetProvisioning/'
56+
'servicetests/tests/FleetProvisioning/',
57+
'servicetests/tests/ShadowUpdate/',
5758
]
5859

5960
for sample_path in samples:

.github/workflows/ci.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ env:
3838
CI_MQTT5_ROLE: arn:aws:iam::180635532705:role/CI_MQTT5_Role
3939
CI_GREENGRASS_ROLE: arn:aws:iam::180635532705:role/CI_Greengrass_Role
4040
CI_JOBS_SERVICE_CLIENT_ROLE: arn:aws:iam::180635532705:role/CI_JobsServiceClient_Role
41+
CI_SHADOW_SERVICE_CLIENT_ROLE: arn:aws:iam::180635532705:role/CI_ShadowServiceClient_Role
4142

4243
jobs:
4344
linux-compat:
@@ -502,7 +503,31 @@ jobs:
502503
run: |
503504
export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils
504505
python3 ./test_cases/test_jobs_execution.py --config-file ${{ env.CI_SERVICE_TESTS_CFG_FOLDER }}/mqtt5_jobs_cfg.json
505-
506+
- name: configure AWS credentials (Shadow)
507+
uses: aws-actions/configure-aws-credentials@v2
508+
with:
509+
role-to-assume: ${{ env.CI_SHADOW_SERVICE_CLIENT_ROLE }}
510+
aws-region: ${{ env.AWS_DEFAULT_REGION }}
511+
- name: run Shadow service client test for MQTT5
512+
working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests
513+
run: |
514+
export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils
515+
python3 ./test_cases/test_shadow_update.py --config-file test_cases/mqtt5_shadow_cfg.json
516+
- name: run Shadow service client test for MQTT311
517+
working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests
518+
run: |
519+
export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils
520+
python3 ./test_cases/test_shadow_update.py --config-file test_cases/mqtt3_shadow_cfg.json
521+
- name: run Named Shadow service client test for MQTT311
522+
working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests
523+
run: |
524+
export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils
525+
python3 ./test_cases/test_shadow_update.py --config-file test_cases/mqtt3_named_shadow_cfg.json
526+
- name: run Named Shadow service client test for MQTT5
527+
working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests
528+
run: |
529+
export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils
530+
python3 ./test_cases/test_shadow_update.py --config-file test_cases/mqtt5_named_shadow_cfg.json
506531
- name: configure AWS credentials (Connect and PubSub)
507532
uses: aws-actions/configure-aws-credentials@v1
508533
with:

samples/jobs/job_execution/main.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,6 @@ int main(int argc, char *argv[])
270270
publishDescribeJobExeCompletedPromise = std::promise<void>();
271271
jobsClient.PublishStartNextPendingJobExecution(
272272
publishRequest, AWS_MQTT_QOS_AT_LEAST_ONCE, publishHandler);
273-
274273
pendingExecutionPromise.get_future().wait();
275274
}
276275

samples/utils/CommandLineUtils.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ namespace Utils
7171
static const char *m_cmd_proxy_user_name = "proxy_user_name";
7272
static const char *m_cmd_proxy_password = "proxy_password";
7373
static const char *m_cmd_shadow_property = "shadow_property";
74+
static const char *m_cmd_shadow_name = "shadow_name";
75+
static const char *m_cmd_shadow_value = "shadow_value";
7476
static const char *m_cmd_region = "region";
7577
static const char *m_cmd_pkcs12_file = "pkcs12_file";
7678
static const char *m_cmd_pkcs12_password = "pkcs12_password";
@@ -1008,6 +1010,9 @@ namespace Utils
10081010
returnData.input_shadowProperty = cmdUtils.GetCommandOrDefault(m_cmd_shadow_property, "color");
10091011
returnData.input_clientId =
10101012
cmdUtils.GetCommandOrDefault(m_cmd_client_id, Aws::Crt::String("test-") + Aws::Crt::UUID().ToString());
1013+
1014+
returnData.input_shadowName = cmdUtils.GetCommandOrDefault(m_cmd_shadow_name, "");
1015+
returnData.input_shadowValue = cmdUtils.GetCommandOrDefault(m_cmd_shadow_value, "");
10111016
return returnData;
10121017
}
10131018

samples/utils/CommandLineUtils.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,8 @@ namespace Utils
280280
Aws::Crt::String input_proxyPassword;
281281
// Shadow
282282
Aws::Crt::String input_shadowProperty;
283+
Aws::Crt::String input_shadowName;
284+
Aws::Crt::String input_shadowValue;
283285
// PKCS12
284286
Aws::Crt::String input_pkcs12File;
285287
Aws::Crt::String input_pkcs12Password;

servicetests/test_cases/mqtt3_jobs_cfg.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
{
2424
"name": "--thing_name",
2525
"data": "ServiceTest_Jobs_$INPUT_UUID"
26+
},
27+
{
28+
"name": "--job_id",
29+
"data": "1"
2630
}
2731
]
2832
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"language": "CPP",
3+
"runnable_file": "../build/servicetests/tests/ShadowUpdate/shadow-update",
4+
"runnable_region": "us-east-1",
5+
"runnable_main_class": "",
6+
"arguments": [
7+
{
8+
"name": "--mqtt_version",
9+
"data": "3"
10+
},
11+
{
12+
"name": "--endpoint",
13+
"secret": "ci/endpoint"
14+
},
15+
{
16+
"name": "--cert",
17+
"data": "tests/ShadowUpdate/certificate.pem.crt"
18+
},
19+
{
20+
"name": "--key",
21+
"data": "tests/ShadowUpdate/private.pem.key"
22+
},
23+
{
24+
"name": "--thing_name",
25+
"data": "ServiceTest_Shadow_$INPUT_UUID"
26+
},
27+
{
28+
"name": "--shadow_property",
29+
"data": "color"
30+
},
31+
{
32+
"name": "--shadow_value",
33+
"data": "on"
34+
},
35+
{
36+
"name": "--shadow_name",
37+
"data": "testShadow"
38+
}
39+
]
40+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"language": "CPP",
3+
"runnable_file": "../build/servicetests/tests/ShadowUpdate/shadow-update",
4+
"runnable_region": "us-east-1",
5+
"runnable_main_class": "",
6+
"arguments": [
7+
{
8+
"name": "--mqtt_version",
9+
"data": "3"
10+
},
11+
{
12+
"name": "--endpoint",
13+
"secret": "ci/endpoint"
14+
},
15+
{
16+
"name": "--cert",
17+
"data": "tests/ShadowUpdate/certificate.pem.crt"
18+
},
19+
{
20+
"name": "--key",
21+
"data": "tests/ShadowUpdate/private.pem.key"
22+
},
23+
{
24+
"name": "--thing_name",
25+
"data": "ServiceTest_Shadow_$INPUT_UUID"
26+
},
27+
{
28+
"name": "--shadow_property",
29+
"data": "color"
30+
},
31+
{
32+
"name": "--shadow_value",
33+
"data": "on"
34+
}
35+
]
36+
}

servicetests/test_cases/mqtt5_jobs_cfg.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
{
2424
"name": "--thing_name",
2525
"data": "ServiceTest_Jobs_$INPUT_UUID"
26+
},
27+
{
28+
"name": "--job_id",
29+
"data": "1"
2630
}
2731
]
2832
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"language": "CPP",
3+
"runnable_file": "../build/servicetests/tests/ShadowUpdate/shadow-update",
4+
"runnable_region": "us-east-1",
5+
"runnable_main_class": "",
6+
"arguments": [
7+
{
8+
"name": "--mqtt_version",
9+
"data": "5"
10+
},
11+
{
12+
"name": "--endpoint",
13+
"secret": "ci/endpoint"
14+
},
15+
{
16+
"name": "--cert",
17+
"data": "tests/ShadowUpdate/certificate.pem.crt"
18+
},
19+
{
20+
"name": "--key",
21+
"data": "tests/ShadowUpdate/private.pem.key"
22+
},
23+
{
24+
"name": "--thing_name",
25+
"data": "ServiceTest_Shadow_$INPUT_UUID"
26+
},
27+
{
28+
"name": "--shadow_property",
29+
"data": "color"
30+
},
31+
{
32+
"name": "--shadow_value",
33+
"data": "on"
34+
},
35+
{
36+
"name": "--shadow_name",
37+
"data": "testShadow"
38+
}
39+
]
40+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"language": "CPP",
3+
"runnable_file": "../build/servicetests/tests/ShadowUpdate/shadow-update",
4+
"runnable_region": "us-east-1",
5+
"runnable_main_class": "",
6+
"arguments": [
7+
{
8+
"name": "--mqtt_version",
9+
"data": "5"
10+
},
11+
{
12+
"name": "--endpoint",
13+
"secret": "ci/endpoint"
14+
},
15+
{
16+
"name": "--cert",
17+
"data": "tests/ShadowUpdate/certificate.pem.crt"
18+
},
19+
{
20+
"name": "--key",
21+
"data": "tests/ShadowUpdate/private.pem.key"
22+
},
23+
{
24+
"name": "--thing_name",
25+
"data": "ServiceTest_Shadow_$INPUT_UUID"
26+
},
27+
{
28+
"name": "--shadow_property",
29+
"data": "color"
30+
},
31+
{
32+
"name": "--shadow_value",
33+
"data": "on"
34+
}
35+
]
36+
}

servicetests/test_cases/test_jobs_execution.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import run_in_ci
1414
import ci_iot_thing
1515

16-
1716
def main():
1817
argument_parser = argparse.ArgumentParser(
1918
description="Run Jobs test in CI")
@@ -55,7 +54,7 @@ def main():
5554
print(f"ERROR: Failed to create IoT thing: {e}")
5655
sys.exit(-1)
5756

58-
thing_job = 'ERROR'
57+
thing_job = 'ERROR'
5958
i = 0;
6059
while 'ERROR' in thing_job and i <= 4:
6160
try:
@@ -69,7 +68,7 @@ def main():
6968
except Exception as e:
7069
print(f"Waiting for a newly created thing to be ready for the Job {e}")
7170
i = i + 1;
72-
time.sleep(1);
71+
time.sleep(1);
7372

7473
# Perform Jobs test. If it's successful, the Job execution should be marked as SUCCEEDED for the thing.
7574
try:

0 commit comments

Comments
 (0)