Channels ▼

Pablo Santos

Dr. Dobb's Bloggers

Test before you run... Part II

March 23, 2009

Once we have the test code ready, as I explained on the first article, it's time to set up the environment.

Deployment

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.

XML configuration

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:

  1. Start an agent at the client machine
  2. Start up the server (this is specific for this test I'm running, but it will vary on yours)
  3. 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:

  1. Start up the Plastic SCM server
  2. 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.

What's next?

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.

Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.
 


Video