Start with the client-side files. It's amazing how much stuff you can do with them (including reboots, etc). The client-side harness will communicate back with the server, and monitor status, etc.

However, if you want to do more powerful things, like control a complex test across a cluster, you'll probably want to use server-side control files. Read the overview documentation on how the server works first, this will help explain things ...

Server-side control files have the same philosophy as the client-side files, but run on the server, so it's still a Python script, with all the flexibility that gives you. You should generally name server-side control files ending in '.srv' - that way if you use the scheduler, it'll understand what they are, and do the right thing for you.

You run a server side control file by doing

server/autoserv mycontrolfile.srv -m <machine,machine,...>

We strip out the -m paramater, break up the comma-separated list, and put that into your namespace as a list called "machines". Anything else on the command line (except the autoserv path, and the control file name) will appear as a list called "args".

A simple one might do something like this:

host = hosts.SSHHost(machines[0])

kernel = rpm_kernel.RPMKernel()
kernel.get('/home/me/kernel-smp-2.6.20.x86_64.rpm')

print host.run("uname -a").stdout
kernel.install(host)
host.reboot()
print host.run("uname -a").stdout
host.reboot()
print host.run("uname -a").stdout

Firstly we create a "host" object from the machine name. That has lots of magic helpers for you, and is how you get most stuff done on the client.

Then we create an RPMKernel object, and set it up with a rpm to use (you can also use a URL here instead, it'll figure it all out).

Now we want to install that kernel on the host with kernel.install(). Don't worry, it can figure out if you're using grub / lilo / yaboot, whatever, and will handle that all transparently for you. In the kernel we're testing is broken, we probably don't want to install it as the default option, so unless you say otherwise, we'll set it up to only boot once, then fall back to the normal default kernel you had set up.

So to check it's working correct, we run "uname -a" on the remote host, and print it's stdout output. Then we reboot to the new kernel, check it again and then back to the old kernel. So you should get the output

OLD KERNEL VERSION
NEW KERNEL VERSION
OLD KERNEL VERSION

OK, so now supposing we want to run some client side tests on that new kernel we created. There are two main helpers - run() and run_test().

So the following are equivalent:

host = hosts.SSHHost(machines[0])
at = autotest.Autotest(host)
at.run_test('kernbench', iterations = 2)

Which is simpler, but the following:

host = hosts.SSHHost(machines[0])
at = autotest.Autotest(host)
control = "job.run_test('kernbench', iterations=2)"
at.run(control)

Allows you to run sets of tests. A more realistic file might be:

host = hosts.SSHHost(machines[0])

kernel = rpm_kernel.RPMKernel()
kernel.get("http://myserver/kernels/kernel-smp-2.6.20.x86_64.rpm")
kernel.install(host)
host.reboot()

at = autotest.Autotest(host)
control = """\
job.run_test('kernbench', iterations=5)
job.run_test('dbench', iterations=5)
job.run_test('tbench', iterations=5)
job.run_test('bonnie', iterations=5)
job.run_test('iozone', iterations=5)
job.run_test('fsx')
"""
at.run(control)

Using parallel

Like in client-side control files, multiple tasks can be run in parallel on a server side job. However, the mechanism for doing so is somewhat different. Instead of using a method on the job object, you need to make use of the contents of the subcommand module on the server. The basic mechanism is to create a subcommand object for each task, which takes as parameters a function and a list of arguments to be passed to it. You then call parallel with the list of your tasks as a parameter.

However, for the common case of running the same task on multiple machines in parallel, a parallel_simple function is provided to run the same task in parallel on a list of machines, as in:

def run(machine):
        host = hosts.SSHHost(machine)
        at = autotest.Autotest(host)
        at.run_test('sleeptest')

parallel_simple(run, machines)

This will run a sleeptest on all the specified machines in parallel.

ServerControlHowto (last edited 2008-01-10 22:26:17 by jadmanski)