-
Notifications
You must be signed in to change notification settings - Fork 231
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
chore: Control each response for calls to the IAM Mock Server #1455
Conversation
"36680232662-vrd7ji19qe3nelgchd0ah2csanun6bnr@developer.gserviceaccount.com"; | ||
|
||
@Test | ||
public void sign_noRetry() throws IOException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sign_success() ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update to include success
. Thanks!
ImpersonatedCredentialsTest.MockIAMCredentialsServiceTransportFactory transportFactory = | ||
new ImpersonatedCredentialsTest.MockIAMCredentialsServiceTransportFactory(); | ||
transportFactory.transport.addStatusCodeAndMessage(502, "Bad Gateway"); | ||
transportFactory.transport.addStatusCodeAndMessage(502, "Bad Gateway"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this fail 3 times to test the boundary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the description for the following test below sign_retryThreeTimes_exception
. I believe that will test the retry boundary as it fails three times before giving up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea here was to test the other side of the boundary: does the code allow the "last retry" to be successful? This isn't tested now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies if I'm misunderstanding your point. The retry is configured to retry three times before giving up and I believe the two sides of the boundaries you are talking about are:
- Retrying while it hasn't reached the number of attempts limit
- Stop retrying after it has reached the number of attempts limit
The first test case sign_retryTwoTimes_success
will receive two 5xx errors and should test the first case above.
The second test case sign_retryThreeTimes_exception
will receive a four 5xx errors and should test the second case above. It'll retry 3 times and the 4th response will be what is sent back to the user. If it's a 5xx error, it'll throw an exception back, otherwise it'll send the response.
does the code allow the "last retry" to be successful?
If I'm understanding this comment correctly, I'll add another test case where it'll have three 5xx errors before returning a successful response. This should return a success back to the user.
transportFactory.transport, | ||
expectedSignature, | ||
ImmutableMap.of())); | ||
assertTrue(exception.getMessage().contains("Failed to sign the provided bytes")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you assert that the server error is not retried? Or is that implicit in the setup of the transport? -- if so please leave a comment about that.
Otherwise please assert a 2nd call didn't arrive, or have the transport returning a success on 2nd request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. I added a method in the transport to track the number of requests being made. This tests should include an assertion assertEquals(4, transportFactory.transport.getNumRequests());
which should ensure that a specific number of retry attempts are made and that the final 5xx errors aren't being retried.
transportFactory.transport.addStatusCodeAndMessage(502, "Bad Gateway"); | ||
transportFactory.transport.addStatusCodeAndMessage(502, "Bad Gateway"); | ||
transportFactory.transport.addStatusCodeAndMessage(502, "Bad Gateway"); | ||
transportFactory.transport.addStatusCodeAndMessage(502, "Bad Gateway"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe assign different error code each time, so this test is more explicit on reporting back the third failure?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, done! There are a few 5xx errors, so I just swapped them to be 500, 502 and 503. It just reports the last status code that came back once all the retries are exhausted. Hopefully this should be clearer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Quality Gate passedIssues Measures |
This is part 2 that follows up on: #1452
Once Part 1 is merged, I can rebase this PR to show the diffs (mostly testing related changes) to allow us to test for retrying the IAM Sign Blob RPC.