From 66f76468b4184cd0f3fd4ad90e783a5fe5378832 Mon Sep 17 00:00:00 2001 From: Taegyun Kim Date: Tue, 12 Nov 2024 09:34:10 -0500 Subject: [PATCH] chore(profiling): run native tests in ci (#11108) 1. Use `pytest-cpp` to discover and run profiling C++ tests a. `pytest-cpp` will find executables that start with `test_` b. all tests are put into `ddtrace/internal/datadog/profiling/test` and `tests/profiling_v2/native_test` will symlink to it for discovery. 3. `DD_PROFILING_NATIVE_TESTS` flag is used to build native tests a. needed to set this in `build_base_venv` b. setup.py includes native test binaries when the flag is set c. gitlab will also propagate those artifacts ## Checklist - [x] PR author has checked that all the criteria below are met - The PR description includes an overview of the change - The PR description articulates the motivation for the change - The change includes tests OR the PR description describes a testing strategy - The PR description notes risks associated with the change, if any - Newly-added code is easy to change - The change follows the [library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) - The change includes or references documentation updates if necessary - Backport labels are set (if [applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)) ## Reviewer Checklist - [x] Reviewer has checked that all the criteria below are met - Title is accurate - All changes are related to the pull request's stated goal - Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes - Testing strategy adequately addresses listed risks - Newly-added code is easy to change - Release note makes sense to a user of the library - If necessary, author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment - Backport labels are set in a manner that is consistent with the [release branch maintenance policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting) --- .gitlab/package.yml | 2 ++ .../requirements/{acb0de0.txt => 118a763.txt} | 11 +++++---- .../requirements/{1452073.txt => 1359ebb.txt} | 7 +++--- .../requirements/{5286dd4.txt => 15e90ee.txt} | 19 +++++++-------- .../requirements/{1744bab.txt => 1600ae2.txt} | 8 ++++--- .../requirements/{18598d3.txt => 18008a7.txt} | 11 +++++---- .../requirements/{1f484c3.txt => 1a9ec51.txt} | 11 +++++---- .../requirements/{ab034bd.txt => 1b284db.txt} | 19 +++++++-------- .../requirements/{d6c4509.txt => 1bc8c1c.txt} | 13 ++++++----- .../requirements/{d79db4d.txt => 1d20be2.txt} | 15 ++++++------ .../requirements/{eb59b31.txt => 1d21682.txt} | 5 ++-- .../requirements/{1e185ef.txt => 2e36381.txt} | 17 +++++++------- .../requirements/{12526ba.txt => 4dd0ff3.txt} | 13 ++++++----- .../requirements/{7f8c636.txt => 6fe81be.txt} | 6 +++-- .../requirements/{1aecc60.txt => a541d7e.txt} | 9 ++++---- .../requirements/{167dd48.txt => b83f7ca.txt} | 23 ++++++++++--------- .../requirements/{8a0f886.txt => d2b6740.txt} | 6 +++-- .../requirements/{1e17619.txt => d3718d9.txt} | 15 ++++++------ .../requirements/{11aeb6a.txt => d62d369.txt} | 11 +++++---- .../requirements/{18d2618.txt => f59e90e.txt} | 17 +++++++------- .../profiling/dd_wrapper/test/CMakeLists.txt | 17 ++++++++++---- .../dd_wrapper/test/{api.cpp => test_api.cpp} | 0 ...rovenance.cpp => test_code_provenance.cpp} | 0 .../test/{forking.cpp => test_forking.cpp} | 2 +- ...ialization.cpp => test_initialization.cpp} | 0 .../{threading.cpp => test_threading.cpp} | 0 .../profiling/stack_v2/test/CMakeLists.txt | 17 ++++++++++++-- ...n_links.cpp => test_thread_span_links.cpp} | 0 .../datadog/profiling/test/.gitignore | 2 ++ riotfile.py | 8 ++++++- setup.py | 9 +++++++- tests/profiling_v2/native_tests | 1 + 32 files changed, 177 insertions(+), 117 deletions(-) rename .riot/requirements/{acb0de0.txt => 118a763.txt} (79%) rename .riot/requirements/{1452073.txt => 1359ebb.txt} (91%) rename .riot/requirements/{5286dd4.txt => 15e90ee.txt} (77%) rename .riot/requirements/{1744bab.txt => 1600ae2.txt} (85%) rename .riot/requirements/{18598d3.txt => 18008a7.txt} (82%) rename .riot/requirements/{1f484c3.txt => 1a9ec51.txt} (83%) rename .riot/requirements/{ab034bd.txt => 1b284db.txt} (78%) rename .riot/requirements/{d6c4509.txt => 1bc8c1c.txt} (82%) rename .riot/requirements/{d79db4d.txt => 1d20be2.txt} (78%) rename .riot/requirements/{eb59b31.txt => 1d21682.txt} (93%) rename .riot/requirements/{1e185ef.txt => 2e36381.txt} (78%) rename .riot/requirements/{12526ba.txt => 4dd0ff3.txt} (81%) rename .riot/requirements/{7f8c636.txt => 6fe81be.txt} (86%) rename .riot/requirements/{1aecc60.txt => a541d7e.txt} (85%) rename .riot/requirements/{167dd48.txt => b83f7ca.txt} (73%) rename .riot/requirements/{8a0f886.txt => d2b6740.txt} (84%) rename .riot/requirements/{1e17619.txt => d3718d9.txt} (79%) rename .riot/requirements/{11aeb6a.txt => d62d369.txt} (79%) rename .riot/requirements/{18d2618.txt => f59e90e.txt} (75%) rename ddtrace/internal/datadog/profiling/dd_wrapper/test/{api.cpp => test_api.cpp} (100%) rename ddtrace/internal/datadog/profiling/dd_wrapper/test/{code_provenance.cpp => test_code_provenance.cpp} (100%) rename ddtrace/internal/datadog/profiling/dd_wrapper/test/{forking.cpp => test_forking.cpp} (99%) rename ddtrace/internal/datadog/profiling/dd_wrapper/test/{initialization.cpp => test_initialization.cpp} (100%) rename ddtrace/internal/datadog/profiling/dd_wrapper/test/{threading.cpp => test_threading.cpp} (100%) rename ddtrace/internal/datadog/profiling/stack_v2/test/{thread_span_links.cpp => test_thread_span_links.cpp} (100%) create mode 100644 ddtrace/internal/datadog/profiling/test/.gitignore create mode 120000 tests/profiling_v2/native_tests diff --git a/.gitlab/package.yml b/.gitlab/package.yml index 115ada9f264..2f896637599 100644 --- a/.gitlab/package.yml +++ b/.gitlab/package.yml @@ -7,6 +7,7 @@ build_base_venvs: variables: CMAKE_BUILD_PARALLEL_LEVEL: 12 PIP_VERBOSE: 1 + DD_PROFILING_NATIVE_TESTS: 1 script: - pip install riot==0.20.0 - riot -P -v generate --python=$PYTHON_VERSION @@ -16,6 +17,7 @@ build_base_venvs: - .riot/venv_* - ddtrace/**/*.so* - ddtrace/internal/datadog/profiling/crashtracker/crashtracker_exe* + - ddtrace/internal/datadog/profiling/test/test_* download_ddtrace_artifacts: image: registry.ddbuild.io/github-cli:v27480869-eafb11d-2.43.0 diff --git a/.riot/requirements/acb0de0.txt b/.riot/requirements/118a763.txt similarity index 79% rename from .riot/requirements/acb0de0.txt rename to .riot/requirements/118a763.txt index 5717bdd07bc..96dddb83cd5 100644 --- a/.riot/requirements/acb0de0.txt +++ b/.riot/requirements/118a763.txt @@ -2,7 +2,7 @@ # This file is autogenerated by pip-compile with Python 3.12 # by the following command: # -# pip-compile --allow-unsafe --no-annotate .riot/requirements/acb0de0.in +# pip-compile --allow-unsafe --no-annotate .riot/requirements/118a763.in # attrs==24.2.0 coverage[toml]==7.6.4 @@ -18,9 +18,10 @@ protobuf==5.28.3 py-cpuinfo==8.0.0 pytest==8.3.3 pytest-asyncio==0.21.1 -pytest-benchmark==4.0.0 -pytest-cov==5.0.0 +pytest-benchmark==5.1.0 +pytest-cov==6.0.0 +pytest-cpp==2.6.0 pytest-mock==3.14.0 -pytest-randomly==3.15.0 +pytest-randomly==3.16.0 sortedcontainers==2.4.0 -uwsgi==2.0.27 +uwsgi==2.0.28 diff --git a/.riot/requirements/1452073.txt b/.riot/requirements/1359ebb.txt similarity index 91% rename from .riot/requirements/1452073.txt rename to .riot/requirements/1359ebb.txt index e2c59087863..75c10c261a8 100644 --- a/.riot/requirements/1452073.txt +++ b/.riot/requirements/1359ebb.txt @@ -2,7 +2,7 @@ # This file is autogenerated by pip-compile with Python 3.10 # by the following command: # -# pip-compile --allow-unsafe --no-annotate .riot/requirements/1452073.in +# pip-compile --allow-unsafe --no-annotate .riot/requirements/1359ebb.in # attrs==24.2.0 coverage[toml]==7.6.4 @@ -22,13 +22,14 @@ pytest==8.3.3 pytest-asyncio==0.21.1 pytest-benchmark==5.1.0 pytest-cov==6.0.0 +pytest-cpp==2.6.0 pytest-mock==3.14.0 pytest-randomly==3.16.0 sortedcontainers==2.4.0 -tomli==2.0.2 +tomli==2.1.0 uwsgi==2.0.28 zope-event==5.0 zope-interface==7.1.1 # The following packages are considered to be unsafe in a requirements file: -setuptools==75.3.0 +setuptools==75.4.0 diff --git a/.riot/requirements/5286dd4.txt b/.riot/requirements/15e90ee.txt similarity index 77% rename from .riot/requirements/5286dd4.txt rename to .riot/requirements/15e90ee.txt index cfa763a35cf..1855f4db88a 100644 --- a/.riot/requirements/5286dd4.txt +++ b/.riot/requirements/15e90ee.txt @@ -2,13 +2,13 @@ # This file is autogenerated by pip-compile with Python 3.10 # by the following command: # -# pip-compile --allow-unsafe --no-annotate .riot/requirements/5286dd4.in +# pip-compile --allow-unsafe --no-annotate .riot/requirements/15e90ee.in # attrs==24.2.0 -coverage[toml]==7.6.1 +coverage[toml]==7.6.3 exceptiongroup==1.2.2 -gevent==24.2.1 -greenlet==3.0.3 +gevent==24.10.2 +greenlet==3.1.1 gunicorn[gevent]==23.0.0 hypothesis==6.45.0 iniconfig==2.0.0 @@ -18,17 +18,18 @@ opentracing==2.4.0 packaging==24.1 pluggy==1.5.0 py-cpuinfo==8.0.0 -pytest==8.3.2 +pytest==8.3.3 pytest-asyncio==0.21.1 pytest-benchmark==4.0.0 pytest-cov==5.0.0 +pytest-cpp==2.6.0 pytest-mock==3.14.0 pytest-randomly==3.15.0 sortedcontainers==2.4.0 -tomli==2.0.1 -uwsgi==2.0.26 +tomli==2.0.2 +uwsgi==2.0.27 zope-event==5.0 -zope-interface==7.0.3 +zope-interface==7.1.0 # The following packages are considered to be unsafe in a requirements file: -setuptools==74.1.2 +setuptools==75.2.0 diff --git a/.riot/requirements/1744bab.txt b/.riot/requirements/1600ae2.txt similarity index 85% rename from .riot/requirements/1744bab.txt rename to .riot/requirements/1600ae2.txt index 2b7720a4378..d330d767bc1 100644 --- a/.riot/requirements/1744bab.txt +++ b/.riot/requirements/1600ae2.txt @@ -2,13 +2,14 @@ # This file is autogenerated by pip-compile with Python 3.7 # by the following command: # -# pip-compile --allow-unsafe --config=pyproject.toml --no-annotate --resolver=backtracking .riot/requirements/1744bab.in +# pip-compile --allow-unsafe --config=pyproject.toml --no-annotate --resolver=backtracking .riot/requirements/1600ae2.in # attrs==24.2.0 +colorama==0.4.6 coverage[toml]==7.2.7 exceptiongroup==1.2.2 gevent==22.10.2 -greenlet==3.0.3 +greenlet==3.1.1 gunicorn[gevent]==23.0.0 hypothesis==6.45.0 importlib-metadata==6.7.0 @@ -23,12 +24,13 @@ pytest==7.4.4 pytest-asyncio==0.21.1 pytest-benchmark==4.0.0 pytest-cov==4.1.0 +pytest-cpp==2.5.0 pytest-mock==3.11.1 pytest-randomly==3.12.0 sortedcontainers==2.4.0 tomli==2.0.1 typing-extensions==4.7.1 -uwsgi==2.0.26 +uwsgi==2.0.27 zipp==3.15.0 zope-event==5.0 zope-interface==6.4.post2 diff --git a/.riot/requirements/18598d3.txt b/.riot/requirements/18008a7.txt similarity index 82% rename from .riot/requirements/18598d3.txt rename to .riot/requirements/18008a7.txt index 49e2a01fcd8..f27f68fb2ce 100644 --- a/.riot/requirements/18598d3.txt +++ b/.riot/requirements/18008a7.txt @@ -2,10 +2,10 @@ # This file is autogenerated by pip-compile with Python 3.11 # by the following command: # -# pip-compile --allow-unsafe --no-annotate .riot/requirements/18598d3.in +# pip-compile --allow-unsafe --no-annotate .riot/requirements/18008a7.in # attrs==24.2.0 -coverage[toml]==7.6.1 +coverage[toml]==7.6.3 gunicorn==23.0.0 hypothesis==6.45.0 iniconfig==2.0.0 @@ -14,13 +14,14 @@ mock==5.1.0 opentracing==2.4.0 packaging==24.1 pluggy==1.5.0 -protobuf==5.28.0 +protobuf==5.28.2 py-cpuinfo==8.0.0 -pytest==8.3.2 +pytest==8.3.3 pytest-asyncio==0.21.1 pytest-benchmark==4.0.0 pytest-cov==5.0.0 +pytest-cpp==2.6.0 pytest-mock==3.14.0 pytest-randomly==3.15.0 sortedcontainers==2.4.0 -uwsgi==2.0.26 +uwsgi==2.0.27 diff --git a/.riot/requirements/1f484c3.txt b/.riot/requirements/1a9ec51.txt similarity index 83% rename from .riot/requirements/1f484c3.txt rename to .riot/requirements/1a9ec51.txt index 8df64afa9f9..832fac60dff 100644 --- a/.riot/requirements/1f484c3.txt +++ b/.riot/requirements/1a9ec51.txt @@ -2,10 +2,10 @@ # This file is autogenerated by pip-compile with Python 3.10 # by the following command: # -# pip-compile --allow-unsafe --no-annotate .riot/requirements/1f484c3.in +# pip-compile --allow-unsafe --no-annotate .riot/requirements/1a9ec51.in # attrs==24.2.0 -coverage[toml]==7.6.1 +coverage[toml]==7.6.3 exceptiongroup==1.2.2 gunicorn==23.0.0 hypothesis==6.45.0 @@ -17,12 +17,13 @@ packaging==24.1 pluggy==1.5.0 protobuf==3.19.0 py-cpuinfo==8.0.0 -pytest==8.3.2 +pytest==8.3.3 pytest-asyncio==0.21.1 pytest-benchmark==4.0.0 pytest-cov==5.0.0 +pytest-cpp==2.6.0 pytest-mock==3.14.0 pytest-randomly==3.15.0 sortedcontainers==2.4.0 -tomli==2.0.1 -uwsgi==2.0.26 +tomli==2.0.2 +uwsgi==2.0.27 diff --git a/.riot/requirements/ab034bd.txt b/.riot/requirements/1b284db.txt similarity index 78% rename from .riot/requirements/ab034bd.txt rename to .riot/requirements/1b284db.txt index 8189def48ce..890031e7402 100644 --- a/.riot/requirements/ab034bd.txt +++ b/.riot/requirements/1b284db.txt @@ -2,16 +2,16 @@ # This file is autogenerated by pip-compile with Python 3.8 # by the following command: # -# pip-compile --allow-unsafe --no-annotate .riot/requirements/ab034bd.in +# pip-compile --allow-unsafe --no-annotate .riot/requirements/1b284db.in # attrs==24.2.0 coverage[toml]==7.6.1 exceptiongroup==1.2.2 gevent==24.2.1 -greenlet==3.0.3 +greenlet==3.1.1 gunicorn[gevent]==23.0.0 hypothesis==6.45.0 -importlib-metadata==8.4.0 +importlib-metadata==8.5.0 iniconfig==2.0.0 lz4==4.3.3 mock==5.1.0 @@ -19,18 +19,19 @@ opentracing==2.4.0 packaging==24.1 pluggy==1.5.0 py-cpuinfo==8.0.0 -pytest==8.3.2 +pytest==8.3.3 pytest-asyncio==0.21.1 pytest-benchmark==4.0.0 pytest-cov==5.0.0 +pytest-cpp==2.6.0 pytest-mock==3.14.0 pytest-randomly==3.15.0 sortedcontainers==2.4.0 -tomli==2.0.1 -uwsgi==2.0.26 -zipp==3.20.1 +tomli==2.0.2 +uwsgi==2.0.27 +zipp==3.20.2 zope-event==5.0 -zope-interface==7.0.3 +zope-interface==7.1.0 # The following packages are considered to be unsafe in a requirements file: -setuptools==74.1.2 +setuptools==75.2.0 diff --git a/.riot/requirements/d6c4509.txt b/.riot/requirements/1bc8c1c.txt similarity index 82% rename from .riot/requirements/d6c4509.txt rename to .riot/requirements/1bc8c1c.txt index 833f8557797..163028cbf3e 100644 --- a/.riot/requirements/d6c4509.txt +++ b/.riot/requirements/1bc8c1c.txt @@ -2,14 +2,14 @@ # This file is autogenerated by pip-compile with Python 3.8 # by the following command: # -# pip-compile --allow-unsafe --no-annotate .riot/requirements/d6c4509.in +# pip-compile --allow-unsafe --no-annotate .riot/requirements/1bc8c1c.in # attrs==24.2.0 coverage[toml]==7.6.1 exceptiongroup==1.2.2 gunicorn==23.0.0 hypothesis==6.45.0 -importlib-metadata==8.4.0 +importlib-metadata==8.5.0 iniconfig==2.0.0 lz4==4.3.3 mock==5.1.0 @@ -18,13 +18,14 @@ packaging==24.1 pluggy==1.5.0 protobuf==3.19.0 py-cpuinfo==8.0.0 -pytest==8.3.2 +pytest==8.3.3 pytest-asyncio==0.21.1 pytest-benchmark==4.0.0 pytest-cov==5.0.0 +pytest-cpp==2.6.0 pytest-mock==3.14.0 pytest-randomly==3.15.0 sortedcontainers==2.4.0 -tomli==2.0.1 -uwsgi==2.0.26 -zipp==3.20.1 +tomli==2.0.2 +uwsgi==2.0.27 +zipp==3.20.2 diff --git a/.riot/requirements/d79db4d.txt b/.riot/requirements/1d20be2.txt similarity index 78% rename from .riot/requirements/d79db4d.txt rename to .riot/requirements/1d20be2.txt index 53f97535f4c..b3e24418d56 100644 --- a/.riot/requirements/d79db4d.txt +++ b/.riot/requirements/1d20be2.txt @@ -2,14 +2,14 @@ # This file is autogenerated by pip-compile with Python 3.9 # by the following command: # -# pip-compile --allow-unsafe --no-annotate .riot/requirements/d79db4d.in +# pip-compile --allow-unsafe --no-annotate .riot/requirements/1d20be2.in # attrs==24.2.0 -coverage[toml]==7.6.1 +coverage[toml]==7.6.3 exceptiongroup==1.2.2 gunicorn==23.0.0 hypothesis==6.45.0 -importlib-metadata==8.4.0 +importlib-metadata==8.5.0 iniconfig==2.0.0 lz4==4.3.3 mock==5.1.0 @@ -18,13 +18,14 @@ packaging==24.1 pluggy==1.5.0 protobuf==3.19.0 py-cpuinfo==8.0.0 -pytest==8.3.2 +pytest==8.3.3 pytest-asyncio==0.21.1 pytest-benchmark==4.0.0 pytest-cov==5.0.0 +pytest-cpp==2.6.0 pytest-mock==3.14.0 pytest-randomly==3.15.0 sortedcontainers==2.4.0 -tomli==2.0.1 -uwsgi==2.0.26 -zipp==3.20.1 +tomli==2.0.2 +uwsgi==2.0.27 +zipp==3.20.2 diff --git a/.riot/requirements/eb59b31.txt b/.riot/requirements/1d21682.txt similarity index 93% rename from .riot/requirements/eb59b31.txt rename to .riot/requirements/1d21682.txt index 5899a214883..93fd622b954 100644 --- a/.riot/requirements/eb59b31.txt +++ b/.riot/requirements/1d21682.txt @@ -2,7 +2,7 @@ # This file is autogenerated by pip-compile with Python 3.12 # by the following command: # -# pip-compile --allow-unsafe --no-annotate .riot/requirements/eb59b31.in +# pip-compile --allow-unsafe --no-annotate .riot/requirements/1d21682.in # attrs==24.2.0 coverage[toml]==7.6.4 @@ -21,6 +21,7 @@ pytest==8.3.3 pytest-asyncio==0.21.1 pytest-benchmark==5.1.0 pytest-cov==6.0.0 +pytest-cpp==2.6.0 pytest-mock==3.14.0 pytest-randomly==3.16.0 sortedcontainers==2.4.0 @@ -29,4 +30,4 @@ zope-event==5.0 zope-interface==7.1.1 # The following packages are considered to be unsafe in a requirements file: -setuptools==75.3.0 +setuptools==75.4.0 diff --git a/.riot/requirements/1e185ef.txt b/.riot/requirements/2e36381.txt similarity index 78% rename from .riot/requirements/1e185ef.txt rename to .riot/requirements/2e36381.txt index e358d5e4586..8629f1a5892 100644 --- a/.riot/requirements/1e185ef.txt +++ b/.riot/requirements/2e36381.txt @@ -2,12 +2,12 @@ # This file is autogenerated by pip-compile with Python 3.11 # by the following command: # -# pip-compile --allow-unsafe --no-annotate .riot/requirements/1e185ef.in +# pip-compile --allow-unsafe --no-annotate .riot/requirements/2e36381.in # attrs==24.2.0 -coverage[toml]==7.6.1 -gevent==24.2.1 -greenlet==3.0.3 +coverage[toml]==7.6.3 +gevent==24.10.2 +greenlet==3.1.1 gunicorn[gevent]==23.0.0 hypothesis==6.45.0 iniconfig==2.0.0 @@ -17,16 +17,17 @@ opentracing==2.4.0 packaging==24.1 pluggy==1.5.0 py-cpuinfo==8.0.0 -pytest==8.3.2 +pytest==8.3.3 pytest-asyncio==0.21.1 pytest-benchmark==4.0.0 pytest-cov==5.0.0 +pytest-cpp==2.6.0 pytest-mock==3.14.0 pytest-randomly==3.15.0 sortedcontainers==2.4.0 -uwsgi==2.0.26 +uwsgi==2.0.27 zope-event==5.0 -zope-interface==7.0.3 +zope-interface==7.1.0 # The following packages are considered to be unsafe in a requirements file: -setuptools==74.1.2 +setuptools==75.2.0 diff --git a/.riot/requirements/12526ba.txt b/.riot/requirements/4dd0ff3.txt similarity index 81% rename from .riot/requirements/12526ba.txt rename to .riot/requirements/4dd0ff3.txt index ecee134c825..539971a6683 100644 --- a/.riot/requirements/12526ba.txt +++ b/.riot/requirements/4dd0ff3.txt @@ -2,10 +2,10 @@ # This file is autogenerated by pip-compile with Python 3.10 # by the following command: # -# pip-compile --allow-unsafe --no-annotate .riot/requirements/12526ba.in +# pip-compile --allow-unsafe --no-annotate .riot/requirements/4dd0ff3.in # attrs==24.2.0 -coverage[toml]==7.6.1 +coverage[toml]==7.6.3 exceptiongroup==1.2.2 gunicorn==23.0.0 hypothesis==6.45.0 @@ -15,14 +15,15 @@ mock==5.1.0 opentracing==2.4.0 packaging==24.1 pluggy==1.5.0 -protobuf==5.28.0 +protobuf==5.28.2 py-cpuinfo==8.0.0 -pytest==8.3.2 +pytest==8.3.3 pytest-asyncio==0.21.1 pytest-benchmark==4.0.0 pytest-cov==5.0.0 +pytest-cpp==2.6.0 pytest-mock==3.14.0 pytest-randomly==3.15.0 sortedcontainers==2.4.0 -tomli==2.0.1 -uwsgi==2.0.26 +tomli==2.0.2 +uwsgi==2.0.27 diff --git a/.riot/requirements/7f8c636.txt b/.riot/requirements/6fe81be.txt similarity index 86% rename from .riot/requirements/7f8c636.txt rename to .riot/requirements/6fe81be.txt index da175e96287..f49865ef3bd 100644 --- a/.riot/requirements/7f8c636.txt +++ b/.riot/requirements/6fe81be.txt @@ -2,9 +2,10 @@ # This file is autogenerated by pip-compile with Python 3.7 # by the following command: # -# pip-compile --allow-unsafe --config=pyproject.toml --no-annotate --resolver=backtracking .riot/requirements/7f8c636.in +# pip-compile --allow-unsafe --config=pyproject.toml --no-annotate --resolver=backtracking .riot/requirements/6fe81be.in # attrs==24.2.0 +colorama==0.4.6 coverage[toml]==7.2.7 exceptiongroup==1.2.2 gunicorn==23.0.0 @@ -22,13 +23,14 @@ pytest==7.4.4 pytest-asyncio==0.21.1 pytest-benchmark==4.0.0 pytest-cov==4.1.0 +pytest-cpp==2.5.0 pytest-mock==3.11.1 pytest-randomly==3.12.0 six==1.16.0 sortedcontainers==2.4.0 tomli==2.0.1 typing-extensions==4.7.1 -uwsgi==2.0.26 +uwsgi==2.0.27 zipp==3.15.0 # The following packages are considered to be unsafe in a requirements file: diff --git a/.riot/requirements/1aecc60.txt b/.riot/requirements/a541d7e.txt similarity index 85% rename from .riot/requirements/1aecc60.txt rename to .riot/requirements/a541d7e.txt index feb58960c23..8b110208b7f 100644 --- a/.riot/requirements/1aecc60.txt +++ b/.riot/requirements/a541d7e.txt @@ -2,10 +2,10 @@ # This file is autogenerated by pip-compile with Python 3.11 # by the following command: # -# pip-compile --allow-unsafe --no-annotate .riot/requirements/1aecc60.in +# pip-compile --allow-unsafe --no-annotate .riot/requirements/a541d7e.in # attrs==24.2.0 -coverage[toml]==7.6.1 +coverage[toml]==7.6.3 gunicorn==23.0.0 hypothesis==6.45.0 iniconfig==2.0.0 @@ -16,11 +16,12 @@ packaging==24.1 pluggy==1.5.0 protobuf==4.22.0 py-cpuinfo==8.0.0 -pytest==8.3.2 +pytest==8.3.3 pytest-asyncio==0.21.1 pytest-benchmark==4.0.0 pytest-cov==5.0.0 +pytest-cpp==2.6.0 pytest-mock==3.14.0 pytest-randomly==3.15.0 sortedcontainers==2.4.0 -uwsgi==2.0.26 +uwsgi==2.0.27 diff --git a/.riot/requirements/167dd48.txt b/.riot/requirements/b83f7ca.txt similarity index 73% rename from .riot/requirements/167dd48.txt rename to .riot/requirements/b83f7ca.txt index e3580c6518a..72d6ac027ea 100644 --- a/.riot/requirements/167dd48.txt +++ b/.riot/requirements/b83f7ca.txt @@ -2,16 +2,16 @@ # This file is autogenerated by pip-compile with Python 3.9 # by the following command: # -# pip-compile --allow-unsafe --no-annotate .riot/requirements/167dd48.in +# pip-compile --allow-unsafe --no-annotate .riot/requirements/b83f7ca.in # attrs==24.2.0 -coverage[toml]==7.6.1 +coverage[toml]==7.6.3 exceptiongroup==1.2.2 -gevent==24.2.1 -greenlet==3.0.3 +gevent==24.10.2 +greenlet==3.1.1 gunicorn[gevent]==23.0.0 hypothesis==6.45.0 -importlib-metadata==8.4.0 +importlib-metadata==8.5.0 iniconfig==2.0.0 lz4==4.3.3 mock==5.1.0 @@ -19,18 +19,19 @@ opentracing==2.4.0 packaging==24.1 pluggy==1.5.0 py-cpuinfo==8.0.0 -pytest==8.3.2 +pytest==8.3.3 pytest-asyncio==0.21.1 pytest-benchmark==4.0.0 pytest-cov==5.0.0 +pytest-cpp==2.6.0 pytest-mock==3.14.0 pytest-randomly==3.15.0 sortedcontainers==2.4.0 -tomli==2.0.1 -uwsgi==2.0.26 -zipp==3.20.1 +tomli==2.0.2 +uwsgi==2.0.27 +zipp==3.20.2 zope-event==5.0 -zope-interface==7.0.3 +zope-interface==7.1.0 # The following packages are considered to be unsafe in a requirements file: -setuptools==74.1.2 +setuptools==75.2.0 diff --git a/.riot/requirements/8a0f886.txt b/.riot/requirements/d2b6740.txt similarity index 84% rename from .riot/requirements/8a0f886.txt rename to .riot/requirements/d2b6740.txt index 19b8536b36e..83fed7d33d5 100644 --- a/.riot/requirements/8a0f886.txt +++ b/.riot/requirements/d2b6740.txt @@ -2,9 +2,10 @@ # This file is autogenerated by pip-compile with Python 3.7 # by the following command: # -# pip-compile --allow-unsafe --config=pyproject.toml --no-annotate --resolver=backtracking .riot/requirements/8a0f886.in +# pip-compile --allow-unsafe --config=pyproject.toml --no-annotate --resolver=backtracking .riot/requirements/d2b6740.in # attrs==24.2.0 +colorama==0.4.6 coverage[toml]==7.2.7 exceptiongroup==1.2.2 gunicorn==23.0.0 @@ -22,10 +23,11 @@ pytest==7.4.4 pytest-asyncio==0.21.1 pytest-benchmark==4.0.0 pytest-cov==4.1.0 +pytest-cpp==2.5.0 pytest-mock==3.11.1 pytest-randomly==3.12.0 sortedcontainers==2.4.0 tomli==2.0.1 typing-extensions==4.7.1 -uwsgi==2.0.26 +uwsgi==2.0.27 zipp==3.15.0 diff --git a/.riot/requirements/1e17619.txt b/.riot/requirements/d3718d9.txt similarity index 79% rename from .riot/requirements/1e17619.txt rename to .riot/requirements/d3718d9.txt index 11ba3494e76..83abce2c34c 100644 --- a/.riot/requirements/1e17619.txt +++ b/.riot/requirements/d3718d9.txt @@ -2,29 +2,30 @@ # This file is autogenerated by pip-compile with Python 3.8 # by the following command: # -# pip-compile --allow-unsafe --no-annotate .riot/requirements/1e17619.in +# pip-compile --allow-unsafe --no-annotate .riot/requirements/d3718d9.in # attrs==24.2.0 coverage[toml]==7.6.1 exceptiongroup==1.2.2 gunicorn==23.0.0 hypothesis==6.45.0 -importlib-metadata==8.4.0 +importlib-metadata==8.5.0 iniconfig==2.0.0 lz4==4.3.3 mock==5.1.0 opentracing==2.4.0 packaging==24.1 pluggy==1.5.0 -protobuf==5.28.0 +protobuf==5.28.2 py-cpuinfo==8.0.0 -pytest==8.3.2 +pytest==8.3.3 pytest-asyncio==0.21.1 pytest-benchmark==4.0.0 pytest-cov==5.0.0 +pytest-cpp==2.6.0 pytest-mock==3.14.0 pytest-randomly==3.15.0 sortedcontainers==2.4.0 -tomli==2.0.1 -uwsgi==2.0.26 -zipp==3.20.1 +tomli==2.0.2 +uwsgi==2.0.27 +zipp==3.20.2 diff --git a/.riot/requirements/11aeb6a.txt b/.riot/requirements/d62d369.txt similarity index 79% rename from .riot/requirements/11aeb6a.txt rename to .riot/requirements/d62d369.txt index 9107c0564a8..4e6a1334fb6 100644 --- a/.riot/requirements/11aeb6a.txt +++ b/.riot/requirements/d62d369.txt @@ -2,7 +2,7 @@ # This file is autogenerated by pip-compile with Python 3.12 # by the following command: # -# pip-compile --allow-unsafe --no-annotate .riot/requirements/11aeb6a.in +# pip-compile --allow-unsafe --no-annotate .riot/requirements/d62d369.in # attrs==24.2.0 coverage[toml]==7.6.4 @@ -18,9 +18,10 @@ protobuf==4.22.0 py-cpuinfo==8.0.0 pytest==8.3.3 pytest-asyncio==0.21.1 -pytest-benchmark==4.0.0 -pytest-cov==5.0.0 +pytest-benchmark==5.1.0 +pytest-cov==6.0.0 +pytest-cpp==2.6.0 pytest-mock==3.14.0 -pytest-randomly==3.15.0 +pytest-randomly==3.16.0 sortedcontainers==2.4.0 -uwsgi==2.0.27 +uwsgi==2.0.28 diff --git a/.riot/requirements/18d2618.txt b/.riot/requirements/f59e90e.txt similarity index 75% rename from .riot/requirements/18d2618.txt rename to .riot/requirements/f59e90e.txt index b9b6eae6054..61250075c82 100644 --- a/.riot/requirements/18d2618.txt +++ b/.riot/requirements/f59e90e.txt @@ -2,29 +2,30 @@ # This file is autogenerated by pip-compile with Python 3.9 # by the following command: # -# pip-compile --allow-unsafe --no-annotate .riot/requirements/18d2618.in +# pip-compile --allow-unsafe --no-annotate .riot/requirements/f59e90e.in # attrs==24.2.0 -coverage[toml]==7.6.1 +coverage[toml]==7.6.3 exceptiongroup==1.2.2 gunicorn==23.0.0 hypothesis==6.45.0 -importlib-metadata==8.4.0 +importlib-metadata==8.5.0 iniconfig==2.0.0 lz4==4.3.3 mock==5.1.0 opentracing==2.4.0 packaging==24.1 pluggy==1.5.0 -protobuf==5.28.0 +protobuf==5.28.2 py-cpuinfo==8.0.0 -pytest==8.3.2 +pytest==8.3.3 pytest-asyncio==0.21.1 pytest-benchmark==4.0.0 pytest-cov==5.0.0 +pytest-cpp==2.6.0 pytest-mock==3.14.0 pytest-randomly==3.15.0 sortedcontainers==2.4.0 -tomli==2.0.1 -uwsgi==2.0.26 -zipp==3.20.1 +tomli==2.0.2 +uwsgi==2.0.27 +zipp==3.20.2 diff --git a/ddtrace/internal/datadog/profiling/dd_wrapper/test/CMakeLists.txt b/ddtrace/internal/datadog/profiling/dd_wrapper/test/CMakeLists.txt index 9ff45b93108..e7fe2ceb3ed 100644 --- a/ddtrace/internal/datadog/profiling/dd_wrapper/test/CMakeLists.txt +++ b/ddtrace/internal/datadog/profiling/dd_wrapper/test/CMakeLists.txt @@ -22,11 +22,18 @@ function(dd_wrapper_add_test name) add_ddup_config(${name}) gtest_discover_tests(${name}) + + set_target_properties(${name} PROPERTIES INSTALL_RPATH "$ORIGIN/..") + + if(LIB_INSTALL_DIR) + install(TARGETS ${name} + RUNTIME DESTINATION ${LIB_INSTALL_DIR}/../test) + endif() endfunction() # Add the tests -dd_wrapper_add_test(initialization initialization.cpp) -dd_wrapper_add_test(api api.cpp) -dd_wrapper_add_test(threading threading.cpp) -dd_wrapper_add_test(forking forking.cpp) -dd_wrapper_add_test(code_provenance code_provenance.cpp) +dd_wrapper_add_test(test_initialization test_initialization.cpp) +dd_wrapper_add_test(test_api test_api.cpp) +dd_wrapper_add_test(test_threading test_threading.cpp) +dd_wrapper_add_test(test_forking test_forking.cpp) +dd_wrapper_add_test(test_code_provenance test_code_provenance.cpp) diff --git a/ddtrace/internal/datadog/profiling/dd_wrapper/test/api.cpp b/ddtrace/internal/datadog/profiling/dd_wrapper/test/test_api.cpp similarity index 100% rename from ddtrace/internal/datadog/profiling/dd_wrapper/test/api.cpp rename to ddtrace/internal/datadog/profiling/dd_wrapper/test/test_api.cpp diff --git a/ddtrace/internal/datadog/profiling/dd_wrapper/test/code_provenance.cpp b/ddtrace/internal/datadog/profiling/dd_wrapper/test/test_code_provenance.cpp similarity index 100% rename from ddtrace/internal/datadog/profiling/dd_wrapper/test/code_provenance.cpp rename to ddtrace/internal/datadog/profiling/dd_wrapper/test/test_code_provenance.cpp diff --git a/ddtrace/internal/datadog/profiling/dd_wrapper/test/forking.cpp b/ddtrace/internal/datadog/profiling/dd_wrapper/test/test_forking.cpp similarity index 99% rename from ddtrace/internal/datadog/profiling/dd_wrapper/test/forking.cpp rename to ddtrace/internal/datadog/profiling/dd_wrapper/test/test_forking.cpp index e7af54abc10..e02849248e6 100644 --- a/ddtrace/internal/datadog/profiling/dd_wrapper/test/forking.cpp +++ b/ddtrace/internal/datadog/profiling/dd_wrapper/test/test_forking.cpp @@ -64,7 +64,7 @@ sample_in_threads_and_fork(unsigned int num_threads, unsigned int sleep_time_ns) int status; done.store(true); waitpid(pid, &status, 0); - upload_in_thread(); + ddup_upload(); if (!is_exit_normal(status)) { std::exit(1); } diff --git a/ddtrace/internal/datadog/profiling/dd_wrapper/test/initialization.cpp b/ddtrace/internal/datadog/profiling/dd_wrapper/test/test_initialization.cpp similarity index 100% rename from ddtrace/internal/datadog/profiling/dd_wrapper/test/initialization.cpp rename to ddtrace/internal/datadog/profiling/dd_wrapper/test/test_initialization.cpp diff --git a/ddtrace/internal/datadog/profiling/dd_wrapper/test/threading.cpp b/ddtrace/internal/datadog/profiling/dd_wrapper/test/test_threading.cpp similarity index 100% rename from ddtrace/internal/datadog/profiling/dd_wrapper/test/threading.cpp rename to ddtrace/internal/datadog/profiling/dd_wrapper/test/test_threading.cpp diff --git a/ddtrace/internal/datadog/profiling/stack_v2/test/CMakeLists.txt b/ddtrace/internal/datadog/profiling/stack_v2/test/CMakeLists.txt index 23fcda3eedb..dd8e149f54c 100644 --- a/ddtrace/internal/datadog/profiling/stack_v2/test/CMakeLists.txt +++ b/ddtrace/internal/datadog/profiling/stack_v2/test/CMakeLists.txt @@ -15,11 +15,24 @@ include(AnalysisFunc) function(dd_wrapper_add_test name) add_executable(${name} ${ARGN}) target_include_directories(${name} PRIVATE ../include) - target_link_libraries(${name} PRIVATE gmock gtest_main _stack_v2) + # this has to refer to the stack_v2 extension name to properly link against + target_link_libraries(${name} PRIVATE gmock gtest_main ${EXTENSION_NAME}) + set_target_properties(${name} PROPERTIES INSTALL_RPATH "$ORIGIN/../stack_v2") + add_ddup_config(${name}) gtest_discover_tests(${name}) + + # This is supplemental artifact so make sure to install it in the right place + if(INPLACE_LIB_INSTALL_DIR) + set(LIB_INSTALL_DIR "${INPLACE_LIB_INSTALL_DIR}") + endif() + + if(LIB_INSTALL_DIR) + install(TARGETS ${name} + RUNTIME DESTINATION ${LIB_INSTALL_DIR}/../test) + endif() endfunction() # Add the tests -dd_wrapper_add_test(thread_span_links thread_span_links.cpp) +dd_wrapper_add_test(test_thread_span_links test_thread_span_links.cpp) diff --git a/ddtrace/internal/datadog/profiling/stack_v2/test/thread_span_links.cpp b/ddtrace/internal/datadog/profiling/stack_v2/test/test_thread_span_links.cpp similarity index 100% rename from ddtrace/internal/datadog/profiling/stack_v2/test/thread_span_links.cpp rename to ddtrace/internal/datadog/profiling/stack_v2/test/test_thread_span_links.cpp diff --git a/ddtrace/internal/datadog/profiling/test/.gitignore b/ddtrace/internal/datadog/profiling/test/.gitignore new file mode 100644 index 00000000000..d6b7ef32c84 --- /dev/null +++ b/ddtrace/internal/datadog/profiling/test/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/riotfile.py b/riotfile.py index 31b91fd889c..c31945aedf3 100644 --- a/riotfile.py +++ b/riotfile.py @@ -2966,10 +2966,16 @@ def select_pys(min_version=MIN_PYTHON_VERSION, max_version=MAX_PYTHON_VERSION): name="profile-v2", # NB riot commands that use this Venv must include --pass-env to work properly command="python -m tests.profiling.run pytest -v --no-cov --capture=no --benchmark-disable {cmdargs} tests/profiling_v2", # noqa: E501 - env={"DD_PROFILING_ENABLE_ASSERTS": "1", "DD_PROFILING_EXPORT_LIBDD_ENABLED": "1"}, + env={ + "DD_PROFILING_ENABLE_ASSERTS": "1", + "DD_PROFILING_EXPORT_LIBDD_ENABLED": "1", + # Enable pytest v2 plugin to handle pytest-cpp items in the test suite + "_DD_CIVISIBILITY_USE_PYTEST_V2": "1", + }, pkgs={ "gunicorn": latest, "lz4": latest, + "pytest-cpp": latest, # # pytest-benchmark depends on cpuinfo which dropped support for Python<=3.6 in 9.0 # See https://github.com/workhorsy/py-cpuinfo/issues/177 diff --git a/setup.py b/setup.py index 727de14e037..ce1aa685596 100644 --- a/setup.py +++ b/setup.py @@ -53,6 +53,8 @@ CRASHTRACKER_DIR = HERE / "ddtrace" / "internal" / "datadog" / "profiling" / "crashtracker" STACK_V2_DIR = HERE / "ddtrace" / "internal" / "datadog" / "profiling" / "stack_v2" +BUILD_PROFILING_NATIVE_TESTS = os.getenv("DD_PROFILING_NATIVE_TESTS", "0").lower() in ("1", "yes", "on", "true") + CURRENT_OS = platform.system() LIBDDWAF_VERSION = "1.20.1" @@ -349,6 +351,9 @@ def build_extension_cmake(self, ext): "-DEXTENSION_NAME={}".format(extension_basename), ] + if BUILD_PROFILING_NATIVE_TESTS: + cmake_args += ["-DBUILD_TESTING=ON"] + # If it's been enabled, also propagate sccache to the CMake build. We have to manually set the default CC/CXX # compilers here, because otherwise the way we wrap sccache will conflict with the CMake wrappers sccache_path = os.getenv("DD_SCCACHE_PATH") @@ -567,7 +572,9 @@ def get_exts_for(name): "ddtrace.appsec": ["rules.json"], "ddtrace.appsec._ddwaf": ["libddwaf/*/lib/libddwaf.*"], "ddtrace.appsec._iast._taint_tracking": ["CMakeLists.txt"], - "ddtrace.internal.datadog.profiling": ["libdd_wrapper*.*"], + "ddtrace.internal.datadog.profiling": ( + ["libdd_wrapper*.*"] + ["ddtrace/internal/datadog/profiling/test/*"] if BUILD_PROFILING_NATIVE_TESTS else [] + ), "ddtrace.internal.datadog.profiling.crashtracker": ["crashtracker_exe*"], }, zip_safe=False, diff --git a/tests/profiling_v2/native_tests b/tests/profiling_v2/native_tests new file mode 120000 index 00000000000..9173c0212ba --- /dev/null +++ b/tests/profiling_v2/native_tests @@ -0,0 +1 @@ +../../ddtrace/internal/datadog/profiling/test \ No newline at end of file