Skip to content
Draft
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
7 changes: 5 additions & 2 deletions tests/auto_inject/test_auto_inject_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ class TestSimpleInstallerAutoInjectManualProfiling(base.AutoInjectBaseTest):
reason="PROF-10783",
)
@irrelevant(
context.vm_name in ["Ubuntu_24_amd64", "Ubuntu_24_arm64"] and context.weblog_variant == "test-app-nodejs",
context.vm_name in ["Ubuntu_24_amd64", "Ubuntu_24_arm64"]
and context.weblog_variant in ["test-app-nodejs", "test-app-nodejs-22"],
reason="PROF-11264",
)
@irrelevant(
Expand All @@ -48,7 +49,8 @@ class TestHostAutoInjectInstallScriptProfiling(base.AutoInjectBaseTest):
reason="PROF-10783",
)
@irrelevant(
context.vm_name in ["Ubuntu_24_amd64", "Ubuntu_24_arm64"] and context.weblog_variant == "test-app-nodejs",
context.vm_name in ["Ubuntu_24_amd64", "Ubuntu_24_arm64"]
and context.weblog_variant in ["test-app-nodejs", "test-app-nodejs-22"],
reason="PROF-11264",
)
@missing_feature(context.vm_os_branch == "windows", reason="Not implemented on Windows")
Expand Down Expand Up @@ -128,6 +130,7 @@ class TestContainerAutoInjectInstallScriptCrashTracking_NoZombieProcess(base.Aut
"test-app-ruby-container",
"test-app-python-container",
"test-app-nodejs-container",
"test-app-nodejs-container-22",
],
reason="Zombies only appears in containers",
)
Expand Down
13 changes: 8 additions & 5 deletions tests/docker_ssi/test_docker_ssi.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
weblog,
logger,
)
from utils.nodejs_runtime import is_supported_nodejs_runtime, is_unsupported_nodejs_runtime


