This repository has been archived by the owner on Dec 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathlib.sh
70 lines (52 loc) · 1.66 KB
/
lib.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
## CONFIG
DOCKER_IMAGE_NAME=zk_testbed
CONFIG_JSON=config.json
ZK_START_WAIT_SECS=5
## ENVS
EQDIR=$(pwd)/../..
export LD_LIBRARY_PATH=$EQDIR/bin:$LD_LIBRARY_PATH
export PYTHONPATH=.:$EQDIR:$PYTHONPATH
## FUNCS
function INFO(){
echo -e "\e[104m\e[97m[INFO]\e[49m\e[39m $@"
}
function IMPORTANT(){
echo -e "\e[105m\e[97m[IMPORTANT]\e[49m\e[39m $@"
}
function BUILD_DOCKER_IMAGE(){
docker build -t $DOCKER_IMAGE_NAME zk_testbed
}
shopt -s expand_aliases
alias EQ_SWITCH="ryu-manager ./zk_switch.py"
alias EQ_ORCHESTRATOR="python -m pyearthquake.cmd.orchestrator_loader $CONFIG_JSON"
alias EQ_INSPECTOR="python ./zk_inspector.py"
function CLEAN_VETHS(){
garbages=$(ip a | egrep -o 'veth.*:' | sed -e s/://g)
for f in $garbages; do sudo ip link delete $f; done
}
function START_DOCKER(){
for f in $(seq 1 3); do
docker run -i -t -d -e ZKID=${f} -e ZKENSEMBLE=1 -h zk${f} --name zk${f} $DOCKER_IMAGE_NAME /bin/bash;
done
}
function SET_PIPEWORK(){
for f in $(seq 1 3); do sudo pipework ovsbr0 zk${f} 192.168.42.${f}/24; done
}
function START_ZOOKEEPER(){
for f in $(seq 1 3); do docker exec -d zk${f} /bin/bash -c '/init.py > /log 2>&1'; done
}
function STOP_EQ_INSPECTION(){
for f in InspectionEndEvents/*.json; do curl --data @$f http://localhost:10000/api/v1; done
}
function CHECK_BUG_REPRODUCED(){
./check.py || (IMPORTANT "THE BUG WAS REPRODUCED!"; false)
}
function COLLECT_ZOOKEEPER_LOG(){
mkdir -p /tmp/eq-zklog
ZOOKEEPER_LOG_DIR=$(mktemp -d /tmp/eq-zklog/XXXXX)
for f in zk1 zk2 zk3; do docker cp $f:/log $ZOOKEEPER_LOG_DIR/$f; done
}
function KILL_DOCKER(){
docker rm -f zk1 zk2 zk3
}