Skip to content
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

test(policy): add extra testing of the matching algorithm #8487

Merged
merged 4 commits into from
Nov 30, 2023

Conversation

lahabana
Copy link
Contributor

@lahabana lahabana commented Nov 29, 2023

  • Add some tests to the policy matching algo
  • Add possibility to add a test as pending in test.EntriesForFolder

Ref #8484

Checklist prior to review

  • Link to relevant issue as well as docs and UI issues --
  • This will not break child repos: it doesn't hardcode values (.e.g "kumahq" as a image registry) and it will work on Windows, system specific functions like syscall.Mkfifo have equivalent implementation on the other OS --
  • Tests (Unit test, E2E tests, manual test on universal and k8s) --
    • Don't forget ci/ labels to run additional/fewer tests
  • Do you need to update UPGRADE.md? --
  • Does it need to be backported according to the backporting policy? (this GH action will add "backport" label based on these file globs, if you want to prevent it from adding the "backport" label use no-backport-autolabel label) --

Add some tests including one as pending which is the repro

Fix kumahq#8484

Signed-off-by: Charly Molter <[email protected]>
@lahabana lahabana requested a review from a team as a code owner November 29, 2023 06:22
@lahabana lahabana requested review from jakubdyszkiewicz and Automaat and removed request for a team November 29, 2023 06:22
@lobkovilya
Copy link
Contributor

Tests in this PR are not expected to pass, because sorting normally is happening here

sort.Sort(ByTargetRef(dpPolicies))
for _, ps := range matchedPoliciesByInbound {
sort.Sort(ByTargetRef(ps))
}

But the test calls core_rules.BuildFromRules function that already expects sorted policies as input.

@lobkovilya
Copy link
Contributor

If you place the same test here pkg/plugins/policies/core/matchers/dataplane_test.go, it works as expected.

@lahabana
Copy link
Contributor Author

Yeah that's what I've noticed later

Signed-off-by: Charly Molter <[email protected]>
@lahabana lahabana changed the title fix(policies): matching at same level doesn't use lexicographic order fix(policy): matching at same level doesn't use lexicographic order Nov 29, 2023
Signed-off-by: Charly Molter <[email protected]>
@lahabana
Copy link
Contributor Author

lahabana commented Nov 29, 2023

Yeah I noticed that after so I added tests there as well and it seems to be working correctly.
As you pointed out in the issue the problem is related to k8s policy naming so I've renamed this PR and we can just add these tests as the policy matching algo is a little light in tests.

@lahabana lahabana changed the title fix(policy): matching at same level doesn't use lexicographic order test(policy): add extra testing of the matching algorithm Nov 29, 2023
@lahabana lahabana enabled auto-merge (squash) November 29, 2023 11:16
@lahabana lahabana added the ci/skip-e2e-test PR: Don't run e2e tests label Nov 30, 2023
@lahabana lahabana merged commit dcba44d into kumahq:master Nov 30, 2023
16 checks passed
@lahabana lahabana deleted the repro8484 branch March 29, 2024 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci/skip-e2e-test PR: Don't run e2e tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants