Develop with iTest

iTest provided functionality

Shell support

iTest implements transparent shell-outs from test written in Java and Groovy. This support is implemented in org.apache.itest.shell package.

...
  Shell sh = new Shell("/bin/bash -s");
  sh.exec("hadoop jar $HADOOP_HOME/hadoop-examples.jar sleep -mt 1 -rt 1 -m 10 -r 10");
  assertTrue ("Non-zero return code", sh.ret == 0);
...

Of cource the same can be done using pure Java (Groovy) code

...
  Configuration conf = new Configuration();
  SleepJob sljob = new SleepJob();
  sljob.setConf(conf);
  conf = sljob.setupJobConf(10, 10, 100, 100, 100, 100);
  RunningJob rJob = JobClient.runJob(conf);
...

Package management

In order to manipulate native packages (e.g. for the purpose of testing their behavior) iTest provides high-level packaging abstraction with concrete implementations for .deb, .rpm, packages. More is in the pipeline.

A typical use of packaged software involves installing/updating/removing packages; manipulating statuses of the services, etc. Here how this can be done with iTest:

  static public PackageManager pm = PackageManager.getPackageManager();
...
  PackageInstance pkg = PackageInstance.getPackageInstance(pm, "hadoop-0.20");
  pm.install(pkg);

This code snippet takes care about getting an instance of the host OS' package manager, creating an instance of "hadoop-0.20" package, and instructing management layer to install said package.

Because package management is implemented on top of JVM platform one can easily run the following scenario of package testing:

  • install package
  • run existing system tests
  • check results
  • remove the package

iTest's package management subsystem also allows certain manipulations with repositories for apt-get, yum, and zypper.

Jar helpers

These helpers are a special kind of functionality to facilitate test execution contained in appopriate artifacts.

A typical use case is to unpack a data which has been archived along with the test code from within the test itself. Normally this might be non-so-easy task. Not so with iTest help.

  JarContent.unpackJarContainer(MyTestClass.class, '.', DATA_DIR);

The above static call will look in the classpath for the jar containing MyTestClass class file and unpack everything matching the pattern ('.' everything in this case) to the specified destination DATA_DIR.

Other manipulations are enabled. Please refer to project's documentation for more information about current framework APIs.