Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
468 changes: 242 additions & 226 deletions MODULE.bazel.lock

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,8 @@ There is an interactive mode that walks you through two demo scenarios.
This mode requires the run.sh script to be executed **in an active tmux** session.

`bazel run //examples:run_examples --config=<...> -- tmux`

## Demo Verification

There are tests that run the demo setup and verify the expected behavior.
`bazel test //examples/... --config=<...>`
57 changes: 57 additions & 0 deletions examples/demo_verification/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# *******************************************************************************
# Copyright (c) 2026 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
load("@rules_pkg//pkg:mappings.bzl", "pkg_attributes", "pkg_files")
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
load("//:defs.bzl", "launch_manager_config")
load("//tests/utils/bazel:integration.bzl", "integration_test")

launch_manager_config(
name = "examples_test_config",
config = ":lifecycle_demo_test.json",
flatbuffer_out_dir = "etc",
)

pkg_files(
name = "examples_main_files",
srcs = [
"//examples/control_application:control_daemon",
"//examples/control_application:lmcontrol",
"//examples/cpp_lifecycle_app",
"//examples/cpp_supervised_app",
"//examples/rust_supervised_app",
"//score/mw/lifecycle:launch_manager",
],
attributes = pkg_attributes(mode = "0755"),
prefix = "tests/examples",
)

pkg_files(
name = "examples_etc_files",
srcs = [":examples_test_config"],
prefix = "tests/examples",
)

pkg_tar(
name = "examples_binaries",
srcs = [
":examples_etc_files",
":examples_main_files",
],
)

integration_test(
name = "examples",
srcs = ["test_examples.py"],
test_binaries = ":examples_binaries",
deps = ["//tests/utils/testing_utils"],
)
142 changes: 142 additions & 0 deletions examples/demo_verification/lifecycle_demo_test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
{
"schema_version": 1,
"defaults": {
"deployment_config": {
"bin_dir": "/tmp/tests/examples",
"ready_timeout": 2.0,
"shutdown_timeout": 2.0,
"ready_recovery_action": {
"restart": {
"number_of_attempts": 0
}
},
"recovery_action": {
"switch_run_target": {
"run_target": "fallback_run_target"
}
},
"environmental_variables": {
"LD_LIBRARY_PATH": "/tmp/tests/examples/lib"
},
"sandbox": {
"uid": 0,
"gid": 0,
"scheduling_policy": "SCHED_OTHER",
"scheduling_priority": 0
}
},
"component_properties": {
"application_profile": {
"application_type": "Reporting",
"is_self_terminating": false,
"alive_supervision": {
"reporting_cycle": 0.1,
"min_indications": 1,
"max_indications": 3,
"failed_cycles_tolerance": 1
}
},
"ready_condition": {
"process_state": "Running"
}
}
},
"components": {
"control_daemon": {
"component_properties": {
"binary_name": "control_daemon",
"application_profile": {
"application_type": "State_Manager",
"alive_supervision": {
"min_indications": 0
}
}
},
"deployment_config": {
"ready_timeout": 1.0,
"shutdown_timeout": 1.0,
"environmental_variables": {
"PROCESSIDENTIFIER": "control_daemon"
}
}
},
"cpp_supervised_app": {
"component_properties": {
"binary_name": "cpp_supervised_app",
"application_profile": {
"application_type": "Reporting_And_Supervised"
},
"process_arguments": [
"-d50"
]
},
"deployment_config": {
"environmental_variables": {
"PROCESSIDENTIFIER": "cpp_supervised_app",
"CONFIG_PATH": "/tmp/tests/examples/etc/hmproc_cpp_supervised_app.bin",
"IDENTIFIER": "cpp_supervised_app"
}
}
},
"rust_supervised_app": {
"component_properties": {
"binary_name": "rust_supervised_app",
"application_profile": {
"application_type": "Reporting_And_Supervised"
},
"process_arguments": [
"-d50"
]
},
"deployment_config": {
"environmental_variables": {
"PROCESSIDENTIFIER": "rust_supervised_app",
"CONFIG_PATH": "/tmp/tests/examples/etc/hmproc_rust_supervised_app.bin",
"IDENTIFIER": "rust_supervised_app"
}
}
},
"lifecycle_app": {
"component_properties": {
"binary_name": "cpp_lifecycle_app"
},
"deployment_config": {
"environmental_variables": {
"PROCESSIDENTIFIER": "lifecycle_app"
}
}
}
},
"run_targets": {
"Startup": {
"depends_on": [
"control_daemon"
],
"recovery_action": {
"switch_run_target": {
"run_target": "fallback_run_target"
}
}
},
"Running": {
"depends_on": [
"control_daemon",
"cpp_supervised_app",
"rust_supervised_app",
"lifecycle_app"
],
"recovery_action": {
"switch_run_target": {
"run_target": "fallback_run_target"
}
}
}
},
"initial_run_target": "Startup",
"alive_supervision": {
"evaluation_cycle": 0.05
},
"fallback_run_target": {
"depends_on": []
}
}
60 changes: 60 additions & 0 deletions examples/demo_verification/test_examples.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# *******************************************************************************
# Copyright (c) 2026 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
import time

from tests.utils.testing_utils.setup_test import setup_test
from attribute_plugin import add_test_properties


@add_test_properties(
partially_verifies=[],
test_type="interface-test",
derivation_technique="explorative-testing",
)
def test_examples(target, setup_test, remote_test_dir):
"""
Objective: Verifies the example demo runs end-to-end without crashing.

Starts the launch manager, transitions to Running (all example apps start), then back to Startup.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to extend this to also kill a process and make a supervision fail as in

read -p "$(echo -e ${COLOR}Next: Killing an application process${NC})"

read -p "$(echo -e ${COLOR}Next: Trigger supervision failure${NC})"
echo "$> fail $(pgrep cpp_supervised)"
kill -s SIGUSR1 $(pgrep cpp_supervised)

Expected Behaviour: All run target transitions complete and the launch manager stays alive throughout.
"""
lm_path = str(remote_test_dir / "launch_manager")
lmcontrol_path = str(remote_test_dir / "lmcontrol")

lm_proc = target.execute_async(lm_path, cwd=str(remote_test_dir))

time.sleep(1.0)
assert lm_proc.is_running(), "Launch manager exited unexpectedly during Startup"

exit_code, _ = target.execute(f"{lmcontrol_path} Running")
assert exit_code == 0, "lmcontrol Running failed"

time.sleep(2.0)
assert lm_proc.is_running(), "Launch manager exited unexpectedly during Running"

for binary in ("cpp_supervised_app", "rust_supervised_app", "cpp_lifecycle_app"):
rc, _ = target.execute(f"grep -qa '{binary}' /proc/*/cmdline 2>/dev/null")
assert rc == 0, f"{binary} is not running after transition to Running"

exit_code, _ = target.execute(f"{lmcontrol_path} Startup")
assert exit_code == 0, "lmcontrol Startup failed"

time.sleep(1.0)
assert lm_proc.is_running(), (
"Launch manager exited unexpectedly after returning to Startup"
)

res, _ = target.execute(f"kill -15 -{lm_proc.pid()}")
assert res == 0, "Failed to send SIGTERM to launch manager process group"
time.sleep(0.5)
assert not lm_proc.is_running(), "Launch manager did not stop after SIGTERM"
2 changes: 2 additions & 0 deletions tests/utils/environments/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ filegroup(
name = "empty_target",
srcs = [],
visibility = [
"//examples:__subpackages__",
"//tests:__subpackages__",
],
)
Expand All @@ -27,6 +28,7 @@ alias(
"//conditions:default": ":empty_target",
}),
visibility = [
"//examples:__subpackages__",
"//tests:__subpackages__",
],
)
1 change: 1 addition & 0 deletions tests/utils/environments/x86_64-linux/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ oci_load(
image = ":image",
repo_tags = ["score_itf_examples:latest"],
visibility = [
"//examples:__subpackages__",
"//tests:__subpackages__",
],
)
5 changes: 4 additions & 1 deletion tests/utils/testing_utils/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ py_library(
"setup_test.py",
"test_results.py",
],
visibility = ["//tests:__subpackages__"],
visibility = [
"//examples:__subpackages__",
"//tests:__subpackages__",
],
deps = [
requirement("junitparser"),
"@score_itf//score/itf/core/process",
Expand Down
Loading