Skip to content

Set RESOURCE_LOCK for tests with shared resources - #4718

Draft
panicgh wants to merge 2 commits into
open-telemetry:mainfrom
panicgh:test-resource-lock
Draft

panicgh wants to merge 2 commits into
open-telemetry:mainfrom
panicgh:test-resource-lock

Conversation

@panicgh

@panicgh panicgh commented Oct 20, 2026

Copy link
Copy Markdown

Some unit tests share resources, which causes them to fail if executed in parallel.

  • curl_http_test uses port 19000
  • prometheus exporter_test uses port 9464, bound by the prometheus-cpp Exposer that the exporter constructor starts

RESOURCE_LOCK is a named mutex between tests: cases holding the same lock never run concurrently. Using two distinct lock names keeps the two groups parallel with each other and with everything else.

See https://cmake.org/cmake/help/v4.5/prop_test/RESOURCE_LOCK.html

Changes

Please provide a brief description of the changes here.

For significant contributions please make sure you have completed the following items:

  • CHANGELOG.md updated for non-trivial changes
  • Unit tests have been added
  • Changes in public API reviewed

@panicgh
panicgh requested a review from a team as a code owner October 20, 2026 13:38
@linux-foundation-easycla

linux-foundation-easycla Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

CLA Missing ID

One or more co-authors of this pull request were not found. You must specify co-authors in commit message trailer via:

Co-authored-by: name <email>

Supported Co-authored-by: formats include:

  1. Anything <id+login@users.noreply.github.com> - it will locate your GitHub user by id part.
  2. Anything <login@users.noreply.github.com> - it will locate your GitHub user by login part.
  3. Anything <public-email> - it will locate your GitHub user by public-email part. Note that this email must be made public on Github.
  4. Anything <other-email> - it will locate your GitHub user by other-email part but only if that email was used before for any other CLA as a main commit author.
  5. login <any-valid-email> - it will locate your GitHub user by login part, note that login part must be at least 3 characters long.

Alternatively, if the co-author should not be included, remove the Co-authored-by: line from the commit message.

Please update your commit message(s) by doing git commit --amend and then git push [--force] and then request re-running CLA check via commenting on this pull request:

/easycla

@marcalff

Copy link
Copy Markdown
Member

Thanks for the fix.

Please apply the following patch (from CI logs) to fix format errors:

diff --git a/ext/test/http/CMakeLists.txt b/ext/test/http/CMakeLists.txt
index 2ba4937..671527b 100644
--- a/ext/test/http/CMakeLists.txt
+++ b/ext/test/http/CMakeLists.txt
@@ -42,5 +42,6 @@ gtest_add_tests(
 
 # curl_http_test.cc: every case drives a server on port 19000.
 if(OTELCPP_WITH_HTTP_CLIENT_CURL)
-  set_tests_properties(${curl_http_test} PROPERTIES RESOURCE_LOCK otelcpp_port_19000)
+  set_tests_properties(${curl_http_test} PROPERTIES RESOURCE_LOCK
+                                                    otelcpp_port_19000)
 endif()

Please sign the EasyCLA, so this fix can be merged.

@codecov

codecov Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.52%. Comparing base (374145e) to head (10d0236).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4718      +/-   ##
==========================================
+ Coverage   86.51%   86.52%   +0.01%     
==========================================
  Files         530      530              
  Lines       21138    21138              
==========================================
+ Hits        18286    18288       +2     
+ Misses       2852     2850       -2     

see 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@panicgh
panicgh marked this pull request as draft October 20, 2026 19:39
Some unit tests share resources, which causes them to fail if executed
in parallel.

* curl_http_test uses port 19000
* prometheus exporter_test uses port 9464, bound by the prometheus-cpp
  Exposer that the exporter constructor starts

RESOURCE_LOCK is a named mutex between tests: cases holding the same
lock never run concurrently. Using two distinct lock names keeps the two
groups parallel with each other and with everything else.

See https://cmake.org/cmake/help/v4.5/prop_test/RESOURCE_LOCK.html

Signed-off-by: Nicolas Benes <nbenes.gh@xandea.de>
Co-authored-by: Jean-François Roche <jfroche@pyxel.be>
Co-authored-by: Nicolas Benes <nbenes.gh@xandea.de>
@panicgh
panicgh force-pushed the test-resource-lock branch from 86e8e0a to a67224a Compare October 21, 2026 20:23
@panicgh

panicgh commented Oct 21, 2026

Copy link
Copy Markdown
Author

/easycla

1 similar comment
@marcalff

Copy link
Copy Markdown
Member

/easycla

@mateenali66 mateenali66 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Format still fails, now on the prometheus file. The job log has the patch.

On main 374145e, ctest -j fails both groups: prometheus exporter_test in 41 of 100 runs on the 9464 bind, curl 7 to 11 of 43 cases in each of 5 runs. With this PR json-v1 shows the lock on all 44 curl and 3 prometheus entries, and every parallel run passed.

Heads-up on #4730, which moves to gtest_discover_tests. Its test list only exists inside ctest, so merged with it ${curl_http_test} and ${exporter_test} are empty at configure time, configure stays quiet and the lock lands on 0 tests. The prometheus hunk merges with no conflict. gtest_discover_tests(... PROPERTIES RESOURCE_LOCK ...) put it back on all of them.

#4730 also splits the OTLP HTTP retry TEST_P (port 4318) into 40 entries, and 37 to 39 of 55 failed under -j8 there. Should otelcpp_port_4318 go in here, or with #4730?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:waiting-on-cla Waiting on CLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants