Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Starting on Saturday, Windows unit tests started sometimes failing. Debugging this was tricky since the test failure was intermittent, only happening on Windows, and the unit test in question has all of stdin, stdout, and stderr mocked out making it hard to use a debugger. I think this all reenforces the idea we've been talking about lately that Certbot testing should be saner/easier.
Check out the Azure Pipeline history if you're curious what all I tried, but the first thing I noticed is that the logging messages in the test failure are very odd. https://dev.azure.com/certbot/certbot/_build/results?buildId=6339&view=logs&j=ed6d8c23-2913-5760-0bd3-640c32c32198&t=f8e8d435-fc2b-5e49-c7a1-d4820401e523&l=958 says the Apache plugin was selected and then https://dev.azure.com/certbot/certbot/_build/results?buildId=6339&view=logs&j=ed6d8c23-2913-5760-0bd3-640c32c32198&t=f8e8d435-fc2b-5e49-c7a1-d4820401e523&l=1038 says we crashed because a plugin wasn't specified. This is especially odd because the failing test doesn't request Apache and the renewal configuration file used in that test specifies standalone.
Checking the commit history, I saw that #9355 landed on Friday (the day before test failures started) and does some mocking causing Apache to be selected. While continuing to dig around, I made a branch that reverted this commit and ran the tests successfully 5 times which is noteworthy because the tests otherwise almost always fails. You can see this at in the Pipeline history where the branch being tested was
test-windows-failure-no-reconfigure.Something/everything below this line is wrong
After noticing that, I looked into how the Apache mocks added in that PR get cleaned up and noticed that we called
super().tearDown()before doing our own tear down. Out of the tests in this file using this pattern of creating mocks insetUpand cleaning them up intearDown, only this test does this. I tried flipping the order and successfully ran the test three times at https://dev.azure.com/certbot/certbot/_build/results?buildId=6349&view=results. (I kept canceling the build after the Certbot unit tests passed and immediately rerunning it.)It's not immediately clear to me why this matters as the default implementation of unittest.tearDown does nothing, however, I suspect that some combination of things like
pytestandpytest-xdisthook into or modify the standardunittest.TestCase.tearDownmethod and by calling it first, our cleanup code isn't always properly being called. pytest does have code modifyingtearDownmethods although that particular line of code seems unlikely to be the offender to me.Regardless of the exact cause here, this seems to reliably fix it as I have not been able to reproduce the failure with this change.