feat: add sessionID HTTP Header to the Docker client setup#570
Merged
mdelapenya merged 5 commits intotestcontainers:mainfrom Oct 18, 2022
Merged
feat: add sessionID HTTP Header to the Docker client setup#570mdelapenya merged 5 commits intotestcontainers:mainfrom
mdelapenya merged 5 commits intotestcontainers:mainfrom
Conversation
mdelapenya
commented
Oct 18, 2022
| } | ||
|
|
||
| // include reaper-specific labels to the reaper container | ||
| for k, v := range reaper.Labels() { |
Member
Author
There was a problem hiding this comment.
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 |
kiview
approved these changes
Oct 18, 2022
Member
kiview
left a comment
There was a problem hiding this comment.
Makes semantically sense from my testcontainers-java point of view 👍 (can't comment on any Go specifics).
HofmeisterAn
approved these changes
Oct 18, 2022
Contributor
HofmeisterAn
left a comment
There was a problem hiding this comment.
Makes semantically sense from my
testcontainers-javapoint of view 👍 (can't comment on any Go specifics).
Same for .NET.
mdelapenya
referenced
this pull request
in mdelapenya/testcontainers-go
Oct 18, 2022
* 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
mdelapenya
referenced
this pull request
in mdelapenya/testcontainers-go
Oct 18, 2022
* main: feat: add sessionID HTTP Header to the Docker client setup (#570)
mdelapenya
added a commit
that referenced
this pull request
Oct 19, 2022
* 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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