Skip to content

Commit

Permalink
Clean leftover from healthcheck migration (#3248)
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeauchesne authored and mtoffl01 committed Oct 17, 2024
1 parent 69583e2 commit f5a2f3b
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 73 deletions.
12 changes: 7 additions & 5 deletions utils/_context/_scenarios/endtoend.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,17 +299,19 @@ def configure(self, config):
container.interface = getattr(interfaces, container.name)
container.interface.configure(self.host_log_folder, self.replay)

library = self.weblog_container.image.env["SYSTEM_TESTS_LIBRARY"]

if self.library_interface_timeout is None:
if self.weblog_container.library == "java":
if library == "java":
self.library_interface_timeout = 25
elif self.weblog_container.library.library in ("golang",):
elif library in ("golang",):
self.library_interface_timeout = 10
elif self.weblog_container.library.library in ("nodejs", "ruby"):
elif library in ("nodejs", "ruby"):
self.library_interface_timeout = 0
elif self.weblog_container.library.library in ("php",):
elif library in ("php",):
# possibly something weird on obfuscator, let increase the delay for now
self.library_interface_timeout = 10
elif self.weblog_container.library.library in ("python",):
elif library in ("python",):
self.library_interface_timeout = 5
else:
self.library_interface_timeout = 40
Expand Down
55 changes: 9 additions & 46 deletions utils/_context/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ def __init__(
# This is worse than the line above though prevents mmap bugs locally
security_opt=["seccomp=unconfined"],
healthcheck={
"test": f"curl --fail --silent --show-error --max-time 2 localhost:{self.port}",
"test": f"curl --fail --silent --show-error --max-time 2 localhost:{self.port}/healthcheck",
"retries": 60,
},
ports={"7777/tcp": self.port, "7778/tcp": weblog._grpc_port},
Expand Down Expand Up @@ -693,33 +693,11 @@ def configure(self, replay):
self.environment["AWS_DEFAULT_REGION"] = os.environ.get("AWS_DEFAULT_REGION", "")
self.environment["AWS_REGION"] = os.environ.get("AWS_REGION", "")

self._library = LibraryVersion(
self.image.env.get("SYSTEM_TESTS_LIBRARY", None), self.image.env.get("SYSTEM_TESTS_LIBRARY_VERSION", None),
)

# https://github.com/DataDog/system-tests/issues/2799
if self.library in (
"cpp",
"dotnet",
"nodejs",
"php",
"python",
"golang",
"ruby",
"java",
"python_otel",
"nodejs_otel",
"java_otel",
):
self.healthcheck = {
"test": f"curl --fail --silent --show-error --max-time 2 localhost:{self.port}/healthcheck",
"retries": 60,
}
library = self.image.env["SYSTEM_TESTS_LIBRARY"]

if self.library in ("cpp", "dotnet", "java", "python"):
if library in ("cpp", "dotnet", "java", "python"):
self.environment["DD_TRACE_HEADER_TAGS"] = "user-agent:http.request.headers.user-agent"

elif self.library in ("golang", "nodejs", "php", "ruby"):
elif library in ("golang", "nodejs", "php", "ruby"):
self.environment["DD_TRACE_HEADER_TAGS"] = "user-agent"
else:
self.environment["DD_TRACE_HEADER_TAGS"] = ""
Expand All @@ -737,26 +715,11 @@ def post_start(self):

logger.debug(f"Docker host is {weblog.domain}")

# new way of getting info from the weblog. Only working for nodejs and python right now
# https://github.com/DataDog/system-tests/issues/2799
if self.library in (
"cpp",
"dotnet",
"nodejs",
"python",
"php",
"golang",
"ruby",
"java",
"python_otel",
"nodejs_otel",
"java_otel",
):
with open(self.healthcheck_log_file, mode="r", encoding="utf-8") as f:
data = json.load(f)
lib = data["library"]

self._library = LibraryVersion(lib["language"], lib["version"])
with open(self.healthcheck_log_file, mode="r", encoding="utf-8") as f:
data = json.load(f)
lib = data["library"]

self._library = LibraryVersion(lib["language"], lib["version"])

logger.stdout(f"Library: {self.library}")

Expand Down
4 changes: 0 additions & 4 deletions utils/build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -254,17 +254,13 @@ build() {
# or an arg. So we use this 2-step trick to get it.
# If anybody has an idea to achieve this in a cleanest way ...

echo "Getting system test context and saving it in weblog image"
SYSTEM_TESTS_LIBRARY_VERSION=$(docker run ${DOCKER_PLATFORM_ARGS} --rm system_tests/weblog cat SYSTEM_TESTS_LIBRARY_VERSION)

docker buildx build \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--load \
--progress=plain \
${DOCKER_PLATFORM_ARGS} \
--build-arg SYSTEM_TESTS_LIBRARY="$TEST_LIBRARY" \
--build-arg SYSTEM_TESTS_WEBLOG_VARIANT="$WEBLOG_VARIANT" \
--build-arg SYSTEM_TESTS_LIBRARY_VERSION="$SYSTEM_TESTS_LIBRARY_VERSION" \
-f utils/build/docker/set-system-tests-weblog-env.Dockerfile \
-t system_tests/weblog \
.
Expand Down
3 changes: 0 additions & 3 deletions utils/build/docker/nodejs/install_ddtrace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,3 @@ else

npm install $target
fi

# nodejs uses the next API to get the library version. See https://github.com/DataDog/system-tests/issues/2799
echo "0.0.0" > SYSTEM_TESTS_LIBRARY_VERSION
2 changes: 0 additions & 2 deletions utils/build/docker/nodejs_otel/express4-otel.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ RUN npm install --save @opentelemetry/auto-instrumentations-node
RUN npm install @opentelemetry/instrumentation-mysql2
RUN npm install --save opentelemetry-instrumentation-mssql

RUN touch SYSTEM_TESTS_LIBRARY_VERSION

# docker startup
COPY utils/build/docker/nodejs/app.sh app.sh
RUN printf 'node --require @opentelemetry/auto-instrumentations-node/register app.js' >> app.sh
Expand Down
2 changes: 0 additions & 2 deletions utils/build/docker/php/apache-mod/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ sed -i s/80/7777/ /etc/apache2/ports.conf

/install_ddtrace.sh 1

SYSTEM_TESTS_LIBRARY_VERSION=$(cat /binaries/SYSTEM_TESTS_LIBRARY_VERSION)

if [[ -f "/etc/php/98-ddtrace.ini" ]]; then
grep -E 'datadog.trace.request_init_hook|datadog.trace.sources_path' /etc/php/98-ddtrace.ini >> /etc/php/php.ini
fi
2 changes: 0 additions & 2 deletions utils/build/docker/php/common/install_ddtrace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ fi
php -d error_reporting='' -d extension=ddtrace.so -d extension=ddappsec.so -r 'echo phpversion("ddtrace");' > \
/binaries/SYSTEM_TESTS_LIBRARY_VERSION

library_version=$(<././SYSTEM_TESTS_LIBRARY_VERSION)
rule_file="/opt/datadog/dd-library/${library_version}/etc/recommended.json"

find /opt -name ddappsec-helper -exec ln -s '{}' /usr/local/bin/ \;
mkdir -p /etc/dd-appsec
Expand Down
5 changes: 0 additions & 5 deletions utils/build/docker/python/install_ddtrace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,3 @@ else
echo "ERROR: Found several wheel files in binaries/, abort."
exit 1
fi

cd -

# python uses the next API to get the library version. See https://github.com/DataDog/system-tests/issues/2799
echo "0.0.0" > SYSTEM_TESTS_LIBRARY_VERSION
1 change: 0 additions & 1 deletion utils/build/docker/python_otel/flask-poc-otel.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ COPY utils/build/docker/python_otel/flask-poc-otel/app.sh /app

RUN opentelemetry-bootstrap -a install
RUN pip freeze | grep opentelemetry
RUN touch SYSTEM_TESTS_LIBRARY_VERSION

ENV OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED=true
ENV FLASK_APP=app.py
Expand Down
3 changes: 0 additions & 3 deletions utils/build/docker/set-system-tests-weblog-env.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ ENV SYSTEM_TESTS_LIBRARY=$SYSTEM_TESTS_LIBRARY
ARG SYSTEM_TESTS_WEBLOG_VARIANT
ENV SYSTEM_TESTS_WEBLOG_VARIANT=$SYSTEM_TESTS_WEBLOG_VARIANT

ARG SYSTEM_TESTS_LIBRARY_VERSION
ENV SYSTEM_TESTS_LIBRARY_VERSION=$SYSTEM_TESTS_LIBRARY_VERSION

# Flush telemetry messages faster
ENV DD_HEARTBEAT_TELEMETRY_INTERVAL=5

Expand Down

0 comments on commit f5a2f3b

Please sign in to comment.