Last updated January 23, 2011 19:07, by Jørgen Austvik
Feedicon  

Example test suite: Memcached

In the jet-example-memcached directory there is an example test suite that is written to demonstrate how you can use JET to test your own product.

Build memcached

This is how to build memcached, memcachetests and libevent from source.

First, you must create some directories for storing the source code:

 $ mkdir devel/memcached
 $ cd devel/memcached

Then you can download the source:

 $ git clone git://github.com/trondn/memcached
 $ git clone git://github.com/trondn/memcachetest.git
 $ curl http://www.monkey.org/~provos/libevent-1.4.13-stable.tar.gz -o libevent-1.4.13-stable.tar.gz

Then create some directories for storing the binaries we build:

 $ mkdir /install
 $ chmod a+rw /install

Build the source. Starting with libevent:

 $ tar xzf libevent-1.4.13-stable.tar.gz
 $ cd libevent-1.4.13-stable
 $ ./configure --prefix=/install/libevent
 $ make
 $ make install
 $ cd ..

Then build the memcached server

 $ cd memcached
 $ ./autogen.sh
 $ ./configure --prefix=/install/memcached --sith-libevent=/install/libevent
 $ make
 $ make install
 $ cd ..

And then memcachetest

 $ cd memcachetest
 $ aclocal
 $ autoheader
 $ automake --add-missing
 $ autoconf
 $ ./configure --prefix=/install/memcacetest
 $ make
 $ make install
 $ cd ..

You should now be able to find the executables:

 $ find /install -name "memcachetest"
 /install/memcachetest
 /install/memcachetest/bin/memcachetest
 $ find /install -name "memcached"
 /install/memcached
 /install/memcached/bin/memcached
 /install/memcached/include/memcached
 $ find /install -name "libevent.la"
 /install/libevent/lib/libevent.la

The source code

The source code is places under jet-example-memcached/src/java, in the com.sun.jet.example.memcached package with sub-packages.

Properties

In src/main/resources/testsuite_jetdefaults.propertie there are added properties that are unique to the tests for memcached. There are some jet.loghandle settings, which says that different levels of logging for our tests should end up in different log files.

'The jet-installpath.* settings tell JET which sub-directories that should be copied for the different software under testing.

There is also some added settings that are added for the mamcached testsuite and the tests that we have here. jet.memcached.* and jet.memcachetest.* are settings that are used when we run the memcached and memcachedtest binaries. These can be set in source code, in the test XML file or in the settings used to run the test.

Setup

There is one setup that is used to start the memcached server, in the src/main/java/com/sun/jet/examples/memcached/setup/MemcachedSetup.java file. It reads parameters to start memcached with from the bindings, and start memcached on all serverhosts (or on the client if there is no server hosts). It will also read the pid file that memcached create, and stop the process when we are done.

Test Case

We have one simple test case, and one class that contains helper methods that our test cases can use. src/main/java/com/sun/jet/examples/memcached/testcase/MemcacheTestCase.java is the parent test case class, and contains utility methods to get the servers that run memcached and the port numbers. More methods would be added here in a real test suite.

src/main/java/com/sun/jet/examples/memcached/testcase/MemcachetestTestCase.java sontains a simple test case with one test method testMemcachetest(), which starts memcachetest against the running servers.

XML File

We have a single XML file that tie the test setups, bindings and test cases together. In this example test suite there exists only one test, src/main/java/com/sun/jet/examples/memcached/test/memcachetest.xml. It runs the MemcachedSetup on time, and then the test one time inside it. Here we could have added several <Binding> elements to start memcached or memcachetest with different options.

Running the test

To run the tests, you need the software under testing, JET and the tests.

Directory Structure

This example uses the following directory structure:

The software under testing is located here:

 /install/software_under_testing_1/bin
 /install/software_under_testing_1/lib
 /install/software_under_testing_2/bin
 /install/software_under_testing_2/include
 ...

The JET infrastructure and tests is located here, and copied to this directory by run.sh:

 ./ts_dir/lib/test

The logs are located here:

 ./JET-logs

Properties

The directory layout above is used in sample_memcached.properties. Here you will see that the software under testing is located by jet.installpath.* settings. In addition there will be a jet.testlogpath that says where the log files should be located, and two settings which tell JET which machines should be used (jet.servermachines and jet.clientmachines). The jet.protbase is unique for you user, so that different users can run independent tests on the same machine.

Run

We have added a simple run.sh command that can be used to run the simple example test case.

  • Mysql
  • Glassfish
  • Jruby
  • Rails
  • Nblogo
Terms of Use; Privacy Policy;
© 2010, Oracle Corporation and/or its affiliates
(revision 20120127.ac94057)
 
 
Close
loading
Please Confirm
Close