Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some fixes #397

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions api/server/graph.cc
Original file line number Diff line number Diff line change
Expand Up @@ -823,11 +823,7 @@ bool Graph::NicAdd(app::Nic *nic_) {
}

BrickShrPtr head1 = vni.nics.begin()->second.head;
if (pg_brick_unlink_edge(vtep_.get(), head1.get(),
&app::pg_error) < 0) {
PG_ERROR_(app::pg_error);
return false;
}
unlink_edge(vtep_, head1);
link(vtep_, vni.sw);
add_vni(vtep_, vni.sw, nic.vni);
link(vni.sw, head1);
Expand Down
2 changes: 1 addition & 1 deletion scripts/tests_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fi
sleep 1

# Crypto test
$BUTTERFLY_ROOT/scripts/tests_crypto.sh $BUTTERFLY_BUILD_ROOT/build
$BUTTERFLY_ROOT/scripts/tests_crypto.sh $BUTTERFLY_BUILD_ROOT
if [ $? != 0 ]; then
tput setaf 1
echo "crypto test failed"
Expand Down
2 changes: 1 addition & 1 deletion scripts/tests_crypto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
BT_BUILD=$1

cd $BT_BUILD
g++ -std=c++11 -lcrypto -DUNIT_TESTS -I../ ../api/common/crypto.cc -o crypto
g++ ../api/common/crypto.cc -std=c++11 -lcrypto -DUNIT_TESTS -I ../ -o crypto
./crypto
RET=$?
rm crypto
Expand Down
59 changes: 34 additions & 25 deletions tests/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ function usage {
echo " -h, --help : print this help" 1>&2
}

declare -A qemu_pids
declare -A server_pids
declare -A socat_pids

Expand Down Expand Up @@ -664,8 +663,6 @@ function qemu_start {
if [ $? -ne 0 ]; then
fail "failed to start qemu, check qemu_${id}_output file"
fi
qemu_pids["$id"]=$pid

# Wait for ssh to be ready
ssh_run_timeout $id 60 true
if [ $? -ne 0 ]; then
Expand Down Expand Up @@ -724,16 +721,24 @@ function qemu_stop {
echo "[VM $id] trying to kill nicely"
ssh_run $id poweroff
sleep 1
ret_check=0
sudo kill -s 0 "$(cat $BUTTERFLY_BUILD_ROOT/qemu_pids$id)" &> /dev/null;
ret_check=$?
echo "[VM $id] stopping (pid $(cat $BUTTERFLY_BUILD_ROOT/qemu_pids$id))"
if [ "$ret_check" -eq 0 ] ; then
sudo kill -15 "$(cat $BUTTERFLY_BUILD_ROOT/qemu_pids$id)" &>/dev/null;
sleep 1
sudo kill -s 0 "$(cat $BUTTERFLY_BUILD_ROOT/qemu_pids$id)" &> /dev/null;
ret_check=$?
if [ "$ret_check" != "1" ]; then
for i in {1..3}; do
sleep 0.1
sudo pkill -9 -f ::500$id &> /dev/null;
sudo kill -s 9 "$(cat $BUTTERFLY_BUILD_ROOT/qemu_pids$id)" &> /dev/null;
done
fi
fi
rm -f $BUTTERFLY_BUILD_ROOT/qemu_pids$id
sudo kill -s 0 ${qemu_pids[$id]} &> /dev/null ;
echo "[VM $id] stopping (pid ${qemu_pids[$id]})"
sudo kill -15 $(ps --ppid ${qemu_pids[$id]} -o pid=) &> /dev/null
sleep 1
sudo kill -9 $(ps --ppid ${qemu_pids[$id]} -o pid=) &> /dev/null
while sudo kill -s 0 ${qemu_pids[$id]} &> /dev/null ; do
sleep 0.1
done
sleep 1
}

function qemus_stop {
Expand Down Expand Up @@ -809,10 +814,15 @@ function do_kill {
should_do=$1
signal=$2

if [ $should_skip -ne 0 ]; then
if [ "$should_do" != "0" ]; then
sudo kill $signal $(ps --ppid ${server_pids[$id]} -o pid=) &> /dev/null
sleep 0.2
sudo kill -s 0 ${server_pids[$id]} &> /dev/null
if [ "$?" != "1" ]; then
sudo kill -9 $(ps --ppid ${server_pids[$id]} -o pid=) &> /dev/null
sleep 0.2
fi
sudo kill -s 0 ${server_pids[$id]} &> /dev/null
return $?
fi
return 0
Expand All @@ -821,16 +831,15 @@ function do_kill {
function server_stop {
id=$1
echo "[butterfly-$id] stopping"
ret=do_kill 1 -2
ret=do_kill $ret -2
ret=do_kill $ret -2
ret=do_kill $ret -15
ret=do_kill $ret -15
while sudo kill -s 0 ${server_pids[$id]} &> /dev/null ; do
sudo kill -9 $(ps --ppid ${server_pids[$id]} -o pid=) &> /dev/null
sleep 0.1
done
sleep 1
sudo kill -15 $(ps --ppid ${server_pids[$id]} -o pid=) &> /dev/null
sleep 0.2
sudo kill -s 0 ${server_pids[$id]} &> /dev/null
if [ "$?" != "1" ]; then
for t in {1..3}; do
sudo pkill -9 -f but$id &> /dev/null
sleep 0.1
done
fi
}

function server_start_ipv4 {
Expand Down Expand Up @@ -1468,7 +1477,7 @@ function sg_member_del {
function check_bin {
run=${@:1}
$run &> /dev/null
if [ ! "$?" == "0" ]; then
if [ "$?" != "0" ]; then
echo "cannot execute $run: not found"
exit 1
fi
Expand Down Expand Up @@ -1530,7 +1539,7 @@ check_bin killall -l
check_bin pkill -h
check_bin nc -h
check_bin wget -h
check_bin netstat -h
check_bin netstat -l
check_bin ncat -h

clean_all
Expand Down