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 problem with parallel loading and limitations on number of agents #141

Merged
merged 2 commits into from
Dec 4, 2016

Conversation

CharliePoole
Copy link
Collaborator

A problem crept into the engine causing all assemblies to be loaded as soon as the MasterTestRunner was created. Of course, this causes all processes to be created at once, in spite of any limitation the user may have set with the --agents option.

After removing the offending line of code, I discovered that there were random failures occuring because of threading issues in RuntimeFramework. This will need a lot of work at some time, so I added an explanatory comment to RuntimeFramework. For the moment, the hack I added to RuntimeFrameworkService prevents the problem from occuring by forcing RuntimeFramework to initialize the list of available frameworks early enough that it's ready for use when multiple threads start trying to access it.

@chris-smith-zocdoc This is the fix you will want to have in your own PR. Since you are set up to test the situation of loading multiple assemblies in parallel, could you pull this and try it out? I have been running with only two processes and various command-line options. I haven't seen the exception thrown for the last dozen or so runs, so I'm fairly confident, but it's hard to test a negative!

@CharliePoole
Copy link
Collaborator Author

This (re) fixes #36

@@ -54,7 +54,7 @@ public MasterTestRunner(IServiceLocator services, TestPackage package)
_runtimeService = _services.GetService<IRuntimeFrameworkService>();
_extensionService = _services.GetService<ExtensionService>();
_engineRunner = _services.GetService<ITestRunnerFactory>().MakeTestRunner(package);
LoadPackage();
//LoadPackage();
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm concerned that without this line we may actually cause a regression of #52 since LoadPackage is never called now

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We need to get @NikolayPianikov to comment on this as well, but it would still be useful if you could check out how it is working in the case of loading multiple assemblies, without necessarily having a project for the.

According to #52, the problem was not that the TestPackage needed to be loaded but that it needed to be expanded. MasterTestRunner uses it's method EnsurePackagesAreExpanded to do that. It might be that we have to call it separately from LoadPackage - possibly in the constructor.

We don't want the package loaded for sure. Loading means loading the assembly and finding all the tests. In the case of multiple processes, it implies creating all the processes, which might amount to 100s of processes for some projects.

While waiting to hear from @NikolayPianikov, let's each test as we can. I'll try running the two assemblies through an NUnit project to see what happens.

@CharliePoole
Copy link
Collaborator Author

I see why @NikolayPianikov added the call to LoadPackage now. It does a bunch of stuff in addition to loading the package, including expanding any projects. So I renamed the method to InitializePackage, removed the loading itself and am calling it. This seems to work and gets us back to the desired behavior where all loading is done by the TestEngineRunners that MasterTestRunner uses.

I'm not completely happy with having this call in the constructor, but I can't see any better place to do it.

@chris-smith-zocdoc
Copy link
Contributor

I've tested this in our environment and can confirm it is working as expected @CharliePoole I'm going to continue letting it run and will let you know if I see any other race conditions cause issues.

@CharliePoole
Copy link
Collaborator Author

Thanks Chris... I'll wait a bit before merging. @NikolayPianikov do you have any comments?

@chris-smith-zocdoc
Copy link
Contributor

Ran it constantly for the last couple hours, no issues

@CharliePoole
Copy link
Collaborator Author

I'll merge this then. When you have rebased, I'll take another look at your PR.

@CharliePoole CharliePoole merged commit 289d17c into master Dec 4, 2016
@CharliePoole CharliePoole deleted the issue-36 branch December 4, 2016 23:42
@chris-smith-zocdoc
Copy link
Contributor

With this change my other PR isn't necessary, I'm going to close it

@CharliePoole
Copy link
Collaborator Author

@chris-smith-zocdoc I'm not sure that's right. See my comment on PR #140

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants