Docker test image random reaper (#106)
* First draft of test dockerfile build * Test dockerfile, build works, container runs and cluster tests go through * Removed fifo for output * renaming dockerfile * Adding functionality for test 12 Added scripts and entrypoint mods to the testing docker image to allow for random shut down and startup (both SIGSTOP and SIGINT) of the ipfs-cluster-service. * test docker image ready for tests 12 and 13
This commit is contained in:
parent
0c9f729662
commit
6e4b325b35
|
@ -25,6 +25,9 @@ RUN apk add --no-cache --virtual cluster-deps make musl-dev go git \
|
||||||
&& make -C ipfs-cluster-service install \
|
&& make -C ipfs-cluster-service install \
|
||||||
&& make -C ipfs-cluster-ctl install \
|
&& make -C ipfs-cluster-ctl install \
|
||||||
&& cp docker/test-entrypoint.sh /usr/local/bin/start-daemons.sh \
|
&& cp docker/test-entrypoint.sh /usr/local/bin/start-daemons.sh \
|
||||||
|
&& cp docker/random-stopper.sh /usr/local/bin/random-stopper.sh \
|
||||||
|
&& cp docker/random-killer.sh /usr/local/bin/random-killer.sh \
|
||||||
|
&& cp docker/wait-killer-stopper.sh /usr/local/bin/wait-killer-stopper.sh \
|
||||||
&& chmod +x /usr/local/bin/start-daemons.sh \
|
&& chmod +x /usr/local/bin/start-daemons.sh \
|
||||||
&& apk del --purge cluster-deps \
|
&& apk del --purge cluster-deps \
|
||||||
&& cd / && rm -rf /go/src /go/bin/gx /go/bin/gx-go
|
&& cd / && rm -rf /go/src /go/bin/gx /go/bin/gx-go
|
||||||
|
|
19
docker/random-killer.sh
Executable file
19
docker/random-killer.sh
Executable file
|
@ -0,0 +1,19 @@
|
||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
# $1=sleep time, $2=first command, $3=second command
|
||||||
|
# Loop forever
|
||||||
|
KILLED=1
|
||||||
|
sleep 2
|
||||||
|
while true; do
|
||||||
|
if [ "$(($RANDOM % 10))" -gt "4" ]; then
|
||||||
|
# Take down cluster
|
||||||
|
if [ "$KILLED" -eq "1" ]; then
|
||||||
|
KILLED=0
|
||||||
|
killall ipfs-cluster-service
|
||||||
|
else # Bring up cluster
|
||||||
|
KILLED=1
|
||||||
|
ipfs-cluster-service &
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
sleep 2.5
|
||||||
|
done
|
19
docker/random-stopper.sh
Executable file
19
docker/random-stopper.sh
Executable file
|
@ -0,0 +1,19 @@
|
||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
# $1=sleep time, $2=first command, $3=second command
|
||||||
|
# Loop forever
|
||||||
|
STOPPED=1
|
||||||
|
sleep 2
|
||||||
|
while true; do
|
||||||
|
if [ "$(($RANDOM % 10))" -gt "4" ]; then
|
||||||
|
# Take down cluster
|
||||||
|
if [ "$STOPPED" -eq "1" ]; then
|
||||||
|
STOPPED=0
|
||||||
|
killall -STOP ipfs-cluster-service
|
||||||
|
else # Take down cluster
|
||||||
|
STOPPED=1
|
||||||
|
killall -CONT ipfs-cluster-service
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
done
|
|
@ -46,5 +46,11 @@ else
|
||||||
sed -i 's/127\.0\.0\.1\/tcp\/9095/0.0.0.0\/tcp\/9095/' "$IPFS_CLUSTER_PATH/service.json"
|
sed -i 's/127\.0\.0\.1\/tcp\/9095/0.0.0.0\/tcp\/9095/' "$IPFS_CLUSTER_PATH/service.json"
|
||||||
fi
|
fi
|
||||||
ipfs-cluster-service $@ &
|
ipfs-cluster-service $@ &
|
||||||
|
/usr/local/bin/random-stopper.sh &
|
||||||
|
kill -STOP $!
|
||||||
|
echo $! > /data/ipfs-cluster/random-stopper-pid
|
||||||
|
/usr/local/bin/random-killer.sh &
|
||||||
|
kill -STOP $!
|
||||||
|
echo $! > /data/ipfs-cluster/random-killer-pid
|
||||||
echo "Daemons launched"
|
echo "Daemons launched"
|
||||||
exec tail -f /dev/null
|
exec tail -f /dev/null
|
||||||
|
|
12
docker/wait-killer-stopper.sh
Executable file
12
docker/wait-killer-stopper.sh
Executable file
|
@ -0,0 +1,12 @@
|
||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
## Wait for cluster service process to exist and the stop the
|
||||||
|
## killer
|
||||||
|
DONE=1
|
||||||
|
while [ $DONE = 1 ]; do
|
||||||
|
sleep 0.1
|
||||||
|
if [ $(pgrep -f ipfs-cluster-service) ]; then
|
||||||
|
kill -STOP $(cat /data/ipfs-cluster/random-killer-pid)
|
||||||
|
DONE=0
|
||||||
|
fi
|
||||||
|
done
|
Loading…
Reference in New Issue
Block a user