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

Split engine into two assemblies #690

Merged
merged 16 commits into from
Oct 24, 2019
Merged

Split engine into two assemblies #690

merged 16 commits into from
Oct 24, 2019

Conversation

CharliePoole
Copy link
Collaborator

@CharliePoole CharliePoole commented Oct 8, 2019

Fixes #684

This is an alternative approach to issue #684, as compared to that of PR #689.

I've brought this up to the same stage of (partial) completion as #689 so they can be compared. There's lots more to do and I'd like to pick one approach before continuing.

As explained elsewhere, I think this PR, which creates only a single new assembly, is to be preferred at the moment. Starting from scratch, I might do it otherwise, but we're pretty far from that. Creating a single new assembly leaves the door open for further splitting if it should be called for.

Both this PR and #689 only deal with splitting the engine, which is still referenced as if it were a single entity. Once the split is complete, then more work is needed to actually use the lower part by itself in the agent assemblies.

I had hoped this could be done as a set of small PRs. But that would require reviewing one bit of it without knowing what comes next. I'm happy to merge either this or #689 as a whole or up to a certain point. Both PRs are probably best reviewed one commit at a time.

FYI @nunit/engine-team - I'll be spending tomorrow flying back to the US and probably won't get back to this until the day after. Let me know which PR you think I should continue.

@ChrisMaddock
Copy link
Member

Hi Charlie - I've had a quick look through both, and long-story-short, I agree. The division in the first version is unclear to me, even as someone who's familiar with the codebase. I'm sure that would start to make sense if I started to pull things apart and learnt more about the inter-dependencies, but second version feels much more approachable to me.

I had hoped this could be done as a set of small PRs. But that would require reviewing one bit of it without knowing what comes next

I prefer working like that myself, if it's possible to cover a quick 'what and why' in the PR description. Whatever works best, though.

@CharliePoole
Copy link
Collaborator Author