@scenarios.docker_ssi
Expand Down Expand Up @@ -42,7 +43,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(is_unsupported_nodejs_runtime(context.library, context.installed_language_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 +78,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(is_unsupported_nodejs_runtime(context.library, context.installed_language_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 +107,9 @@ 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(
context.library == "nodejs" and is_supported_nodejs_runtime(context.library, context.installed_language_runtime)
)
@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 +148,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(is_unsupported_nodejs_runtime(context.library, context.installed_language_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 +171,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(is_unsupported_nodejs_runtime(context.library, context.installed_language_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
3 changes: 2 additions & 1 deletion tests/docker_ssi/test_docker_ssi_appsec.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from tests.parametric.test_telemetry import _mapped_telemetry_name
from utils import scenarios, interfaces, weblog, features, irrelevant, context
from utils.nodejs_runtime import is_unsupported_nodejs_runtime


@features.appsec_service_activation_origin_metric
Expand All @@ -17,7 +18,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(is_unsupported_nodejs_runtime(context.library, context.installed_language_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
8 changes: 4 additions & 4 deletions tests/docker_ssi/test_docker_ssi_crash.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
interfaces,
)
from utils import weblog, logger
from utils.nodejs_runtime import is_unsupported_nodejs_runtime


@scenarios.docker_ssi_crashtracking
Expand Down Expand Up @@ -36,14 +37,13 @@ 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(is_unsupported_nodejs_runtime(context.library, context.installed_language_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"""
logger.info(f"Testing Docker SSI crash tracking: {context.library.name}")
assert self.r.status_code is None, (
f"Response from request {scenarios.docker_ssi_crashtracking.weblog_url + '/crashme'} was supposed to fail: {self.r}"
)
crash_url = scenarios.docker_ssi_crashtracking.weblog_url + "/crashme"
assert self.r.status_code is None, f"Response from request {crash_url} was supposed to fail: {self.r}"

# No traces should have been generated
assert not interfaces.test_agent.get_traces(self.r), (
Expand Down
85 changes: 85 additions & 0 deletions tests/test_the_test/test_nodejs_runtime.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import pytest

from utils._context.component_version import ComponentVersion, Version
from utils.nodejs_runtime import (
filter_nodejs_runtimes_for_ci,
infer_minimum_nodejs_runtime_for_ci,
is_supported_nodejs_runtime,
select_nodejs_aws_weblog_for_ci,
)


def _clear_nodejs_runtime_env(monkeypatch: pytest.MonkeyPatch):
for env_name in [
"SYSTEM_TESTS_NODEJS_MIN_RUNTIME",
"DD_NODEJS_RUNTIME_VERSION",
"DD_INSTALLER_LIBRARY_VERSION",
"DD_INSTALLER_LIBRARY_VERSION_NODEJS",
"CI_COMMIT_BRANCH",
"CI_COMMIT_REF_NAME",
"CI_MERGE_REQUEST_SOURCE_BRANCH_NAME",
"CI_COMMIT_TAG",
"GITHUB_REF_NAME",
"GITHUB_HEAD_REF",
]:
monkeypatch.delenv(env_name, raising=False)


def test_nodejs_runtime_support_depends_on_library_major():
assert is_supported_nodejs_runtime(ComponentVersion("nodejs", "5.0.0"), Version("18.20"))
assert is_supported_nodejs_runtime(ComponentVersion("nodejs", "5.0.0"), Version("20.18"))
assert not is_supported_nodejs_runtime(ComponentVersion("nodejs", "6.0.0-pre"), Version("20.18"))
assert is_supported_nodejs_runtime(ComponentVersion("nodejs", "6.0.0-pre"), Version("22.0"))


def test_infer_minimum_nodejs_runtime_for_ci_from_library_version(monkeypatch: pytest.MonkeyPatch):
_clear_nodejs_runtime_env(monkeypatch)

assert infer_minimum_nodejs_runtime_for_ci("5.0.0") == "18.0"
assert infer_minimum_nodejs_runtime_for_ci("6.0.0-pre") == "22.0"


def test_infer_minimum_nodejs_runtime_for_ci_from_ref(monkeypatch: pytest.MonkeyPatch):
_clear_nodejs_runtime_env(monkeypatch)

monkeypatch.setenv("CI_COMMIT_BRANCH", "master")
assert infer_minimum_nodejs_runtime_for_ci("pipeline-123") == "22.0"

monkeypatch.setenv("CI_COMMIT_BRANCH", "v5.67.0-proposal")
assert infer_minimum_nodejs_runtime_for_ci("pipeline-123") == "18.0"

monkeypatch.setenv("CI_COMMIT_BRANCH", "v6.0.0-proposal")
assert infer_minimum_nodejs_runtime_for_ci("pipeline-123") == "22.0"

monkeypatch.delenv("CI_COMMIT_BRANCH")
monkeypatch.setenv("CI_COMMIT_REF_NAME", "refs/heads/v5.68.0")
assert infer_minimum_nodejs_runtime_for_ci("pipeline-123") == "18.0"


def test_filter_nodejs_runtimes_for_ci(monkeypatch: pytest.MonkeyPatch):
_clear_nodejs_runtime_env(monkeypatch)

monkeypatch.setenv("CI_COMMIT_BRANCH", "master")
runtimes = [
{"version_id": "JS1820", "version": "18.20"},
{"version_id": "JS2018", "version": "20.18"},
{"version_id": "JS2200", "version": "22.0"},
{"version_id": "JS2300", "version": "23.0"},
]

assert filter_nodejs_runtimes_for_ci(runtimes) == [
{"version_id": "JS2200", "version": "22.0"},
{"version_id": "JS2300", "version": "23.0"},
]


def test_select_nodejs_aws_weblog_for_ci(monkeypatch: pytest.MonkeyPatch):
_clear_nodejs_runtime_env(monkeypatch)

monkeypatch.setenv("CI_COMMIT_BRANCH", "master")
assert select_nodejs_aws_weblog_for_ci("test-app-nodejs") == "test-app-nodejs-22"
assert select_nodejs_aws_weblog_for_ci("test-app-nodejs-container") == "test-app-nodejs-container-22"
assert select_nodejs_aws_weblog_for_ci("test-app-nodejs-esm") == "test-app-nodejs-esm-22"
assert select_nodejs_aws_weblog_for_ci("test-app-nodejs-unsupported-defaults") == (
"test-app-nodejs-unsupported-defaults"
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
lang_variant:
name: nodejs22
version: 22
cache: true
install:
- os_type: linux
os_distro: deb
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
remote-command: |
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 22
nvm use 22
n=$(which node)
n=${n%/bin/node}
chmod -R 755 "$n/bin/"*
sudo cp -r "$n"/bin "$n"/lib "$n"/share /usr/local

weblog:
name: test-app-nodejs-22
install:
- os_type: linux
copy_files:
- name: copy-service
local_path: utils/build/virtual_machine/weblogs/common/test-app.service

- name: copy-service-run-script
local_path: utils/build/virtual_machine/weblogs/common/create_and_run_app_service.sh

- name: copy-run-weblog-script
local_path: utils/build/virtual_machine/weblogs/nodejs/test-app-nodejs/test-app-nodejs_run.sh

- name: copy-binary
local_path: lib-injection/build/docker/nodejs/sample-app/index.js

remote-command: sh test-app-nodejs_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
weblog:
name: test-app-nodejs-container-22
runtime_version: 22
install:
- os_type: linux
copy_files:
- name: copy-container-run-script
local_path: utils/build/virtual_machine/weblogs/common/create_and_run_app_container.sh

- name: copy-docker-compose-file
local_path: utils/build/virtual_machine/weblogs/common/docker-compose.yml

- name: copy-nodejs-app
local_path: lib-injection/build/docker/nodejs/sample-app

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

remote-command: sh create_and_run_app_container.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
weblog:
name: test-app-nodejs-esm-22
nginx_config: utils/build/virtual_machine/weblogs/nodejs/test-app-nodejs-esm-22/nginx.conf
install:
- os_type: linux
copy_files:
- name: copy-multicontainer-run-script
local_path: utils/build/virtual_machine/weblogs/common/create_and_run_app_multicontainer.sh
- name: copy-docker-compose-file
local_path: utils/build/virtual_machine/weblogs/nodejs/test-app-nodejs-esm-22/docker-compose.yml
- name: copy-nodejs-app
local_path: lib-injection/build/docker/nodejs/sample-app
- name: copy-node22-app-dockerfile
local_path: utils/build/virtual_machine/weblogs/nodejs/test-app-nodejs-esm-22/Dockerfile.node22
- name: copy-nodejs-app-dockerfile
local_path: utils/build/virtual_machine/weblogs/nodejs/test-app-nodejs-esm-22/Dockerfile.node
- name: copy-reverseproxy-dockerfile
local_path: utils/build/virtual_machine/weblogs/nodejs/test-app-nodejs-esm-22/Dockerfile.reverseproxy
- name: copy-reverseproxy-conf
local_path: utils/build/virtual_machine/weblogs/nodejs/test-app-nodejs-esm-22/nginx.conf
remote-command: sh create_and_run_app_multicontainer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM public.ecr.aws/docker/library/node:22

# Create app directory
WORKDIR /usr/src/app

COPY . .
# Install dependencies with exact versions using npm ci
RUN npm ci --only=production --no-audit --no-fund
EXPOSE 18080
CMD [ "node", "index.js" ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM public.ecr.aws/docker/library/node:22-slim

# Create app directory
WORKDIR /usr/src/app

COPY . .

# https://datadoghq.atlassian.net/browse/INPLAT-441
ENV DD_NODEJS_EXPERIMENTAL_ESM=true

EXPOSE 18080
CMD [ "node", "index.mjs" ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM public.ecr.aws/docker/library/node:22-slim

# Create app directory
WORKDIR /usr/src/app

COPY . .

# https://datadoghq.atlassian.net/browse/INPLAT-441
ENV DD_NODEJS_EXPERIMENTAL_ESM=true

EXPOSE 18080
CMD [ "node", "index.mjs" ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM public.ecr.aws/nginx/nginx:stable-perl

COPY nginx.conf /etc/nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
version: '2'

services:
reverseproxy:
image: reverseproxy:latest
ports:
- 5985:8080
restart: always
build:
context: .
dockerfile: Dockerfile.reverseproxy
healthcheck:
test: "curl -f http://localhost:8080"

node_22:
env_file: "scenario_app.env"
image: system-tests/node_22:latest
restart: always
build:
context: .
dockerfile: Dockerfile.node22
healthcheck:
test: "node health"

node:
env_file: "scenario_app.env"
image: system-tests/node:latest
restart: always
build:
context: .
dockerfile: Dockerfile.node
healthcheck:
test: "node health"
Loading
Loading