Test before you run... Part II
Once we have the test code ready, as I explained on the first article, it's time to set up the environment.
I built the code shown in the previous post into a test assembly cmtest.dll.
Then I copied the assembly and the PNUnit binaries to all the test machines. Fortunately the test network is quite nicely set up, so all the linux machines share a directory which makes deployment very simple.
In case you need any additional data such us configuration files for your test or data, you need to deploy them to the test machines too.
In our case we need to have a Plastic SCM client on each machine. Fortunately we don't have to run an installation since Plastic supports copy deployment, and replacing versions is pretty simple, since we just put the binaries on the shared path.
Note: so far PNUnit (remember, Parallel NUnit, although probably Distributed would be a better word) does not handle deployment. It just focuses on letting you create a network of agents and a launcher to run tests on these agents. You've to take care of copying both the test framework and the test code into the test machines.
As I wrote in my previous post, we'll be running several clients against a single server, stress testing it and gathering results.
In this case all the client machines will be running the same code, something that could be easily changed just writing more test scenarios in C#.
How does the XML configuration file looks like?
<br /><TestGroup><br /> <ParallelTests><br /> <ParallelTest><br /> <Name>LoadTest</Name><br /> <Agents><br /> <string>l101a1:8080</string><br /> </Agents> <Tests><br /> <TestConf><br /> <Name>nopDeveloperDani1</Name><br /> <Assembly>cmtest.dll</Assembly><br /> <TestToRun><br /> cmtest.BotTesting.DeveloperBot.RunSimplified<br /> </TestToRun></p> <Machine>_AGENT0</Machine></p> <TestParams><br /> <string>/tmp</string> <!-- wk dir --><br /> <string>server:8084</string><br /> <string>default</string> <!-- repository --><br /> <string>5</string> <!-- iterations --><br /> </TestParams></p> </TestConf><br /> </Tests><br /> </ParallelTest><br /> </ParallelTest><br /></ParallelTests><br /></TestGroup></p>
The previous listing shows how a simple test setup looks like. I'm just specifying a single client machine this time (since I'll be starting up the server manually), which will run on the agent started up (this is another step) on machine l101a1 at port 8080.
Running a 100 test bots will be as simple as creating 100 entries on the agents section and setting up new TestConf sections (the hardest and most boring task to do).
In my case I've developed a small C# app to generate the XML test script from a list of available machines. It's really simple.
Note: remember I'm testing Plastic and SVN, so I'm using a shared path to store the test code, but I'm specifying /tmp as the path for the workspaces (the place where the tests will create their data) which is local to each test machine and hence will not impact performance due to additional network usage.
Running the first test
The steps to run the test are simple:
- Start an agent at the client machine
- Start up the server (this is specific for this test I'm running, but it will vary on yours)
- Launch the test using the PNUnit launcher application
And the steps will be:
On the client machine:
$ /home/scm/pnunit/pnunit-agent 8080 /home/scm/pnunit
On the server machine:
- Start up the Plastic SCM server
- pnunit-launcher.exe test01.conf
Once I execute the launcher, it will send a message to the agent to start up the test there, which in turn will launch Plastic (or SVN) commands to make operations against the server.
The launcher is executed at the same location where the Plastic server is, but it is not a requirement, I mean, I could be launching the tests from a totally different machine.
Running a single test is quite simple, but what if we've to start up 100 pnunit-agents at the same time? Then a little bit of scripting can help making things simpler, right?In the next post I'll show how to use ssh to start up and stop agents remotely.