From 6a5476b99c65d96cd407044a654fb33a162493a3 Mon Sep 17 00:00:00 2001 From: Aaron Abbott Date: Tue, 28 Mar 2023 02:43:31 +0000 Subject: [PATCH] test: force ipv4 DNS preference within containers --- system-test/Dockerfile.linux | 6 ++++-- system-test/Dockerfile.node-alpine | 5 ++++- system-test/system_test.sh | 10 +++++++--- system-test/test.sh | 4 ++++ 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/system-test/Dockerfile.linux b/system-test/Dockerfile.linux index 43c6597f..039dba54 100644 --- a/system-test/Dockerfile.linux +++ b/system-test/Dockerfile.linux @@ -1,7 +1,7 @@ FROM golang:1.17-stretch as builder RUN apt-get update && apt-get install -y \ git \ - && rm -rf /var/lib/apt/lists/* + && rm -rf /var/lib/apt/lists/* WORKDIR /root/ RUN go get github.com/google/pprof @@ -12,7 +12,9 @@ ARG ADDITIONAL_PACKAGES ARG VERIFY_TIME_LINE_NUMBERS RUN apt-get update && apt-get install -y curl $ADDITIONAL_PACKAGES \ - && rm -rf /var/lib/apt/lists/* + && rm -rf /var/lib/apt/lists/* \ + # workaround needed to force ipv4 on kokoro + && echo "precedence ::ffff:0:0/96 100" >> /etc/gai.conf ENV NVM_DIR /bin/.nvm RUN mkdir -p $NVM_DIR diff --git a/system-test/Dockerfile.node-alpine b/system-test/Dockerfile.node-alpine index b1980deb..e54fd713 100644 --- a/system-test/Dockerfile.node-alpine +++ b/system-test/Dockerfile.node-alpine @@ -9,7 +9,10 @@ FROM node:${NODE_VERSION}-alpine ARG ADDITIONAL_PACKAGES -RUN apk add --no-cache bash $ADDITIONAL_PACKAGES +RUN apk add --no-cache bash $ADDITIONAL_PACKAGES \ + # workaround needed to force ipv4 on kokoro + && echo "precedence ::ffff:0:0/96 100" >> /etc/gai.conf + WORKDIR /root/ COPY --from=builder /go/bin/pprof /bin RUN chmod a+x /bin/pprof diff --git a/system-test/system_test.sh b/system-test/system_test.sh index e5752959..f0a30f23 100755 --- a/system-test/system_test.sh +++ b/system-test/system_test.sh @@ -10,11 +10,15 @@ set -eox pipefail cd $(dirname $0) +echo "------------- DEBUGGGGG system_test.sh" +cat /etc/gai.conf +node -e 'const dns = require("dns"); dns.lookup("registry.npmjs.org", (err, address, family) => {console.log(err, address, family);});' + # The list of tested versions below should be in sync with node's # official releases. https://nodejs.org/en/about/releases/ if [[ -z "$BINARY_HOST" ]]; then ADDITIONAL_PACKAGES="python3 g++ make" - NODE_VERSIONS=(14 16 18 19) + NODE_VERSIONS=(18) else # Tested versions for pre-built binaries are limited based on # what node-pre-gyp can specify as its target version. @@ -30,7 +34,7 @@ for i in ${NODE_VERSIONS[@]}; do docker run -v $PWD/..:/src -e BINARY_HOST="$BINARY_HOST" node$i-linux \ /src/system-test/test.sh - docker run -v $PWD/..:/src -e BINARY_HOST="$BINARY_HOST" \ + docker run --sysctl net.ipv6.conf.all.disable_ipv6=1 --sysctl net.ipv6.conf.default.disable_ipv6=1 -v $PWD/..:/src -e BINARY_HOST="$BINARY_HOST" \ -e VERIFY_TIME_LINE_NUMBERS="true" node$i-linux \ /src/system-test/test.sh @@ -39,7 +43,7 @@ for i in ${NODE_VERSIONS[@]}; do --build-arg ADDITIONAL_PACKAGES="$ADDITIONAL_PACKAGES" \ --build-arg NODE_VERSION=$i -t node$i-alpine . - docker run -v $PWD/..:/src -e BINARY_HOST="$BINARY_HOST" node$i-alpine \ + docker run --sysctl net.ipv6.conf.all.disable_ipv6=1 --sysctl net.ipv6.conf.default.disable_ipv6=1 -v $PWD/..:/src -e BINARY_HOST="$BINARY_HOST" node$i-alpine \ /src/system-test/test.sh done diff --git a/system-test/test.sh b/system-test/test.sh index 9c632f32..090715df 100755 --- a/system-test/test.sh +++ b/system-test/test.sh @@ -25,6 +25,10 @@ cd "$SRCDIR" NODEDIR=$(dirname $(dirname $(which node))) +echo "------------- DEBUGGGGG test.sh" +cat /etc/gai.conf +node -e 'const dns = require("dns"); dns.lookup("registry.npmjs.org", (err, address, family) => {console.log(err, address, family);});' + retry npm_install --nodedir="$NODEDIR" \ ${BINARY_HOST:+--pprof_binary_host_mirror=$BINARY_HOST} >/dev/null