Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
5 changes: 5 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,17 @@ build:stub --@score_baselibs//score/mw/log/flags:KRemote_Logging=False
build:stub --@score_logging//score/mw/log/flags:KRemote_Logging=False
build:stub --@score_baselibs//score/json:base_library=nlohmann

# Target configuration for running integration tests on localhost
build:host --define config=host
test:host --sandbox_writable_path=/opt/score

# Target configuration for CPU:x86-64|OS:Linux build (do not use it in case of system toolchains!)
build:x86_64-linux --config=stub
build:x86_64-linux --config=toolchain_common
build:x86_64-linux --platforms=@score_bazel_platforms//:x86_64-linux-gcc_12.2.0-posix
build:x86_64-linux --extra_toolchains=@score_gcc_x86_64_toolchain//:x86_64-linux-gcc_12.2.0-posix
build:x86_64-linux --extra_toolchains=@score_toolchains_rust//toolchains/ferrocene:ferrocene_x86_64_unknown_linux_gnu
build:x86_64-linux --define config=x86_64-linux

# Target configuration for CPU:AArch64|OS:Linux build (do not use it in case of system toolchains!)
build:arm64-linux --config=stub
Expand Down
23 changes: 23 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module(
bazel_dep(name = "rules_python", version = "1.8.3")
bazel_dep(name = "rules_rust", version = "0.61.0")
bazel_dep(name = "rules_cc", version = "0.2.16")
bazel_dep(name = "rules_oci", version = "2.3.0")
bazel_dep(name = "aspect_rules_lint", version = "2.0.0")
bazel_dep(name = "buildifier_prebuilt", version = "8.2.0.2")
bazel_dep(name = "platforms", version = "1.0.0")
Expand Down Expand Up @@ -133,6 +134,22 @@ pip.parse(
)
use_repo(pip, "score_lifecycle_pip")

bazel_dep(name = "score_itf", version = "0.1.0", dev_dependency = True)
git_override(
module_name = "score_itf",
commit = "e0afbd741929c18b5951029f348dbbd5877cc120",
remote = "https://github.com/eclipse-score/itf.git",
)

oci = use_extension("@rules_oci//oci:extensions.bzl", "oci", dev_dependency = True)
oci.pull(
name = "linux_runtime",
Comment thread
MaciejKaszynski marked this conversation as resolved.
Outdated
image = "index.docker.io/library/debian",
platforms = ["linux/amd64"],
tag = "bookworm",
Comment thread
MaciejKaszynski marked this conversation as resolved.
Outdated
)
use_repo(oci, "linux_runtime", "linux_runtime_linux_amd64")

bazel_dep(name = "score_baselibs_rust", version = "0.1.0")
bazel_dep(name = "score_baselibs", version = "0.2.4")
bazel_dep(name = "score_logging", version = "0.1.0")
Expand All @@ -155,3 +172,9 @@ git_override(
# Replace the commit hash (above) with the latest (https://github.com/hedronvision/bazel-compile-commands-extractor/commits/main).
# Even better, set up Renovate and let it do the work for you (see "Suggestion: Updates" in the README).
)

# TODO: remove once dependencies are working
single_version_override(
Comment thread
MaciejKaszynski marked this conversation as resolved.
Outdated
module_name = "grpc-java",
version = "1.70.0",
)
782 changes: 228 additions & 554 deletions MODULE.bazel.lock

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions config/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ config_setting(
},
)

config_setting(
name = "host",
define_values = {
"config": "host",
},
)