@ChrisMaddock I'll continue in this way - splitting into two assemblies - and I'll eventually delete the old ones (both #689 and #580).

Regarding small PRs, let's use this one as a roadmap. I've added @jnm2 to the requested reviewers. @jnm2 can you figure out where in the series of commits this starts interfering with what you are doing? It's trivial to break this big PR up if we want.

Meanwhile, I'm continuing in this path, using some of the jet-lag energy I have after flying home yesterday.

@CharliePoole CharliePoole changed the title WIP - Issue 684b Split engine into two assemblies Oct 11, 2019
@CharliePoole
Copy link
Collaborator Author

This is ready for review now.

All the commits up to the last one simply move code to the new assembly and make adjustments so that the tests keep passing. The final commit is the real meat of it, since it causes the agents to reference the nunit.engine.core assembly and use CoreEngine, rather than nunit.engine and TestEngine.

There are a few more things that could be done, but this PR is as big as I want to go. I'm also willing to split it up into several PRs if anyone sees value in that.

@CharliePoole
Copy link
Collaborator Author

@nunit/engine-team I'd appreciate somebody - or even everybody - chiming in on this. I'm blocked on about four other things while waiting for clarification on which way you want to go. To be clear, even if it isn't quite ready to be merged, I need to know what direction folks want to go before I'll be able to work on those other things. So if you don't have time for a detailed review, that's OK, but your views on (1) whether to break up the engine this way, (2) whether to have two pieces or three and (3) whether I need to break up this PR to accommodate other work in progress would really help.

@ChrisMaddock
Copy link
Member

Hi Charlie. Have left my thoughts on direction above. This PR looks fine to review as is to me, it's a lot of changes, but the vast majority are just file moves

@CharliePoole
Copy link
Collaborator Author

Good! Now if somebody could review it please!

@nunit/engine-team Chris has said he doesn't have a lot of time, so it would be great if somebody else took a look.

@jnm2 I'm particularly concerned about not messing up the long-running PR you are working on.

Copy link
Member

@ChrisMaddock ChrisMaddock left a comment

Choose a reason for hiding this comment

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

Hey Charlie,

This looks great! I've left a bunch of comments on minor bits and pieces throughout - the overall picture looks a lot clearer than what we currently have. Some additional thoughts, as I can't leave a comment attached to a file move...

  • I would have suggested moving the files in Core/Agents out of the Engine Core to the agent - but I think @jnm2's work will shortly be removing those classes anyway, so I'm not too worried.
  • It would be great to get RuntimeFramework, and all the related classes over to the main engine - it looks like it's only used by the agent to create a single log message! That can be a separate PR however, there's enough in this one!
  • Also for future: I wonder if there's any way we can get the ExtensionService over to nunit.engine as well. That feels like a big piece of functionality, which shouldn't be required in the agent. (I can see that it's currently needed by the DriverService, however!)

src/NUnitEngine/nunit-agent/Program.cs Outdated Show resolved Hide resolved
@@ -14,7 +14,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="..\EngineVersion.cs" LinkBase="Properties" />
<Compile Include="..\nunit.engine\Internal\ExceptionHelper.cs" Link="ExceptionHelper.cs" />
<Compile Include="..\nunit.engine.core\Internal\ExceptionHelper.cs" Link="ExceptionHelper.cs" />
Copy link
Member

Choose a reason for hiding this comment

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

If this is in the core library, I guess it can just be referenced rather than linked in now, right? That would make it consistent with the rest of the structure.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's tricky. The console runner would then have to directly reference the core engine directly. Otherwise we end up with duplication of the class in console tests. I followed that path for a bit, until it became too hairy and I reverted to shared source code for this particular helper.

@@ -12,7 +12,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="..\EngineVersion.cs" LinkBase="Properties" />
<Compile Include="..\nunit.engine\Internal\ExceptionHelper.cs" Link="ExceptionHelper.cs" />
<Compile Include="..\nunit.engine.core\Internal\ExceptionHelper.cs" Link="ExceptionHelper.cs" />
Copy link
Member

Choose a reason for hiding this comment

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

As above


private readonly List<ExtensionPoint> _extensionPoints = new List<ExtensionPoint>();
private readonly Dictionary<string, ExtensionPoint> _pathIndex = new Dictionary<string, ExtensionPoint>();

private readonly List<ExtensionNode> _extensions = new List<ExtensionNode>();
private readonly List<ExtensionAssembly> _assemblies = new List<ExtensionAssembly>();

public IList<Assembly> RootAssemblies { get; } = new List<Assembly>();
Copy link
Member

Choose a reason for hiding this comment

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

This look unused?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Odd... it was used. Looking just at the code, it appears that extension points in the nunit.engine.core and nunit.engine.api will be found but not those in nunit.engine. But we know they are found because the tests pass!

Obviously, in the course of implementing this three times, I must have changed the approach. I'll verify and possibly remove this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OK... I realized at some point that all our extension points are currently defined in nunit.engine.api and nunit.engine.core (only one in the latter). I think RootAssemblies was needed in a three-way split, but not in a two-way split.

I think some way to specify roots to be searched for extension points will be needed at some point - for example if we want to allow extension points in nunit3-console. However, it could be removed now or just commented as being for future use. I'm OK either way.

@@ -21,9 +21,11 @@
<ItemGroup>
<Compile Include="..\EngineVersion.cs" LinkBase="Properties" />
<Compile Include="..\nunit-agent\AgentExitCodes.cs" LinkBase="Agents" />
<Compile Include="..\nunit.engine.core\Internal\ExceptionHelper.cs" Link="Internal\ExceptionHelper.cs" />
Copy link
Member

Choose a reason for hiding this comment

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

As above - can this just reference this class directly, rather than the link, to be consistent with the other Util classes?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

See earlier comment.

@CharliePoole
Copy link
Collaborator Author

@ChrisMaddock Thanks for your comments. I'll go through and make fixes this evening - moving house today!

Regarding putting some of the things with the agent itself... I envision a future where we have multiple agents, which is why I was playing around with the idea of a third library to hold stuff that is used in common by agents. I saw this change as the minimum needed to be done all at once to have something that made sense but I didn't want to add more.

I'll definitely be going further with this approach - perhaps in my own build, or simultaneously with NUnit if we end up going the same way. For what it's worth, my notion of an "agent" is that it encapsulates the "where we run" part of things along with the particular type of communication used to send commands and receive events and results. Right now, we only have one true agent, which runs in a separate process on the same machine and uses remoting to communicate. IME the big benefit of splitting out agents and making them as simple as possible is that we don't have to limit how many agents we support.

@ChrisMaddock
Copy link
Member

@CharliePoole Oh! We'll need to update all the packaging for this too, right? NuGet, Choco and the msi will all definitely be affected - not sure about how the zip is gathered in Cake, off the top of my head.

@CharliePoole
Copy link
Collaborator Author

Agreed. Are you OK with that as a separate PR?

@ChrisMaddock
Copy link
Member

I'd prefer to keep master releasable with this one (i.e. all in one PR) - but happy to go with two separate PR's, if you feel this is getting laborious to work with. 🙂

@CharliePoole
Copy link
Collaborator Author

Amount of work for me is about the same but one PR gives re-reviews of the whole thing. Also, current PR will likely cause merge conflicts for others whereas packaging probably won't.

@CharliePoole
Copy link
Collaborator Author

Easiest packaging will be to retain same packages for this release. Consider adding separate core package later.

@ChrisMaddock
Copy link
Member

ChrisMaddock commented Oct 22, 2019

Absolutely agree on not adding 'core package' - was just thinking the new assembly needs to be included in the current packages, otherwise they won't work! I think it would be better to do that in the same PR if that's ok with you - it's only a few lines, and easy to review separately. 🙂

At this point, I'm planning to rebase other PR's over this one, rather than the other way round - as I think that'll be easier to do.

In terms of reviews on this, I'm happy to merge this just with mine and yours reviews, if you would be - I appreciate others are pretty busy at the moment, and this is a lot to look through! I'm happy that enough seen/commented on #684 and #580 to agree with the approach - and the details are pretty clear-cut here if we're aiming for 'minimum change', and can always be changed in future. 👍

@CharliePoole
Copy link
Collaborator Author

OK... let's do that. Ill-treatment to finish today, Pacific time.

@ChrisMaddock
Copy link
Member

No rush on my part! 🙂

This was referenced Oct 22, 2019
@CharliePoole
Copy link
Collaborator Author

@ChrisMaddock Ready for another review. I added nunit.engine.core to all the packages with nunit.engine and verified the contents for everything but the msi, which I'm not set up to build locally. Someone should check that.

Copy link
Member

@ChrisMaddock ChrisMaddock left a comment

Choose a reason for hiding this comment

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

Ok - let's get this merged! There's a couple of 'tidy-up' bits, but at this point, I'm keen to get this in, and handle those in a separate PR.

Thanks for pulling this together @CharliePoole - it's a real big step along the road to more minimal agents. 😄

@ChrisMaddock ChrisMaddock merged commit 0958996 into master Oct 24, 2019
@ChrisMaddock ChrisMaddock deleted the issue-684b branch October 24, 2019 16:50
@jnm2
Copy link
Collaborator

jnm2 commented Oct 24, 2019

I'm particularly concerned about not messing up the long-running PR you are working on.

Thanks. I was already planning to redo it all though, just referencing my current PR as I go and trying to do it in as small of PRs as I can figure out. I hope you are able to feel free not to worry about the long-running PR. (Maybe I should close it for now?)

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.

Split engine into upper and lower parts
3 participants