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
2 changes: 2 additions & 0 deletions bazel_common/score_modules_target_sw.MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ git_override(
commit = "6282f3a2ec6b1eeeab87c8e9a4435c586bcf9973",
patch_strip = 1,
patches = [
"//patches/logging:001-logging-example-visibility.patch",
"//patches/logging:002-needs-json-deps-not-dev-dependency.patch",
"//patches/logging:003-docs-as-code-not-dev-dependency.patch",
"//patches/logging:004-rules-pkg-not-dev-dependency.patch",
],
remote = "https://github.com/eclipse-score/logging.git",
)
Expand Down
43 changes: 43 additions & 0 deletions feature_integration_tests/itf/test_remote_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,46 @@ def test_remote_logging(datarouter_running, dlt_config):
assert message_count > 1, (
f"Expected atleast one DLT message with app_id: {APP_ID} and context_id: {CTX_ID}, but got {message_count}"
)


# DLT message identifiers for the Logging App
LOGGING_APP_ID = "EXA"
LOGGING_CTX_ID = "DFLT"

_LOGGINGAPP_START_CMD = "cd /showcases/data/logging/logging_app/etc && nohup /showcases/bin/logging_app &"


def test_logging_app_logs_forwarded_to_dlt(datarouter_running, target, dlt_config):
"""Verifies that Logging App logs are forwarded to DLT."""

with DltWindow(
protocol=Protocol.UDP,
host_ip=dlt_config.host_ip,
multicast_ips=dlt_config.multicast_ips,
print_to_stdout=True,
binary_path=dlt_config.dlt_receive_path,
) as window:
logger.info("Starting logging_app...")
exit_code, out = target.execute(_LOGGINGAPP_START_CMD)

logger.info("logging_app start exit_code=%s", exit_code)
logger.info(out.decode(errors="replace"))

assert exit_code == 0, "Failed to start logging_app"

time.sleep(CAPTURE_DURATION_SECONDS)

record = window.record(filters=[(LOGGING_APP_ID, LOGGING_CTX_ID)])
messages = record.find(query=dict(apid=LOGGING_APP_ID, ctid=LOGGING_CTX_ID))

logger.debug(
"Found %d messages with app_id=%s, context_id=%s",
len(messages),
LOGGING_APP_ID,
LOGGING_CTX_ID,
)

assert len(messages) > 0, (
f"Expected at least one DLT message with app_id={LOGGING_APP_ID} "
f"and context_id={LOGGING_CTX_ID}, but got {len(messages)}"
)
4 changes: 3 additions & 1 deletion known_good.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,10 @@
"repo": "https://github.com/eclipse-score/logging.git",
"hash": "6282f3a2ec6b1eeeab87c8e9a4435c586bcf9973",
"bazel_patches": [
"//patches/logging:001-logging-example-visibility.patch",
"//patches/logging:002-needs-json-deps-not-dev-dependency.patch",
"//patches/logging:003-docs-as-code-not-dev-dependency.patch"
"//patches/logging:003-docs-as-code-not-dev-dependency.patch",
"//patches/logging:004-rules-pkg-not-dev-dependency.patch"

],
"metadata": {
Expand Down
38 changes: 38 additions & 0 deletions patches/logging/001-logging-example-visibility.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
diff --git a/score/test/component/dlt_generator_app/BUILD b/score/test/component/dlt_generator_app/BUILD
index 9736cac..a60ebd6 100644
--- a/score/test/component/dlt_generator_app/BUILD
+++ b/score/test/component/dlt_generator_app/BUILD
@@ -29,9 +29,14 @@ load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
cc_binary(
name = "dlt_generator",
srcs = ["dlt_generator.cpp"],
+ visibility = ["//visibility:public"],
deps = ["//score/mw/log"],
)

+exports_files([
+ "etc/logging.json",
+])
+
pkg_tar(
name = "dlt_generator_bin_pkg",
srcs = [":dlt_generator"],
diff --git a/score/test/component/logging_app/BUILD b/score/test/component/logging_app/BUILD
index de63c65..f9f3346 100644
--- a/score/test/component/logging_app/BUILD
+++ b/score/test/component/logging_app/BUILD
@@ -29,9 +29,14 @@ load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
cc_binary(
name = "logging_app",
srcs = ["logging_app.cpp"],
+ visibility = ["//visibility:public"],
deps = ["//score/mw/log"],
)

+exports_files([
+ "etc/logging.json",
+])
+
pkg_tar(
name = "logging_app_bin_pkg",
srcs = [":logging_app"],
13 changes: 13 additions & 0 deletions patches/logging/004-rules-pkg-not-dev-dependency.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/MODULE.bazel b/MODULE.bazel
index 5eed2f9..06fb222 100644
--- a/MODULE.bazel
+++ b/MODULE.bazel
@@ -47,7 +47,7 @@ bazel_dep(name = "score_itf", version = "0.4.0", dev_dependency = True)

# OCI / Docker image rules for integration tests
bazel_dep(name = "rules_oci", version = "2.2.7", dev_dependency = True)
-bazel_dep(name = "rules_pkg", version = "1.2.0", dev_dependency = True)
+bazel_dep(name = "rules_pkg", version = "1.2.0")

# QNX image filesystem rules for QNX integration tests
bazel_dep(name = "score_rules_imagefs", version = "0.0.1", dev_dependency = True)
1 change: 1 addition & 0 deletions showcases/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ score_pkg_bundle(
"//showcases/standalone:comm_pkg_files",
"//showcases/standalone:kyron_pkg_files",
"//showcases/standalone:time_pkg_files",
"//showcases/standalone:logging_pkg_files",
"//showcases/orchestration_persistency:orch_per_pkg_files",
"//showcases/simple_lifecycle:simple_lifecycle_pkg_files",
],
Expand Down
7 changes: 7 additions & 0 deletions showcases/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Logging App Demo

This Logging App demonstrates logging using mw::log with all log levels and configured backends (kConsole|kRemote|kFile) enabled.

For remote (DLT) logging, please refer to the following documentation:

[Remote logging](https://github.com/eclipse-score/logging/blob/main/score/datarouter/doc/guideline/dlt_capture_demo.md)
16 changes: 16 additions & 0 deletions showcases/standalone/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,19 @@ score_pkg_bundle(
],
package_dir = "standalone",
)

score_pkg_bundle(
name = "logging",
bins = [
"@score_logging//score/test/component/logging_app:logging_app",
"@score_logging//score/test/component/dlt_generator_app:dlt_generator",
],
config_data = [
"//showcases/standalone:logging.score.json",
],
custom_layout = {
"@score_logging//score/test/component/logging_app:etc/logging.json": "logging_app/etc/logging.json",
"@score_logging//score/test/component/dlt_generator_app:etc/logging.json": "dlt_generator/etc/logging.json",
},
package_dir = "standalone",
)
27 changes: 27 additions & 0 deletions showcases/standalone/logging.score.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "LoggingApp Demo",
"description": "A Logging app that demonstrates logging with mw::log with kConsole|kRemote|kFile config.",
"apps": [
{
"path": "/bin/sh",
"args": [
"-c",
"cd /usr/bin/datarouter && ./datarouter --no_adaptive_runtime >/dev/null 2>&1 &"
],
"env": {}
},
{
"path": "/showcases/bin/logging_app",
"args": [],
"env": {},
"dir": "/showcases/data/logging/logging_app/etc"
},

{
"path": "/showcases/bin/dlt_generator",
"args": [],
"env": {},
"dir": "/showcases/data/logging/dlt_generator/etc"
}
]
}
Loading