datadog-agent icon indicating copy to clipboard operation
datadog-agent copied to clipboard

[CI] Upload JUnit and Coverage to Datadog and Codecov

Open amenasria opened this issue 1 year ago • 2 comments

What does this PR do?

This PR uploads:

  • the JUnit data to Datadog to display the Unit Tests info in Test Visibility.
  • the coverage data to Codecov.

Motivation

Better visibility & coverage.

Additional Notes

Possible Drawbacks / Trade-offs

Describe how to test/QA your changes

amenasria avatar Aug 28 '24 11:08 amenasria

Regression Detector

Regression Detector Results

Run ID: facfcbe0-ea61-4227-907b-507f95fad775 Metrics dashboard Target profiles

Baseline: 3b921baa5fbb9f1633406c66a9b52aa13a069041 Comparison: b675f1fb332b5d7f958c136ea5e50ce2d9b92070

Performance changes are noted in the perf column of each table:

  • ✅ = significantly better comparison variant performance
  • ❌ = significantly worse comparison variant performance
  • ➖ = no significant change in performance

No significant changes in experiment optimization goals

Confidence level: 90.00% Effect size tolerance: |Δ mean %| ≥ 5.00%

There were no significant changes in experiment optimization goals at this confidence level and effect size tolerance.

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI trials links
otel_to_otel_logs ingress throughput +1.05 [+0.24, +1.86] 1 Logs
file_tree memory utilization +0.69 [+0.61, +0.78] 1 Logs
uds_dogstatsd_to_api_cpu % cpu utilization +0.26 [-0.49, +1.01] 1 Logs
tcp_dd_logs_filter_exclude ingress throughput -0.00 [-0.01, +0.01] 1 Logs
uds_dogstatsd_to_api ingress throughput -0.03 [-0.11, +0.05] 1 Logs
idle memory utilization -0.09 [-0.14, -0.04] 1 Logs
tcp_syslog_to_blackhole ingress throughput -0.13 [-0.18, -0.07] 1 Logs
pycheck_lots_of_tags % cpu utilization -0.90 [-3.33, +1.54] 1 Logs
basic_py_check % cpu utilization -1.02 [-3.76, +1.72] 1 Logs

Bounds Checks

perf experiment bounds_check_name replicates_passed
idle memory_usage 10/10

Explanation

A regression test is an A/B test of target performance in a repeatable rig, where "performance" is measured as "comparison variant minus baseline variant" for an optimization goal (e.g., ingress throughput). Due to intrinsic variability in measuring that goal, we can only estimate its mean value for each experiment; we report uncertainty in that value as a 90.00% confidence interval denoted "Δ mean % CI".

For each experiment, we decide whether a change in performance is a "regression" -- a change worth investigating further -- if all of the following criteria are true:

  1. Its estimated |Δ mean %| ≥ 5.00%, indicating the change is big enough to merit a closer look.

  2. Its 90.00% confidence interval "Δ mean % CI" does not contain zero, indicating that if our statistical model is accurate, there is at least a 90.00% chance there is a difference in performance between baseline and comparison variants.

  3. Its configuration does not mark it "erratic".

pr-commenter[bot] avatar Aug 28 '24 12:08 pr-commenter[bot]

Gitlab CI Configuration Changes

Modified Jobs

.tests_macos_gitlab
  .tests_macos_gitlab:
    allow_failure: true
