Skip to content

fix(tests): stabilize AuthzITs and some other cleanups#3103

Merged
tombentley merged 6 commits intokroxylicious:mainfrom
k-wall:stablise-tests
Jan 8, 2026
Merged

fix(tests): stabilize AuthzITs and some other cleanups#3103
tombentley merged 6 commits intokroxylicious:mainfrom
k-wall:stablise-tests

Conversation

@k-wall
Copy link
Copy Markdown
Member

@k-wall k-wall commented Jan 6, 2026

Type of change

Select the type of your PR

  • Bugfix

Description

The AuthzITs are unstable for me on my main work machine. We are also seeing the same failures in CI.

I am running this command:

mvn verify -Dit.test='*AuthzIT' -DskipUTs  -Dfailsafe.failIfNoSpecifiedTests=false -pl kroxylicious-integration-tests -am

The issues I'm seeing:

Side-effect assertion sporadically failing

The side effect assertions are failing. For instance, in DeleteTopicsAuthzIT I see failures like so:

org.opentest4j.AssertionFailedError: 
expected: []
 but was: ["eve-topic", "alice-topic"]
Expected :[]
Actual   :["eve-topic", "alice-topic"]
at io.kroxylicious.proxy.filter.authorization.AuthzIT.verifyApiEqivalence(AuthzIT.java:588)
	at io.kroxylicious.proxy.filter.authorization.AuthzIT$Equivalence.verifyBehaviour(AuthzIT.java:239)
	at io.kroxylicious.proxy.filter.authorization.DeleteTopicsAuthzIT.shouldEnforceAccessToTopics(DeleteTopicsAuthzIT.java:292)

I think this is down the the eventually consistent nature of Kafka. Just because you've say, just created a topic, doesn't give you the guarantee that an admin observation will observe it.

Proxied/reference response mismatches

I'm seeing some fails like this:

org.opentest4j.AssertionFailedError: [Expect proxied response to be the same as the reference response with equivalent AuthZ] 
expected: 
  {"alice"="{
    "throttleTimeMs" : 0,
    "responses" : [ {
      "name" : "alice-topic",
      "errorCode" : 29,
      "topicId" : null
    }, {
      "name" : "bob-topic",
      "errorCode" : 29,
      "topicId" : null
    }, {
      "name" : "eve-topic",
      "errorCode" : 29,
      "topicId" : null
    } ]
  }", "bob"="{
    "throttleTimeMs" : 0,
    "responses" : [ {
      "name" : "alice-topic",
      "errorCode" : 29,
      "topicId" : null
    }, {
      "name" : "bob-topic",
      "errorCode" : 29,
      "topicId" : null
    }, {
      "name" : "eve-topic",
      "errorCode" : 29,
      "topicId" : null
    } ]
  }", "eve"="{
    "throttleTimeMs" : 0,
    "responses" : [ {
      "name" : "alice-topic",
      "errorCode" : 29,
      "topicId" : null
    }, {
      "name" : "bob-topic",
      "errorCode" : 29,
      "topicId" : null
    }, {
      "name" : "eve-topic",
      "errorCode" : 29,
      "topicId" : null
    } ]
  }"}
 but was: 
  {"alice"="{
    "throttleTimeMs" : 0,
    "responses" : [ {
      "name" : "alice-topic",
      "errorCode" : 0,
      "topicId" : null
    }, {
      "name" : "bob-topic",
      "errorCode" : 29,
      "topicId" : null
    }, {
      "name" : "eve-topic",
      "errorCode" : 29,
      "topicId" : null
    } ]
  }", "bob"="{
    "throttleTimeMs" : 0,
    "responses" : [ {
      "name" : "alice-topic",
      "errorCode" : 29,
      "topicId" : null
    }, {
      "name" : "bob-topic",
      "errorCode" : 0,
      "topicId" : null
    }, {
      "name" : "eve-topic",
      "errorCode" : 29,
      "topicId" : null
    } ]
  }", "eve"="{
    "throttleTimeMs" : 0,
    "responses" : [ {
      "name" : "alice-topic",
      "errorCode" : 29,
      "topicId" : null
    }, {
      "name" : "bob-topic",
      "errorCode" : 29,
      "topicId" : null
    }, {
      "name" : "eve-topic",
      "errorCode" : 29,
      "topicId" : null
    } ]
  }"}
