-
Notifications
You must be signed in to change notification settings - Fork 135
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
Some Integration Tests Can Fail When Temporarily Unable to Connect to GitHub #505
Comments
I had this the other day too - across multiple repos (not just this one). I think there was a network blip between AppVeyor and GitHub. But in my case AppVeyor couldn't pull the source code at all: But I agree, a more resilient approach to cloning the DSCResouce.Tests would be good - with maybe a back off and retry x times policy. |
I realized after the fact that this 'git clone' command probably came from the DSC test templates. Do you think we should address this directly in DSCResources\Tests.Template (https://github.com/PowerShell/DscResources/blob/master/Tests.Template)? |
Yep, I reckon that would be the best place to do it. |
I did a little more research on this, and discovered a couple oddities. First, I realized that different tests are trying to connect to GitHub. The code in the latest DSC test templates will only try to do a Git operation if the cloned repo doesn't already exist locally. The fact that this is getting called in potentially every test means we aren't checking to see whether the repos exist first. That could potentially be slowing down our tests significantly too. So if nothing else comes out of this, we may want to update the Git clone section to use the current code from the test templates:
Second, it looks like the Git operation is coming from function Enter-DscResourceTestEnvironment in Tests\CommonTestHelper.psm1. It looks like this code needs to be updated (perhaps taking the template code from above) so that we don't do a git pull every time the module is imported.
So I guess we have two options here. One would be to update the code in Enter-DscResourceTestEnvironment to use the DSC test template code for downloading DSCResources.Tests. The other would be to stop using this helper function and to put the same template code in every file. Any thoughts on which direction is best? I'd lean towards the former option because it would require less code updates, but that option doesn't help us align with the DSC test templates. And I still think getting an update in the DSC test templates themselves to be able to perform retries would be good, but we can save that for another issue in another repo. |
I'm traveling for work this week so won't be able to respond in depth till the weekend. However a bit of context around the git clone behavior. The scenario we were trying to prevent by checking the git repo was up-to-date each time was if the user had an old version in their copy of a module repo and was using it to test against. This was a bit of a problem a year or so back when we were adding improvements to the tests in DSCResource.Tests quite frequently. But I'm sure we could find a little bit smarter way of doing this check that doesn't go out to GH every time. As you day that is slow and fragile. |
We should switch to using the full template for both unit and integration test and remove any left over helper functions. These helper functions are probably the old and first version that later became the test framework. My thoughts. 😄 |
If we go that direction @johlju , do we need helper function Enter-DscResourceTestEnvironment at all? It looks like that calls Initialize-TestEnvironment, but we could just move that directly into the Unit and Integration test files themselves. |
I don’t think Enter-DscResourceTestEnvironment is needed. That is already handled in the logic of the test template (see header). Same with exit* function, it can probably be removed from this repo too. |
See the header here https://github.com/PowerShell/DscResources/blob/master/Tests.Template/unit_template.ps1 Same for the integration test template. |
The only problem with removing Enter-DscResourceTestEnvironment is that if we start increasing the complexity and amount of code in how we clone/pull the DSCResources.TEsts repo, the more code we end up duplicating in every test file. Making a CommonTestHelper.psm1 file that contains these functions standard in the template might actually be the better approach? And moving all repos to be compliant with that pattern instead of the other way round (backing this out of xPSDesiredStateConfiguration). |
Yes, then maybe we could remove code from the header of each unit- and integration test instead of adding more. |
Let's bring it up at the next community call! |
Update Common Test Helper to only update DSCResource.Tests when over 60 minutes old - Fixes #505
Details of the scenario you tried and the problem that is occurring
#447 hit an issue where CI failed multiple times for certain Integration tests, as they were temporarily unable to connect to GitHub. I suspect this was a transient issue. We should update the way GitHub is used in tests to make it more resilient, and able to deal with transient failures. Perhaps putting Git related code into a helper function that can retry if necessary would help.
Verbose logs showing the problem
Here's a couple examples of this from different CI runs:
Version of the DSC module that was used ('dev' if using current dev branch)
dev
The text was updated successfully, but these errors were encountered: