Skip to content

Commit

Permalink
ci(profiling): run smoke test with built wheels (#12128)
Browse files Browse the repository at this point in the history
  • Loading branch information
taegyunkim authored Jan 30, 2025
1 parent f73a3fe commit 0ed084a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build_python_3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ jobs:
runs-on: ${{ matrix.os }}
name: Build ${{ matrix.only }}
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.build-wheels-matrix.outputs.include) }}

Expand Down
40 changes: 36 additions & 4 deletions tests/smoke_test.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import copy
import os
from platform import system
import platform
import subprocess
import sys
import textwrap


def mac_supported_iast_version():
if system() == "Darwin":
if platform.system() == "Darwin":
# TODO: MacOS 10.9 or lower has a old GCC version but cibuildwheel has a GCC old version in newest mac versions
# mac_version = [int(i) for i in mac_ver()[0].split(".")]
# mac_version > [10, 9]
Expand Down Expand Up @@ -45,7 +45,7 @@ def emit(self, record):

if __name__ == "__main__":
# ASM IAST smoke test
if sys.version_info >= (3, 6, 0) and system() != "Windows" and mac_supported_iast_version():
if sys.version_info >= (3, 6, 0) and platform.system() != "Windows" and mac_supported_iast_version():
print("Running native IAST module load test...")
test_code = textwrap.dedent(test_native_load_code)
cmd = [sys.executable, "-c", test_code]
Expand All @@ -67,7 +67,7 @@ def emit(self, record):
os.environ = orig_env

# ASM WAF smoke test
if system() != "Linux" or sys.maxsize > 2**32:
if platform.system() != "Linux" or sys.maxsize > 2**32:
import ddtrace.appsec._ddwaf
import ddtrace.bootstrap.sitecustomize as module

Expand All @@ -80,3 +80,35 @@ def emit(self, record):
else:
# Skip the test for 32-bit Linux systems
print("Skipping test, 32-bit DDWAF not ready yet")

# Profiling smoke test
print("Running profiling smoke test...")
profiling_cmd = [sys.executable, "-c", "import ddtrace.profiling.auto"]
if sys.version_info >= (3, 13, 0):
print("Skipping profiling smoke test for Python 3.13+ as it's not supported yet")
elif (
# echion doesn't work on Windows
platform.system() == "Windows"
# libdatadog x86_64-apple-darwin has not yet been integrated to dd-trace-py
or (platform.system() == "Darwin" and platform.machine() == "x86_64")
# echion only works with 3.8+
or sys.version_info < (3, 8, 0)
# echion crashes on musl linux with Python 3.12 for both x86_64 and
# aarch64
or (platform.system() == "Linux" and sys.version_info[:2] == (3, 12) and platform.libc_ver()[0] != "glibc")
):
orig_env = os.environ.copy()
copied_env = copy.deepcopy(orig_env)
copied_env["DD_PROFILING_STACK_V2_ENABLED"] = "False"
if platform.system() == "Windows":
# Memory profiler crashes on Windows
copied_env["DD_PROFILING_MEMORY_ENABLED"] = "False"
result = subprocess.run(profiling_cmd, env=copied_env, capture_output=True, text=True)
assert result.returncode == 0, "Failed with DD_PROFILING_STACK_V2_ENABLED=0: %s, %s" % (
result.stdout,
result.stderr,
)
else:
result = subprocess.run(profiling_cmd, capture_output=True, text=True)
assert result.returncode == 0, "Failed: %s, %s" % (result.stdout, result.stderr)
print("Profiling smoke test completed successfully")

0 comments on commit 0ed084a

Please sign in to comment.