Add timelog when set network down
[doctor.git] / tests / run.sh
index eefa79b..1b21f09 100755 (executable)
@@ -8,6 +8,8 @@
 # http://www.apache.org/licenses/LICENSE-2.0
 ##############################################################################
 
+# Configuration
+
 [[ "${CI_DEBUG:-true}" == [Tt]rue ]] && set -x
 
 IMAGE_URL=https://launchpad.net/cirros/trunk/0.3.0/+download/cirros-0.3.0-x86_64-disk.img
@@ -33,6 +35,8 @@ as_doctor_user="--os-username $DOCTOR_USER --os-password $DOCTOR_PW
                 --os-tenant-name $DOCTOR_PROJECT"
 
 
+# Functions
+
 get_compute_host_info() {
     # get computer host info which VM boot in
     COMPUTE_HOST=$(openstack $as_doctor_user server show $VM_NAME |
@@ -232,6 +236,7 @@ inject_failure() {
 dev=$(sudo ip a | awk '/ @COMPUTE_IP@\//{print $7}')
 sleep 1
 sudo ip link set $dev down
+echo "doctor set host down at" $(date "+%s.%N")
 sleep 180
 sudo ip link set $dev up
 sleep 1
@@ -242,12 +247,25 @@ END_TXT
     ssh $ssh_opts_cpu "$COMPUTE_USER@$COMPUTE_IP" 'nohup ./disable_network.sh > disable_network.log 2>&1 &'
 }
 
+profile_performance_poc() {
+    total=`python -c "print(int(($notified-$detected)*1000))"`
+
+    export DOCTOR_PROFILER_T00=0
+    export DOCTOR_PROFILER_T09=$((total))
+    python profiler-poc.py
+}
+
 calculate_notification_time() {
     detected=$(grep "doctor monitor detected at" monitor.log | awk '{print $10}')
     notified=$(grep "doctor consumer notified at" consumer.log | awk '{print $10}')
     if ! grep -q "doctor consumer notified at" consumer.log ; then
         die $LINENO "Consumer hasn't received fault notification."
     fi
+
+    if [[ PROFILER == 'poc' ]]; then
+        profile_performance_poc
+    fi
+
     echo "$notified $detected" | \
         awk '{
             d = $1 - $2;
@@ -305,6 +323,7 @@ cleanup() {
     cleanup_inspector
 }
 
+# Main process
 
 echo "Note: doctor/tests/run.sh has been executed."