Skip to content

Commit b2144da

Browse files
committed
local integration tests: stay runnable on dd-trace v6 trees
The pack step ran `yarn install --frozen-lockfile` directly. On a tree that pins dd-trace v6 (engines node >=22) with a host Node older than 22 — e.g. this repo's GitHub Actions runner image, which sets up Node 18.12 — that install fails with "The engine \"node\" is incompatible with this module", so every local integration test leg on a v6 PR fails before any container is built. Two changes, both no-ops on the current v5 tree: - Pack step: when scripts/install_deps.sh exists (v6 world), install through it with TARGET_NODE_MAJOR=$RUNTIME_PARAM (default 22) so the v5 fallback line is installed for older runtimes and --ignore-engines covers v6 on older hosts. The script restores package.json/yarn.lock on exit, so the worktree stays clean. Without it, fall back to the previous plain yarn install. - Container builds: pass a DD_TRACE_VERSION build-arg resolved through scripts/dd_trace_versions.sh (v5 line for node <22) so the fixture image installs a tracer its runtime can actually run. Current fixture Dockerfiles declare no such ARG, so docker only warns; v6-world fixtures consume it via npm pkg set. Verified: - v5 tree: RUNTIME_PARAM=22 CASE_PARAM=container-cjs passes end to end. - v6 tree (onzia/moreddtrace6 + this harness): node18 leg installs dd-trace 5.124.0 and node22 leg installs 6.12.0 on a Node 18 host (the original failure scenario), containers build and run; the only remaining diffs are the expected tracer-version snapshot drift (5.118 -> 5.124/6.x drop empty "links": [] and populate dd_trace meta), which the v6 PR owns regenerating, same as it already did for the AWS snapshots.
1 parent 866639a commit b2144da

2 files changed

Lines changed: 33 additions & 1 deletion

File tree

‎integration_tests_local/README.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ SKIP_PACK=true RUNTIME_PARAM=18 CASE_PARAM=container-esm ./integration_tests_loc
4444
PLATFORM=linux/amd64 ./integration_tests_local/run.sh
4545
```
4646

47+
On a tree that pins dd-trace v6 (which older runtimes cannot install), the
48+
pack step installs through `scripts/install_deps.sh` with
49+
`TARGET_NODE_MAJOR=$RUNTIME_PARAM` and the container fixtures get a matching
50+
`DD_TRACE_VERSION` build-arg. Run per-runtime there, like CI does: a full
51+
sweep packs only once, so its layer fixture would carry the first leg's
52+
tracer line into every other leg.
53+
4754
The case names are:
4855

4956
| Case | What it covers |

‎integration_tests_local/run.sh‎

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,20 @@ fi
331331
if [ -z "$SKIP_PACK" ]; then
332332
echo "Packing local datadog-lambda-js for container tests"
333333
cd "$repo_dir"
334-
yarn install --frozen-lockfile
334+
if [ -f "$repo_dir/scripts/install_deps.sh" ]; then
335+
# dd-trace v6 world: the repo pins a tracer whose engines may reject
336+
# the host node (e.g. v6 requires node >=22 while CI hosts node 18).
337+
# install_deps.sh installs the tracer line matching the target
338+
# runtime, rewriting package.json/yarn.lock and restoring them via a
339+
# trap on exit, so the worktree is left untouched.
340+
# NOTE: in the v6 world a full local sweep packs once with
341+
# TARGET_NODE_MAJOR=$RUNTIME_PARAM (default 22); run per-runtime like
342+
# CI does (RUNTIME_PARAM=18 ./integration_tests_local/run.sh) so the
343+
# layer fixture's pinned dd-trace matches each leg.
344+
TARGET_NODE_MAJOR=${RUNTIME_PARAM:-22} "$repo_dir/scripts/install_deps.sh"
345+
else
346+
yarn install --frozen-lockfile
347+
fi
335348
yarn build
336349
npm pack
337350
cp datadog-lambda-js-*.tgz "$integration_tests_dir/container/cjs/datadog-lambda-js-local.tgz"
@@ -488,6 +501,17 @@ function write_snapshot() {
488501

489502
for node_version in "${RUNTIMES[@]}"; do
490503
node_image_tag=$(lambda_node_image_tag "$node_version")
504+
# In the dd-trace v6 world the container fixtures take a DD_TRACE_VERSION
505+
# build-arg (fixture package.json pins the newest line, which older
506+
# runtimes cannot install). Pin the fixture to the tracer line that
507+
# actually supports this runtime. On the v5 world there is no
508+
# dd_trace_versions.sh and the fixture Dockerfiles declare no such ARG;
509+
# docker only warns about the unused build-arg, so this stays harmless.
510+
dd_trace_build_version=""
511+
if [ -f "$repo_dir/scripts/dd_trace_versions.sh" ]; then
512+
. "$repo_dir/scripts/dd_trace_versions.sh"
513+
dd_trace_build_version=$(dd_trace_version_for_node_major "$node_version")
514+
fi
491515
for case_name in "${CASES[@]}"; do
492516
configure_case "$case_name" || exit 1
493517
handler_name="$case_name"
@@ -510,6 +534,7 @@ for node_version in "${RUNTIMES[@]}"; do
510534
echo "=== Building $image_tag from Lambda Node image $node_image_tag (platform $PLATFORM) ==="
511535
docker build --platform "$PLATFORM" \
512536
--build-arg NODE_VERSION="$node_image_tag" \
537+
--build-arg DD_TRACE_VERSION="$dd_trace_build_version" \
513538
-t "$image_tag" \
514539
"$integration_tests_dir/container/$case_image" || exit 1
515540

0 commit comments

Comments
 (0)