New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add sessionID HTTP Header to the Docker client setup #570
Conversation
@@ -72,6 +71,11 @@ func NewReaper(ctx context.Context, sessionID string, provider ReaperProvider, r | |||
WaitingFor: wait.ForListeningPort(listeningPort), | |||
} | |||
|
|||
// include reaper-specific labels to the reaper container | |||
for k, v := range reaper.Labels() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We identified that the Labels() function contains more information: about the SessionID
Codecov Report
@@ Coverage Diff @@
## main #570 +/- ##
===========================================
- Coverage 69.25% 34.43% -34.83%
===========================================
Files 22 13 -9
Lines 2202 1757 -445
===========================================
- Hits 1525 605 -920
- Misses 539 1056 +517
+ Partials 138 96 -42
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes semantically sense from my testcontainers-java
point of view 👍 (can't comment on any Go specifics).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes semantically sense from my
testcontainers-java
point of view 👍 (can't comment on any Go specifics).
Same for .NET.
* chore: create network's session ID for reaper, only * chore: include reaper-specific labels to the reaper container * feat: initialise sessionID just once * chore: do not expose the sessionID function * fix: update reaper tests
* main: feat: add sessionID HTTP Header to the Docker client setup (#570)
* fix: pass docker context key when reusing a container * feat: add sessionID HTTP Header to the Docker client setup (#570) * chore: create network's session ID for reaper, only * chore: include reaper-specific labels to the reaper container * feat: initialise sessionID just once * chore: do not expose the sessionID function * fix: update reaper tests * chore: add unit tests for extracting the docker host for reaper * chore: add tests for the docker host when it's passed as part of the context
What does this PR do?
It initialises the sessionID of the containers just once, as in the past it was created per-container, and this is not the expected behavior.
For that, we have created a global sessionID variable that is protected by sync.Once, therefore it's called just once.
This variable is used in the library with a singleton method, which is called from everywhere that a new UUID was required by a container. Therefore, all containers will share the same sessionID during a test execution/session.
Besides that, we detected a minor change in how the reaper was declaring its sessionID, using a variable with a wider scope: we have moved that sessionID variable to its own scope.
Finally, we are adding an HTTP header to the setup of the Docker client, which will allow improving tracing and other operations.
Why is it important
Better observability at the Docker API level, as we are instrumenting the HTTP requests.
With these changes we are also decoupling bit-by-bit the existing codebase: before them, the calculation of the sessionID happened everytime a container/network was created. Now, it happens just once per test execution.
Related issues