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
42 changes: 42 additions & 0 deletions tests/auto_inject/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,35 @@
from threading import Timer


_NODEJS_V6_MAJOR = 6
_NODEJS_V6_MINIMUM_RUNTIME_MAJOR = 22
_NODEJS_PRE_V6_MINIMUM_RUNTIME_MAJOR = 18
_NODEJS_MULTICONTAINER_WEBLOG = "test-app-nodejs-multicontainer"


def _unsupported_nodejs_multicontainer_runtime(runtime_version: str | None) -> bool:
if (
context.library != "nodejs"
or context.weblog_variant != _NODEJS_MULTICONTAINER_WEBLOG
or not runtime_version
or runtime_version == "latest"
):
return False

try:
runtime_major = int(runtime_version.split(".", maxsplit=1)[0])
except ValueError:
return False

min_runtime_major = (
_NODEJS_V6_MINIMUM_RUNTIME_MAJOR
if context.library.version.major >= _NODEJS_V6_MAJOR
else _NODEJS_PRE_V6_MINIMUM_RUNTIME_MAJOR
)

return runtime_major < min_runtime_major


class AutoInjectBaseTest:
def _test_install(
self,
Expand All @@ -21,13 +50,26 @@ def _test_install(
"""If there is a multicontainer app, we need to make a request to each app"""

if virtual_machine.get_deployed_weblog().app_type == "multicontainer":
tested_supported_runtime = False
for app in virtual_machine.get_deployed_weblog().multicontainer_apps:
vm_context_url = (
f"http://{virtual_machine.get_ip()}:{virtual_machine.deffault_open_port}{app.app_context_url}"
)

if _unsupported_nodejs_multicontainer_runtime(app.runtime_version):
logger.info(
"Skipping unsupported multicontainer app runtime [%s] for library [%s]",
app.runtime_version,
context.library,
)
continue

self._check_install(
virtual_machine, vm_context_url, profile=profile, appsec=appsec, origin_detection=origin_detection
)
tested_supported_runtime = True

assert tested_supported_runtime, "No supported multicontainer app found to test"

else:
vm_context_url = f"http://{virtual_machine.get_ip()}:{virtual_machine.deffault_open_port}{virtual_machine.get_deployed_weblog().app_context_url}"
Expand Down
18 changes: 13 additions & 5 deletions tests/docker_ssi/test_docker_ssi.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
)


_NODEJS_REQUIRES_NODE_22 = context.library == "nodejs" and context.library.version.major >= 6
_NODEJS_UNSUPPORTED_RUNTIME = context.library == "nodejs" and (
(_NODEJS_REQUIRES_NODE_22 and context.installed_language_runtime < "22.0")
or (not _NODEJS_REQUIRES_NODE_22 and context.installed_language_runtime < "17.0")
)
_NODEJS_ABORT_IRRELEVANT = context.library == "nodejs" and not _NODEJS_UNSUPPORTED_RUNTIME


@scenarios.docker_ssi
class TestDockerSSIFeatures:
"""Test the ssi in a simulated host injection environment (docker container + test agent)
Expand Down Expand Up @@ -42,7 +50,7 @@ def setup_install_supported_runtime(self):
@irrelevant(context.library == "python" and context.installed_language_runtime < "3.8.0")
@irrelevant(context.library == "java" and context.installed_language_runtime < "1.8.0_0")
@irrelevant(context.library == "php" and context.installed_language_runtime < "7.0")
@irrelevant(context.library == "nodejs" and context.installed_language_runtime < "17.0")
@irrelevant(_NODEJS_UNSUPPORTED_RUNTIME)
@irrelevant(context.library >= "python@4.0.0rc1" and context.installed_language_runtime < "3.9.0")
@irrelevant(context.library == "ruby" and context.installed_language_runtime < "2.6.0")
def test_install_supported_runtime(self):
Expand Down Expand Up @@ -77,7 +85,7 @@ def test_install_weblog_running(self):
)
@irrelevant(context.library == "java" and context.installed_language_runtime < "1.8.0_0")
@irrelevant(context.library == "php" and context.installed_language_runtime < "7.0")
@irrelevant(context.library == "nodejs" and context.installed_language_runtime < "17.0")
@irrelevant(_NODEJS_UNSUPPORTED_RUNTIME)
@irrelevant(context.library >= "python@4.0.0rc1" and context.installed_language_runtime < "3.9.0")
@irrelevant(context.library == "ruby" and context.installed_language_runtime < "2.6.0")
def test_telemetry(self):
Expand Down Expand Up @@ -106,7 +114,7 @@ def test_telemetry(self):
@irrelevant(context.library == "php" and context.installed_language_runtime >= "7.0")
@bug(context.library == "nodejs" and context.installed_language_runtime < "12.17.0", reason="INPLAT-252")
@bug(context.library == "java" and context.installed_language_runtime == "1.7.0-201", reason="INPLAT-427")
@irrelevant(context.library == "nodejs" and context.installed_language_runtime >= "17.0")
@irrelevant(_NODEJS_ABORT_IRRELEVANT)
@irrelevant(context.library == "dotnet" and context.installed_language_runtime >= "6.0.0")
@irrelevant(context.library == "ruby" and context.installed_language_runtime >= "2.6.0")
def test_telemetry_abort(self):
Expand Down Expand Up @@ -145,7 +153,7 @@ def setup_instrumentation_source_ssi(self):
@irrelevant(context.library == "python" and context.installed_language_runtime < "3.9.0")
@irrelevant(context.library == "java" and context.installed_language_runtime < "1.8.0_0")
@irrelevant(context.library == "php" and context.installed_language_runtime < "7.1")
@irrelevant(context.library == "nodejs" and context.installed_language_runtime < "17.0")
@irrelevant(_NODEJS_UNSUPPORTED_RUNTIME)
@irrelevant(context.library >= "python@4.0.0.dev" and context.installed_language_runtime < "3.9.0")
@irrelevant(context.library < "python@4.0.0.dev" and context.installed_language_runtime < "3.8.0")
@irrelevant(context.library == "ruby" and context.installed_language_runtime < "2.6.0")
Expand All @@ -168,7 +176,7 @@ def setup_injection_metadata(self):
@irrelevant(context.library == "python" and context.installed_language_runtime < "3.8.0")
@irrelevant(context.library == "java" and context.installed_language_runtime < "1.8.0_0")
@irrelevant(context.library == "php" and context.installed_language_runtime < "7.1")
@irrelevant(context.library == "nodejs" and context.installed_language_runtime < "17.0")
@irrelevant(_NODEJS_UNSUPPORTED_RUNTIME)
@irrelevant(context.library >= "python@4.0.0rc1" and context.installed_language_runtime < "3.9.0")
def test_injection_metadata(self):
logger.info("Testing injection result variables")
Expand Down
9 changes: 8 additions & 1 deletion tests/docker_ssi/test_docker_ssi_appsec.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
from utils import scenarios, interfaces, weblog, features, irrelevant, context


_NODEJS_REQUIRES_NODE_22 = context.library == "nodejs" and context.library.version.major >= 6
_NODEJS_UNSUPPORTED_RUNTIME = context.library == "nodejs" and (
(_NODEJS_REQUIRES_NODE_22 and context.installed_language_runtime < "22.0")
or (not _NODEJS_REQUIRES_NODE_22 and context.installed_language_runtime < "17.0")
)


@features.appsec_service_activation_origin_metric
@scenarios.docker_ssi_appsec
class TestDockerSSIAppsecFeatures:
Expand All @@ -17,7 +24,7 @@ def setup_telemetry_source_ssi(self):

@irrelevant(context.library == "java" and context.installed_language_runtime < "1.8.0_0")
@irrelevant(context.library == "php" and context.installed_language_runtime < "7.1")
@irrelevant(context.library == "nodejs" and context.installed_language_runtime < "17.0")
@irrelevant(_NODEJS_UNSUPPORTED_RUNTIME)
@irrelevant(context.library >= "python@4.0.0.dev" and context.installed_language_runtime < "3.9.0")
@irrelevant(context.library < "python@4.0.0.dev" and context.installed_language_runtime < "3.8.0")
@irrelevant(context.library == "ruby" and context.installed_language_runtime < "2.6.0", reason="Ruby 2.6+ required")
Expand Down
9 changes: 8 additions & 1 deletion tests/docker_ssi/test_docker_ssi_crash.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
from utils import weblog, logger


_NODEJS_REQUIRES_NODE_22 = context.library == "nodejs" and context.library.version.major >= 6
_NODEJS_UNSUPPORTED_RUNTIME = context.library == "nodejs" and (
(_NODEJS_REQUIRES_NODE_22 and context.installed_language_runtime < "22.0")
or (not _NODEJS_REQUIRES_NODE_22 and context.installed_language_runtime < "17.0")
)


@scenarios.docker_ssi_crashtracking
class TestDockerSSICrash:
"""Test the ssi in a simulated host injection environment (docker container + test agent)
Expand All @@ -36,7 +43,7 @@ def setup_crash(self):

@features.ssi_crashtracking
@irrelevant(context.library == "python" and context.installed_language_runtime < "3.7.0")
@irrelevant(context.library == "nodejs" and context.installed_language_runtime < "17.0")
@irrelevant(_NODEJS_UNSUPPORTED_RUNTIME)
@irrelevant(context.library == "ruby" and context.installed_language_runtime < "2.6.0")
def test_crash(self):
"""Validate that a crash report is generated when the application crashes"""
Expand Down
1 change: 1 addition & 0 deletions utils/_context/_scenarios/docker_ssi.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def configure(self, config: pytest.Config):
self._arch = config.option.ssi_arch

self._env = "prod" if config.option.ssi_env is None or config.option.ssi_env == "prod" else "dev"
self.configuration["env"] = self._env
self._custom_library_version = config.option.ssi_library_version
self._custom_injector_version = config.option.ssi_injector_version

Expand Down
4 changes: 2 additions & 2 deletions utils/build/ssi/base/install_script_ssi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ if [ -n "${DD_INSTALLER_LIBRARY_VERSION}" ]; then
fi

if [ "${DD_LANG}" == "js" ] && [ "${SSI_ENV}" == "dev" ] && [ -z "${DD_INSTALLER_DEFAULT_PKG_VERSION_DATADOG_APM_LIBRARY_JS}" ]; then
# Special case for Node.js, the staging major version is 1 above the prod major (6 here)
export DD_INSTALLER_DEFAULT_PKG_VERSION_DATADOG_APM_LIBRARY_JS="6"
# Special case for Node.js, the staging major version is 1 above the prod major (7 here)
export DD_INSTALLER_DEFAULT_PKG_VERSION_DATADOG_APM_LIBRARY_JS="7"
fi

#We want specfic injector version (to run on auto_inject pipelines)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
if command -v docker >/dev/null 2>&1; then
echo "Docker is installed, ensuring service is enabled and running..."
sudo systemctl enable docker.service docker.socket

if ! sudo systemctl is-active --quiet docker.service; then
echo "Docker service is not running, starting it..."
sudo systemctl start docker.service docker.socket

# Wait for Docker to be fully ready
echo "Waiting for Docker service to be ready..."
MAX_WAIT=20
Expand All @@ -34,7 +34,7 @@
sleep 1
((COUNTER++))
done

if [ $COUNTER -eq $MAX_WAIT ]; then
echo "WARNING: Docker service did not become ready after $MAX_WAIT seconds"
fi
Expand All @@ -56,8 +56,8 @@
export DD_INSTALLER_DEFAULT_PKG_VERSION_DATADOG_APM_LIBRARY_PYTHON=4
fi

else
export DD_SITE="datadoghq.com"
else
export DD_SITE="datadoghq.com"
#The latest release of python tracer version is 2.x we want to use 3.x. Get from repo tags v3* and not rc*. We get the SHA of the tag.
#more details: https://datadoghq.atlassian.net/browse/APMSP-2259
if [ "${DD_LANG}" == "python" ]; then
Expand All @@ -75,8 +75,8 @@
fi

if [ "${DD_LANG}" == "js" ] && [ "${DD_env}" == "dev" ] && [ -z "${DD_INSTALLER_DEFAULT_PKG_VERSION_DATADOG_APM_LIBRARY_JS}" ]; then
# Special case for Node.js, the staging major version is 1 above the prod major (6 here)
export DD_INSTALLER_DEFAULT_PKG_VERSION_DATADOG_APM_LIBRARY_JS="6"
# Special case for Node.js, the staging major version is 1 above the prod major (7 here)
export DD_INSTALLER_DEFAULT_PKG_VERSION_DATADOG_APM_LIBRARY_JS="7"
fi

if [ -n "${DD_INSTALLER_INJECTOR_VERSION}" ]; then
Expand Down Expand Up @@ -156,10 +156,10 @@
sudo cp debug_config.yaml /etc/datadog-agent/inject/debug_config.yaml

for i in 1 2 3 4 5; do sudo datadog-installer apm instrument docker && break || sleep 1; done

# Add dd-agent user to docker group for docker socket access
sudo usermod -aG docker dd-agent || echo "Warning: Could not add dd-agent to docker group"

# Restart datadog-agent so the new group membership takes effect
sudo systemctl restart datadog-agent || echo "Warning: Could not restart datadog-agent"
- os_type: windows
Expand Down Expand Up @@ -201,7 +201,7 @@
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;
$env:DD_SITE = "datadoghq.com";
$env:DD_APM_INSTRUMENTATION_ENABLED = "iis"

# Check if Install-Datadog.ps1 exists locally in binaries folder
if (Test-Path "Install-Datadog.ps1") {
Write-Host "*** Execute installation script from provided binaries ***"
Expand All @@ -210,5 +210,5 @@
Write-Host "Download installation script from datadoghq.com"
(New-Object System.Net.WebClient).DownloadFile('https://install.datadoghq.com/Install-Datadog.ps1', 'C:\Windows\SystemTemp\Install-Datadog.ps1');
}

C:\Windows\SystemTemp\Install-Datadog.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ if [ "${DD_env}" == "dev" ]; then
if [ "${DD_LANG}" == "python" ]; then
export DD_INSTALLER_DEFAULT_PKG_VERSION_DATADOG_APM_LIBRARY_PYTHON=4
fi
else
export DD_SITE="datadoghq.com"
else
export DD_SITE="datadoghq.com"
#The latest release of python tracer version is 2.x we want to use 4.x. Get from repo tags v3* and not rc*. We get the SHA of the tag.
#more details: https://datadoghq.atlassian.net/browse/APMSP-2259
if [ "${DD_LANG}" == "python" ]; then
Expand All @@ -37,12 +37,12 @@ export DD_APM_INSTRUMENTATION_LIBRARIES="${DD_LANG}"

if [ -n "${DD_INSTALLER_LIBRARY_VERSION}" ]; then
export "DD_INSTALLER_REGISTRY_URL_APM_LIBRARY_$(echo "$DD_LANG" | tr "[:lower:]" "[:upper:]")_PACKAGE"='installtesting.datad0g.com'
export "DD_INSTALLER_DEFAULT_PKG_VERSION_DATADOG_APM_LIBRARY_$(echo "$DD_LANG" | tr "[:lower:]" "[:upper:]")"="${DD_INSTALLER_LIBRARY_VERSION}"
export "DD_INSTALLER_DEFAULT_PKG_VERSION_DATADOG_APM_LIBRARY_$(echo "$DD_LANG" | tr "[:lower:]" "[:upper:]")"="${DD_INSTALLER_LIBRARY_VERSION}"
fi

if [ "${DD_LANG}" == "js" ] && [ "${DD_env}" == "dev" ] && [ -z "${DD_INSTALLER_DEFAULT_PKG_VERSION_DATADOG_APM_LIBRARY_JS}" ]; then
# Special case for Node.js, the staging major version is 1 above the prod major (6 here)
export DD_INSTALLER_DEFAULT_PKG_VERSION_DATADOG_APM_LIBRARY_JS="6"
# Special case for Node.js, the staging major version is 1 above the prod major (7 here)
export DD_INSTALLER_DEFAULT_PKG_VERSION_DATADOG_APM_LIBRARY_JS="7"
fi

if [ -n "${DD_INSTALLER_INJECTOR_VERSION}" ]; then
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
weblog:
name: test-app-nodejs-alpine
runtime_version: 18
runtime_version: 22
Comment thread
pabloerhard marked this conversation as resolved.
install:
- os_type: linux
copy_files:
Expand All @@ -15,6 +15,5 @@ weblog:

- name: copy-nodejs-app-dockerfile
local_path: utils/build/virtual_machine/weblogs/nodejs/test-app-nodejs-alpine/Dockerfile.template
remote_path: Dockerfile.template

remote-command: sh create_and_run_app_container.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
weblog:
name: test-app-nodejs-container
runtime_version: 18
runtime_version: 22
install:
- os_type: linux
copy_files:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ weblog:
local_path: utils/build/virtual_machine/weblogs/nodejs/test-app-nodejs-esm/docker-compose.yml
- name: copy-nodejs-app
local_path: lib-injection/build/docker/nodejs/sample-app
- name: copy-node20-app-dockerfile
local_path: utils/build/virtual_machine/weblogs/nodejs/test-app-nodejs-esm/Dockerfile.node20
- name: copy-node22-app-dockerfile
local_path: utils/build/virtual_machine/weblogs/nodejs/test-app-nodejs-esm/Dockerfile.node22
- name: copy-nodejs-app-dockerfile
local_path: utils/build/virtual_machine/weblogs/nodejs/test-app-nodejs-esm/Dockerfile.node
- name: copy-reverseproxy-dockerfile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,35 @@ lang_variant:
install:
- os_type: linux
os_distro: deb
remote-command: sudo apt-get update && sudo apt-get install -y nodejs
remote-command: |
sudo apt-get update
sudo apt-get install -y ca-certificates curl gnupg
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt-get install -y nodejs

- os_type: linux
os_distro: rpm
os_branch: redhat
remote-command: |
sudo dnf -y module enable nodejs:20
sudo dnf -y module switch-to nodejs:20
sudo dnf install -y nodejs
sudo yum install tar -y || sudo dnf install tar -y || true
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm install --no-progress 22.11.0
nvm use 22.11.0
n=$(which node);n=${n%/bin/node}; chmod -R 755 $n/bin/*; sudo cp -r $n/{bin,lib,share} /usr/local

- os_type: linux
os_distro: rpm
os_branch: centos_8_amd64
remote-command: |
#one of the default method for centos 8
#https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-centos-8
sudo dnf -y module enable nodejs:20
sudo dnf -y module switch-to nodejs:20
sudo dnf install -y nodejs
sudo yum install tar -y || sudo dnf install tar -y || true
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm install --no-progress 22.11.0
nvm use 22.11.0
n=$(which node);n=${n%/bin/node}; chmod -R 755 $n/bin/*; sudo cp -r $n/{bin,lib,share} /usr/local

- os_type: linux
os_distro: rpm
Expand All @@ -35,8 +45,8 @@ lang_variant:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
nvm install --lts
nvm use node
nvm install --no-progress 22.11.0
nvm use 22.11.0
n=$(which node);n=${n%/bin/node}; chmod -R 755 $n/bin/*; sudo cp -r $n/{bin,lib,share} /usr/local

weblog:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM public.ecr.aws/docker/library/node:18
FROM public.ecr.aws/docker/library/node:22

# Create app directory
WORKDIR /usr/src/app
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM public.ecr.aws/docker/library/node:20-slim
FROM public.ecr.aws/docker/library/node:22-slim

# Create app directory
WORKDIR /usr/src/app
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM public.ecr.aws/docker/library/node:20-slim
FROM public.ecr.aws/docker/library/node:22-slim

# Create app directory
WORKDIR /usr/src/app
Expand Down
Loading
Loading