Skip to content

Commit efa5d8a

Browse files
authored
Add bazel coverage job for linux x86 (#54613)
<!--Please give us some feedback on your experience writing this PR ! https://app.datadoghq.com/forms/43db4c02-6837-400c-8083-692e141b1b88 !--> ### What does this PR do? - Drop an old and unused hybrid test job that combined both legacy `go test` and `bazel test` executions - Introduce a new coverage job for Linux x86 driven by Bazel. This is one of the chunks that is needed to ensure parity in CI functionality between legacy and Bazel driven activities. With this change we can now collect and compare coverage reports between `tests_linux-x64-py3` and `bazel:coverage` to identify blindspots and address them. ### Motivation This is one more step towards fully migrating unit testing to Bazel. Co-authored-by: joseph.gette <joseph.gette@datadoghq.com>
1 parent 3c9c9f9 commit efa5d8a

3 files changed

Lines changed: 18 additions & 26 deletions

File tree

.gitlab/build/bazel/test.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,22 @@
3232
.bazel:test:reporting:ci_links:
3333
- dda inv -- -e gitlab.generate-ci-visibility-links --output=$EXTERNAL_LINKS_PATH
3434

35+
bazel:coverage:linux-amd64:
36+
extends: [.bazel:test:reporting, .bazel:runner:linux-amd64, .bazel:test]
37+
script:
38+
- !reference [.bazel:test:reporting:ci_links]
39+
- bazel coverage --config=go --config=gorace --config=dd-agent-go-tests-only --jobs=$KUBERNETES_CPU_REQUEST --build_tests_only --keep_going --remote_download_outputs=toplevel --build_event_json_file=$BEP_FILE //...
40+
after_script:
41+
- !reference [.bazel:test:reporting, after_script]
42+
- cp "$(bazel info output_path)/_coverage/_coverage_report.dat" "$CI_PROJECT_DIR/coverage-bazel-$CI_JOB_NAME_SLUG.out"
43+
artifacts:
44+
paths:
45+
- junit-*.tgz
46+
- bazel-bep-*.json
47+
- coverage-bazel-*.out
48+
variables:
49+
KUBERNETES_CPU_REQUEST: 16
50+
3551
bazel:test:linux-amd64:
3652
extends: [.bazel:test:reporting, .bazel:runner:linux-amd64, .bazel:test]
3753
script:

.gitlab/build/source_test/linux.yml

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -60,32 +60,6 @@ tests_linux-x64-py3:
6060
variables:
6161
CONDA_ENV: ddpy3
6262

63-
tests_linux-x64-py3_hybrid:
64-
extends:
65-
- .bazel:runner:linux-arm64
66-
- .linux_tests
67-
- .linux_x64
68-
after_script:
69-
# In the hybrid test, bazel gets run, and that leaves a symlink to junit-out-base.xml. The uploader chokes on symlinks.
70-
- find $(bazel info execution_root) -type l -name 'junit-*.xml' -delete
71-
- !reference [.upload_junit_source]
72-
# skip coverage upload for several reasons
73-
# 1. It would conflate with coverate from the regular job
74-
# 2. the bazel tests are not doing coverage yet
75-
# 3. when bazel starts it makes the symlink .cache/bazel/…/execroot/_main/junit-out-AgentFlavor.base.xml
76-
# pointing to <top>/junit-out-AgentFlavor.base.xml. Then the coverage uploader fails on the symlink.
77-
# A possible fix for that is to change `datadog-ci coverage upload` so that it can gracefully
78-
# skip symlinks rather than choking. Or, we move XDG_CACHE out of the CI root.
79-
variables:
80-
CONDA_ENV: ddpy3
81-
EXPERIMENTAL_USE_BAZEL_TESTS: "1"
82-
allow_failure: true # This is for measurement during migration. It is not the actual test job.
83-
retry: 0 # allowed to fail, ~35 min exec time
84-
rules:
85-
- !reference [.except_mergequeue] # allowed to fail, not a gate at this stage
86-
- !reference [.except_disable_unit_tests]
87-
- !reference [.fast_on_dev_branch_only]
88-
8963
tests_flavor_iot_linux-x64:
9064
extends:
9165
- .linux_tests

bazel/configs/go_tests.bazelrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# last-wins rather than additive, so any config or command line that sets it has to
44
# repeat this exclusion.
55
test --test_tag_filters=-tagset_linux_bpf
6+
# To produce verbose test.xml files
7+
test --test_env=GO_TEST_WRAP_TESTV=1
68

79
# Go race detector for test invocations. Usage: bazel test --config=gorace //...
810
test:gorace --@rules_go//go/config:race

0 commit comments

Comments
 (0)