Open DracoStriker opened 2 months ago
Yes, you can run multiple pumba
commands.
#!/bin/bash
# start two containers (alpine with iproute2 package)
docker run -d --name container1 hphil/alpine-iproute2 sh -c "trap 'exit 0' SIGTERM; while true; do sleep 1; done"
docker run -d --name container2 hphil/alpine-iproute2 sh -c "trap 'exit 0' SIGTERM; while true; do sleep 1; done"
# Delay packets on eth0 of container1
pumba netem --interface=eth0 --duration=60s delay container1 &
# Stop container2 and restart it after 120s
pumba stop --duration=120s --restart container2 &
# Wait for 1 minute
sleep 60
# Drop packets on eth0 of container1
pumba netem --interface=eth0 --duration=60s loss container1 &
# Wait for 1 minute
sleep 60
# Wait for all background processes to finish
wait
Container Initialization:
container1
and container2
using the hphil/alpine-iproute2
image.SIGTERM
signal gracefully.Network Delay Simulation:
eth0
interface of container1
for a duration of 60 seconds.Container Stop and Restart:
container2
for a duration of 120 seconds using Pumba, after which the container is automatically restarted.Packet Loss Simulation:
eth0
interface of container1
for 60 seconds.Final Wait:
wait
command ensures that all background processes initiated by Pumba finish executing.Overall Purpose:
That's exactly what I need, thanks for the detailed explanation and example!
Hi,
I have tried out Pumba, it's an incredible tool! I require my test case to perform different perturbations simultaneously in different docker containers and interfaces. Is it possible to perform multiple subcommands to the same interface, or even to multiple interfaces or containers in the same main command or is it required to run multiple processes, one for each subcommand, forking in a bash script?
For example: eth0 of container 1 has packets delayed, container 2 is temporarily stopped, 1 minute after I require to drop some packets from eth0 of container 1 and 1 min after restore container 2.
If you think is a better way to achieve this I'm open to ideas.
Best regards