Skip to content

Commit 09b4c65

Browse files
Adding process_simple_rep_failure and process_complex_rep_failure integration tests (#238)
* AZB 97324 Source files for tests 183 and 184 * Fix build * Remove not needed cmp & its impl * Rename: Part one, folder only * Rename: Part two, files and content * Update test description * Drop verbose mode as it is nearly not used * Code review rework: Fix Williams comments * Move test process cpp to test_helper folder * Update list of requirements * Verify fallback run target has been activated * Tiny documentation changes * AZB 97324 Addressing PR comments * AZB 97324 Removing unnecessary code from complex_reporting_process.cpp * Updating the partially verified lists (#238) * Removing feat_req__lifecycle__process_failure_react for process_simple_rep_failure * Removing feat_req__lifecycle__process_failure_react for process_complex_rep_failure * AZB 97324 Fixing launch manager references in the BUILD files * Fixing source and BUILD files to reflect the folder structure (#238) * Fixing Test Helper BUILD file to reflect the folder structure (#238) * AZB 97324 Fixing the config for process_complex_rep_failure * Fixing formatting (#238) --------- Co-authored-by: Timo Steuerwald <stt1rlz@bosch.com>
1 parent ce199e9 commit 09b4c65

12 files changed

Lines changed: 867 additions & 1 deletion

File tree

tests/integration/crash_on_startup/crash_on_startup.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@
1717

1818

1919
@add_test_properties(
20-
fully_verifies=["feat_req__lifecycle__failure_detect"],
20+
fully_verifies=[
21+
"feat_req__lifecycle__failure_detect",
22+
"feat_req__lifecycle__recov_run_target_switch",
23+
],
24+
partially_verifies=["feat_req__lifecycle__recovery_action_support"],
2125
test_type="requirements-based",
2226
derivation_technique="requirements-analysis",
2327
)
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# *******************************************************************************
2+
# Copyright (c) 2026 Contributors to the Eclipse Foundation
3+
#
4+
# See the NOTICE file(s) distributed with this work for additional
5+
# information regarding copyright ownership.
6+
#
7+
# This program and the accompanying materials are made available under the
8+
# terms of the Apache License Version 2.0 which is available at
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# SPDX-License-Identifier: Apache-2.0
12+
# *******************************************************************************
13+
load("@rules_pkg//pkg:mappings.bzl", "pkg_attributes", "pkg_files")
14+
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
15+
load("//:defs.bzl", "launch_manager_config")
16+
load("//tests/utils/bazel:integration.bzl", "integration_test")
17+
18+
launch_manager_config(
19+
name = "lm_process_complex_rep_failure_config",
20+
config = "//tests/integration/process_complex_rep_failure:process_complex_rep_failure.json",
21+
flatbuffer_out_dir = "etc",
22+
)
23+
24+
cc_binary(
25+
name = "control_client_mock",
26+
srcs = ["control_client_mock.cpp"],
27+
deps = [
28+
"//score/launch_manager:control_cc",
29+
"//score/launch_manager:lifecycle_cc",
30+
"//tests/utils/test_helper",
31+
"@googletest//:gtest_main",
32+
],
33+
)
34+
35+
cc_binary(
36+
name = "complex_reporting_process",
37+
srcs = ["//tests/utils/test_helper:complex_reporting_process.cpp"],
38+
visibility = ["//tests:__subpackages__"],
39+
deps = [
40+
"//score/launch_manager:lifecycle_cc",
41+
"//tests/utils/test_helper",
42+
"@googletest//:gtest_main",
43+
],
44+
)
45+
46+
pkg_files(
47+
name = "process_complex_rep_failure_main_files",
48+
srcs = [
49+
":complex_reporting_process",
50+
":control_client_mock",
51+
"//score/launch_manager",
52+
"//tests/utils/test_helper:verification_process",
53+
],
54+
attributes = pkg_attributes(mode = "0755"),
55+
prefix = "tests/process_complex_rep_failure",
56+
)
57+
58+
pkg_files(
59+
name = "process_complex_rep_failure_etc_files",
60+
srcs = [":lm_process_complex_rep_failure_config"],
61+
prefix = "tests/process_complex_rep_failure",
62+
)
63+
64+
pkg_tar(
65+
name = "process_complex_rep_failure_binaries",
66+
srcs = [
67+
":process_complex_rep_failure_etc_files",
68+
":process_complex_rep_failure_main_files",
69+
],
70+
)
71+
72+
integration_test(
73+
name = "process_complex_rep_failure",
74+
srcs = ["process_complex_rep_failure.py"],
75+
tags = ["integration"],
76+
test_binaries = ":process_complex_rep_failure_binaries",
77+
deps = ["//tests/utils/testing_utils"],
78+
)
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/********************************************************************************
2+
* Copyright (c) 2026 Contributors to the Eclipse Foundation
3+
*
4+
* See the NOTICE file(s) distributed with this work for additional
5+
* information regarding copyright ownership.
6+
*
7+
* This program and the accompanying materials are made available under the
8+
* terms of the Apache License Version 2.0 which is available at
9+
* https://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* SPDX-License-Identifier: Apache-2.0
12+
********************************************************************************/
13+
#include <gtest/gtest.h>
14+
15+
#include "tests/utils/test_helper/test_helper.hpp"
16+
#include <score/mw/lifecycle/control_client.h>
17+
#include <score/mw/lifecycle/lifecycle_client.h>
18+
19+
// Given a correct configuration with:
20+
// - An initial Run Target named "Startup" containing component named
21+
// "control_client_mock"
22+
// - A Run Target named "run_target_app_does_report_krunning_in_time"
23+
// containing "control_client_mock" and
24+
// "component_does_report_krunning_in_time"
25+
// - A Run Target named "run_target_app_does_not_report_krunning_in_time"
26+
// containing "control_client_mock" and
27+
// "component_does_not_report_krunning_in_time"
28+
29+
TEST(RecoveryActionComplexRepFailure, ControlClientMock) {
30+
score::mw::lifecycle::ControlClient client;
31+
32+
ASSERT_TRUE(check_clean({test_end_location, fallback_file}));
33+
34+
// Establish communication with launch manager
35+
TEST_STEP("Report kRunning from ControlClientMock") {
36+
auto result = score::mw::lifecycle::LifecycleClient{}.ReportExecutionState(
37+
score::mw::lifecycle::ExecutionState::kRunning);
38+
ASSERT_TRUE(result.has_value())
39+
<< "ReportExecutionState() failed: " << result.error().Message();
40+
}
41+
// Start the run target run_target_app_does_report_krunning_in_time
42+
TEST_STEP("Activate RunTarget run_target_app_does_report_krunning_in_time") {
43+
score::cpp::stop_token stop_token;
44+
auto result =
45+
client.ActivateRunTarget("run_target_app_does_report_krunning_in_time")
46+
.Get(stop_token);
47+
EXPECT_TRUE(result.has_value())
48+
<< "Activating target run_target_app_does_report_krunning_in_time "
49+
"failed: "
50+
<< result.error().Message();
51+
}
52+
// Limitation: we cannot wait for the transition to fallback to complete
53+
sleep(1);
54+
// Then, the LM should continue without triggering the fallback
55+
TEST_STEP("Verify fallback run target has not been activated") {
56+
EXPECT_FALSE(std::filesystem::exists(fallback_file))
57+
<< "Fallback run target should have not been activated";
58+
}
59+
// Start the run target run_target_app_does_not_report_krunning_in_time
60+
TEST_STEP(
61+
"Activate RunTarget run_target_app_does_not_report_krunning_in_time") {
62+
score::cpp::stop_token stop_token;
63+
auto result = client
64+
.ActivateRunTarget(
65+
"run_target_app_does_not_report_krunning_in_time")
66+
.Get(stop_token);
67+
EXPECT_FALSE(result.has_value())
68+
<< "Activating target run_target_app_does_not_report_krunning_in_time "
69+
"did not fail as expected.";
70+
}
71+
// Limitation: we cannot wait for the transition to fallback to complete
72+
sleep(1);
73+
// Then, the LM should exhaust retries and trigger the fallback
74+
TEST_STEP("Verify fallback run target was activated") {
75+
EXPECT_TRUE(std::filesystem::exists(fallback_file))
76+
<< "Fallback run target should have been activated";
77+
}
78+
79+
TEST_STEP("Activate RunTarget Off") { client.ActivateRunTarget("Off"); }
80+
}
81+
82+
int main(int argc, char **argv) {
83+
return TestRunner(__FILE__, TerminationBehavior::kContinue,
84+
TerminationNotification::kTestEnd)
85+
.RunTests();
86+
}
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
{
2+
"schema_version": 1,
3+
"defaults": {
4+
"deployment_config": {
5+
"bin_dir": "/tmp/tests/process_complex_rep_failure",
6+
"ready_timeout": 1.0,
7+
"shutdown_timeout": 1.0,
8+
"ready_recovery_action": {
9+
"restart": {
10+
"number_of_attempts": 0
11+
}
12+
},
13+
"recovery_action": {
14+
"switch_run_target": {
15+
"run_target": "fallback_run_target"
16+
}
17+
},
18+
"environmental_variables": {
19+
"LD_LIBRARY_PATH": "/opt/lib"
20+
},
21+
"sandbox": {
22+
"uid": 0,
23+
"gid": 0,
24+
"scheduling_policy": "SCHED_OTHER",
25+
"scheduling_priority": 0
26+
}
27+
},
28+
"component_properties": {
29+
"application_profile": {
30+
"application_type": "Reporting",
31+
"is_self_terminating": true,
32+
"alive_supervision": {
33+
"reporting_cycle": 0.1,
34+
"min_indications": 1,
35+
"max_indications": 3,
36+
"failed_cycles_tolerance": 1
37+
}
38+
},
39+
"ready_condition": {
40+
"process_state": "Running"
41+
}
42+
}
43+
},
44+
"components": {
45+
"control_client_mock": {
46+
"component_properties": {
47+
"binary_name": "control_client_mock",
48+
"application_profile": {
49+
"application_type": "State_Manager",
50+
"alive_supervision": {
51+
"min_indications": 0
52+
}
53+
}
54+
},
55+
"deployment_config": {
56+
"ready_timeout": 1.0,
57+
"shutdown_timeout": 1.0,
58+
"environmental_variables": {
59+
"PROCESSIDENTIFIER": "control_client_mock"
60+
}
61+
}
62+
},
63+
"component_does_report_krunning_in_time": {
64+
"component_properties": {
65+
"binary_name": "complex_reporting_process",
66+
"process_arguments": [
67+
"500.0"
68+
]
69+
},
70+
"deployment_config": {
71+
"ready_timeout": 1.0,
72+
"shutdown_timeout": 1.0,
73+
"environmental_variables": {
74+
"PROCESSIDENTIFIER": "component_does_report_krunning_in_time"
75+
}
76+
}
77+
},
78+
"component_does_not_report_krunning_in_time": {
79+
"component_properties": {
80+
"binary_name": "complex_reporting_process",
81+
"process_arguments": [
82+
"1500.0"
83+
]
84+
},
85+
"deployment_config": {
86+
"ready_timeout": 1.0,
87+
"shutdown_timeout": 1.0,
88+
"environmental_variables": {
89+
"PROCESSIDENTIFIER": "component_does_not_report_krunning_in_time"
90+
}
91+
}
92+
},
93+
"verification_component": {
94+
"component_properties": {
95+
"binary_name": "verification_process",
96+
"application_profile": {
97+
"application_type": "Native",
98+
"is_self_terminating": true
99+
},
100+
"ready_condition": {
101+
"process_state": "Terminated"
102+
}
103+
}
104+
}
105+
},
106+
"run_targets": {
107+
"Startup": {
108+
"depends_on": [
109+
"control_client_mock"
110+
],
111+
"recovery_action": {
112+
"switch_run_target": {
113+
"run_target": "fallback_run_target"
114+
}
115+
}
116+
},
117+
"run_target_app_does_report_krunning_in_time": {
118+
"depends_on": [
119+
"control_client_mock",
120+
"component_does_report_krunning_in_time"
121+
],
122+
"recovery_action": {
123+
"switch_run_target": {
124+
"run_target": "fallback_run_target"
125+
}
126+
}
127+
},
128+
"run_target_app_does_not_report_krunning_in_time": {
129+
"depends_on": [
130+
"control_client_mock",
131+
"component_does_not_report_krunning_in_time"
132+
],
133+
"recovery_action": {
134+
"switch_run_target": {
135+
"run_target": "fallback_run_target"
136+
}
137+
}
138+
},
139+
"Off": {
140+
"depends_on": []
141+
}
142+
},
143+
"initial_run_target": "Startup",
144+
"alive_supervision": {
145+
"evaluation_cycle": 0.05
146+
},
147+
"fallback_run_target": {
148+
"depends_on": [
149+
"control_client_mock",
150+
"verification_component"
151+
]
152+
}
153+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# *******************************************************************************
2+
# Copyright (c) 2026 Contributors to the Eclipse Foundation
3+
#
4+
# See the NOTICE file(s) distributed with this work for additional
5+
# information regarding copyright ownership.
6+
#
7+
# This program and the accompanying materials are made available under the
8+
# terms of the Apache License Version 2.0 which is available at
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# SPDX-License-Identifier: Apache-2.0
12+
# *******************************************************************************
13+
from tests.utils.testing_utils.run_until_file_deployed import run_until_file_deployed
14+
from tests.utils.testing_utils.setup_test import setup_test
15+
from tests.utils.testing_utils.test_results import assert_test_results
16+
from attribute_plugin import add_test_properties
17+
18+
19+
@add_test_properties(
20+
partially_verifies=[
21+
"feat_req__lifecycle__recov_run_target_switch",
22+
"feat_req__lifecycle__recovery_action_support",
23+
],
24+
fully_verifies=[
25+
"feat_req__lifecycle__failure_detect",
26+
],
27+
test_type="requirements-based",
28+
derivation_technique="requirements-analysis",
29+
)
30+
def test_recovery_action_complex_rep_failure(
31+
target, setup_test, assert_test_results, remote_test_dir
32+
):
33+
"""
34+
Objective: Verifies that recovery action is executed when the reporting of kRunning via mw::lifecycle library (named "complex reporting" in the following) is not happening in time and vice versa.
35+
36+
Case 1: Using complex reporting, the process does report kRunning in time (500ms below boundary)
37+
Expected Behaviour: Reporting kRunning is successful, recovery action is not executed.
38+
39+
Case 2: Using complex reporting, the process does not report kRunning in time (500ms above boundary)
40+
Expected Behaviour: Reporting kRunning is not successful, recovery action is executed.
41+
The recovery action switches to the fallback run target, the activation of the fallback run target is verified in the test.
42+
"""
43+
44+
run_until_file_deployed(
45+
target=target,
46+
binary_path=str(remote_test_dir / "launch_manager"),
47+
file_path=remote_test_dir.parent / "test_end",
48+
cwd=str(remote_test_dir),
49+
timeout_s=10.0,
50+
)
51+
52+
assert_test_results({"control_client_mock.xml", "complex_reporting_process.xml"})

0 commit comments

Comments
 (0)