Skip to content

Commit 8824fc9

Browse files
committed
changed the decorators
1 parent 1c4ef2c commit 8824fc9

4 files changed

Lines changed: 43 additions & 94 deletions

File tree

‎feature_integration_tests/test_cases/conftest.py‎

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818

1919

2020
_DEFAULT_RUST_TARGET = "//feature_integration_tests/test_scenarios/rust:rust_test_scenarios"
21-
_LIFECYCLE_ONLY_RUST_TARGET = "//feature_integration_tests/test_scenarios/rust:rust_lifecycle_test_scenarios"
22-
_LIFECYCLE_TESTS_DIR = Path("feature_integration_tests/test_cases/tests/lifecycle")
2321

2422

2523
def _selected_versions(session: pytest.Session) -> set[str]:
@@ -41,54 +39,6 @@ def _selected_versions(session: pytest.Session) -> set[str]:
4139
return selected_versions or {"rust", "cpp"}
4240

4341

44-
def _is_lifecycle_only_selection(session: pytest.Session) -> bool:
45-
"""Return True when pytest was invoked only for lifecycle test paths."""
46-
if not session.config.args:
47-
return False
48-
49-
normalized_args: list[Path] = []
50-
for arg in session.config.args:
51-
if arg.startswith("-"):
52-
continue
53-
candidate = Path(arg)
54-
normalized_args.append(candidate if candidate.is_absolute() else Path.cwd() / candidate)
55-
56-
if not normalized_args:
57-
return False
58-
59-
lifecycle_root = (Path.cwd() / _LIFECYCLE_TESTS_DIR).resolve()
60-
for candidate in normalized_args:
61-
resolved = candidate.resolve()
62-
try:
63-
resolved.relative_to(lifecycle_root)
64-
except ValueError:
65-
if resolved != lifecycle_root:
66-
return False
67-
return True
68-
69-
70-
def _selected_rust_target_name(session: pytest.Session) -> str:
71-
"""Choose the Rust scenario target for the requested test slice."""
72-
rust_target_name = session.config.getoption("--rust-target-name")
73-
if rust_target_name != _DEFAULT_RUST_TARGET:
74-
return rust_target_name
75-
if _is_lifecycle_only_selection(session):
76-
return _LIFECYCLE_ONLY_RUST_TARGET
77-
return rust_target_name
78-
79-
80-
# [tool.pytest] in pyproject.toml is not read by pytest (it only honors
81-
# [tool.pytest.ini_options]), so the marker declarations there are silently ignored.
82-
# Register them here instead to suppress PytestUnknownMarkWarning.
83-
def pytest_configure(config: pytest.Config) -> None:
84-
config.addinivalue_line("markers", "metadata")
85-
config.addinivalue_line("markers", "test_properties(dict): Add custom properties to test XML output")
86-
config.addinivalue_line("markers", "cpp")
87-
config.addinivalue_line("markers", "rust")
88-
config.addinivalue_line("markers", "daemon")
89-
config.addinivalue_line("markers", "manual")
90-
91-
9242
# Cmdline options
9343
def pytest_addoption(parser):
9444
parser.addoption(
@@ -167,7 +117,7 @@ def pytest_sessionstart(session):
167117
if "rust" in selected_versions:
168118
print("Building Rust test scenarios executable...")
169119
rust_tools = BazelTools(option_prefix="rust", build_timeout=build_timeout)
170-
rust_target_name = _selected_rust_target_name(session)
120+
rust_target_name = session.config.getoption("--rust-target-name")
171121
rust_tools.build(rust_target_name)
172122

173123
# Build C++ test scenarios.

‎feature_integration_tests/test_cases/tests/lifecycle/test_conditional_launching.py‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ def _wait_until(predicate, timeout_s: float, interval_s: float = 0.2) -> bool:
8989

9090
@add_test_properties(
9191
partially_verifies=["feat_req__lifecycle__launch_support"],
92-
test_type="integration",
93-
derivation_technique="end-to-end-testing",
92+
test_type="requirements-based",
93+
derivation_technique="requirements-analysis",
9494
)
9595
def test_startup_launches_conditioned_processes(self, launch_manager_daemon: dict[str, Any], version: str) -> None:
9696
"""Verify supervised processes are launched as part of conditional startup."""
@@ -106,8 +106,8 @@ def test_startup_launches_conditioned_processes(self, launch_manager_daemon: dic
106106
"feat_req__lifecycle__process_ordering",
107107
"feat_req__lifecycle__cond_process_start",
108108
],
109-
test_type="integration",
110-
derivation_technique="end-to-end-testing",
109+
test_type="requirements-based",
110+
derivation_technique="requirements-analysis",
111111
)
112112
def test_rust_launch_is_conditioned_on_cpp_dependency(
113113
self,
@@ -140,9 +140,9 @@ def test_rust_launch_is_conditioned_on_cpp_dependency(
140140
)
141141

142142
@add_test_properties(
143-
partially_verifies=["feat_req__lifecycle__dependency_check"],
144-
test_type="integration",
145-
derivation_technique="end-to-end-testing",
143+
partially_verifies=["feat_req__lifecycle__define_swc_dependencies"],
144+
test_type="requirements-based",
145+
derivation_technique="requirements-analysis",
146146
)
147147
def test_dependency_is_declared_in_lifecycle_config(
148148
self,
@@ -201,8 +201,8 @@ def _wait_until(predicate, timeout_s: float, interval_s: float = 0.2) -> bool:
201201
"feat_req__lifecycle__dependency_check",
202202
"feat_req__lifecycle__cond_process_start",
203203
],
204-
test_type="integration",
205-
derivation_technique="end-to-end-testing",
204+
test_type="requirements-based",
205+
derivation_technique="requirements-analysis",
206206
)
207207
def test_rust_stays_down_until_cpp_dependency_becomes_available(
208208
self, tmp_path_factory: pytest.TempPathFactory, version: str

‎feature_integration_tests/test_cases/tests/lifecycle/test_process_launching_with_daemon.py‎

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ def _wait_until(predicate, timeout_s: float, interval_s: float = 0.2) -> bool:
164164

165165
@add_test_properties(
166166
partially_verifies=["feat_req__lifecycle__parallel_launch_support"],
167-
test_type="integration",
168-
derivation_technique="end-to-end-testing",
167+
test_type="requirements-based",
168+
derivation_technique="requirements-analysis",
169169
)
170170
def test_startup_declares_and_launches_multiple_processes(
171171
self,
@@ -195,8 +195,8 @@ def test_startup_declares_and_launches_multiple_processes(
195195

196196
@add_test_properties(
197197
partially_verifies=["feat_req__lifecycle__process_launch_args"],
198-
test_type="integration",
199-
derivation_technique="end-to-end-testing",
198+
test_type="requirements-based",
199+
derivation_technique="requirements-analysis",
200200
)
201201
def test_launch_process_arguments_are_applied(
202202
self,
@@ -236,33 +236,41 @@ def test_launch_process_environment_is_applied(
236236
launch_manager_daemon: dict[str, Any],
237237
version: str,
238238
) -> None:
239-
"""Verify launched process environment contains configured identifiers."""
239+
"""Verify launched process environment matches every configured environment variable.
240+
241+
Reads the expected variables from the config itself (rather than hardcoded
242+
literals) so this test tracks config drift instead of only ever re-checking
243+
values that happen to coincide with the app name.
244+
"""
240245
daemon_info = launch_manager_daemon
241246
app_name = "rust_supervised_app" if version == "rust" else "cpp_supervised_app"
242247
app_path = str(daemon_info["apps"][version])
243248

249+
config_path = Path(__file__).resolve().parents[3] / "configs" / "lifecycle_daemon_config.json"
250+
config = json.loads(config_path.read_text(encoding="utf-8"))
251+
configured_env = config["components"][app_name]["deployment_config"]["environmental_variables"]
252+
assert configured_env, f"{app_name} does not configure any environmental_variables to verify against"
253+
244254
started = self._wait_until(lambda: self._is_running(app_path), timeout_s=8.0)
245255
assert started, f"{app_name} was not launched before environment verification"
246256

247257
pid = self._first_pid(app_path)
248258
assert pid is not None, f"Could not resolve PID for {app_name}"
249259
proc_env = self._proc_environ(pid)
250260

251-
assert proc_env.get("PROCESSIDENTIFIER") == app_name, (
252-
f"PROCESSIDENTIFIER mismatch for {app_name}: {proc_env.get('PROCESSIDENTIFIER')}"
253-
)
254-
assert proc_env.get("IDENTIFIER") == app_name, (
255-
f"IDENTIFIER mismatch for {app_name}: {proc_env.get('IDENTIFIER')}"
256-
)
261+
for key, expected_value in configured_env.items():
262+
assert proc_env.get(key) == expected_value, (
263+
f"{key} mismatch for {app_name}: expected {expected_value!r}, got {proc_env.get(key)!r}"
264+
)
257265

258266
@add_test_properties(
259267
partially_verifies=[
260268
"feat_req__lifecycle__uid_gid_support",
261269
"feat_req__lifecycle__launch_priority_support",
262270
"feat_req__lifecycle__scheduling_policy",
263271
],
264-
test_type="integration",
265-
derivation_technique="end-to-end-testing",
272+
test_type="requirements-based",
273+
derivation_technique="requirements-analysis",
266274
)
267275
def test_config_defines_uid_gid_scheduling_and_priority(
268276
self, launch_manager_daemon: dict[str, Any], version: str
@@ -279,8 +287,8 @@ def test_config_defines_uid_gid_scheduling_and_priority(
279287

280288
@add_test_properties(
281289
partially_verifies=["feat_req__lifecycle__uid_gid_support"],
282-
test_type="integration",
283-
derivation_technique="end-to-end-testing",
290+
test_type="requirements-based",
291+
derivation_technique="requirements-analysis",
284292
)
285293
def test_launched_process_uid_gid_matches_config_when_applied(
286294
self,
@@ -325,8 +333,8 @@ def test_launched_process_uid_gid_matches_config_when_applied(
325333
"feat_req__lifecycle__launch_priority_support",
326334
"feat_req__lifecycle__scheduling_policy",
327335
],
328-
test_type="integration",
329-
derivation_technique="end-to-end-testing",
336+
test_type="requirements-based",
337+
derivation_technique="requirements-analysis",
330338
)
331339
def test_launched_process_scheduling_matches_config_when_applied(
332340
self,
@@ -381,8 +389,8 @@ def test_launched_process_scheduling_matches_config_when_applied(
381389

382390
@add_test_properties(
383391
partially_verifies=["feat_req__lifecycle__secpol_non_root"],
384-
test_type="integration",
385-
derivation_technique="end-to-end-testing",
392+
test_type="requirements-based",
393+
derivation_technique="requirements-analysis",
386394
)
387395
def test_launch_manager_and_apps_are_not_running_as_root(
388396
self,
@@ -413,8 +421,8 @@ def test_launch_manager_and_apps_are_not_running_as_root(
413421
"feat_req__lifecycle__monitor_abnormal_term",
414422
"feat_req__lifecycle__retries_configurable",
415423
],
416-
test_type="integration",
417-
derivation_technique="end-to-end-testing",
424+
test_type="requirements-based",
425+
derivation_technique="requirements-analysis",
418426
)
419427
def test_supervised_app_recovery(self, launch_manager_daemon: dict[str, Any], version: str) -> None:
420428
"""
@@ -456,8 +464,8 @@ def test_supervised_app_recovery(self, launch_manager_daemon: dict[str, Any], ve
456464
"feat_req__lifecycle__liveliness_detection",
457465
"feat_req__lifecycle__smart_watchdog_config",
458466
],
459-
test_type="integration",
460-
derivation_technique="end-to-end-testing",
467+
test_type="requirements-based",
468+
derivation_technique="requirements-analysis",
461469
)
462470
class TestHealthMonitoringWithDaemon:
463471
"""

‎feature_integration_tests/test_scenarios/cpp/src/scenarios/lifecycle/conditional_launching.cpp‎

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
#include "conditional_launching.h"
1515

16+
#include "internals/persistency/kvs_build_helpers.h"
1617
#include "score/json/json_parser.h"
1718

1819
#include <algorithm>
@@ -33,18 +34,8 @@ namespace {
3334

3435
constexpr const char* kTarget = "cpp_test_scenarios::scenarios::lifecycle::conditional_launching";
3536

36-
std::string unix_seconds_string() {
37-
const auto now = std::chrono::system_clock::now();
38-
const auto secs = std::chrono::duration_cast<std::chrono::seconds>(now.time_since_epoch()).count();
39-
return std::to_string(secs);
40-
}
41-
42-
// Emits the same structured JSON shape the Rust `tracing` subscriber produces, so FIT's
43-
// LogContainer (which filters on the "target"/"level" fields) can find these messages instead
44-
// of falling back to a raw stdout substring match.
4537
void log_info(const std::string& message) {
46-
std::cout << "{\"timestamp\":\"" << unix_seconds_string() << "\",\"level\":\"INFO\",\"fields\":{\"message\":\""
47-
<< message << "\"},\"target\":\"" << kTarget << "\",\"threadId\":\"ThreadId(1)\"}" << std::endl;
38+
kvs_build_helpers::log_info("\"message\":\"" + message + "\"", kTarget);
4839
}
4940

5041
bool path_condition_met(const std::string& path) {

0 commit comments

Comments
 (0)