HomeBlogMeet Pumba: Your Gateway to Chaos Testing

Meet Pumba: Your Gateway to Chaos Testing

Author

Date

Category

Chaos testing, also known as chaos engineering, is a proactive method for assessing the resilience of software systems by deliberately introducing failures and unexpected conditions. Unlike traditional testing approaches, which focus on expected behaviors, chaos testing aims to simulate real-world scenarios of system failure or instability. By subjecting systems to controlled chaos, engineers can uncover weaknesses, identify points of failure, and enhance overall system robustness. This approach helps organizations gain insights into how their systems behave under stress, enabling them to optimize performance and reliability before potential issues impact end users, ultimately fostering greater confidence in system resilience and stability.

What is Pumba?

Pumba is an open-source tool used for chaos testing and network emulation in containerized environments, particularly in Docker and Kubernetes ecosystems. It is designed to simulate various network conditions and failures, such as packet loss, latency, and network partitioning, to assess how containerized applications respond under adverse circumstances. Pumba allows developers and DevOps teams to introduce controlled chaos into their testing environments, helping them identify weaknesses, improve fault tolerance, and enhance the overall resilience of their containerized applications. With its flexible and customizable features, Pumba has become a valuable tool for implementing chaos engineering practices in modern software development workflows.

What Pumba can do?

Pumba offers a range of capabilities aimed at chaos testing and network emulation within containerized environments like Docker and Kubernetes. Here are some of the key features and functionalities of Pumba:

  1. Network Emulation: Pumba can simulate various network conditions and failures, including packet loss, latency, bandwidth limitations, and network partitioning. This allows developers to test how their containerized applications behave under different network scenarios.
  2. Chaos Injection: Pumba enables controlled chaos testing by introducing disruptions and faults into containerized environments. It can randomly kill, pause, or stop containers, as well as introduce CPU or memory stress, to assess system resilience and fault tolerance.
  3. Targeted Container Actions: Pumba allows users to target specific containers or groups of containers for chaos testing, providing flexibility and granularity in testing scenarios.
  4. Customizable Behavior: Users can customize Pumba’s behavior and parameters to suit their testing needs, including specifying failure rates, durations, and scheduling chaos events.
  5. Integration with Orchestration Platforms: Pumba seamlessly integrates with container orchestration platforms like Docker Swarm and Kubernetes, making it easy to incorporate chaos testing into existing development and deployment pipelines.
  6. Docker Compose Support: Pumba supports Docker Compose, enabling users to define and orchestrate multi-container applications for chaos testing purposes.

How to install and run Pumba?

To install and run Pumba, follow these general steps:

  1. Install Docker: Pumba is typically used within Docker containers. Ensure Docker is installed on your system by following the official Docker installation guide for your operating system.
  2. Pull Pumba Docker Image: Pumba is available as a Docker image on Docker Hub. You can pull the latest Pumba image using the following command:
$ docker pull gaiaadm/pumba
  1. Run Pumba Container: Once you have the Pumba Docker image, you can run it as a container. Depending on your testing requirements, you can specify various options and parameters to customize Pumba’s behavior. Here’s a basic example of how to run Pumba:
$ docker run -it --rm --name pumba gaiaadm/pumba

This command starts a Pumba container interactively and removes it after it stops running.

  1. Run Chaos Tests: With the Pumba container running, you can execute chaos tests by running specific Pumba commands inside the container. For example, to introduce network latency to containers named “my-container”, you can use:
$ pumba --random latency --duration 60s --interval 10s --name my-container

This command introduces random latency to the specified containers for a duration of 60 seconds, with a latency change every 10 seconds.

  1. Explore Pumba Commands: Pumba offers various commands and options for chaos testing. You can explore these commands and their usage by accessing the Pumba documentation or running pumba --help inside the container.

Remember to adjust the commands and options based on your specific testing requirements and environment. Additionally, ensure that you have the necessary permissions to run Docker commands and access Docker resources on your system.

Pumba CLI at a glance

$ pumba helpPumba version v0.2.0
NAME:
Pumba - Pumba is a resilience testing tool, that helps applications tolerate random Docker container failures: process, network and performance.USAGE:
pumba [global options] command [command options] containers (name, list of names, RE2 regex)VERSION:
v0.2.0COMMANDS:
kill kill specified containers
netem emulate the properties of wide area networks
pause pause all processes
stop stop containers
rm remove containers
help, h Shows a list of commands or help for one commandGLOBAL OPTIONS:
--host value, -H value daemon socket to connect to (default: "unix:///var/run/docker.sock") [$DOCKER_HOST]
--tls use TLS; implied by --tlsverify
--tlsverify use TLS and verify the remote [$DOCKER_TLS_VERIFY]
--tlscacert value trust certs signed only by this CA (default: "/etc/ssl/docker/ca.pem")
--tlscert value client certificate for TLS authentication (default: "/etc/ssl/docker/cert.pem")
--tlskey value client key for TLS authentication (default: "/etc/ssl/docker/key.pem")
--debug enable debug mode with verbose logging
--json produce log in JSON format: Logstash and Splunk friendly
--slackhook value web hook url; send Pumba log events to Slack
--slackchannel value Slack channel (default #pumba) (default: "#pumba")
--interval value, -i value recurrent interval for chaos command; use with optional unit suffix: 'ms/s/m/h'
--random, -r randomly select single matching container from list of target containers
--dry dry runl does not create chaos, only logs planned chaos commands
--help, -h show help
--version, -v print the version

Pumba in Docker Container

In order to give Pumba access to the Docker daemon on the host machine, you will need to mount var/run/docker.sock unix socket. With this command Pumba will not kill its own container.

$ docker run -d \
-v /var/run/docker.sock:/var/run/docker.sock \
gaiaadm/pumba:master pumba \
kill --interval 10s --signal SIGTERM ^hp

Get to know more about Pumba

Have a look at official Pubma home page on Github and its documentations at:

https://github.com/gaia-adm/pumba

Mehdi Shokoohi

Software Quality Engineer

Recent posts

Recent comments