Skip to content

Commit

Permalink
Docker SSI: report data to FPD
Browse files Browse the repository at this point in the history
  • Loading branch information
robertomonteromiguel committed Nov 21, 2024
1 parent 9f4ee4b commit 06e1449
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 24 deletions.
32 changes: 28 additions & 4 deletions utils/_context/_scenarios/docker_ssi.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
_get_client as get_docker_client,
)
from utils.docker_ssi.docker_ssi_matrix_utils import resolve_runtime_version
from utils.docker_ssi.docker_ssi_definitions import SupportedImages
from utils.tools import logger
from utils.virtual_machine.vm_logger import vm_logger

Expand All @@ -39,6 +40,8 @@ def __init__(self, name, doc, scenario_groups=None) -> None:
self._required_containers.append(self._weblog_injection)
self.weblog_url = "http://localhost:18080"
self._tested_components = {}
# scenario configuration that is going to be reported in the final report
self._configuration = {"app_type": "docker_ssi"}

def configure(self, config):
assert config.option.ssi_library, "library must be set: java,python,nodejs,dotnet,ruby,php"
Expand Down Expand Up @@ -96,6 +99,7 @@ def configure(self, config):
# Extract version of the components that we are testing.
json_tested_component = self.ssi_image_builder.tested_components()
self.fill_context(json_tested_component)
self.print_installed_components()

self._weblog_composed_name = f"{self._base_weblog}_{self.ssi_image_builder.get_base_docker_tag()}"
for container in self._required_containers:
Expand Down Expand Up @@ -141,21 +145,37 @@ def close_targets(self):
def fill_context(self, json_tested_components):
""" After extract the components from the weblog, fill the context with the data """

logger.stdout("\nInstalled components:\n")
image_internal_name = SupportedImages().get_internal_name_from_base_image(self._base_image, self._arch)
self.configuration["os"] = image_internal_name
self.configuration["arch"] = self._arch

for key in json_tested_components:
self._tested_components[key] = json_tested_components[key].lstrip(" ")
if key == "weblog_url" and json_tested_components[key]:
self.weblog_url = json_tested_components[key].lstrip(" ")
continue
if key == "runtime_version" and json_tested_components[key]:
self._installed_language_runtime = Version(json_tested_components[key].lstrip(" "))
# Runtime version is stored as configuration not as dependency
del self._tested_components[key]
self.configuration["runtime_version"] = self._installed_language_runtime
if key.startswith("datadog-apm-inject") and json_tested_components[key]:
self._datadog_apm_inject_version = f"v{json_tested_components[key].lstrip(' ')}"
if key.startswith("datadog-apm-library-") and json_tested_components[key]:
if key.startswith("datadog-apm-library-") and self._tested_components[key]:
library_version_number = json_tested_components[key].lstrip(" ")
self._libray_version = LibraryVersion(self._library, library_version_number)
self._tested_components[key] = json_tested_components[key].lstrip(" ")
logger.stdout(f"{key}: {self._tested_components[key]}")
# We store without the lang sufix
self._tested_components["datadog-apm-library"] = self._tested_components[key]
del self._tested_components[key]

def print_installed_components(self):
logger.terminal.write_sep("=", "Installed components", bold=True)
for component in self.components:
logger.stdout(f"{component}: {self.components[component]}")

logger.terminal.write_sep("=", "Configuration", bold=True)
for conf in self.configuration:
logger.stdout(f"{conf}: {self.configuration[conf]}")

def post_setup(self):
logger.stdout("--- Waiting for all traces and telemetry to be sent to test agent ---")
Expand Down Expand Up @@ -188,6 +208,10 @@ def weblog_variant(self):
def dd_apm_inject_version(self):
return self._datadog_apm_inject_version

@property
def configuration(self):
return self._configuration


class DockerSSIImageBuilder:
""" Manages the docker image building for the SSI scenario """
Expand Down
44 changes: 25 additions & 19 deletions utils/docker_ssi/docker_ssi_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,36 @@ class SupportedImages:
""" All supported images """

def __init__(self) -> None:

self.UBUNTU_22_AMD64 = DockerImage("ubuntu:22.04", LINUX_AMD64)
self.UBUNTU_22_ARM64 = DockerImage("ubuntu:22.04", LINUX_ARM64)
self.UBUNTU_16_AMD64 = DockerImage("ubuntu:16.04", LINUX_AMD64)
self.UBUNTU_16_ARM64 = DockerImage("ubuntu:16.04", LINUX_ARM64)
self.CENTOS_7_AMD64 = DockerImage("centos:7", LINUX_AMD64)
self.ORACLELINUX_9_ARM64 = DockerImage("oraclelinux:9", LINUX_ARM64)
self.ORACLELINUX_9_AMD64 = DockerImage("oraclelinux:9", LINUX_AMD64)
self.ORACLELINUX_8_ARM64 = DockerImage("oraclelinux:8.10", LINUX_ARM64)
self.ORACLELINUX_8_AMD64 = DockerImage("oraclelinux:8.10", LINUX_AMD64)

self.ALMALINUX_9_ARM64 = DockerImage("almalinux:9.4", LINUX_ARM64)
self.ALMALINUX_9_AMD64 = DockerImage("almalinux:9.4", LINUX_AMD64)
self.ALMALINUX_8_ARM64 = DockerImage("almalinux:8.10", LINUX_ARM64)
self.ALMALINUX_8_AMD64 = DockerImage("almalinux:8.10", LINUX_AMD64)
# Try to set the same name as utils/_context/virtual_machines.py
self.UBUNTU_22_AMD64 = DockerImage("Ubuntu_22", "ubuntu:22.04", LINUX_AMD64)
self.UBUNTU_22_ARM64 = DockerImage("Ubuntu_22", "ubuntu:22.04", LINUX_ARM64)
self.UBUNTU_16_AMD64 = DockerImage("Ubuntu_16", "ubuntu:16.04", LINUX_AMD64)
self.UBUNTU_16_ARM64 = DockerImage("Ubuntu_16", "ubuntu:16.04", LINUX_ARM64)
self.CENTOS_7_AMD64 = DockerImage("CentOS_7", "centos:7", LINUX_AMD64)
self.ORACLELINUX_9_ARM64 = DockerImage("OracleLinux_9", "oraclelinux:9", LINUX_ARM64)
self.ORACLELINUX_9_AMD64 = DockerImage("OracleLinux_9", "oraclelinux:9", LINUX_AMD64)
self.ORACLELINUX_8_ARM64 = DockerImage("OracleLinux_8_10", "oraclelinux:8.10", LINUX_ARM64)
self.ORACLELINUX_8_AMD64 = DockerImage("OracleLinux_8_10", "oraclelinux:8.10", LINUX_AMD64)

self.ALMALINUX_9_ARM64 = DockerImage("AlmaLinux_9", "almalinux:9.4", LINUX_ARM64)
self.ALMALINUX_9_AMD64 = DockerImage("AlmaLinux_9", "almalinux:9.4", LINUX_AMD64)
self.ALMALINUX_8_ARM64 = DockerImage("AlmaLinux_8", "almalinux:8.10", LINUX_ARM64)
self.ALMALINUX_8_AMD64 = DockerImage("AlmaLinux_8", "almalinux:8.10", LINUX_AMD64)

# Currently bugged
# DockerImage("centos:7", LINUX_ARM64, short_name="centos_7")
# DockerImage("alpine:3", LINUX_AMD64, short_name="alpine_3"),
# DockerImage("alpine:3", LINUX_ARM64, short_name="alpine_3"),
self.TOMCAT_9_AMD64 = DockerImage("tomcat:9", LINUX_AMD64)
self.TOMCAT_9_ARM64 = DockerImage("tomcat:9", LINUX_ARM64)
self.WEBSPHERE_AMD64 = DockerImage("icr.io/appcafe/websphere-traditional", LINUX_AMD64)
self.JBOSS_AMD64 = DockerImage("quay.io/wildfly/wildfly:26.1.2.Final", LINUX_AMD64)
self.TOMCAT_9_AMD64 = DockerImage("Tomcat_9", "tomcat:9", LINUX_AMD64)
self.TOMCAT_9_ARM64 = DockerImage("Tomcat_9", "tomcat:9", LINUX_ARM64)
self.WEBSPHERE_AMD64 = DockerImage("Websphere", "icr.io/appcafe/websphere-traditional", LINUX_AMD64)
self.JBOSS_AMD64 = DockerImage("Wildfly", "quay.io/wildfly/wildfly:26.1.2.Final", LINUX_AMD64)

def get_internal_name_from_base_image(self, base_image, arch):
for image in self.__dict__.values():
if image.tag == base_image and image.platform == arch:
return image.internal_name
raise ValueError(f"Image {base_image} not supported")


class JavaRuntimeInstallableVersions:
Expand Down
4 changes: 3 additions & 1 deletion utils/docker_ssi/docker_ssi_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ def __init__(self, version_id, version) -> None:
class DockerImage:
""" Encapsulates information of the docker image """

def __init__(self, tag, platform) -> None:
def __init__(self, internal_name, tag, platform) -> None:
# Try to set the same name as utils/_context/virtual_machines.py
self.internal_name = internal_name
self.tag = tag
self.platform = platform
self.runtime_versions = []
Expand Down

0 comments on commit 06e1449

Please sign in to comment.