-
Notifications
You must be signed in to change notification settings - Fork 42
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
Improve SystemTests execution time #253
Conversation
34a5c36
to
e7e716c
Compare
Oh... Thx for taking care of this...
I have also tried that earlier, but dropped because if you have other Visual Studio instances open that use Reqnroll (e.g. exploratory test projects) then the folder deletion is sometimes not possible ("access denied"), because Visual Studio somehow puts a lock on the dll-s from the package. This is pretty random, but happens time to time. If we would simply swallow this error, it would cause some unpredictability but if we let it fail, it will cause build failures (even if you don't run the tests). So my decision was to undo this. 😢 (The speed difference is not that significant.) (The method level parallelization is fine.) Maybe what we could do is a mixed approach: we keep a persistent duplicated nuget cache only for the system tests and we only delete our packages from that one. That cache is obviously not used by other VS instances so there will be no lock. What do you think? |
When does the lock happen on your machine? I ask this way because the lock only happens when I use the SystemTests, so a separate NuGet cache folder for all SystemTests would probably not help. If these are the same locks, I currently see three options
|
@obligaron No. In my case I see the error if I have a normal Reqnroll sample project open in Visual Studio, not the System Tests one. In my case it particularly locks the If it would only happen for debugging the projects generated by system tests, I think that would be acceptable (I usually open these projects in VSCode anyway), but it affects all others. This is why I thought that just having one duplicate for all system tests would be beneficial. |
Interesting. On my machine it also happens that Visual Studio locks the Perhaps previous the deletion wasn't version specific and it tried to delete Can reproduce it with this PR? If yes, I can look into using a persistent duplicated nuget package. |
@obligaron I will try to reproduce it and give feedback. |
I can reproduce it with your version... 😥
What I did:
Of course this is a special situation, because normally no one is using the To be honest, the current status is also not ideal, because currently I have to manually delete the packages from the packages folder if I want to re-test the stuff with my exploratory tests (and sometimes close VS because of the locks). But in many cases I only modify the Reqnroll runtime, so I only need to delete the Reqnroll package, so I am not affected with the locked Let me test the System Test execution as well -> I put it to another comment. |
With "normal" runs, the System Tests execution is fine. I use NCrunch that runs the tests isolated in the background. Normally when I build, it realizes that the build output has changed and restarts those tests. With your change this process is different, because I get a build error, so I cannot build the project. I have to first stop the test execution, build and restart the execution. But I can configure NCrunch to set the |
Thinking about this a bit more... Maybe all-in-all your optimization has more advantages than disadvantages. Maybe we could make some optimizations:
What do you think? |
Another note (independent of all the others): Two tests from the |
… and the nuget cache can't be cleared show only a build warning
Sorry for the misunderstanding. I thought you meant that other versions of reqnroll can be accessed (not the newly build version).
With the new behavior in the good case the manual deletion could be avoided. This would also ensure that the nuget cache and the nuget packages stay in sync.
Sadly at least windows don't allow to rename the folder when a file is locked. 😢
I introduced
Thanks. I removed them. 👍 |
Thx for the additions. On reviving #64... this might be a good idea. Let's consider this separately.
Yes, that is the point. Maybe I was not clear enough. When it is locked you cannot rename, so it is fully untouched. But with the current behavior, it is deleting half of the files and it stops at deleting the |
If we want to ensure that the deletion works, we would probably need something like you suggested ((check old renamed folder exists and delete if present) -> rename -> delete). |
@obligaron Why do you think it would need a more complex solution? What if we would just do a
Or do I miss something? |
…e no half-removed cache entries
I missed that I could check that the rename directory exists in So I tried to implement this, but I failed because the So I tired to implement it with |
@obligaron oh cool. i give it a try (probably only on Friday) and give feedback. |
* main: Bump version VS Code integration proper doc title (#280) Fix: Reqnroll generates invalid code for rule backgrounds in Visual Basic (#284) Update nunit.md (#276) SolutionTests: Check if SDK version is installed and if not ignore the test (#266) Fix for #271 This PR modifies the Feature AST visitor to appropriately handle Rule Background steps. (#272) Bugfix/fix reqnroll.verify parallelization (#255)
@obligaron I played with this and found funny things... It seems that in some situations Windows is able to rename the folder even with a lock on it, but then could not delete the renamed files... So I needed to add a bit more try/catch to the solution to somehow handle these. But altogether it works. I also played with re-introducing the |
🤔 What's changed?
This PR improves the execution time of Reqnroll.SystemTests.
This is mainly done by two changes.
1. Use global nuget cache by default
Currently the execution of SystemTests uses a custom local nuget cache.
This results in ~600MB being copied on each SystemTests run (once for all tests).
This is necessary because we create a new nuget package with the same version after each build.
But the global nuget cache doesn't allow to remove a specific nuget package.
Based on https://www.nyckel.com/blog/nuget-packages a custom build target has been introduced to remove the Reqnroll nuget packages from the nuget cache. This allows us to still use the default nuget cache and avoid copying ~600MB.
This results in a speedup from ~1.4 minutes to ~1.2 minutes on my machine.
The old behavior can be enabled by a setting (
PerRunNuGetPackages
config switch).2. Allow method-level parallelization
This change allows multiple tests in a class to run in parallel.
This results in a speedup from ~1.2 minutes to ~51 seconds on my machine.
⚡️ What's your motivation?
When contributing
🏷️ What kind of change is this?
♻️ Anything particular you want feedback on?
I'm not sure if this change should be included in the CHANGELOG.md since it only affects Reqnroll contributors.
Also, during testing, I had some sporadic occurrence of #249,
📋 Checklist: