Skip to content

Integration tests keep connections in batches #2101

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

Merged

Conversation

JoukoVirtanen
Copy link
Contributor

@JoukoVirtanen JoukoVirtanen commented Apr 23, 2025

Description

Modified integration tests such that instead of simply maintaining a list of connections seen for each container, information about which scrape the connections were seen in is also maintained. To be more precise instead of having a map where the key is the container ID and the value is a list of all connections seen, there is now a map where the key is the container ID and the value is a 2D slice where the first index is the scrape. Scrapes with no connections are not saved, so there are no empty slices of connections.

This change was made to better test changes to the connections sent when runtime configuration is changed. More specifically if external IPs is initially disabled and then enabled, normalized connections should be reported closed in the same scrape interval as the unnormalized connections are reported as being open. Similar logic applies to when external IPs is initially enabled and then disabled.

That work was done here #2068

The integration tests here will continue to fail until the above PR is merged.

Checklist

  • Investigated and inspected CI test results
  • Updated documentation accordingly

Automated testing
- [ ] Added unit tests
- [ ] Added integration tests
- [ ] Added regression tests

This just changes some integration tests so these things are not needed.

Testing Performed

These integration tests were run without the changes from #2068 and failed as expected and are now passing with those changes, showing that these changes work and are useful.

@codecov-commenter
Copy link

codecov-commenter commented Apr 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 28.52%. Comparing base (66584ea) to head (6bfe170).

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2101   +/-   ##
=======================================
  Coverage   28.52%   28.52%           
=======================================
  Files          94       94           
  Lines        5757     5757           
  Branches     2547     2547           
=======================================
  Hits         1642     1642           
  Misses       3393     3393           
  Partials      722      722           
Flag Coverage Δ
collector-unit-tests 28.52% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@JoukoVirtanen JoukoVirtanen force-pushed the jv-integration-tests-keep-connections-in-batches branch from 2263802 to 6bfe170 Compare April 29, 2025 16:13
@JoukoVirtanen JoukoVirtanen marked this pull request as ready for review April 30, 2025 02:47
@JoukoVirtanen JoukoVirtanen requested a review from a team as a code owner April 30, 2025 02:47
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @JoukoVirtanen - I've reviewed your changes - here's some feedback:

  • Consider renaming Connections to ConnectionsByScrape and GetAllConnections to Connections for clarity, although this might require more refactoring.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Collaborator

@Molter73 Molter73 left a comment

Choose a reason for hiding this comment

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

LGTM!

Just some minor nitpicks.

@JoukoVirtanen JoukoVirtanen force-pushed the jv-integration-tests-keep-connections-in-batches branch from 3259cc0 to a7adacc Compare May 28, 2025 06:02
@@ -150,26 +149,48 @@ func (m *MockSensor) LiveConnections() <-chan *sensorAPI.NetworkConnection {

// Connections returns a list of all connections that have been received for
// a given container ID
func (m *MockSensor) Connections(containerID string) []types.NetworkInfo {
func (m *MockSensor) Connections(containerID string) []types.NetworkInfoBatch {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should keep the Connections function operating in the way it always has and then add a new function to retrieve the batches. This will mean that existing tests that do not care about batch consistency can remain unchanged, while new tests that verify batch consistency can use the new API to perform their tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@Molter73
Copy link
Collaborator

@JoukoVirtanen, rebasing should fix the arm integration test failures you are seeing.

@JoukoVirtanen JoukoVirtanen force-pushed the jv-integration-tests-keep-connections-in-batches branch from a7adacc to 622cd92 Compare May 28, 2025 17:14
@JoukoVirtanen JoukoVirtanen requested a review from Stringy May 29, 2025 07:11
@JoukoVirtanen JoukoVirtanen merged commit 81fd844 into master May 29, 2025
83 of 86 checks passed
@JoukoVirtanen JoukoVirtanen deleted the jv-integration-tests-keep-connections-in-batches branch May 29, 2025 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants