Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Setting up VM Nodes at runtime
Jochen
#1 Posted : Friday, January 27, 2017 11:07:12 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 1/27/2017(UTC)
Posts: 5

Thanks: 1 times
Hi, I am looking to use NCrunch in a rather unusual way.
At the moment, I have NCrunch setup with distributed processing to manually execute functional GUI tests on VirtualBox VM's. All these VM's are run locally, on my development laptop.
Since I am manipulating all kinds of Windows services during these GUI tests, I sometimes break the environment of the VM.
This gives me problems: all tests that run on this node after breaking the environment automatically fail.

To solve this issue, I would like to be able to setup the VM and tear it down again in my test code.

Ideally, the flow would go as this:
1: In Visual Studio 2015, I right click on an NCrunch test and choose 'Run selected test on server' -> 'Node 1'.
2: The VM of 'Node 1' is booted, NCrunch connects to this node and starts remote test execution (of only this test) after building the solution.
3: After test execution, the VM of 'Node 1' is shut down.

I understand that this might be impossible to do. However, the following flow would still be acceptable:
1: In Visual Studio 2015, I run a test from the VS Test Explorer (using NUnitV3 test adapter)
2: The test itself knows that it needs to boot up the VM 'Node 1'.
3: The VM of 'Node 1' is booted by the test, NCrunch connects to this node and starts remote test execution (of only this test) after building the solution.
4: After test execution, the test result is fed back into the VS Test Explorer.
5: The test shuts down the VM of 'Node 1'.

Now, I think that the 2nd scenario is possible using the Console version of NCrunch.
I've been looking through the documentation of the NCrunch console, however, and I can't seem to really figure it out.
I have the following questions:
- Is it possible to drive NCrunch programmatically to connect to a Node?
- Is it possible to tell an NCrunch node to only run 1 test programmatically? Do I have to create seperate engines for each test?
- How do I route the test results back into the NUnit test adapter?

The answer to some of these questions might be obvious.
I'm not very experienced in working with VM's and the documentation for the console is a little lacking, honestly.

The ideal solution would be that I could tell the host computer, which is running NCrunch in VS2015, to run some scripts (that setup the VM, for example) before building and testing the solution on a remote Node when I tell NCrunch to run the tests.
The problem I have at the moment is chicken and egg: all tests are run in the Node's NCrunch workspace, so I can't use a SetupFixture or anything to setup my VM, since the VM needs to already exist in order to run the test.
Jochen
#2 Posted : Friday, January 27, 2017 3:35:22 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 1/27/2017(UTC)
Posts: 5

Thanks: 1 times
What I actually need to be able to do is to run some scripts on the host computer before and after each test run.
At the moment I've hacked together a rather brittle way to enforce this by running the following script at the [TearDown] of my tests:
"shutdown /r /t 5 /f"

This will shut down and restart the VM with a 5 second delay, just enough time for NCrunch to intercept the test results. Ofcourse extremely extremely brittle.
This, combined with the "--autoreset" functionality of VirtualBox, ensures that my VM has a clean slate before each test.

Do you see any way that I can make this workaround more robust?
One edge case that isn't covered is when the 5 second delay before rebooting isn't enough time to send the test results back to the host or if the following test is already getting executed within this 5 second timeframe.
Is there a way for me to set a delay in between test executions, so that I can be sure that the VM doesn't reboot while the next test is already being executed?

By the way: keep in mind that these are extremely expensive GUI tests. Every test takes between 1 to 5 minutes to complete.
The added overhead of rebooting the VM and reconnecting the Node isn't a concern.

We're trialing NCrunch in a professional .NET developers environment at the moment.
We really like the software but it would unfortunately be a deal breaker for our project manager if it's impossible to integrate it in the described test flow above.
So please, help us shoehorn your great tool into our workflow and we'll be able to return the favor by acquiring a corporate license ;)
Remco
#3 Posted : Friday, January 27, 2017 10:03:18 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,145

Thanks: 960 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi, thanks for posting!

Short of an unstable solution requiring considerable micro-management, I don't think it's possible to get the NCrunch infrastructure to behave in the way that you've described. This is because what you are after is effectively a dynamic grid node that is remotely controlled with user code. At the moment, the only places where NCrunch is able to execute user code is in the tests themselves or in the build process.

I would instead urge you to think of this problem in a different way. This isn't really a distributed processing problem - it's more of a compatibility testing problem. The VMs themselves are essentially just an extension of the tests; they don't exist to scale the NCrunch engine, rather they are transient containers to isolate unstable code from the development environment.

The best way to resolve this is to build the infrastructure into the tests themselves. If you have a use case that requires code to be run in a VM, place all this code within the scope of a single fixture. In the setup code for the fixture, initialise the VM and open a network connection to your own software running inside the VM that executes the test code. The results are then reported back over the network connection and the VM can be torn down in the teardown code at the end of the run. It takes a bit of plumbing to get this up and running, but it does work very well. You can then look into scaling this solution horizontally using NCrunch distributed processing, where each grid node has their own set of VMs.
1 user thanked Remco for this useful post.
Jochen on 1/30/2017(UTC)
Jochen
#4 Posted : Saturday, January 28, 2017 5:08:55 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 1/27/2017(UTC)
Posts: 5

Thanks: 1 times
The problem with that is that the GUI automation framework (using TestStack.White) needs to run ON the VM in order for it to be able to inspect the UIA elements.
That was the whole reason we want to use NCrunch, because we'd otherwise have to develop my our library that copied code from the host to a VM and compiled and ran it on target. Developing all of that is seriously out of scope for our project.
Remco
#5 Posted : Saturday, January 28, 2017 9:56:56 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,145

Thanks: 960 times
Was thanked: 1290 time(s) in 1196 post(s)
Sorry, there may not be much I can do to help you then. The kind of setup you're looking for would require considerable changes to be made to the NCrunch engine. I'm not personally aware of any project that will enable such a setup out of the box.
Jochen
#6 Posted : Monday, January 30, 2017 8:26:06 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 1/27/2017(UTC)
Posts: 5

Thanks: 1 times
Why would it require such a large change to the engine? I might be blissfully ignorant as to the complexity of this, but I imagined the following:
If we could inject a blocking delegate on the host that returns a Boolean right before NCrunch sends the 'go' signal to a node that, we could implement a function that starts up the VM and returns a Boolean exit code.
Same thing afterwards, inject a blocking delegate on the host that returns a Boolean right after receiving the test results from the node, where we could implement a function that shuts down the VM.
If I added this to the feature request, would this be something that you would consider implementing?
In my opinion, this is a really useful feature for anyone who wants to run parallel and continuous end-to-end or user acceptance tests using NCrunch (which might not have been the original idea behind developing NCrunch, but which I think is a huge use-case).
Remco
#7 Posted : Monday, January 30, 2017 9:04:51 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,145

Thanks: 960 times
Was thanked: 1290 time(s) in 1196 post(s)
You are always most welcome to post feature requests to uservoice. This would make excellent sense as a feature request, and I agree it would be a valuable feature.

However, as developers we do often tend to oversimplify these sorts of problems on first glance. Because NCrunch is a packaged product, such a feature would require a certain level of polish before it could be considered safe to release. There are many edge cases to consider and the feature would need to fit with the existing model so that people could easily make sense of it. I say this only to try to help you understand that nothing is ever as simple as it seems with such a complex product.
Jochen
#8 Posted : Monday, January 30, 2017 9:14:26 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 1/27/2017(UTC)
Posts: 5

Thanks: 1 times
Remco;9753 wrote:
You are always most welcome to post feature requests to uservoice. This would make excellent sense as a feature request, and I agree it would be a valuable feature.

However, as developers we do often tend to oversimplify these sorts of problems on first glance. Because NCrunch is a packaged product, such a feature would require a certain level of polish before it could be considered safe to release. There are many edge cases to consider and the feature would need to fit with the existing model so that people could easily make sense of it. I say this only to try to help you understand that nothing is ever as simple as it seems with such a complex product.


I absolutely understand and I know first-hand how nothing is ever as simple as it seems with a real-life product.
I will post the feature request to uservoice.
Now I know you can't give me anything concrete or make any promises, but would this feature be something that you would implement in the near future (and thus for example, we could expect it to be available in a couple of weeks/months) or would it definitely be something that gets a back seat when compared to other development work on NCrunch?
Thank you for you quick responses!
Remco
#9 Posted : Monday, January 30, 2017 11:37:23 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,145

Thanks: 960 times
Was thanked: 1290 time(s) in 1196 post(s)
Jochen;9754 wrote:

I absolutely understand and I know first-hand how nothing is ever as simple as it seems with a real-life product.
I will post the feature request to uservoice.
Now I know you can't give me anything concrete or make any promises, but would this feature be something that you would implement in the near future (and thus for example, we could expect it to be available in a couple of weeks/months) or would it definitely be something that gets a back seat when compared to other development work on NCrunch?
Thank you for you quick responses!


I can say at this stage that there won't be any kind of movement on such a feature within the next 3 months.

This is because the product is undergoing major upgrades to handle the next generation of .NET (.NET core).

Beyond this, it depends entirely on how badly the feature is wanted (i.e. votes in uservoice etc) as to whether it is scoped.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.070 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download