Skip to content

Conversation

tklauser
Copy link
Member

@tklauser tklauser commented Oct 9, 2024

Fix a bug in Set[T].Equal introduced in #34692. Also increase the test coverage to cover the single element case in all methods. Moreover, assign pkg/container/set to @cilium/sig-policy as this is the primary user of the package.

See commits for details.

The Set type is currently only used in pkg/policy. Make sure future
changes don't have implications on the policy engine by assigning it to
the corresponding team.

Signed-off-by: Tobias Klauser <tobias@cilium.io>
@tklauser tklauser added sig/policy Impacts whether traffic is allowed or denied based on user-defined policies. release-note/misc This PR makes changes that have no direct user impact. labels Oct 9, 2024
@tklauser tklauser requested a review from jrajahalme October 9, 2024 12:41
@tklauser tklauser requested review from a team as code owners October 9, 2024 12:41
@tklauser tklauser requested review from pippolo84 and qmonnet October 9, 2024 12:41
@tklauser
Copy link
Member Author

tklauser commented Oct 9, 2024

/test

Currently, if the sets being compared contain more that a single element
each, only the first element would be checked. Fix Set[T].Equal to
consider all elements in both maps and also add an additional test
cheing two maps of equal length with some different elements that would
fail before this fix but pass afterwards.

Fixes: 75181db ("containers: Add new set.Set type")

Signed-off-by: Tobias Klauser <tobias@cilium.io>
Increase the test coverage of TestSet by:

- Testing that calling Insert twice with the same value on a previously
  empty set will not change the Set (i.e. return false) on the second
  Insert call.
- Adding test coverage for the previously uncovered RemoveSets method.
- Adding test coverage for Members and MembersOfType on single entry
  Sets.

Combined these changes increast test coverage from ~75% to ~87%.

Signed-off-by: Tobias Klauser <tobias@cilium.io>
@tklauser tklauser force-pushed the pr/tklauser/container-set-test-cov branch from e1f8198 to 3561ca5 Compare October 9, 2024 13:00
@tklauser
Copy link
Member Author

tklauser commented Oct 9, 2024

/test

@tklauser tklauser enabled auto-merge October 9, 2024 13:00
Copy link
Member

@pippolo84 pippolo84 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@tklauser
Copy link
Member Author

tklauser commented Oct 9, 2024

/ci-runtime

Hit #34731 https://github.com/cilium/cilium/actions/runs/11255508705

@tklauser tklauser added this pull request to the merge queue Oct 9, 2024
Merged via the queue into main with commit 81cd7d6 Oct 9, 2024
268 of 270 checks passed
@tklauser tklauser deleted the pr/tklauser/container-set-test-cov branch October 9, 2024 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note/misc This PR makes changes that have no direct user impact. sig/policy Impacts whether traffic is allowed or denied based on user-defined policies.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants