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

Fix Key Vault tests that are completing too soon #18546

Closed
wants to merge 1 commit into from

Conversation

heaths
Copy link
Member

@heaths heaths commented Feb 8, 2021

Several invocations of Assert.ThrowsAsync were incorrect which likely
lead to the issues failing nightly live tests.

Several invocations of Assert.ThrowsAsync were incorrect which likely
lead to the issues failing nightly live tests.
@heaths heaths requested a review from schaabs as a code owner February 8, 2021 18:56
@ghost ghost added the KeyVault label Feb 8, 2021
@@ -60,7 +62,7 @@ public void StartCreateCertificateError()
},
};

RequestFailedException ex = Assert.ThrowsAsync<RequestFailedException>(() => Client.StartCreateCertificateAsync(certName, certificatePolicy));
RequestFailedException ex = Assert.ThrowsAsync<RequestFailedException>(async () => await Client.StartCreateCertificateAsync(certName, certificatePolicy));
Copy link
Contributor

Choose a reason for hiding this comment

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

Hm, what does this change? It was a Task-returning lambda before as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

What, I believe, is different is how exceptions are actually handled. The operations tests that keep failing during live runs appear to be firing too early, and I believe the lack of the state machine higher up the call stack may be to blame. I'm not 100% sure, though. I've walked through the code before and can't think of any other reasons that status is still "inProgress" when the method call returns.

All the other changes is just because I noticed all other code in our repo seems to be using async/await with Assert.ThrowsAsync. Previously, I figured any Task-returning method would be fine, and most of the tests I updated throw synchronously anyway (e.g. ArgumentNullException immediately after method invocation).

If you'd rather, I could revert all the other changes besides the ones I intended, but I feel this also makes the code consistent with other projects. I don't think the addition of the state machine will noticeably hinder test code.

Copy link
Contributor

@pakrym pakrym Feb 8, 2021

Choose a reason for hiding this comment

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

I want to understand if there is really a problem and see if we need to fix other projects the same way. I would think the exception handling is the same as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

There's definitely a problem (expected OperationCancelledException not thrown in CertificateClientLiveTests) but I'm not 100% sure this will fix it. But it seems the only plausible explanation because if not awaiting the call, exception handling I believe would be different. I'll ping you offline with a link to the issue.

@heaths heaths marked this pull request as draft February 8, 2021 21:22
@heaths
Copy link
Member Author

heaths commented Feb 8, 2021

Per offline discussion, I'll enable content logging first till we get the next hit. Perhaps it's possible that we're getting error details while the status is "inProgress". Won't know without content (and would seem like a service bug in that case).

@ghost ghost added the no-recent-activity There has been no recent activity on this issue. label Mar 12, 2021
@ghost
Copy link

ghost commented Mar 12, 2021

Hi @heaths. There hasn't been recent engagement on this pull request. If this is still an active work stream, please let us know by removing the no-recent-activity label. Otherwise, we'll close this out in 7 days.

@heaths
Copy link
Member Author

heaths commented Mar 15, 2021

Closing this for now, but will keep the branch alive.

@heaths heaths closed this Mar 15, 2021
azure-sdk pushed a commit that referenced this pull request Feb 2, 2024
https://learn.microsoft.com/en-us/powershell/scripting/whats-new/what-s-new-in-powershell-74?view=powershell-7.4
- Add AllowInsecureRedirect switch to Web cmdlets (#18546)

That new option cause a new exception type that exposed
a bug where we assumed if InnerException property existed
that it was not null. This fix verifies that the property
is not null.
azure-sdk added a commit that referenced this pull request Feb 2, 2024
https://learn.microsoft.com/en-us/powershell/scripting/whats-new/what-s-new-in-powershell-74?view=powershell-7.4
- Add AllowInsecureRedirect switch to Web cmdlets (#18546)

That new option cause a new exception type that exposed
a bug where we assumed if InnerException property existed
that it was not null. This fix verifies that the property
is not null.

Co-authored-by: Wes Haggard <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
KeyVault no-recent-activity There has been no recent activity on this issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants