Code Review
/
doctor.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Merge "support pep8 check"
[doctor.git]
/
tests
/
run.sh
diff --git
a/tests/run.sh
b/tests/run.sh
index
b838ada
..
b5c5687
100755
(executable)
--- a/
tests/run.sh
+++ b/
tests/run.sh
@@
-29,7
+29,7
@@
DOCTOR_USER=doctor
DOCTOR_PW=doctor
DOCTOR_PROJECT=doctor
DOCTOR_ROLE=_member_
DOCTOR_PW=doctor
DOCTOR_PROJECT=doctor
DOCTOR_ROLE=_member_
-PROFILER_TYPE=${PROFILER_TYPE:-
none
}
+PROFILER_TYPE=${PROFILER_TYPE:-
poc
}
PYTHON_ENABLE=${PYTHON_ENABLE:-false}
TOP_DIR=$(cd $(dirname "$0") && pwd)
PYTHON_ENABLE=${PYTHON_ENABLE:-false}
TOP_DIR=$(cd $(dirname "$0") && pwd)
@@
-42,6
+42,8
@@
ceilometer="ceilometer $as_doctor_user"
as_admin_user="--os-username admin --os-project-name $DOCTOR_PROJECT
--os-tenant-name $DOCTOR_PROJECT"
as_admin_user="--os-username admin --os-project-name $DOCTOR_PROJECT
--os-tenant-name $DOCTOR_PROJECT"
+upper_constraints="https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?h=stable/ocata"
+pip_install="pip install -c${upper_constraints}"
# Functions
# Functions
@@
-212,17
+214,6
@@
create_alarm() {
done
}
done
}
-start_monitor() {
- pgrep -f "python monitor.py" && return 0
- sudo -E python monitor.py "$COMPUTE_HOST" "$COMPUTE_IP" "$INSPECTOR_TYPE" \
- > monitor.log 2>&1 &
-}
-
-stop_monitor() {
- pgrep -f "python monitor.py" || return 0
- sudo kill $(pgrep -f "python monitor.py")
-}
-
start_consumer() {
pgrep -f "python consumer.py" && return 0
python consumer.py "$CONSUMER_PORT" > consumer.log 2>&1 &
start_consumer() {
pgrep -f "python consumer.py" && return 0
python consumer.py "$CONSUMER_PORT" > consumer.log 2>&1 &
@@
-294,8
+285,12
@@
inject_failure() {
echo "disabling network of compute host [$COMPUTE_HOST] for 3 mins..."
cat > disable_network.sh << 'END_TXT'
#!/bin/bash -x
echo "disabling network of compute host [$COMPUTE_HOST] for 3 mins..."
cat > disable_network.sh << 'END_TXT'
#!/bin/bash -x
-dev=$(sudo ip a | awk '/ @COMPUTE_IP@\//{print $NF}')
sleep 1
sleep 1
+if [ -n "@INTERFACE_NAME@" ]; then
+ dev=@INTERFACE_NAME@
+else
+ dev=$(sudo ip a | awk '/ @COMPUTE_IP@\//{print $NF}')
+fi
sudo ip link set $dev down
echo "doctor set link down at" $(date "+%s.%N")
sleep 180
sudo ip link set $dev down
echo "doctor set link down at" $(date "+%s.%N")
sleep 180
@@
-303,6
+298,7
@@
sudo ip link set $dev up
sleep 1
END_TXT
sed -i -e "s/@COMPUTE_IP@/$COMPUTE_IP/" disable_network.sh
sleep 1
END_TXT
sed -i -e "s/@COMPUTE_IP@/$COMPUTE_IP/" disable_network.sh
+ sed -i -e "s/@INTERFACE_NAME@/$INTERFACE_NAME/" disable_network.sh
chmod +x disable_network.sh
scp $ssh_opts_cpu disable_network.sh "$COMPUTE_USER@$COMPUTE_IP:"
ssh $ssh_opts_cpu "$COMPUTE_USER@$COMPUTE_IP" 'nohup ./disable_network.sh > disable_network.log 2>&1 &'
chmod +x disable_network.sh
scp $ssh_opts_cpu disable_network.sh "$COMPUTE_USER@$COMPUTE_IP:"
ssh $ssh_opts_cpu "$COMPUTE_USER@$COMPUTE_IP" 'nohup ./disable_network.sh > disable_network.log 2>&1 &'
@@
-327,8
+323,11
@@
calculate_notification_time() {
wait_consumer 60
#keep 'at' as the last keyword just before the value, and
#use regex to get value instead of the fixed column
wait_consumer 60
#keep 'at' as the last keyword just before the value, and
#use regex to get value instead of the fixed column
+ if [ ! -f monitor.log ]; then
+ scp $ssh_opts_cpu "$COMPUTE_USER@$COMPUTE_IP:monitor.log" .
+ fi
detected=$(grep "doctor monitor detected at" monitor.log |\
detected=$(grep "doctor monitor detected at" monitor.log |\
- sed -e "s/^.* at //")
+ sed -e "s/^.* at //"
| tail -1
)
notified=$(grep "doctor consumer notified at" consumer.log |\
sed -e "s/^.* at //" | tail -1)
notified=$(grep "doctor consumer notified at" consumer.log |\
sed -e "s/^.* at //" | tail -1)
@@
-424,18
+423,18
@@
run_profiler() {
export DOCTOR_PROFILER_T09=$(python -c \
"print(int(($notified-$relative_start)*1000))")
export DOCTOR_PROFILER_T09=$(python -c \
"print(int(($notified-$relative_start)*1000))")
- python profiler
-poc.py >
doctor_profiler.log 2>&1
+ python profiler
_poc.py >
doctor_profiler.log 2>&1
fi
}
cleanup() {
set +e
echo "cleanup..."
fi
}
cleanup() {
set +e
echo "cleanup..."
- stop_monitor
stop_inspector
stop_consumer
unset_forced_down_hosts
stop_inspector
stop_consumer
unset_forced_down_hosts
+ stop_monitor
collect_logs
vms=$(openstack $as_doctor_user server list)
collect_logs
vms=$(openstack $as_doctor_user server list)
@@
-467,6
+466,7
@@
cleanup() {
cleanup_installer
cleanup_inspector
cleanup_installer
cleanup_inspector
+ cleanup_monitor
# NOTE: Temporal log printer.
for f in $(find . -name '*.log')
# NOTE: Temporal log printer.
for f in $(find . -name '*.log')
@@
-478,9
+478,23
@@
cleanup() {
done
}
done
}
+setup_python_packages() {
+ pip freeze |grep -i flask\= > /dev/null || sudo ${pip_install} flask
+ command -v openstack || sudo ${pip_install} python-openstackclient
+ command -v ceilometer || sudo ${pip_install} python-ceilometerclient
+ command -v congress || sudo ${pip_install} python-congressclient
+}
+
# Main process
# Main process
-if $PYTHON_ENABLE; then
+if [[ $PYTHON_ENABLE == [Tt]rue ]]; then
+ which tox || sudo ${pip_install} tox
+ if [ -f /usr/bin/apt-get ]; then
+ sudo apt-get install -y python3-dev
+ elif [ -f /usr/bin/yum ] ; then
+ sudo yum install -y python3-devel
+ fi
+
cd $TOP_DIR
echo "executing tox..."
tox
cd $TOP_DIR
echo "executing tox..."
tox
@@
-492,9
+506,14
@@
git log --oneline -1 || true # ignore even you don't have git installed
trap cleanup EXIT
trap cleanup EXIT
+setup_python_packages
+
source $TOP_DIR/functions-common
source $TOP_DIR/lib/installer
source $TOP_DIR/lib/inspector
source $TOP_DIR/functions-common
source $TOP_DIR/lib/installer
source $TOP_DIR/lib/inspector
+source $TOP_DIR/lib/monitor
+
+rm -f *.log
setup_installer
setup_installer
@@
-524,8
+543,8
@@
echo "injecting host failure..."
inject_failure
check_host_status "(DOWN|UNKNOWN)" 60
inject_failure
check_host_status "(DOWN|UNKNOWN)" 60
-calculate_notification_time
unset_forced_down_hosts
unset_forced_down_hosts
+calculate_notification_time
collect_logs
run_profiler
collect_logs
run_profiler