|
| 1 | +# ******************************************************************************* |
| 2 | +# Copyright (c) 2026 Contributors to the Eclipse Foundation |
| 3 | +# |
| 4 | +# See the NOTICE file(s) distributed with this work for additional |
| 5 | +# information regarding copyright ownership. |
| 6 | +# |
| 7 | +# This program and the accompanying materials are made available under the |
| 8 | +# terms of the Apache License Version 2.0 which is available at |
| 9 | +# https://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# SPDX-License-Identifier: Apache-2.0 |
| 12 | +# ******************************************************************************* |
| 13 | + |
| 14 | +load("@rules_oci//oci:defs.bzl", "oci_image", "oci_load") |
| 15 | +load("@score_itf//:defs.bzl", "py_itf_test") |
| 16 | + |
| 17 | +def _extend_list_in_kwargs(kwargs, key, values): |
| 18 | + kwargs[key] = kwargs.get(key, []) + values |
| 19 | + return kwargs |
| 20 | + |
| 21 | +def py_logging_itf_test(name, srcs, filesystem, **kwargs): |
| 22 | + """Integration test macro for score_logging using Docker + DLT plugins. |
| 23 | +
|
| 24 | + Builds a per-test Docker image from the given filesystem tar layers |
| 25 | + (which must include the test app binaries/configs) combined with the |
| 26 | + shared base layers (DLT daemon, datarouter). |
| 27 | +
|
| 28 | + Args: |
| 29 | + name: Test target name. |
| 30 | + srcs: Python test source files. |
| 31 | + filesystem: A pkg_tar target containing the test-specific binaries |
| 32 | + and configuration files. |
| 33 | + **kwargs: Forwarded to py_itf_test (e.g. deps, data, tags, timeout). |
| 34 | + """ |
| 35 | + image_name = "_image_{}".format(name) |
| 36 | + image_loader = "_image_{}_loader".format(name) |
| 37 | + repo_tag = "{}:latest".format(name) |
| 38 | + |
| 39 | + oci_image( |
| 40 | + name = image_name, |
| 41 | + base = "@ubuntu_24_04", |
| 42 | + tars = [ |
| 43 | + "//score/test/integration:dlt_pkg", |
| 44 | + "//score/test/integration:datarouter_pkg", |
| 45 | + filesystem, |
| 46 | + ], |
| 47 | + ) |
| 48 | + |
| 49 | + oci_load( |
| 50 | + name = image_loader, |
| 51 | + image = image_name, |
| 52 | + repo_tags = [repo_tag], |
| 53 | + ) |
| 54 | + |
| 55 | + _extend_list_in_kwargs(kwargs, "data", [image_loader]) |
| 56 | + _extend_list_in_kwargs(kwargs, "args", [ |
| 57 | + "--docker-image-bootstrap=$(location {})".format(image_loader), |
| 58 | + "--docker-image={}".format(repo_tag), |
| 59 | + ]) |
| 60 | + |
| 61 | + if "tags" not in kwargs: |
| 62 | + kwargs["tags"] = [] |
| 63 | + if "integration" not in kwargs["tags"]: |
| 64 | + kwargs["tags"] = kwargs["tags"] + ["integration"] |
| 65 | + |
| 66 | + if "size" not in kwargs: |
| 67 | + kwargs["size"] = "enormous" |
| 68 | + |
| 69 | + if "timeout" not in kwargs: |
| 70 | + kwargs["timeout"] = "short" |
| 71 | + |
| 72 | + py_itf_test( |
| 73 | + name = name, |
| 74 | + srcs = srcs, |
| 75 | + plugins = [ |
| 76 | + "@score_itf//score/itf/plugins:docker_plugin", |
| 77 | + "@score_itf//score/itf/plugins:dlt_plugin", |
| 78 | + "//score/test/integration:logging_plugin", |
| 79 | + ], |
| 80 | + env = {"DOCKER_HOST": ""}, |
| 81 | + **kwargs |
| 82 | + ) |
0 commit comments