Skip to content

Commit 56f5f7c

Browse files
authored
chore(ssi): move SSI tests to node 22 (#7271)
1 parent 48c0eeb commit 56f5f7c

17 files changed

Lines changed: 127 additions & 53 deletions

File tree

tests/auto_inject/utils.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,35 @@
99
from threading import Timer
1010

1111

12+
_NODEJS_V6_MAJOR = 6
13+
_NODEJS_V6_MINIMUM_RUNTIME_MAJOR = 22
14+
_NODEJS_PRE_V6_MINIMUM_RUNTIME_MAJOR = 18
15+
_NODEJS_MULTICONTAINER_WEBLOG = "test-app-nodejs-multicontainer"
16+
17+
18+
def _unsupported_nodejs_multicontainer_runtime(runtime_version: str | None) -> bool:
19+
if (
20+
context.library != "nodejs"
21+
or context.weblog_variant != _NODEJS_MULTICONTAINER_WEBLOG
22+
or not runtime_version
23+
or runtime_version == "latest"
24+
):
25+
return False
26+
27+
try:
28+
runtime_major = int(runtime_version.split(".", maxsplit=1)[0])
29+
except ValueError:
30+
return False
31+
32+
min_runtime_major = (
33+
_NODEJS_V6_MINIMUM_RUNTIME_MAJOR
34+
if context.library.version.major >= _NODEJS_V6_MAJOR
35+
else _NODEJS_PRE_V6_MINIMUM_RUNTIME_MAJOR
36+
)
37+
38+
return runtime_major < min_runtime_major
39+
40+
1241
class AutoInjectBaseTest:
1342
def _test_install(
1443
self,
@@ -21,13 +50,26 @@ def _test_install(
2150
"""If there is a multicontainer app, we need to make a request to each app"""
2251

2352
if virtual_machine.get_deployed_weblog().app_type == "multicontainer":
53+
tested_supported_runtime = False
2454
for app in virtual_machine.get_deployed_weblog().multicontainer_apps:
2555
vm_context_url = (
2656
f"http://{virtual_machine.get_ip()}:{virtual_machine.deffault_open_port}{app.app_context_url}"
2757
)
58+
59+
if _unsupported_nodejs_multicontainer_runtime(app.runtime_version):
60+
logger.info(
61+
"Skipping unsupported multicontainer app runtime [%s] for library [%s]",
62+
app.runtime_version,
63+
context.library,
64+
)
65+
continue
66+
2867
self._check_install(
2968
virtual_machine, vm_context_url, profile=profile, appsec=appsec, origin_detection=origin_detection
3069
)
70+
tested_supported_runtime = True
71+
72+
assert tested_supported_runtime, "No supported multicontainer app found to test"
3173

3274
else:
3375
vm_context_url = f"http://{virtual_machine.get_ip()}:{virtual_machine.deffault_open_port}{virtual_machine.get_deployed_weblog().app_context_url}"

tests/docker_ssi/test_docker_ssi.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@
1414
)
1515

1616

17+
_NODEJS_REQUIRES_NODE_22 = context.library == "nodejs" and context.library.version.major >= 6
18+
_NODEJS_UNSUPPORTED_RUNTIME = context.library == "nodejs" and (
19+
(_NODEJS_REQUIRES_NODE_22 and context.installed_language_runtime < "22.0")
20+
or (not _NODEJS_REQUIRES_NODE_22 and context.installed_language_runtime < "17.0")
21+
)
22+
_NODEJS_ABORT_IRRELEVANT = context.library == "nodejs" and not _NODEJS_UNSUPPORTED_RUNTIME
23+
24+
1725
@scenarios.docker_ssi
1826
class TestDockerSSIFeatures:
1927
"""Test the ssi in a simulated host injection environment (docker container + test agent)
@@ -42,7 +50,7 @@ def setup_install_supported_runtime(self):
4250
@irrelevant(context.library == "python" and context.installed_language_runtime < "3.8.0")
4351
@irrelevant(context.library == "java" and context.installed_language_runtime < "1.8.0_0")
4452
@irrelevant(context.library == "php" and context.installed_language_runtime < "7.0")
45-
@irrelevant(context.library == "nodejs" and context.installed_language_runtime < "17.0")
53+
@irrelevant(_NODEJS_UNSUPPORTED_RUNTIME)
4654
@irrelevant(context.library >= "python@4.0.0rc1" and context.installed_language_runtime < "3.9.0")
4755
@irrelevant(context.library == "ruby" and context.installed_language_runtime < "2.6.0")
4856
def test_install_supported_runtime(self):
@@ -77,7 +85,7 @@ def test_install_weblog_running(self):
7785
)
7886
@irrelevant(context.library == "java" and context.installed_language_runtime < "1.8.0_0")
7987
@irrelevant(context.library == "php" and context.installed_language_runtime < "7.0")
80-
@irrelevant(context.library == "nodejs" and context.installed_language_runtime < "17.0")
88+
@irrelevant(_NODEJS_UNSUPPORTED_RUNTIME)
8189
@irrelevant(context.library >= "python@4.0.0rc1" and context.installed_language_runtime < "3.9.0")
8290
@irrelevant(context.library == "ruby" and context.installed_language_runtime < "2.6.0")
8391
def test_telemetry(self):
@@ -106,7 +114,7 @@ def test_telemetry(self):
106114
@irrelevant(context.library == "php" and context.installed_language_runtime >= "7.0")
107115
@bug(context.library == "nodejs" and context.installed_language_runtime < "12.17.0", reason="INPLAT-252")
108116
@bug(context.library == "java" and context.installed_language_runtime == "1.7.0-201", reason="INPLAT-427")
109-
@irrelevant(context.library == "nodejs" and context.installed_language_runtime >= "17.0")
117+
@irrelevant(_NODEJS_ABORT_IRRELEVANT)
110118
@irrelevant(context.library == "dotnet" and context.installed_language_runtime >= "6.0.0")
111119
@irrelevant(context.library == "ruby" and context.installed_language_runtime >= "2.6.0")
112120
def test_telemetry_abort(self):
@@ -145,7 +153,7 @@ def setup_instrumentation_source_ssi(self):
145153
@irrelevant(context.library == "python" and context.installed_language_runtime < "3.9.0")
146154
@irrelevant(context.library == "java" and context.installed_language_runtime < "1.8.0_0")
147155
@irrelevant(context.library == "php" and context.installed_language_runtime < "7.1")
148-
@irrelevant(context.library == "nodejs" and context.installed_language_runtime < "17.0")
156+
@irrelevant(_NODEJS_UNSUPPORTED_RUNTIME)
149157
@irrelevant(context.library >= "python@4.0.0.dev" and context.installed_language_runtime < "3.9.0")
150158
@irrelevant(context.library < "python@4.0.0.dev" and context.installed_language_runtime < "3.8.0")
151159
@irrelevant(context.library == "ruby" and context.installed_language_runtime < "2.6.0")
@@ -168,7 +176,7 @@ def setup_injection_metadata(self):
168176
@irrelevant(context.library == "python" and context.installed_language_runtime < "3.8.0")
169177
@irrelevant(context.library == "java" and context.installed_language_runtime < "1.8.0_0")
170178
@irrelevant(context.library == "php" and context.installed_language_runtime < "7.1")
171-
@irrelevant(context.library == "nodejs" and context.installed_language_runtime < "17.0")
179+
@irrelevant(_NODEJS_UNSUPPORTED_RUNTIME)
172180
@irrelevant(context.library >= "python@4.0.0rc1" and context.installed_language_runtime < "3.9.0")
173181
def test_injection_metadata(self):
174182
logger.info("Testing injection result variables")

tests/docker_ssi/test_docker_ssi_appsec.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44
from utils import scenarios, interfaces, weblog, features, irrelevant, context
55

66

7+
_NODEJS_REQUIRES_NODE_22 = context.library == "nodejs" and context.library.version.major >= 6
8+
_NODEJS_UNSUPPORTED_RUNTIME = context.library == "nodejs" and (
9+
(_NODEJS_REQUIRES_NODE_22 and context.installed_language_runtime < "22.0")
10+
or (not _NODEJS_REQUIRES_NODE_22 and context.installed_language_runtime < "17.0")
11+
)
12+
13+
714
@features.appsec_service_activation_origin_metric
815
@scenarios.docker_ssi_appsec
916
class TestDockerSSIAppsecFeatures:
@@ -17,7 +24,7 @@ def setup_telemetry_source_ssi(self):
1724

1825
@irrelevant(context.library == "java" and context.installed_language_runtime < "1.8.0_0")
1926
@irrelevant(context.library == "php" and context.installed_language_runtime < "7.1")
20-
@irrelevant(context.library == "nodejs" and context.installed_language_runtime < "17.0")
27+
@irrelevant(_NODEJS_UNSUPPORTED_RUNTIME)
2128
@irrelevant(context.library >= "python@4.0.0.dev" and context.installed_language_runtime < "3.9.0")
2229
@irrelevant(context.library < "python@4.0.0.dev" and context.installed_language_runtime < "3.8.0")
2330
@irrelevant(context.library == "ruby" and context.installed_language_runtime < "2.6.0", reason="Ruby 2.6+ required")

tests/docker_ssi/test_docker_ssi_crash.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@
1010
from utils import weblog, logger
1111

1212

13+
_NODEJS_REQUIRES_NODE_22 = context.library == "nodejs" and context.library.version.major >= 6
14+
_NODEJS_UNSUPPORTED_RUNTIME = context.library == "nodejs" and (
15+
(_NODEJS_REQUIRES_NODE_22 and context.installed_language_runtime < "22.0")
16+
or (not _NODEJS_REQUIRES_NODE_22 and context.installed_language_runtime < "17.0")
17+
)
18+
19+
1320
@scenarios.docker_ssi_crashtracking
1421
class TestDockerSSICrash:
1522
"""Test the ssi in a simulated host injection environment (docker container + test agent)
@@ -36,7 +43,7 @@ def setup_crash(self):
3643

3744
@features.ssi_crashtracking
3845
@irrelevant(context.library == "python" and context.installed_language_runtime < "3.7.0")
39-
@irrelevant(context.library == "nodejs" and context.installed_language_runtime < "17.0")
46+
@irrelevant(_NODEJS_UNSUPPORTED_RUNTIME)
4047
@irrelevant(context.library == "ruby" and context.installed_language_runtime < "2.6.0")
4148
def test_crash(self):
4249
"""Validate that a crash report is generated when the application crashes"""

utils/_context/_scenarios/docker_ssi.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ def configure(self, config: pytest.Config):
7070
self._arch = config.option.ssi_arch
7171

7272
self._env = "prod" if config.option.ssi_env is None or config.option.ssi_env == "prod" else "dev"
73+
self.configuration["env"] = self._env
7374
self._custom_library_version = config.option.ssi_library_version
7475
self._custom_injector_version = config.option.ssi_injector_version
7576

utils/build/ssi/base/install_script_ssi.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ if [ -n "${DD_INSTALLER_LIBRARY_VERSION}" ]; then
3030
fi
3131

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

3737
#We want specfic injector version (to run on auto_inject pipelines)

utils/build/virtual_machine/provisions/auto-inject/auto-inject_installer_manual.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
if command -v docker >/dev/null 2>&1; then
1717
echo "Docker is installed, ensuring service is enabled and running..."
1818
sudo systemctl enable docker.service docker.socket
19-
19+
2020
if ! sudo systemctl is-active --quiet docker.service; then
2121
echo "Docker service is not running, starting it..."
2222
sudo systemctl start docker.service docker.socket
23-
23+
2424
# Wait for Docker to be fully ready
2525
echo "Waiting for Docker service to be ready..."
2626
MAX_WAIT=20
@@ -34,7 +34,7 @@
3434
sleep 1
3535
((COUNTER++))
3636
done
37-
37+
3838
if [ $COUNTER -eq $MAX_WAIT ]; then
3939
echo "WARNING: Docker service did not become ready after $MAX_WAIT seconds"
4040
fi
@@ -56,8 +56,8 @@
5656
export DD_INSTALLER_DEFAULT_PKG_VERSION_DATADOG_APM_LIBRARY_PYTHON=4
5757
fi
5858
59-
else
60-
export DD_SITE="datadoghq.com"
59+
else
60+
export DD_SITE="datadoghq.com"
6161
#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.
6262
#more details: https://datadoghq.atlassian.net/browse/APMSP-2259
6363
if [ "${DD_LANG}" == "python" ]; then
@@ -75,8 +75,8 @@
7575
fi
7676
7777
if [ "${DD_LANG}" == "js" ] && [ "${DD_env}" == "dev" ] && [ -z "${DD_INSTALLER_DEFAULT_PKG_VERSION_DATADOG_APM_LIBRARY_JS}" ]; then
78-
# Special case for Node.js, the staging major version is 1 above the prod major (6 here)
79-
export DD_INSTALLER_DEFAULT_PKG_VERSION_DATADOG_APM_LIBRARY_JS="6"
78+
# Special case for Node.js, the staging major version is 1 above the prod major (7 here)
79+
export DD_INSTALLER_DEFAULT_PKG_VERSION_DATADOG_APM_LIBRARY_JS="7"
8080
fi
8181
8282
if [ -n "${DD_INSTALLER_INJECTOR_VERSION}" ]; then
@@ -156,10 +156,10 @@
156156
sudo cp debug_config.yaml /etc/datadog-agent/inject/debug_config.yaml
157157
158158
for i in 1 2 3 4 5; do sudo datadog-installer apm instrument docker && break || sleep 1; done
159-
159+
160160
# Add dd-agent user to docker group for docker socket access
161161
sudo usermod -aG docker dd-agent || echo "Warning: Could not add dd-agent to docker group"
162-
162+
163163
# Restart datadog-agent so the new group membership takes effect
164164
sudo systemctl restart datadog-agent || echo "Warning: Could not restart datadog-agent"
165165
- os_type: windows
@@ -201,7 +201,7 @@
201201
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;
202202
$env:DD_SITE = "datadoghq.com";
203203
$env:DD_APM_INSTRUMENTATION_ENABLED = "iis"
204-
204+
205205
# Check if Install-Datadog.ps1 exists locally in binaries folder
206206
if (Test-Path "Install-Datadog.ps1") {
207207
Write-Host "*** Execute installation script from provided binaries ***"
@@ -210,5 +210,5 @@
210210
Write-Host "Download installation script from datadoghq.com"
211211
(New-Object System.Net.WebClient).DownloadFile('https://install.datadoghq.com/Install-Datadog.ps1', 'C:\Windows\SystemTemp\Install-Datadog.ps1');
212212
}
213-
213+
214214
C:\Windows\SystemTemp\Install-Datadog.ps1

utils/build/virtual_machine/provisions/auto-inject/repositories/autoinstall/execute_install_script.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ if [ "${DD_env}" == "dev" ]; then
2323
if [ "${DD_LANG}" == "python" ]; then
2424
export DD_INSTALLER_DEFAULT_PKG_VERSION_DATADOG_APM_LIBRARY_PYTHON=4
2525
fi
26-
else
27-
export DD_SITE="datadoghq.com"
26+
else
27+
export DD_SITE="datadoghq.com"
2828
#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.
2929
#more details: https://datadoghq.atlassian.net/browse/APMSP-2259
3030
if [ "${DD_LANG}" == "python" ]; then
@@ -37,12 +37,12 @@ export DD_APM_INSTRUMENTATION_LIBRARIES="${DD_LANG}"
3737

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

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

4848
if [ -n "${DD_INSTALLER_INJECTOR_VERSION}" ]; then

utils/build/virtual_machine/weblogs/nodejs/provision_test-app-nodejs-alpine.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
weblog:
22
name: test-app-nodejs-alpine
3-
runtime_version: 18
3+
runtime_version: 22
44
install:
55
- os_type: linux
66
copy_files:
@@ -15,6 +15,5 @@ weblog:
1515

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

2019
remote-command: sh create_and_run_app_container.sh

utils/build/virtual_machine/weblogs/nodejs/provision_test-app-nodejs-container.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
weblog:
22
name: test-app-nodejs-container
3-
runtime_version: 18
3+
runtime_version: 22
44
install:
55
- os_type: linux
66
copy_files:

0 commit comments

Comments
 (0)