nunit-console
nunit-console copied to clipboard
Implement Pluggable agents
@ChrisMaddock @mikkelbu @rprouse @jnm2
I'm calling this a question, but I mean it as a question we are asking ourselves.
Here's a rough outline of what I want to try with some spike code. Some of this is new ground so it would be nice to have all our brains on it.
FIRST, here's how things generally work. Except as noted, they are the same in both the current NUnit engine and the testcentric fork. Also, for clarity, I've simplified things a lot here.
- When the user asks the engine for a runner, passing a package, it always gets a
MasterTestRunner. - That runner is initially "bare" without any lower-level runners to back it up. But as soon as the tests need to be loaded,
MasterTestRunneruses various services to fill in the appropriate internal runner (ITestEngineRunner). - If the
ITestRunneris one of the in-process runners, it finds a driver (IFrameworkDriver) that knows how to run the tests. On platforms that supportAppDomains, it creates one in which to run the test. - OTOH. if the runner is a
ProcessRunner, things work differently.ProcessRunneruses theTestAgencyservice to get an agent. Although we usually just call them "agents", think of them as "process proxy agents" for this discussion, because the serve as an in-process proxy for the runner executing in a separate process. TestAgencylaunches that process and waits for it to establish communication. Once it does it returns the proxy to theProcessRunner.- The
ProcessRunnerissues commands to the remote runner and the remote runner goes through steps 1 to 3 itself.
The current GUI engine deviates from the above by
- Not supporting in-process execution - so step 3 never takes place.
- Supporting "pluggable agents", i.e. agents as extensions. However, they are still always proxies for a remote process, which they launch. (UPDATE: this is not yet merged to main)
~~Because the GUI engine has already taken those steps toward generalized agents, I'm using that engine for my spike.~~ UPDATE: See further comment on selection of a base for the spike.
SECOND, here's how I'd like to see agents work...
- Continue to use a
MasterTestRunneras we now do. - Rather than holding internal runners directly,
MasterTestRunnerwill acquire an agent. A new service will be needed, which knows what agents are available and can decide which ones to use based on settings in the package. - An agent will return an internal runner on request. The engine will not actually know where that runner is located - whether in-process, in a separate process or on a separate machine.
- Once `MasterTestRunner has a set of agents with runners, it will continue to call the runners directly, as it now does.
- I'll wait to see what the code tells us, but I think we'll see some structural changes as a consequence of all this:
TestAgencywill either disappear or be seriously restricted in what it does. The process management functionality will move into the particular agent type, for example.- We may end up distinguishing engine services from agent services, possibly leading to splitting the engine.core assembly.
FINALLY, if we decide that the spike answers the question in the title positively, I'll define a set of steps - independent PRs - to get it into the 4.0 release.
Your proposal does sound 'cleaner' and looks like it simplifies supporting different runners without the complexity that we have now. I think that as you say, we'll need to see what the code tells us. I'd be interested in where this goes, but I will leave it up to @ChrisMaddock.
I originally thought of using the GUI engine as a base for the spike. On reflection, that would be easy initially but would create more work at the end as everything would then have to be recreated in the NUnit engine.
~~That leaves the question of what we may want to do in the dev-4.0 branch before I fork the spike branch. Here's my plan, which I'll keep up to date as items are added or completed.~~
The spike was completed and the dev-4.0 branch is no longer used. This list now reflects changes being made to main
- [x] #912
- [x] #913
- [x] #889
- [x] #861
- [x] #1168
- [ ] #877
- [ ] #955
- [ ] Replace ProcessRunner with agent launchers
I have nothing to add, all this sounds great to me!
See plan update above
The spike having been completed, we are now in the process of working toward an actual 4.0 release. I'm renaming this to cover actual implementation of the feature.