1 ##############################################################################
2 # Copyright (c) 2017 ZTE Corporation and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
11 from doctor_tests.common.utils import match_rep_in_file
14 def calculate_notification_time():
15 log_file = '{0}/{1}'.format(sys.path[0], 'doctor.log')
17 reg = '(?<=doctor monitor detected at )\d+.\d+'
18 result = match_rep_in_file(reg, log_file)
20 raise Exception('Can not match detected time')
21 detected = result.group(0)
23 reg = '(?<=doctor consumer notified at )\d+.\d+'
24 result = match_rep_in_file(reg, log_file)
26 raise Exception('Can not match notified time')
27 notified = result.group(0)
29 return float(notified) - float(detected)