Skip to content
Merged
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
33 changes: 33 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,34 @@ bazel_dep(name = "rules_cc", version = "0.1.1")
###############################################################################
bazel_dep(name = "rules_shell", version = "0.6.0")

###############################################################################
#
# Container dependencies
#
###############################################################################
bazel_dep(name = "rules_oci", version = "1.8.0")

oci = use_extension("@rules_oci//oci:extensions.bzl", "oci")

# Declare external images you need to pull, for example:
oci.pull(
name = "ubuntu_24_04",
digest = "sha256:2e863c44b718727c860746568e1d54afd13b2fa71b160f5cd9058fc436217b30",
image = "ubuntu",
platforms = ["linux/amd64"],
tag = "24.04",
)

# For each oci.pull call, repeat the "name" here to expose them as dependencies.
use_repo(oci, "ubuntu_24_04")

###############################################################################
#
# Packaging dependencies
#
###############################################################################
bazel_dep(name = "rules_pkg", version = "1.0.1")

###############################################################################
#
# Score custom modules loading
Expand All @@ -97,5 +125,10 @@ git_repository(
name = "dlt_daemon",
branch = "master",
build_file = "//third_party/dlt:dlt_daemon.BUILD",
patch_args = ["-p1"],
patches = [
"//third_party/dlt:0000-initialize-global-vars.patch",
"//third_party/dlt:0001-enable-multicast-udp.patch",
],
remote = "https://github.com/draganbjedov/dlt-daemon.git",
)
4 changes: 2 additions & 2 deletions examples/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ oci = use_extension("@rules_oci//oci:extensions.bzl", "oci")

# Declare external images you need to pull, for example:
oci.pull(
name = "ubuntu_24_04",
name = "ubuntu_24_04_examples",
digest = "sha256:2e863c44b718727c860746568e1d54afd13b2fa71b160f5cd9058fc436217b30",
image = "ubuntu",
platforms = ["linux/amd64"],
tag = "24.04",
)

# For each oci.pull call, repeat the "name" here to expose them as dependencies.
use_repo(oci, "ubuntu_24_04")
use_repo(oci, "ubuntu_24_04_examples")

###############################################################################
#
Expand Down
2 changes: 1 addition & 1 deletion examples/examples/docker/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ load("@rules_oci//oci:defs.bzl", "oci_image", "oci_tarball")

oci_image(
name = "image",
base = "@ubuntu_24_04",
base = "@ubuntu_24_04_examples",
tars = [
"//examples/cpp:example-app-pkg",
],
Expand Down
2 changes: 0 additions & 2 deletions itf/plugins/plugins.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,5 @@ dlt = py_itf_plugin(
"@score_itf//third_party/dlt:dlt-receive",
],
tags = [
"local",
"manual",
],
)
6 changes: 6 additions & 0 deletions test/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,14 @@ py_itf_test(
srcs = [
"test_dlt.py",
],
args = [
"--docker-image-bootstrap=$(location //test/resources:image_tarball)",
"--docker-image=score_itf_examples:latest",
],
data = ["//test/resources:image_tarball"],
plugins = [
dlt,
docker,
],
)

Expand Down
55 changes: 55 additions & 0 deletions test/resources/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# *******************************************************************************
# 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_oci//oci:defs.bzl", "oci_image", "oci_tarball")
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")

pkg_tar(
name = "dlt-bins-pkg",
srcs = [
"@score_itf//third_party/dlt:dlt-adaptor-stdin",
"@score_itf//third_party/dlt:dlt-daemon",
"@score_itf//third_party/dlt:dlt-receive",
],
package_dir = "usr/bin",
)

pkg_tar(
name = "dlt-conf-pkg",
srcs = [
"@score_itf//third_party/dlt:dlt-daemon-conf",
],
package_dir = "etc",
)

pkg_tar(
name = "dlt-pkg",
deps = [
":dlt-bins-pkg",
":dlt-conf-pkg",
],
)

oci_image(
name = "image",
base = "@ubuntu_24_04",
tars = [
":dlt-pkg",
],
)

oci_tarball(
name = "image_tarball",
image = ":image",
repo_tags = ["score_itf_examples:latest"],
visibility = ["//test:__pkg__"],
)
73 changes: 71 additions & 2 deletions test/test_dlt.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
import pytest
import time

from itf.plugins.dlt.dlt_receive import DltReceive, Protocol


