You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

188 lines
2.8 KiB

#!/usr/bin/env bash
set -eu
export WITH_GUI=0
synopsis() {
cat << EOF
Usage : `basename $0` [-h]
EOF
}
help() {
cat << EOF
`basename $0` tests les scripts "repair*" des réseaux."
`synopsis`
-h : affiche cette aide
-g : avec l'interface graphique
EOF
}
usage() {
synopsis
exit 1
}
args() {
local opt
while getopts "hg" opt; do
case $opt in
h) help; exit 0;;
g) WITH_GUI=1;;
?) usage;;
esac
done
}
testHeader() {
n=$1
echo
echo "Test $n"
echo "=================="
vdn-set-network-dir $VDN_PATH/networks/$n
export NETWORK_DIR=$VDN_PATH/networks/$n
if [ $WITH_GUI = 1 ]; then
sendToGui "quit"
vdn $n &
fi
}
testFinish() {
systems=$@
for i in $systems; do
vdn-halt $i
done
#wait
#vdn-clean -f $systems
if [ $WITH_GUI = 1 ]; then
sendToGui "quit"
fi
}
testRoutingStatic() {
local n
n=routing-static
testHeader $n
systems=$(vdn-list | grep -v '^#')
vdn-clean -f $systems
vdn-scripts -n configAll
vdn-scripts -n repairAll
vdn-scripts -n testAll
testFinish $systems
}
testRoutingOspf() {
local n
n=routing-ospf
testHeader $n
systems=$(vdn-list | grep -v '^#')
vdn-clean -f $systems
vdn-scripts -n configAll
vdn-scripts -n repairAll
vdn-scripts -n testAll
testFinish $systems
}
testRoutingRip() {
local n
n=routing-rip
testHeader $n
systems=$(vdn-list | grep -v '^#')
vdn-clean -f $systems
vdn-scripts -n configAll
vdn-scripts -n repairAll
vdn-scripts -n testAll
testFinish $systems
}
testFirewall() {
local n
n=firewall
testHeader $n
systems=$(vdn-list | grep -v '^#')
vdn-clean -f $systems
vdn-scripts -n configAll
vdn-scripts -n repairFirewall
vdn-scripts -n testFirewall
vdn-scripts -n repairIPv6
vdn-scripts -n testIPv6
testFinish $systems
}
testFixme() {
local n
n=fixme
testHeader $n
systems=$(vdn-list | grep -v '^#')
vdn-clean -f $systems
vdn-scripts -n configAll
vdn-scripts -n repairAll
vdn-scripts -n testAll
testFinish $systems
}
testDocker() {
local n
n=docker
testHeader $n
systems=$(vdn-list | grep -v '^#')
vdn-clean -f $systems
vdn-scripts -n configAll
vdn-scripts -n testAll
testFinish $systems
}
testNagios() {
local n
n=nagios
testHeader $n
systems=$(vdn-list | grep -v '^#')
vdn-clean -f $systems
vdn-scripts -n configAll
vdn-scripts -n testAll
testFinish $systems
}
# Programme principal
VDN_PATH=$(readlink -f $(dirname $0)/..); . $VDN_PATH/bin/functions.sh
args "$@"
export DISABLE_PARALLEL=1 # force sequential mode
export FORCE_BG=1
time (
#time testFirewall
#time testRoutingStatic
#time testRoutingOspf
#time testRoutingRip
#time testFixme
#time testDocker
time testNagios
)