-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_demo_iot_app.py
103 lines (77 loc) · 3.04 KB
/
test_demo_iot_app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#
# Copyright (C) 2019-2024, HENSOLDT Cyber GmbH
#
# SPDX-License-Identifier: GPL-2.0-or-later
#
# For commercial licensing, contact: [email protected]
#
import pytest
import logs # logs module from the common directory in TA
# Timeouts of the tests are set based on CI profiling.
#-------------------------------------------------------------------------------
@pytest.mark.dependency()
def test_config_backend_init_ok(boot_with_proxy):
"""
Test that the configuration backend is successfully initialized by the
Config Server component.
"""
test_runner = boot_with_proxy()
(ret, text, expr_fail) = logs.check_log_match_sequence(
test_runner.get_system_log(),
["Config Server initialized"],
60)
if not ret:
pytest.fail(" missing: %s"%(expr_fail))
#-------------------------------------------------------------------------------
@pytest.mark.dependency(depends=["test_config_backend_init_ok"])
def test_server_connect_ok(boot_with_proxy, mosquitto_broker):
"""
Test that the TCP connection with the configured server is successfully established.
"""
test_runner = boot_with_proxy()
(ret, text, expr_fail) = logs.check_log_match_sequence(
test_runner.get_system_log(),
["TCP connection established successfully"],
180)
if not ret:
pytest.fail(" missing: %s"%(expr_fail))
#-------------------------------------------------------------------------------
@pytest.mark.dependency(depends=["test_config_backend_init_ok",
"test_server_connect_ok"])
def test_tls_handshake_ok(boot_with_proxy, mosquitto_broker):
"""
Test that the TLS Handshake is successfully completed.
"""
test_runner = boot_with_proxy()
(ret, text, expr_fail) = logs.check_log_match_sequence(
test_runner.get_system_log(),
["TLS session established successfully"],
60)
if not ret:
pytest.fail(" missing: %s"%(expr_fail))
#-------------------------------------------------------------------------------
@pytest.mark.dependency(depends=["test_tls_handshake_ok"])
def test_mqtt_connect_ok(boot_with_proxy, mosquitto_broker):
"""
Test that the MQTT connect step is successfully acknowledged by the broker.
"""
test_runner = boot_with_proxy()
(ret, text, expr_fail) = logs.check_log_match_sequence(
test_runner.get_system_log(),
["CloudConnector initialized"],
60)
if not ret:
pytest.fail(" missing: %s"%(expr_fail))
#-------------------------------------------------------------------------------
@pytest.mark.dependency(depends=["test_mqtt_connect_ok"])
def test_mqtt_publish_ok(boot_with_proxy, mosquitto_broker):
"""
Test that the MQTT message is successfully published to the broker.
"""
test_runner = boot_with_proxy()
(ret, text, expr_fail) = logs.check_log_match_sequence(
test_runner.get_system_log(),
["MQTT publish on WAN successful"],
60)
if not ret:
pytest.fail(" missing: %s"%(expr_fail))