+   artifacts:
+     expire_in: 2 weeks
+     paths:
+     - $TEST_OUTPUT_FILE
+     - junit-*.tgz
+     reports:
+       annotations:
+       - $EXTERNAL_LINKS_PATH
+       junit: '**/junit-out-*.xml'
+     when: always
    before_script:
    - 'eval $(gimme $(cat .go-version))
  
      export GOPATH=$GOROOT
  
      echo "Don''t forget to regularly delete unused versions. Here are the installed
      versions and their memory usage on the runner:"
  
      du -sh $HOME/.gimme/versions/*
  
      '
    - "PYTHON_REPO_VERSION=$(cat .python-version)\nPYTHON_VERSION=$(python3 --version\
      \ | awk '{print $2}' | sed 's/\\.[0-9]*$//')\nif [ \"$PYTHON_REPO_VERSION\" !=\
      \ \"$PYTHON_VERSION\" ]; then\n  echo \"Python version $PYTHON_VERSION is different\
      \ from $PYTHON_REPO_VERSION in .python-version. Cleaning the environment.\"\n\
      \  pyenv uninstall -f datadog-agent\n  echo \"Installing Python $PYTHON_REPO_VERSION...\"\
      \n  pyenv virtualenv 3.11.8 datadog-agent\n  pyenv activate datadog-agent\nelse\n\
      \  echo \"Python current version $PYTHON_VERSION is the same as .python-version.\
      \ Keeping the existing environment.\"\nfi\n"
    - python3 -m pip install -r requirements.txt -r tasks/libs/requirements-github.txt
    - pyenv rehash
    - inv -e rtloader.make --python-runtimes $PYTHON_RUNTIMES
    - inv -e rtloader.install
    - inv -e install-tools
    - inv -e deps
    needs:
    - setup_agent_version
    rules:
    - if: $CI_COMMIT_BRANCH =~ /^mq-working-branch-/
      when: never
    - allow_failure: true
      when: manual
    script:
+   - inv -e gitlab.generate-ci-visibility-links --output=$EXTERNAL_LINKS_PATH
    - FAST_TESTS_FLAG=""
    - if [[ "$FAST_TESTS" == "true" ]]; then FAST_TESTS_FLAG="--only-impacted-packages";
      fi
    - inv -e test --rerun-fails=2 --python-runtimes $PYTHON_RUNTIMES --race --profile
      --cpus 12 --save-result-json $TEST_OUTPUT_FILE --junit-tar "junit-${CI_JOB_NAME}.tgz"
      $FAST_TESTS_FLAG
    - inv -e invoke-unit-tests
    stage: source_test
    variables:
      PYTHON_RUNTIMES: '3'
      TEST_OUTPUT_FILE: test_output.json
tests_macos_gitlab_amd64
  tests_macos_gitlab_amd64:
+   after_script:
+   - $CI_PROJECT_DIR/tools/ci/junit_upload.sh
+   - CODECOV_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $CODECOV_TOKEN) || exit
+     $?; export CODECOV_TOKEN
+   - inv -e coverage.upload-to-codecov $COVERAGE_CACHE_FLAG || true
    allow_failure: true
+   artifacts:
+     expire_in: 2 weeks
+     paths:
+     - $TEST_OUTPUT_FILE
+     - junit-*.tgz
+     reports:
+       annotations:
+       - $EXTERNAL_LINKS_PATH
+       junit:
+       - '**/junit-out-*.xml'
+     when: always
    before_script:
    - 'eval $(gimme $(cat .go-version))
  
      export GOPATH=$GOROOT
  
      echo "Don''t forget to regularly delete unused versions. Here are the installed
      versions and their memory usage on the runner:"
  
      du -sh $HOME/.gimme/versions/*
  
      '
    - "PYTHON_REPO_VERSION=$(cat .python-version)\nPYTHON_VERSION=$(python3 --version\
      \ | awk '{print $2}' | sed 's/\\.[0-9]*$//')\nif [ \"$PYTHON_REPO_VERSION\" !=\
      \ \"$PYTHON_VERSION\" ]; then\n  echo \"Python version $PYTHON_VERSION is different\
      \ from $PYTHON_REPO_VERSION in .python-version. Cleaning the environment.\"\n\
      \  pyenv uninstall -f datadog-agent\n  echo \"Installing Python $PYTHON_REPO_VERSION...\"\
      \n  pyenv virtualenv 3.11.8 datadog-agent\n  pyenv activate datadog-agent\nelse\n\
      \  echo \"Python current version $PYTHON_VERSION is the same as .python-version.\
      \ Keeping the existing environment.\"\nfi\n"
    - python3 -m pip install -r requirements.txt -r tasks/libs/requirements-github.txt
    - pyenv rehash
    - inv -e rtloader.make --python-runtimes $PYTHON_RUNTIMES
    - inv -e rtloader.install
    - inv -e install-tools
    - inv -e deps
    needs:
    - setup_agent_version
    rules:
    - if: $CI_COMMIT_BRANCH =~ /^mq-working-branch-/
      when: never
    - allow_failure: true
      when: manual
    script:
+   - inv -e gitlab.generate-ci-visibility-links --output=$EXTERNAL_LINKS_PATH
    - FAST_TESTS_FLAG=""
    - if [[ "$FAST_TESTS" == "true" ]]; then FAST_TESTS_FLAG="--only-impacted-packages";
      fi
    - inv -e test --rerun-fails=2 --python-runtimes $PYTHON_RUNTIMES --race --profile
      --cpus 12 --save-result-json $TEST_OUTPUT_FILE --junit-tar "junit-${CI_JOB_NAME}.tgz"
      $FAST_TESTS_FLAG
    - inv -e invoke-unit-tests
    stage: source_test
    tags:
    - macos:monterey-amd64
    - specific:true
    variables:
      PYTHON_RUNTIMES: '3'
      TEST_OUTPUT_FILE: test_output.json
tests_macos_gitlab_arm64
  tests_macos_gitlab_arm64:
+   after_script:
+   - $CI_PROJECT_DIR/tools/ci/junit_upload.sh
+   - CODECOV_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $CODECOV_TOKEN) || exit
+     $?; export CODECOV_TOKEN
+   - inv -e coverage.upload-to-codecov $COVERAGE_CACHE_FLAG || true
    allow_failure: true
+   artifacts:
+     expire_in: 2 weeks
+     paths:
+     - $TEST_OUTPUT_FILE
+     - junit-*.tgz
+     reports:
+       annotations:
+       - $EXTERNAL_LINKS_PATH
+       junit:
+       - '**/junit-out-*.xml'
+     when: always
    before_script:
    - 'eval $(gimme $(cat .go-version))
  
      export GOPATH=$GOROOT
  
      echo "Don''t forget to regularly delete unused versions. Here are the installed
      versions and their memory usage on the runner:"
  
      du -sh $HOME/.gimme/versions/*
  
      '
    - "PYTHON_REPO_VERSION=$(cat .python-version)\nPYTHON_VERSION=$(python3 --version\
      \ | awk '{print $2}' | sed 's/\\.[0-9]*$//')\nif [ \"$PYTHON_REPO_VERSION\" !=\
      \ \"$PYTHON_VERSION\" ]; then\n  echo \"Python version $PYTHON_VERSION is different\
      \ from $PYTHON_REPO_VERSION in .python-version. Cleaning the environment.\"\n\
      \  pyenv uninstall -f datadog-agent\n  echo \"Installing Python $PYTHON_REPO_VERSION...\"\
      \n  pyenv virtualenv 3.11.8 datadog-agent\n  pyenv activate datadog-agent\nelse\n\
      \  echo \"Python current version $PYTHON_VERSION is the same as .python-version.\
      \ Keeping the existing environment.\"\nfi\n"
    - python3 -m pip install -r requirements.txt -r tasks/libs/requirements-github.txt
    - pyenv rehash
    - inv -e rtloader.make --python-runtimes $PYTHON_RUNTIMES
    - inv -e rtloader.install
    - inv -e install-tools
    - inv -e deps
    needs:
    - setup_agent_version
    rules:
    - if: $CI_COMMIT_BRANCH =~ /^mq-working-branch-/
      when: never
    - allow_failure: true
      when: manual
    script:
+   - inv -e gitlab.generate-ci-visibility-links --output=$EXTERNAL_LINKS_PATH
    - FAST_TESTS_FLAG=""
    - if [[ "$FAST_TESTS" == "true" ]]; then FAST_TESTS_FLAG="--only-impacted-packages";
      fi
    - inv -e test --rerun-fails=2 --python-runtimes $PYTHON_RUNTIMES --race --profile
      --cpus 12 --save-result-json $TEST_OUTPUT_FILE --junit-tar "junit-${CI_JOB_NAME}.tgz"
      $FAST_TESTS_FLAG
    - inv -e invoke-unit-tests
    stage: source_test
    tags:
    - macos:monterey-arm64
    - specific:true
    variables:
      PYTHON_RUNTIMES: '3'
      TEST_OUTPUT_FILE: test_output.json

Changes Summary

Removed Modified Added Renamed
0 3 0 0

pr-commenter[bot] avatar Aug 28 '24 14:08 pr-commenter[bot]

/merge

amenasria avatar Sep 24 '24 14:09 amenasria

:steam_locomotive: MergeQueue: waiting for PR to be ready

This merge request is not mergeable yet, because of pending checks/missing approvals. It will be added to the queue as soon as checks pass and/or get approvals. Note: if you pushed new commits since the last approval, you may need additional approval. You can remove it from the waiting list with /remove command.

Use /merge -c to cancel this operation!

dd-devflow[bot] avatar Sep 24 '24 14:09 dd-devflow[bot]

:warning: MergeQueue: This merge request was unqueued

This merge request was unqueued

If you need support, contact us on Slack #devflow!

dd-devflow[bot] avatar Sep 24 '24 18:09 dd-devflow[bot]

/merge

amenasria avatar Sep 25 '24 08:09 amenasria

:steam_locomotive: MergeQueue: waiting for PR to be ready

This merge request is not mergeable yet, because of pending checks/missing approvals. It will be added to the queue as soon as checks pass and/or get approvals. Note: if you pushed new commits since the last approval, you may need additional approval. You can remove it from the waiting list with /remove command.

Use /merge -c to cancel this operation!

dd-devflow[bot] avatar Sep 25 '24 08:09 dd-devflow[bot]

:warning: MergeQueue: This merge request was unqueued

This merge request was unqueued

If you need support, contact us on Slack #devflow!

dd-devflow[bot] avatar Sep 25 '24 12:09 dd-devflow[bot]

/merge

amenasria avatar Sep 25 '24 14:09 amenasria

:steam_locomotive: MergeQueue: pull request added to the queue

The median merge time in main is 23m.

Use /merge -c to cancel this operation!

dd-devflow[bot] avatar Sep 25 '24 14:09 dd-devflow[bot]