Merge branch 'master' into master

This commit is contained in:
debugtalk
2018-05-29 15:54:36 +08:00
committed by GitHub
6 changed files with 12 additions and 10 deletions

View File

@@ -103,8 +103,8 @@ class HttpSession(requests.Session):
self.meta_data["request_time"] = time.time() self.meta_data["request_time"] = time.time()
response = self._send_request_safe_mode(method, url, **kwargs) response = self._send_request_safe_mode(method, url, **kwargs)
# record the consumed time # record the consumed time
self.meta_data["response_time(ms)"] = round((time.time() - self.meta_data["request_time"]) * 1000, 2) self.meta_data["response_time_ms"] = round((time.time() - self.meta_data["request_time"]) * 1000, 2)
self.meta_data["elapsed(ms)"] = response.elapsed.microseconds / 1000.0 self.meta_data["elapsed_ms"] = response.elapsed.microseconds / 1000.0
self.meta_data["url"] = (response.history and response.history[0] or response)\ self.meta_data["url"] = (response.history and response.history[0] or response)\
.request.url .request.url
@@ -140,7 +140,7 @@ class HttpSession(requests.Session):
logger.log_info( logger.log_info(
"""status_code: {}, response_time(ms): {} ms, response_length: {} bytes""".format( """status_code: {}, response_time(ms): {} ms, response_length: {} bytes""".format(
self.meta_data["status_code"], self.meta_data["status_code"],
self.meta_data["response_time(ms)"], self.meta_data["response_time_ms"],
self.meta_data["content_size"] self.meta_data["content_size"]
) )
) )

View File

@@ -217,6 +217,7 @@ class Context(object):
def do_validation(self, validator_dict): def do_validation(self, validator_dict):
""" validate with functions """ validate with functions
""" """
# TODO: move comparator uniform to init_task_suite
comparator = utils.get_uniform_comparator(validator_dict["comparator"]) comparator = utils.get_uniform_comparator(validator_dict["comparator"])
validate_func = self.testcase_parser.get_bind_function(comparator) validate_func = self.testcase_parser.get_bind_function(comparator)

View File

@@ -210,7 +210,7 @@ class Runner(object):
for variable in output_variables_list: for variable in output_variables_list:
if variable not in variables_mapping: if variable not in variables_mapping:
logger.log_warning( logger.log_warning(
"variable '{}' can not be found in variables mapping, failed to ouput!"\ "variable '{}' can not be found in variables mapping, failed to output!"\
.format(variable) .format(variable)
) )
continue continue

View File

@@ -202,6 +202,7 @@ def init_task_suite(path_or_testsets, mapping=None, http_client_session=None):
else: else:
testsets = path_or_testsets testsets = path_or_testsets
# TODO: move comparator uniform here
mapping = mapping or {} mapping = mapping or {}
return TaskSuite(testsets, mapping, http_client_session) return TaskSuite(testsets, mapping, http_client_session)

View File

@@ -180,7 +180,7 @@
<tr id="record_{{loop.index}}"> <tr id="record_{{loop.index}}">
<th class="{{record.status}}" style="width:5em;">{{record.status}}</td> <th class="{{record.status}}" style="width:5em;">{{record.status}}</td>
<td>{{record.name}}</td> <td>{{record.name}}</td>
<td style="text-align:center;width:6em;">{{ record.meta_data["response_time(ms)"] }} ms</td> <td style="text-align:center;width:6em;">{{ record.meta_data["response_time_ms"] }} ms</td>
<td class="detail"> <td class="detail">
<a class="button" href="#popup_log_{{loop.index}}">log</a> <a class="button" href="#popup_log_{{loop.index}}">log</a>
@@ -264,11 +264,11 @@
</tr> </tr>
<tr> <tr>
<th>response_time(ms)</th> <th>response_time(ms)</th>
<td>{{ record.meta_data["response_time(ms)"] }}</td> <td>{{ record.meta_data["response_time_ms"] }}</td>
</tr> </tr>
<tr> <tr>
<th>elapsed(ms)</th> <th>elapsed(ms)</th>
<td>{{ record.meta_data["elapsed(ms)"] }}</td> <td>{{ record.meta_data["elapsed_ms"] }}</td>
</tr> </tr>
</table> </table>
</div> </div>

View File

@@ -165,7 +165,7 @@
test-id='{{ loop.index }}'> test-id='{{ loop.index }}'>
<div class='test-heading'> <div class='test-heading'>
<span class='test-name'>{{ record.name }}</span> <span class='test-name'>{{ record.name }}</span>
<span class='test-time'>{{ record.meta_data["response_time(ms)"] }} ms</span> <span class='test-time'>{{ record.meta_data.response_time_ms }} ms</span>
<span class='test-status right pass'>pass</span> <span class='test-status right pass'>pass</span>
</div> </div>
{% elif record.status == 'error' %} {% elif record.status == 'error' %}
@@ -173,13 +173,13 @@
test-id='{{ loop.index }}'> test-id='{{ loop.index }}'>
<div class='test-heading'> <div class='test-heading'>
<span class='test-name'>{{ record.name }}</span> <span class='test-name'>{{ record.name }}</span>
<span class='test-time'>{{ record.meta_data["response_time(ms)"] }} ms</span> <span class='test-time'>{{ record.meta_data.response_time_ms }} ms</span>
<span class='test-status right fail'>fail</span> <span class='test-status right fail'>fail</span>
</div> </div>
{% endif %} {% endif %}
<div class='test-content hide'> <div class='test-content hide'>
<div class='test-time-info'> <div class='test-time-info'>
<span class='label start-time'>{{ record.meta_data["response_time(ms)"] }} ms</span> <span class='label start-time'>{{ record.meta_data.response_time_ms }} ms</span>
</div> </div>
<div class='test-steps'> <div class='test-steps'>
<table class='bordered table-results'> <table class='bordered table-results'>