summaryrefslogtreecommitdiffstats
path: root/tests/main.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/main.py')
-rw-r--r--tests/main.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/main.py b/tests/main.py
index 7e7c3bc2..df7e95f3 100644
--- a/tests/main.py
+++ b/tests/main.py
@@ -14,6 +14,7 @@ import time
from alarm import Alarm
from common.constants import Host
+from common.utils import match_rep_in_file
import config
from consumer import get_consumer
from identity_auth import get_identity_auth
@@ -26,6 +27,7 @@ import logger as doctor_log
from network import Network
from monitor import get_monitor
from os_clients import nova_client
+from profiler_poc import main as profiler_main
from scenario.common import calculate_notification_time
from scenario.network_failure import NetworkFault
from user import User
@@ -110,6 +112,11 @@ class DoctorTest(object):
else:
LOG.error('doctor test failed, notification_time=%s' % notification_time)
sys.exit(1)
+
+ if self.conf.profiler_type:
+ LOG.info('doctor test begin to run profile.......')
+ self.collect_logs()
+ self.run_profiler()
except Exception as e:
LOG.error('doctor test failed, Exception=%s' % e)
sys.exit(1)
@@ -145,6 +152,39 @@ class DoctorTest(object):
time.sleep(2)
self.check_host_status(self.down_host.name, 'up')
+ def collect_logs(self):
+ self.fault.get_disable_network_log()
+
+ def run_profiler(self):
+
+ log_file = '{0}/{1}'.format(sys.path[0], 'disable_network.log')
+ reg = '(?<=doctor set link down at )\d+.\d+'
+ linkdown = float(match_rep_in_file(reg, log_file).group(0))
+
+ log_file = '{0}/{1}'.format(sys.path[0], 'doctor.log')
+ reg = '(.* doctor mark vm.* error at )(\d+.\d+)'
+ vmdown = float(match_rep_in_file(reg, log_file).group(2))
+
+ reg = '(?<=doctor mark host.* down at )\d+.\d+'
+ hostdown = float(match_rep_in_file(reg, log_file).group(2))
+
+ reg = '(?<=doctor monitor detected at )\d+.\d+'
+ detected = float(match_rep_in_file(reg, log_file).group(0))
+
+ reg = '(?<=doctor consumer notified at )\d+.\d+'
+ notified = float(match_rep_in_file(reg, log_file).group(0))
+
+ # TODO(yujunz) check the actual delay to verify time sync status
+ # expected ~1s delay from $trigger to $linkdown
+ relative_start = linkdown
+ os.environ['DOCTOR_PROFILER_T00'] = str(int((linkdown - relative_start)*1000))
+ os.environ['DOCTOR_PROFILER_T01'] = str(int((detected - relative_start) * 1000))
+ os.environ['DOCTOR_PROFILER_T03'] = str(int((vmdown - relative_start) * 1000))
+ os.environ['DOCTOR_PROFILER_T04'] = str(int((hostdown - relative_start) * 1000))
+ os.environ['DOCTOR_PROFILER_T09'] = str(int((notified - relative_start) * 1000))
+
+ profiler_main(log=LOG)
+
def cleanup(self):
self.unset_forced_down_hosts()
self.inspector.stop()