def test_dlt(dlt_config):
def test_dlt_standard_config(target, dlt_config):
with DltReceive(
protocol=Protocol.UDP,
host_ip=dlt_config.host_ip,
Expand All @@ -26,7 +27,7 @@ def test_dlt(dlt_config):
time.sleep(1)


def test_dlt_custom_config(dlt_config):
def test_dlt_custom_config(target, dlt_config):
with DltReceive(
protocol=Protocol.UDP,
host_ip="127.0.0.1",
Expand All @@ -40,3 +41,71 @@ def test_dlt_custom_config(dlt_config):
binary_path=dlt_config.dlt_receive_path,
):
time.sleep(1)


def get_container_ip(target):
target.reload()
return target.attrs["NetworkSettings"]["Networks"]["bridge"]["IPAddress"]


def get_docker_network_gateway(target):
target.reload()
return target.attrs["NetworkSettings"]["Networks"]["bridge"]["Gateway"]


def test_dlt_direct_tcp(target, dlt_config, caplog):
ipaddress = get_container_ip(target)
target.exec_run(f"/usr/bin/dlt-daemon -d")

with DltReceive(
protocol=Protocol.TCP,
target_ip=ipaddress,
print_to_stdout=True,
logger_name="fixed_dlt_receive",
binary_path=dlt_config.dlt_receive_path,
):
for i in range(10):
target.exec_run(f'/bin/sh -c "echo message{i} | /usr/bin/dlt-adaptor-stdin"')

target.exec_run(f'/bin/sh -c "echo This is a secret message | /usr/bin/dlt-adaptor-stdin"')

for i in range(10):
target.exec_run(f'/bin/sh -c "echo message{i} | /usr/bin/dlt-adaptor-stdin"')

captured_logs = []
for record in caplog.records:
if record.name == "fixed_dlt_receive":
if "This is a secret message" in record.getMessage():
break
else:
pytest.fail("Expected DLT message was not received")


def test_dlt_multicast_udp(target, dlt_config, caplog):
ipaddress = get_container_ip(target)
gateway = get_docker_network_gateway(target)
target.exec_run(f"/usr/bin/dlt-daemon -d")

with DltReceive(
protocol=Protocol.UDP,
host_ip="172.17.0.1",
multicast_ips=["224.0.0.1"],
print_to_stdout=True,
logger_name="fixed_dlt_receive",
binary_path=dlt_config.dlt_receive_path,
):
for i in range(10):
target.exec_run(f'/bin/sh -c "echo message{i} | /usr/bin/dlt-adaptor-stdin"')

target.exec_run(f'/bin/sh -c "echo This is a secret message | /usr/bin/dlt-adaptor-stdin"')

for i in range(10):
target.exec_run(f'/bin/sh -c "echo message{i} | /usr/bin/dlt-adaptor-stdin"')

captured_logs = []
for record in caplog.records:
if record.name == "fixed_dlt_receive":
if "This is a secret message" in record.getMessage():
break
else:
pytest.fail("Expected DLT message was not received")
32 changes: 32 additions & 0 deletions third_party/dlt/0000-initialize-global-vars.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
diff --git a/src/offlinelogstorage/dlt_offline_logstorage.c b/src/offlinelogstorage/dlt_offline_logstorage.c
index edf7b23..c9b9be0 100644
--- a/src/offlinelogstorage/dlt_offline_logstorage.c
+++ b/src/offlinelogstorage/dlt_offline_logstorage.c
@@ -41,6 +41,11 @@
#define GENERAL_BASE_NAME "General"
/* Hash map functions */

+/* logstorage max cache */
+unsigned int g_logstorage_cache_max;
+/* current logstorage cache size */
+unsigned int g_logstorage_cache_size;
+
static int dlt_logstorage_hash_create(int num_entries, struct hsearch_data *htab)
{
memset(htab, 0, sizeof(*htab));
diff --git a/src/offlinelogstorage/dlt_offline_logstorage.h b/src/offlinelogstorage/dlt_offline_logstorage.h
index df232b7..9b6122b 100644
--- a/src/offlinelogstorage/dlt_offline_logstorage.h
+++ b/src/offlinelogstorage/dlt_offline_logstorage.h
@@ -125,9 +125,9 @@
#define DLT_OFFLINE_LOGSTORAGE_IS_STRATEGY_SET(S, s) ((S) & (s))

/* logstorage max cache */
-unsigned int g_logstorage_cache_max;
+extern unsigned int g_logstorage_cache_max;
/* current logstorage cache size */
-unsigned int g_logstorage_cache_size;
+extern unsigned int g_logstorage_cache_size;

typedef struct
{
20 changes: 20 additions & 0 deletions third_party/dlt/0001-enable-multicast-udp.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
diff --git a/src/daemon/dlt.conf b/src/daemon/dlt.conf
index 736f417..363cb0e 100644
--- a/src/daemon/dlt.conf
+++ b/src/daemon/dlt.conf
@@ -183,12 +183,12 @@ PrintASCII = 1
# Connect with DLT Viewer UDP option to get messages by UDP socket.

# Activate UDP multicast streaming by setting this option to 1 (Default: OFF)
-# udpStreamActive = 0
+udpStreamActive = 1

# Multicast/Broadcast address to which the daemon send the messages
# Parameter is only used if udpStreamActive = 1. Only IPv4 is supported.
-# udpStreamIP = 224.0.0.1
+udpStreamIP = 224.0.0.1

# UDP port to which the daemon send the messages.
# Parameter is only used if udpStreamActive = 1.
-# udpStreamPort = 3491
+udpStreamPort = 3490
24 changes: 24 additions & 0 deletions third_party/dlt/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,27 @@ alias(
"//visibility:public",
],
)

alias(
name = "dlt-adaptor-stdin",
actual = "@dlt_daemon//:dlt-adaptor-stdin",
visibility = [
"//visibility:public",
],
)

alias(
name = "dlt-daemon",
actual = "@dlt_daemon//:dlt-daemon",
visibility = [
"//visibility:public",
],
)

alias(
name = "dlt-daemon-conf",
actual = "@dlt_daemon//:dlt-daemon-conf",
visibility = [
"//visibility:public",
],
)
Loading