Arquillian Cube Q Extension 1.0.0.Alpha1 Released

Since we wrote this post we didn't laze around. Check our latest announcement.

The Arquillian team is proud to announce the 1.0.0.Alpha1 release of the Arquillian Cube Q Extension component!

This is the first release of Arquillian Cube Q. Q is an extension of Arquillian Cube that allows you to write chaos tests. As in Cube, it relies on Docker to execute these kind of tests.

There are several level of chaos that you might introduce in order to verify how your services are behaving when unexpected happens. Starting from network chaos (latency, bandwidth limitation, …​) to operative system chaos (cpu burn, io burn, dill disk, …​). Arquillian Q as all the Arquillian projects, reuses existing chaos frameworks by integrating them into Arquillian universe.

Supported Chaos

Network Chaos

Arquillian Cube Q implements network chaos leveraging Toxiproxy project.

You can use following toxics:

A test with network chaos with Arquillian Cube Q looks like:

@RunWith(Arquillian.class)
public class ToxicFuntionalTestCase {

  @ArquillianResource
  private NetworkChaos networkChaos;

  @HostIp
  private String ip;

  @Test
  public void shouldAddLatency() throws Exception {
    networkChaos.on("pingpong", 8080).latency(latencyInMillis(4000))
      .exec(() -> {

        URL url = new URL("http://" + ip + ":" + 8081 + "/hw/HelloWorld");
        final long l = System.currentTimeMillis();
        String response = IOUtil.asString(url.openStream());
        System.out.println(response);
        System.out.println("Time:" + (System.currentTimeMillis() - l));
        // assertions
    });
  }
}

In this example, the communication with pingpong container on exposed port 8080 is toxified with a latency of 4 seconds.

You can read more about network chaos at https://github.com/arquillian/arquillian-cube-q#network-chaos and an example at https://github.com/arquillian/arquillian-cube-q/tree/master/ftest-toxic

Container Chaos

In order to introduce chaos to the container, Arquillian Q integrates with Pumba project.

It supports following toxics:

  • stopping a container
  • removing a container
  • killing a container process with a signal.

A test with container chaos with Arquillian Cube Q looks as simple as:

@RunWith(Arquillian.class)
public class PumbaFunctionalTestCase {

  @ArquillianResource
  ContainerChaos containerChaos;

  @ArquillianResource
  DockerClient dockerClient;

  @Test
  public void shouldKillContainers() throws Exception {
    containerChaos
            .onCubeDockerHost()
                .killRandomly(
                        ContainerChaos.ContainersType.regularExpression("^pingpong"),
                        ContainerChaos.IntervalType.intervalInSeconds(4),
                        ContainerChaos.KillSignal.SIGTERM
                )
            .exec();

        final List<Container> containers = dockerClient.listContainersCmd().exec();
        // Pumba container is not killed by itself
        assertThat(containers).hasSize(1);

    }

}

In this example, containers called pingpong are killed every 4 seconds.

You can read more about container chaos at https://github.com/arquillian/arquillian-cube-q#container-chaos and an example at https://github.com/arquillian/arquillian-cube-q/tree/master/ftest-pumba

Operative System Chaos

To do operative system chaos Arquillian Q uses some modified version of Netflix Simian Army project scripts.

At this moment we provide:

  • blocking a port
  • burning CPU or IO
  • filling the disk
  • killing the process
  • null route

Here’s the example of the test with operative system chaos using Arquillian Cube Q:

@RunWith(Arquillian.class)
public class SimianArmyFunctionalTestCase {

    @ArquillianResource
    OperativeSystemChaos operativeSystemChaos;

    @HostIp
    String dockerHost;

    @HostPort(containerName = "pingpong ", value = 8080)
    int port;

    @Test(expected = Exception.class)
    public void shouldExecuteBurnCpuChaos() throws Exception {
        operativeSystemChaos.on("pingpong")
            .burnCpu(singleCpu())
            .exec();
        //.....
    }
}

p.This test burns one of the CPU

You can read more about operative system chaos at https://github.com/arquillian/arquillian-cube-q#operative-system-chaos and an example at https://github.com/arquillian/arquillian-cube-q/tree/master/ftest-simianarmy

What’s Next

As it is an Alpha1 release, you might expect some changes in the API as we move towards the final version, although we will try hard to not break anything.

Currently the toxics are explicitly defined in the code, for example you statically define latency of 4 seconds. Next step is creating a random method using which you can randomize the parameters of the toxics. Similarly you would be able to randomize the order of applying toxics.

What is Arquillian?

Arquillian is open source software that empowers you to test JVM-based applications more effectively. Created to defend the software galaxy from bugs, Arquillian brings your test to the runtime so you can focus on testing your application's behavior rather than managing the runtime. Using Arquillian, you can develop a comprehensive suite of tests from the convenience of your IDE and run them in any IDE, build tool or continuous integration environment.

Release details

Component Arquillian Cube Q Extension
Version 1.0.0.Alpha1 view tag
Release date 2016-08-29
Released by Alex Soto
Compiled against

Published artifacts org.arquillian.cube.q

  • org.arquillian.cube.q » arquillian-cube-q-api jar javadoc pom
  • org.arquillian.cube.q » arquillian-cube-q-spi jar javadoc pom
  • org.arquillian.cube.q » arquillian-cube-q-core jar javadoc pom
  • org.arquillian.cube.q » arquillian-cube-q-toxic jar javadoc pom
  • org.arquillian.cube.q » arquillian-cube-q-pumba jar javadoc pom
  • org.arquillian.cube.q » arquillian-cube-q-simianarmy jar javadoc pom

Thanks to the following list of contributors: Alex Soto, Aslak Knutsen, Stefan Miklosovic