<Click to see difference>


	at io.kroxylicious.proxy.filter.authorization.AuthzIT.verifyApiEqivalence(AuthzIT.java:583)
	at io.kroxylicious.proxy.filter.authorization.AuthzIT$Equivalence.verifyBehaviour(AuthzIT.java:241)
	at io.kroxylicious.proxy.filter.authorization.DeleteTopicsAuthzIT.shouldEnforceAccessToTopics(DeleteTopicsAuthzIT.java:292)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at java.base/java.util.Optional.ifPresent(Optional.java:178)

This again is an eventually consistency issue. The test harness creates the topic (alice-topic etc), and then the test proceeds to perform an operation on the topic

Additional Context

Why are you making this pull request?

Checklist

Please go through this checklist and make sure all applicable tasks have been done

  • PR raised from a fork of this repository and made from a branch rather than main.
  • Write tests
  • Update documentation
  • Make sure all unit/integration tests pass
  • Make sure all Sonarcloud warnings are addressed or are justifiably ignored.
  • If applicable to the change, trigger the system test suite. Make sure tests pass.
  • If applicable to the change, trigger the performance test suite. Ensure that any degradations to performance numbers are understood and justified.
  • Ensure the PR references relevant issue(s) so they are closed on merging.
  • For user facing changes, update CHANGELOG.md (remember to include changes affecting the API of the test artefacts too).

NOTE: You must be a member of @kroxylicious/developers to trigger the system test and performance test suites. If you are not part of this group, comment on the PR requesting a trigger, tagging @kroxylicious/developers.

@k-wall k-wall requested a review from a team as a code owner January 6, 2026 18:41
@k-wall k-wall changed the title chore(tests): stabilize authzit chore(tests): stabilize AuthzITs Jan 6, 2026
@k-wall k-wall marked this pull request as draft January 6, 2026 18:41
@k-wall k-wall changed the title chore(tests): stabilize AuthzITs fix(tests): stabilize AuthzITs Jan 6, 2026
@k-wall k-wall changed the title fix(tests): stabilize AuthzITs fix(tests): stabilize AuthzITs (part 1) Jan 7, 2026
@k-wall k-wall marked this pull request as ready for review January 7, 2026 11:05
@k-wall k-wall added the test Relates to testing label Jan 7, 2026
apiKeys,
prettyJsonString(responseConverter.writer().apply(response, apiVersion)),
cluster.name());
LOG.atDebug().setMessage("{} {} response: {} << {}")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why change to debug here instead of using .atInfo() to match the previous behavior?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

In my opinion, these tests were writing too much output. I just want to see the names of test classes which is quick to eyeball when the tests run cleanly. When the test fails, I want the test to produce a good assertion message. I can then turn up logging if I need to to investigate the failure.

If tests spew war-and-peace on the happy path, that's disruptive for me.

Copy link
Copy Markdown
Member

@piotrpdev piotrpdev left a comment

Choose a reason for hiding this comment

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

LGTM

@tombentley
Copy link
Copy Markdown
Member

@k-wall sorry, but I've only just seen this after merging #3109 and opening #3110. Neither #3106 nor #3107 showed any indication that you were looking at them. I think we need to be more diligent about assigning issues to people, and referencing issues in PRs intended to address them.

k-wall added 3 commits January 8, 2026 12:26
kill some unused code.

Signed-off-by: Keith Wall <kwall@apache.org>
…ually consistent nature of kafka

Signed-off-by: Keith Wall <kwall@apache.org>
…sponse to ease reasoning about the differences

Signed-off-by: Keith Wall <kwall@apache.org>
@k-wall
Copy link
Copy Markdown
Member Author

k-wall commented Jan 8, 2026

@k-wall sorry, but I've only just seen this after merging #3109 and opening #3110. Neither #3106 nor #3107 showed any indication that you were looking at them. I think we need to be more diligent about assigning issues to people, and referencing issues in PRs intended to address them.

No problem. I'd been talking about the issue for a couple of days on Slack, so I'd assumed that everyone might have noticed. But we have too many channels for everyone to monitor everything!

k-wall added 2 commits January 8, 2026 16:08
… to the broker before commencing the test