config_setting(
name = "thread_sanitizer_enabled",
define_values = {"sanitize": "thread"},
Expand Down
24 changes: 1 addition & 23 deletions tests/integration/BUILD
Comment thread
MaciejKaszynski marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ load("@rules_python//python:pip.bzl", "compile_pip_requirements")
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
load("@score_lifecycle_pip//:requirements.bzl", "all_requirements")
load("@score_tooling//python_basics:defs.bzl", "score_py_pytest", "score_virtualenv")
load("@score_tooling//python_basics:defs.bzl", "score_virtualenv")

# In order to update the requirements, change the `requirements.txt` file and run:
# `bazel run //tests/integration:requirements.update`.
Expand All @@ -40,25 +40,3 @@ score_virtualenv(
reqs = all_requirements,
venv_name = ".python_tc_venv",
)

cc_library(
name = "test_helper",
hdrs = ["test_helper.hpp"],
visibility = ["//tests:__subpackages__"],
deps = [
"@googletest//:gtest_main",
],
)

py_library(
name = "control_interface",
srcs = ["control_interface.py"],
visibility = ["//tests:__subpackages__"],
)

py_library(
name = "testing_utils",
srcs = ["testing_utils.py"],
visibility = ["//tests:__subpackages__"],
deps = [":control_interface"],
)
58 changes: 0 additions & 58 deletions tests/integration/control_interface.py

This file was deleted.

6 changes: 1 addition & 5 deletions tests/integration/readme.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
# Local integration testing

## Prerequisites
- fakechroot must be installed to run these tests
- `sudo apt install fakechroot`

## Running the tests
Comment thread
MaciejKaszynski marked this conversation as resolved.
Outdated

To run all tests, simply run `bazel test //tests/integration/...`
Comment thread
MaciejKaszynski marked this conversation as resolved.
Outdated

## Running a single test
Comment thread
MaciejKaszynski marked this conversation as resolved.
Outdated
You can run a single integration test locally using `bazel test //tests/integration/<test name>`
You can run a single integration test locally using `bazel test //tests/integration/<test name>`
Comment thread
MaciejKaszynski marked this conversation as resolved.
Outdated
41 changes: 21 additions & 20 deletions tests/integration/smoke/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
load("@score_itf//:defs.bzl", "py_itf_test")
load("@score_lifecycle_pip//:requirements.bzl", "all_requirements")
load("@score_tooling//:defs.bzl", "score_py_pytest")
load("//:defs.bzl", "launch_manager_config")
load("//config:flatbuffers_rules.bzl", "flatbuffer_json_to_bin")
load("//tests/utils/bazel:integration.bzl", "integration_test")
load("//tests/utils/bazel:package_test_binaries.bzl", "package_test_binaries")

exports_files(
["lm_demo.json"],
Expand All @@ -33,7 +36,7 @@ cc_binary(
deps = [
"//src/control_client_lib",
"//src/launch_manager_daemon/lifecycle_client_lib:lifecycle_client",
"//tests/integration:test_helper",
"//tests/utils/test_helper",
"@googletest//:gtest_main",
],
)
Expand All @@ -44,28 +47,26 @@ cc_binary(
deps = [
"//src/control_client_lib",
"//src/launch_manager_daemon/lifecycle_client_lib:lifecycle_client",
"//tests/integration:test_helper",
"//tests/utils/test_helper",
"@googletest//:gtest_main",
],
)

score_py_pytest(
package_test_binaries(
name = "smoke_binaries",
binaries = {
"//src/launch_manager_daemon:launch_manager": "",
":control_daemon_mock": "",
":gtest_process": "",
":lm_smoketest_config": "etc",
},
test_name = "smoke",
)

integration_test(
name = "smoke",
srcs = [
"smoke.py",
],
args = [
],
data = [
":control_daemon_mock",
":gtest_process",
":lm_smoketest_config",
"//src/launch_manager_daemon:launch_manager",
],
tags = [
"integration",
],
deps = all_requirements + [
"//tests/integration:testing_utils",
],
srcs = ["smoke.py"],
tags = ["integration"],
test_binaries = ":smoke_binaries",
deps = ["//tests/utils/testing_utils"],
)
6 changes: 3 additions & 3 deletions tests/integration/smoke/control_daemon_mock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@
#include <score/lcm/lifecycle_client.h>
#include <score/lcm/control_client.h>
#include <score/lcm/identifier_hash.hpp>
#include "tests/integration/test_helper.hpp"
#include "tests/utils/test_helper/test_helper.hpp"

score::lcm::ControlClient client;

TEST(Smoke, Daemon) {
TEST_STEP("Control daemon report kRunning") {
// report kRunning
auto result = score::lcm::LifecycleClient{}.ReportExecutionState(score::lcm::ExecutionState::kRunning);
ASSERT_TRUE(result.has_value()) << "client.ReportExecutionState() failed";
ASSERT_TRUE(result.has_value()) << "client.ReportExecutionState() failed: " << result.error().Message();
}
TEST_STEP("Activate RunTarget Running") {
score::cpp::stop_token stop_token;
auto result = client.ActivateRunTarget("Running").Get(stop_token);
EXPECT_TRUE(result.has_value());
EXPECT_TRUE(result.has_value()) << "Activating target Running failed: " << result.error().Message();
}
TEST_STEP("Activate RunTarget Startup") {
score::cpp::stop_token stop_token;
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/smoke/gtest_process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <unistd.h>

#include <csignal>
#include "tests/integration/test_helper.hpp"
#include "tests/utils/test_helper/test_helper.hpp"

TEST(Smoke, Process) {
// report kRunning
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/smoke/lifecycle_smoketest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"schema_version": 1,
"defaults": {
"deployment_config": {
"bin_dir": "/tests/integration/smoke",
"bin_dir": "/opt/score/tests/smoke",
"ready_timeout": 1.0,
"shutdown_timeout": 1.0,
"ready_recovery_action": {
Expand Down Expand Up @@ -113,4 +113,4 @@
"fallback_run_target": {
"depends_on": []
}
}
}
39 changes: 26 additions & 13 deletions tests/integration/smoke/smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
from tests.integration.testing_utils import (
get_common_interface,
check_for_failures,
format_logs,
)
from pathlib import Path
import logging
from tests.utils.testing_utils.run_until_file_deployed import run_until_file_deployed
from tests.utils.testing_utils.setup_test import setup_test
from tests.utils.testing_utils.test_results import check_for_failures
from attribute_plugin import add_test_properties


Expand All @@ -24,13 +22,28 @@
test_type="interface-test",
derivation_technique="explorative-testing",
)
def test_smoke():
"""Smoke test for the launch manager daemon."""
code, stdout, stderr = get_common_interface().run_until_file_deployed(
"src/launch_manager_daemon/launch_manager"
def test_smoke(target, setup_test, test_output_dir, remote_test_dir):
Comment thread
MaciejKaszynski marked this conversation as resolved.
"""Smoke test for the launch manager daemon running inside a Docker container."""
test_end_file = str(remote_test_dir.parent / "test_end")

run_until_file_deployed(
target=target,
binary_path=str(remote_test_dir / "launch_manager"),
file_path=test_end_file,
cwd=str(remote_test_dir),
timeout_s=60.0,
)

print(format_logs(code, stdout, stderr))
local_results = test_output_dir / "results"
logging.error(local_results)
local_results.mkdir(exist_ok=True)
for xml_name in ("control_daemon_mock.xml", "gtest_process.xml"):
try:
target.download(
str(remote_test_dir / xml_name), str(local_results / xml_name)
)
target.execute(f"rm {str(remote_test_dir / xml_name)}")
except Exception:
pass

check_for_failures(Path("tests/integration/smoke"), 2)
assert code == 0
check_for_failures(local_results, 2)
Loading
Loading