From 50a5e154b4242c2ad17133cd47d7a9eb003bbeca Mon Sep 17 00:00:00 2001 From: Charles de Beauchesne Date: Wed, 16 Oct 2024 18:19:00 +0200 Subject: [PATCH] Clean leftover from healthcheck migration (#3248) --- utils/_context/_scenarios/endtoend.py | 12 ++-- utils/_context/containers.py | 55 +++---------------- utils/build/build.sh | 4 -- utils/build/docker/nodejs/install_ddtrace.sh | 3 - .../nodejs_otel/express4-otel.Dockerfile | 2 - utils/build/docker/php/apache-mod/build.sh | 2 - .../docker/php/common/install_ddtrace.sh | 2 - utils/build/docker/python/install_ddtrace.sh | 5 -- .../python_otel/flask-poc-otel.Dockerfile | 1 - .../set-system-tests-weblog-env.Dockerfile | 3 - 10 files changed, 16 insertions(+), 73 deletions(-) diff --git a/utils/_context/_scenarios/endtoend.py b/utils/_context/_scenarios/endtoend.py index 10f3e01823..58d8e96b6e 100644 --- a/utils/_context/_scenarios/endtoend.py +++ b/utils/_context/_scenarios/endtoend.py @@ -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 diff --git a/utils/_context/containers.py b/utils/_context/containers.py index 5e511fc685..7795cf97a3 100644 --- a/utils/_context/containers.py +++ b/utils/_context/containers.py @@ -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}, @@ -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"] = "" @@ -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}") diff --git a/utils/build/build.sh b/utils/build/build.sh index f6871a7040..9d54b567b0 100755 --- a/utils/build/build.sh +++ b/utils/build/build.sh @@ -254,9 +254,6 @@ 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 \ @@ -264,7 +261,6 @@ build() { ${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 \ . diff --git a/utils/build/docker/nodejs/install_ddtrace.sh b/utils/build/docker/nodejs/install_ddtrace.sh index fa26751263..36af174c09 100755 --- a/utils/build/docker/nodejs/install_ddtrace.sh +++ b/utils/build/docker/nodejs/install_ddtrace.sh @@ -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 diff --git a/utils/build/docker/nodejs_otel/express4-otel.Dockerfile b/utils/build/docker/nodejs_otel/express4-otel.Dockerfile index fde95dff3e..9262035584 100644 --- a/utils/build/docker/nodejs_otel/express4-otel.Dockerfile +++ b/utils/build/docker/nodejs_otel/express4-otel.Dockerfile @@ -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 diff --git a/utils/build/docker/php/apache-mod/build.sh b/utils/build/docker/php/apache-mod/build.sh index ad45f5bd32..7e36ff20fa 100755 --- a/utils/build/docker/php/apache-mod/build.sh +++ b/utils/build/docker/php/apache-mod/build.sh @@ -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 diff --git a/utils/build/docker/php/common/install_ddtrace.sh b/utils/build/docker/php/common/install_ddtrace.sh index dfe07f1584..cb59347547 100755 --- a/utils/build/docker/php/common/install_ddtrace.sh +++ b/utils/build/docker/php/common/install_ddtrace.sh @@ -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 diff --git a/utils/build/docker/python/install_ddtrace.sh b/utils/build/docker/python/install_ddtrace.sh index 5990cee4a7..f996b67fb4 100755 --- a/utils/build/docker/python/install_ddtrace.sh +++ b/utils/build/docker/python/install_ddtrace.sh @@ -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 \ No newline at end of file diff --git a/utils/build/docker/python_otel/flask-poc-otel.Dockerfile b/utils/build/docker/python_otel/flask-poc-otel.Dockerfile index 2e8d3dfce1..42a26577f4 100644 --- a/utils/build/docker/python_otel/flask-poc-otel.Dockerfile +++ b/utils/build/docker/python_otel/flask-poc-otel.Dockerfile @@ -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 diff --git a/utils/build/docker/set-system-tests-weblog-env.Dockerfile b/utils/build/docker/set-system-tests-weblog-env.Dockerfile index 7851e2c563..4e8f157ab2 100644 --- a/utils/build/docker/set-system-tests-weblog-env.Dockerfile +++ b/utils/build/docker/set-system-tests-weblog-env.Dockerfile @@ -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