Signed-off-by: Keith Wall <kwall@apache.org>
Signed-off-by: Keith Wall <kwall@apache.org>
@k-wall k-wall changed the title fix(tests): stabilize AuthzITs (part 1) fix(tests): stabilize AuthzITs and some other cleanups Jan 8, 2026
return scenario.clobberResponse(cl, node);
});
assertThat(mapValues(proxiedResponsesByUser,
assertThatJson(mapValues(proxiedResponsesByUser,
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This gives a much more human readable diff when the assertion fails.

if (!scenario.needsRetry(r)) {
break;
}
try {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The sleep didn't seem to be achieving anything.

<!-- </module>-->
<module name="IllegalImport">
<!-- we shouldn't be relying on class shaded into TC for dependencies -->
<property name="illegalPkgs" value="org.testcontainers.shaded"/>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for this!

…roxy/filter/authorization/KafkaDriver.java

Signed-off-by: Tom Bentley <tombentley@users.noreply.github.com>
@tombentley tombentley enabled auto-merge (rebase) January 8, 2026 20:09
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Jan 8, 2026

@tombentley tombentley merged commit b5cba98 into kroxylicious:main Jan 8, 2026
24 checks passed
k-wall added a commit to k-wall/kroxylicious that referenced this pull request Feb 4, 2026
why: in kroxylicious#3103 666c64d we changed the AuthzIT tests to ensure that the topics were in a consistent
state before the starting the tests.  The AbstractAuthzEquivalenceIT tests have their own cluster prep code, so didn't benefit from
this change meaning those tests could still fail owning to lack of consistency.  This change pulls out a common base class and
refactors both AuthzIT and AbstractAuthzEquivalenceIT to use it.

Signed-off-by: Keith Wall <kwall@apache.org>
k-wall added a commit to k-wall/kroxylicious that referenced this pull request Feb 4, 2026
why: in kroxylicious#3103 666c64d we changed the AuthzIT tests to ensure that the topics were in a consistent
state before the starting the tests.  The AbstractAuthzEquivalenceIT tests have their own cluster prep code, so didn't benefit from
this change meaning those tests could still fail owning to lack of consistency.  This change pulls out a common base class and
refactors both AuthzIT and AbstractAuthzEquivalenceIT to use it.

Signed-off-by: Keith Wall <kwall@apache.org>
k-wall added a commit to k-wall/kroxylicious that referenced this pull request Feb 4, 2026
why: in kroxylicious#3103 666c64d we changed the AuthzIT tests to ensure that the topics were in a consistent
state before the starting the tests.  The AbstractAuthzEquivalenceIT tests have their own cluster prep code, so didn't benefit from
this change meaning those tests could still fail owning to lack of consistency.  This change pulls out a common base class and
refactors both AuthzIT and AbstractAuthzEquivalenceIT to use it.

Signed-off-by: Keith Wall <kwall@apache.org>
k-wall added a commit to k-wall/kroxylicious that referenced this pull request Feb 4, 2026
why: in kroxylicious#3103 666c64d we changed the AuthzIT tests to ensure that the topics were in a consistent
state before the starting the tests.  The AbstractAuthzEquivalenceIT tests have their own cluster prep code, so didn't benefit from
this change meaning those tests could still fail owning to lack of consistency.  This change pulls out a common base class and
refactors both AuthzIT and AbstractAuthzEquivalenceIT to use it.

Signed-off-by: Keith Wall <kwall@apache.org>
k-wall added a commit to k-wall/kroxylicious that referenced this pull request Feb 4, 2026
why: in kroxylicious#3103 666c64d we changed the AuthzIT tests to ensure that the topics were in a consistent
state before the starting the tests.  The AbstractAuthzEquivalenceIT tests have their own cluster prep code, so didn't benefit from
this change meaning those tests could still fail owning to lack of consistency.  This change pulls out a common base class and
refactors both AuthzIT and AbstractAuthzEquivalenceIT to use it.

Signed-off-by: Keith Wall <kwall@apache.org>
robobario pushed a commit to k-wall/kroxylicious that referenced this pull request Feb 8, 2026
why: in kroxylicious#3103 666c64d we changed the AuthzIT tests to ensure that the topics were in a consistent
state before the starting the tests.  The AbstractAuthzEquivalenceIT tests have their own cluster prep code, so didn't benefit from
this change meaning those tests could still fail owning to lack of consistency.  This change pulls out a common base class and
refactors both AuthzIT and AbstractAuthzEquivalenceIT to use it.

Signed-off-by: Keith Wall <kwall@apache.org>
robobario pushed a commit that referenced this pull request Feb 9, 2026
why: in #3103 666c64d we changed the AuthzIT tests to ensure that the topics were in a consistent
state before the starting the tests.  The AbstractAuthzEquivalenceIT tests have their own cluster prep code, so didn't benefit from
this change meaning those tests could still fail owning to lack of consistency.  This change pulls out a common base class and
refactors both AuthzIT and AbstractAuthzEquivalenceIT to use it.

Signed-off-by: Keith Wall <kwall@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test Relates to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants