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

KNOX-3069 - Fix Flakey Test - TokenServiceResourceTest #938

Merged
merged 1 commit into from
Oct 11, 2024

Conversation

lmccay
Copy link
Contributor

@lmccay lmccay commented Oct 11, 2024

What changes were proposed in this pull request?

TokenServiceResourceTest - testLimitingTokensPerUser method acquires many tokens within a tight for loop and does not insure that the tokenIds are unique.

This results in test failures for the unlimited tokens per user on certain machines.

This may also point to a larger concurrency problem which needs investigation. Will file a separate JIRA for this. This may be an issue with the test or the UUID use for the tokenID in general. In the meantime, we can't have builds failing on certain machines.

This change interrogates the response and adds an assertion to ensure that the tokenId is unique. It seems the time spent in doing the check "fixes" the failures. The same "fix" was accomplished with a sleep of 1ms between token acquisitions.

How was this patch tested?

Prior to this fix the following test failure was encountered for every run on my local machine:

[ERROR] Tests run: 60, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 1.113 s <<< FAILURE! - in org.apache.knox.gateway.service.knoxtoken.TokenServiceResourceTest
[ERROR] testUnlimitedTokensPerUser(org.apache.knox.gateway.service.knoxtoken.TokenServiceResourceTest) Time elapsed: 0.118 s <<< FAILURE!
java.lang.AssertionError: expected:<94> but was:<105>
at org.apache.knox.gateway.service.knoxtoken.TokenServiceResourceTest.testLimitingTokensPerUser(TokenServiceResourceTest.java:1145)
at org.apache.knox.gateway.service.knoxtoken.TokenServiceResourceTest.testLimitingTokensPerUser(TokenServiceResourceTest.java:1110)
at org.apache.knox.gateway.service.knoxtoken.TokenServiceResourceTest.testUnlimitedTokensPerUser(TokenServiceResourceTest.java:1046)

This change looks for the root cause of the failure but also introduces a time lag between token acquisitions such that the tokenIDs are indeed unique.

Copy link
Contributor

@moresandeep moresandeep left a comment

Choose a reason for hiding this comment

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

Looks good!

@lmccay lmccay merged commit 9b34e27 into apache:master Oct 11, 2024
2 checks passed
lmccay added a commit to lmccay/knox that referenced this pull request Nov 9, 2024
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.

2 participants