本文整理汇总了Python中bzt.modules.blazemeter.BlazeMeterUploader.prepare方法的典型用法代码示例。如果您正苦于以下问题:Python BlazeMeterUploader.prepare方法的具体用法?Python BlazeMeterUploader.prepare怎么用?Python BlazeMeterUploader.prepare使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bzt.modules.blazemeter.BlazeMeterUploader
的用法示例。
在下文中一共展示了BlazeMeterUploader.prepare方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_direct_feeding
# 需要导入模块: from bzt.modules.blazemeter import BlazeMeterUploader [as 别名]
# 或者: from bzt.modules.blazemeter.BlazeMeterUploader import prepare [as 别名]
def test_direct_feeding(self):
obj = BlazeMeterUploader()
self.sniff_log(obj.log)
obj.engine = EngineEmul()
mock = BZMock(obj._user)
mock.mock_post.update({
'https://data.blazemeter.com/submit.php?session_id=direct&signature=sign&test_id=None&user_id=None&pq=0&target=labels_bulk&update=1': {},
'https://data.blazemeter.com/api/v4/image/direct/files?signature=sign': {"result": True},
'https://a.blazemeter.com/api/v4/sessions/direct/stop': {"result": True},
'https://data.blazemeter.com/submit.php?session_id=direct&signature=sign&test_id=None&user_id=None&pq=0&target=engine_health&update=1': {
'result': {'session': {}}}
})
mock.mock_get.update({
'https://a.blazemeter.com/api/v4/sessions/direct': {"result": {}}
})
mock.mock_patch.update({
'https://a.blazemeter.com/api/v4/sessions/direct': {"result": {}}
})
obj.parameters['session-id'] = 'direct'
obj.parameters['signature'] = 'sign'
obj.settings['token'] = 'FakeToken'
obj.prepare()
obj.startup()
obj.check()
obj.shutdown()
obj.engine.stopping_reason = TaurusException("To cover")
obj.post_process()
self.assertNotIn("Failed to finish online", self.log_recorder.warn_buff.getvalue())
self.assertEquals('direct', obj._session['id'])
self.assertEqual(9, len(mock.requests), "Requests were: %s" % mock.requests)
示例2: test_some_errors
# 需要导入模块: from bzt.modules.blazemeter import BlazeMeterUploader [as 别名]
# 或者: from bzt.modules.blazemeter.BlazeMeterUploader import prepare [as 别名]
def test_some_errors(self):
client = BlazeMeterClientEmul(logging.getLogger(''))
client.results.append({"marker": "ping", 'result': {}})
client.results.append({"marker": "projects", 'result': []})
client.results.append({"marker": "project-create", 'result': {
"id": time.time(),
"name": "boo",
"userId": time.time(),
"description": None,
"created": time.time(),
"updated": time.time(),
"organizationId": None
}})
client.results.append({"marker": "tests", 'result': {}})
client.results.append({"marker": "test-create", 'result': {'id': 'unittest1'}})
client.results.append(
{"marker": "sess-start",
"result": {
'session': {'id': 'sess1', 'userId': 1},
'master': {'id': 'master1', 'userId': 1},
'signature': ''}})
client.results.append({"marker": "post-proc push", 'result': {'session': {}}})
client.results.append({"marker": "upload1", "result": True}) # post-proc error stats
client.results.append({"marker": "terminate", 'result': {'session': {}}})
client.results.append({"marker": "terminate2", 'result': {'session': {}}})
client.results.append({"marker": "sess-e", "result": {'session': {'id': 'sess1', 'note': 'n'}}})
client.results.append({"marker": "sess-e", "result": {'session': {}}})
client.results.append({"marker": "sess-e", "result": {'master': {'id': 'sess1', 'note': 'n'}}})
client.results.append({"marker": "sess-e", "result": {'master': {}}})
client.results.append({"marker": "upload-file", "result": {}})
obj = BlazeMeterUploader()
obj.parameters['project'] = 'Proj name'
obj.settings['token'] = '123'
obj.settings['browser-open'] = 'none'
obj.engine = EngineEmul()
obj.client = client
obj.prepare()
obj.startup()
obj.engine.stopping_reason = ValueError('wrong value')
obj.aggregated_second(random_datapoint(10))
obj.kpi_buffer[-1][DataPoint.CURRENT][''][KPISet.ERRORS] = [
{'msg': 'Forbidden', 'cnt': 10, 'type': KPISet.ERRTYPE_ASSERT, 'urls': [], KPISet.RESP_CODES: '111'},
{'msg': 'Allowed', 'cnt': 20, 'type': KPISet.ERRTYPE_ERROR, 'urls': [], KPISet.RESP_CODES: '222'}]
obj.post_process()
self.assertEqual(0, len(client.results))
data = json.loads(client.requests[6]['data'])
self.assertEqual(1, len(data['labels']))
total_item = data['labels'][0]
self.assertEqual('ALL', total_item['name'])
self.assertEqual(total_item['assertions'], [{
'failureMessage': 'Forbidden',
'failures': 10,
'name': 'All Assertions'}])
self.assertEqual(total_item['errors'], [{
'm': 'Allowed',
'count': 20,
'rc': '222'}])
示例3: test_monitoring_buffer_limit_option
# 需要导入模块: from bzt.modules.blazemeter import BlazeMeterUploader [as 别名]
# 或者: from bzt.modules.blazemeter.BlazeMeterUploader import prepare [as 别名]
def test_monitoring_buffer_limit_option(self):
obj = BlazeMeterUploader()
obj.engine = EngineEmul()
obj.client = BlazeMeterClientEmul(logging.getLogger(''))
obj.client.results.append({"marker": "ping", 'result': {}})
obj.settings["monitoring-buffer-limit"] = 100
obj.prepare()
for i in range(1000):
mon = [{"ts": i, "source": "local", "cpu": float(i) / 1000 * 100, "mem": 2, "bytes-recv": 100, "other": 0}]
obj.monitoring_data(mon)
for source, buffer in iteritems(obj.monitoring_buffer.data):
self.assertLessEqual(len(buffer), 100)
示例4: test_monitoring_buffer_limit_option
# 需要导入模块: from bzt.modules.blazemeter import BlazeMeterUploader [as 别名]
# 或者: from bzt.modules.blazemeter.BlazeMeterUploader import prepare [as 别名]
def test_monitoring_buffer_limit_option(self):
obj = BlazeMeterUploader()
obj.engine = EngineEmul()
mock = BZMock(obj._user)
obj.settings["monitoring-buffer-limit"] = 100
obj.prepare()
for i in range(1000):
mon = [{"ts": i, "source": "local", "cpu": float(i) / 1000 * 100, "mem": 2, "bytes-recv": 100, "other": 0}]
obj.monitoring_data(mon)
for source, buffer in iteritems(obj.monitoring_buffer.data):
self.assertLessEqual(len(buffer), 100)
self.assertEqual(1, len(mock.requests))
示例5: test_check
# 需要导入模块: from bzt.modules.blazemeter import BlazeMeterUploader [as 别名]
# 或者: from bzt.modules.blazemeter.BlazeMeterUploader import prepare [as 别名]
def test_check(self):
client = BlazeMeterClientEmul(logging.getLogger(''))
client.results.append({"marker": "ping", 'result': {}})
client.results.append({"marker": "projects", 'result': []})
client.results.append({"marker": "project-create", 'result': {
"id": time.time(),
"name": "boo",
"userId": time.time(),
"description": None,
"created": time.time(),
"updated": time.time(),
"organizationId": None
}})
client.results.append({"marker": "tests", 'result': {}})
client.results.append({"marker": "test-create", 'result': {'id': 'unittest1'}})
client.results.append(
{"marker": "sess-start", 'result': {'session': {'id': 'sess1', 'userId': 1}, 'signature': ''}})
client.results.append({"marker": "first push", 'result': {'session': {}}})
# client.results.append(None) # first check error stats
client.results.append({"marker": "mon push", "result": True})
client.results.append({"marker": "second push", 'result': {'session': {"statusCode": 140, 'status': 'ENDED'}}})
# client.results.append(None) # second check error stats
client.results.append({"marker": "post-proc push", 'result': {'session': {}}})
client.results.append({"marker": "upload1", "result": True}) # post-proc error stats
client.results.append({"marker": "terminate", 'result': {'session': {}}})
obj = BlazeMeterUploader()
obj.parameters['project'] = 'Proj name'
obj.settings['token'] = '123'
obj.settings['browser-open'] = 'none'
obj.engine = EngineEmul()
shutil.copy(__file__, obj.engine.artifacts_dir + os.path.basename(__file__))
obj.client = client
obj.prepare()
obj.startup()
for x in range(0, 31):
obj.aggregated_second(random_datapoint(x))
mon = [{"ts": 1, "source": "local", "cpu": 1, "mem": 2, "bytes-recv": 100, "other": 0}]
obj.monitoring_data(mon)
obj.check()
for x in range(32, 65):
obj.aggregated_second(random_datapoint(x))
try:
obj.check()
self.fail()
except KeyboardInterrupt:
pass
obj.aggregated_second(random_datapoint(10))
obj.shutdown()
obj.post_process()
示例6: test_multiple_reporters_one_monitoring
# 需要导入模块: from bzt.modules.blazemeter import BlazeMeterUploader [as 别名]
# 或者: from bzt.modules.blazemeter.BlazeMeterUploader import prepare [as 别名]
def test_multiple_reporters_one_monitoring(self):
obj1 = BlazeMeterUploader()
obj1.engine = EngineEmul()
BZMock(obj1._user)
obj2 = BlazeMeterUploader()
obj2.engine = EngineEmul()
BZMock(obj2._user)
obj1.prepare()
obj2.prepare()
for i in range(10):
mon = [{"ts": i, "source": "local", "cpu": float(i) / 1000 * 100, "mem": 2, "bytes-recv": 100, "other": 0}]
obj1.monitoring_data(mon)
obj2.monitoring_data(mon)
示例7: test_some_errors
# 需要导入模块: from bzt.modules.blazemeter import BlazeMeterUploader [as 别名]
# 或者: from bzt.modules.blazemeter.BlazeMeterUploader import prepare [as 别名]
def test_some_errors(self):
client = BlazeMeterClientEmul(logging.getLogger(''))
client.results.append({"marker": "ping", 'result': {}})
client.results.append({"marker": "projects", 'result': []})
client.results.append({"marker": "project-create", 'result': {
"id": time.time(),
"name": "boo",
"userId": time.time(),
"description": None,
"created": time.time(),
"updated": time.time(),
"organizationId": None
}})
client.results.append({"marker": "tests", 'result': {}})
client.results.append({"marker": "test-create", 'result': {'id': 'unittest1'}})
client.results.append(
{"marker": "sess-start",
"result": {
'session': {'id': 'sess1', 'userId': 1},
'master': {'id': 'master1', 'userId': 1},
'signature': ''}})
client.results.append({"marker": "post-proc push", 'result': {'session': {}}})
client.results.append({"marker": "upload1", "result": True}) # post-proc error stats
client.results.append({"marker": "terminate", 'result': {'session': {}}})
client.results.append({"marker": "terminate2", 'result': {'session': {}}})
client.results.append({"marker": "sess-e", "result": {'session': {'id': 'sess1', 'note': 'n'}}})
client.results.append({"marker": "sess-e", "result": {'session': {}}})
client.results.append({"marker": "sess-e", "result": {'master': {'id': 'sess1', 'note': 'n'}}})
client.results.append({"marker": "sess-e", "result": {'master': {}}})
client.results.append({"marker": "upload-file", "result": {}})
obj = BlazeMeterUploader()
obj.parameters['project'] = 'Proj name'
obj.settings['token'] = '123'
obj.settings['browser-open'] = 'none'
obj.engine = EngineEmul()
obj.client = client
obj.prepare()
obj.startup()
obj.engine.stopping_reason = ValueError('wrong value')
obj.aggregated_second(random_datapoint(10))
obj.kpi_buffer[-1][DataPoint.CUMULATIVE][''][KPISet.ERRORS] = [
{'msg': 'Forbidden', 'cnt': 7373, 'type': KPISet.ERRTYPE_ASSERT, 'urls': [], KPISet.RESP_CODES: '403'},
{'msg': 'Allowed', 'cnt': 7373, 'type': KPISet.ERRTYPE_ERROR, 'urls': [], KPISet.RESP_CODES: '403'}]
obj.post_process()
示例8: test_check
# 需要导入模块: from bzt.modules.blazemeter import BlazeMeterUploader [as 别名]
# 或者: from bzt.modules.blazemeter.BlazeMeterUploader import prepare [as 别名]
def test_check(self):
client = BlazeMeterClientEmul(logging.getLogger(''))
client.results.append({"marker": "ping", 'result': {}})
client.results.append({"marker": "tests", 'result': {}})
client.results.append({"marker": "test-create", 'result': {'id': 'unittest1'}})
client.results.append(
{"marker": "sess-start", 'result': {'session': {'id': 'sess1', 'userId': 1}, 'signature': ''}})
client.results.append({"marker": "first push", 'result': {'session': {}}})
# client.results.append(None) # first check error stats
client.results.append(
{"marker": "second push", 'result': {'session': {"statusCode": 140, 'status': 'ENDED'}}})
# client.results.append(None) # second check error stats
client.results.append({"marker": "post-proc push", 'result': {'session': {}}})
client.results.append({"marker": "upload1", "result": True}) # post-proc error stats
client.results.append({"marker": "terminate", 'result': {'session': {}}})
obj = BlazeMeterUploader()
obj.settings['token'] = '123'
obj.settings['browser-open'] = 'none'
obj.engine = EngineEmul()
shutil.copy(__file__, obj.engine.artifacts_dir + os.path.basename(__file__))
obj.client = client
obj.prepare()
obj.startup()
obj.aggregated_second(random_datapoint(0))
obj.aggregated_second(random_datapoint(1))
obj.aggregated_second(random_datapoint(2))
obj.aggregated_second(random_datapoint(3))
obj.aggregated_second(random_datapoint(4))
obj.check()
obj.aggregated_second(random_datapoint(5))
obj.aggregated_second(random_datapoint(6))
obj.aggregated_second(random_datapoint(7))
obj.aggregated_second(random_datapoint(8))
obj.aggregated_second(random_datapoint(9))
try:
obj.check()
self.fail()
except KeyboardInterrupt:
pass
obj.aggregated_second(random_datapoint(10))
obj.shutdown()
obj.post_process()
示例9: test_new_project_new_test
# 需要导入模块: from bzt.modules.blazemeter import BlazeMeterUploader [as 别名]
# 或者: from bzt.modules.blazemeter.BlazeMeterUploader import prepare [as 别名]
def test_new_project_new_test(self):
obj = BlazeMeterUploader()
mock = BZMock(obj._user)
mock.mock_get.update({
'https://a.blazemeter.com/api/v4/tests?workspaceId=1&name=Taurus+Test': {'result': []},
'https://a.blazemeter.com/api/v4/projects?workspaceId=1': {'result': []}
})
mock.mock_post.update({
'https://a.blazemeter.com/api/v4/projects': {"result": {"id": 1}},
'https://a.blazemeter.com/api/v4/tests': {"result": {"id": 1}},
})
obj.settings['token'] = '123'
obj.settings['browser-open'] = 'none'
obj.engine = EngineEmul()
obj.prepare()
self.assertEquals('https://a.blazemeter.com/api/v4/projects', mock.requests[6]['url'])
self.assertEquals('POST', mock.requests[6]['method'])
self.assertEquals('https://a.blazemeter.com/api/v4/tests', mock.requests[7]['url'])
self.assertEquals('POST', mock.requests[7]['method'])
示例10: test_public_report
# 需要导入模块: from bzt.modules.blazemeter import BlazeMeterUploader [as 别名]
# 或者: from bzt.modules.blazemeter.BlazeMeterUploader import prepare [as 别名]
def test_public_report(self):
mock = BZMock()
mock.mock_get.update({
'https://a.blazemeter.com/api/v4/tests?workspaceId=1&name=Taurus+Test': {"result": []}
})
mock.mock_post.update({
'https://a.blazemeter.com/api/v4/projects': {"result": {'id': 1}},
'https://a.blazemeter.com/api/v4/tests': {'result': {'id': 'unittest1'}},
'https://a.blazemeter.com/api/v4/tests/unittest1/start-external': {"result": {
'session': {'id': 'sess1', 'userId': 1, 'testId': 1},
'master': {'id': 'master1', 'userId': 1},
'signature': ''
}},
'https://a.blazemeter.com/api/v4/masters/master1/public-token': {'result': {'publicToken': 'publicToken'}},
'https://data.blazemeter.com/submit.php?session_id=sess1&signature=&test_id=1&user_id=1&pq=0&target=labels_bulk&update=1': {
"result": {'session': {}}},
'https://data.blazemeter.com/api/v4/image/sess1/files?signature=': {'result': True},
})
obj = BlazeMeterUploader()
obj.settings['token'] = '123'
obj.settings['browser-open'] = 'none'
obj.settings['public-report'] = True
obj.settings['send-monitoring'] = False
obj.engine = EngineEmul()
mock.apply(obj._user)
self.sniff_log(obj.log)
obj.prepare()
obj.startup()
obj.aggregated_second(random_datapoint(10))
obj.check()
obj.shutdown()
obj.post_process()
log_buff = self.log_recorder.info_buff.getvalue()
log_line = "Public report link: https://a.blazemeter.com/app/?public-token=publicToken#/masters/master1/summary"
self.assertIn(log_line, log_buff)
ROOT_LOGGER.warning("\n".join([x['url'] for x in mock.requests]))
self.assertEqual(14, len(mock.requests))
示例11: test_proxy
# 需要导入模块: from bzt.modules.blazemeter import BlazeMeterUploader [as 别名]
# 或者: from bzt.modules.blazemeter.BlazeMeterUploader import prepare [as 别名]
def test_proxy(self):
client = BlazeMeterClientEmul(logging.getLogger(''))
client.results.append({"marker": "ping", 'result': {}})
client.results.append({"marker": "tests", 'result': {}})
client.results.append({"marker": "test-create", 'result': {'id': 'unittest1'}})
obj = BlazeMeterUploader()
obj.settings['token'] = '123'
obj.settings['browser-open'] = 'none'
obj.engine = EngineEmul()
obj.engine.config.merge(
{"settings": {'proxy': {"username": "user", "password": "password", "address": "http://127.0.0.1:8080"}}})
obj.client = client
try:
from urllib2 import _opener
except ImportError:
from urllib.request import _opener
old_opener = _opener
obj.prepare()
try:
from urllib2 import _opener
except ImportError:
from urllib.request import _opener
new_opener = _opener
self.assertNotEqual(old_opener, new_opener) # test if opener installed
obj = BlazeMeterUploader()
obj.settings['token'] = '123'
obj.settings['browser-open'] = 'none'
obj.engine = EngineEmul()
client.results.append({"marker": "ping", 'result': {}})
client.results.append({"marker": "tests", 'result': {}})
client.results.append({"marker": "test-create", 'result': {'id': 'unittest1'}})
obj.client = client
try:
from urllib2 import _opener
except ImportError:
from urllib.request import _opener
_opener = None
obj.prepare()
self.assertIsNone(_opener)
示例12: test_no_notes_for_public_reporting
# 需要导入模块: from bzt.modules.blazemeter import BlazeMeterUploader [as 别名]
# 或者: from bzt.modules.blazemeter.BlazeMeterUploader import prepare [as 别名]
def test_no_notes_for_public_reporting(self):
mock = BZMock()
mock.mock_post.update({
'https://a.blazemeter.com/api/v4/sessions/1/terminate-external': {},
'https://data.blazemeter.com/submit.php?session_id=1&signature=None&test_id=1&user_id=1&pq=0&target=labels_bulk&update=1': {},
})
obj = BlazeMeterUploader()
obj.parameters['project'] = 'Proj name'
obj.settings['token'] = '' # public reporting
obj.settings['browser-open'] = 'none'
obj.engine = EngineEmul()
mock.apply(obj._user)
obj.prepare()
obj._session = Session(obj._user, {'id': 1, 'testId': 1, 'userId': 1})
obj._master = Master(obj._user, {'id': 1})
obj.engine.stopping_reason = ValueError('wrong value')
obj.aggregated_second(random_datapoint(10))
obj.kpi_buffer[-1][DataPoint.CUMULATIVE][''][KPISet.ERRORS] = [
{'msg': 'Forbidden', 'cnt': 10, 'type': KPISet.ERRTYPE_ASSERT, 'urls': [], KPISet.RESP_CODES: '111',
'tag': ""},
{'msg': 'Allowed', 'cnt': 20, 'type': KPISet.ERRTYPE_ERROR, 'urls': [], KPISet.RESP_CODES: '222'}]
obj.send_monitoring = False
obj.post_process()
# TODO: looks like this whole block of checks is useless
# check for note appending in _postproc_phase3()
reqs = [{'url': '', 'data': ''} for _ in range(4)] # add template for minimal size
reqs = (reqs + mock.requests)[-4:]
self.assertNotIn('api/v4/sessions/1', reqs[0]['url'])
self.assertNotIn('api/v4/sessions/1', reqs[1]['url'])
self.assertNotIn('api/v4/masters/1', reqs[2]['url'])
self.assertNotIn('api/v4/masters/1', reqs[3]['url'])
if reqs[1]['data']:
self.assertNotIn('ValueError: wrong value', reqs[1]['data'])
if reqs[3]['data']:
self.assertNotIn('ValueError: wrong value', reqs[3]['data'])
示例13: test_anonymous_feeding
# 需要导入模块: from bzt.modules.blazemeter import BlazeMeterUploader [as 别名]
# 或者: from bzt.modules.blazemeter.BlazeMeterUploader import prepare [as 别名]
def test_anonymous_feeding(self):
obj = BlazeMeterUploader()
obj.engine = EngineEmul()
obj.browser_open = False
mock = BZMock(obj._user)
mock.mock_post.update({
'https://a.blazemeter.com/api/v4/sessions': {"result": {
"signature": "sign",
"publicTokenUrl": "publicUrl",
"session": {"id": 1, "testId": 1, "userId": 1},
"master": {"id": 1},
}},
'https://data.blazemeter.com/submit.php?session_id=1&signature=sign&test_id=1&user_id=1&pq=0&target=labels_bulk&update=1': {},
'https://data.blazemeter.com/api/v4/image/1/files?signature=sign': {"result": True},
'https://data.blazemeter.com/submit.php?session_id=1&signature=sign&test_id=1&user_id=1&pq=0&target=engine_health&update=1': {'result': {'session': {}}},
})
obj.prepare()
obj.startup()
obj.check()
obj.shutdown()
obj.post_process()
self.assertEquals(1, obj._session['id'])
self.assertEqual(6, len(mock.requests), "Requests were: %s" % mock.requests)
示例14: test_new_project_existing_test
# 需要导入模块: from bzt.modules.blazemeter import BlazeMeterUploader [as 别名]
# 或者: from bzt.modules.blazemeter.BlazeMeterUploader import prepare [as 别名]
def test_new_project_existing_test(self):
obj = BlazeMeterUploader()
mock = BZMock(obj._user)
mock.mock_get.update({
'https://a.blazemeter.com/api/v4/tests?workspaceId=1&name=Taurus+Test': {'result': [
{'id': 1, 'name': 'Taurus Test', 'configuration': {"type": 'external'}}
]},
'https://a.blazemeter.com/api/v4/tests?projectId=1&name=Taurus+Test': {'result': []}
})
mock.mock_post.update({
'https://a.blazemeter.com/api/v4/projects': {"result": {"id": 1}},
'https://a.blazemeter.com/api/v4/tests': {"result": {"id": 1}},
})
obj.parameters['project'] = 'Proj name'
obj.settings['token'] = '123'
obj.settings['browser-open'] = 'none'
obj.engine = EngineEmul()
obj.prepare()
self.assertEquals('https://a.blazemeter.com/api/v4/projects', mock.requests[4]['url'])
self.assertEquals('POST', mock.requests[4]['method'])
self.assertEquals('https://a.blazemeter.com/api/v4/tests', mock.requests[6]['url'])
self.assertEquals('POST', mock.requests[6]['method'])
示例15: test_some_errors
# 需要导入模块: from bzt.modules.blazemeter import BlazeMeterUploader [as 别名]
# 或者: from bzt.modules.blazemeter.BlazeMeterUploader import prepare [as 别名]
def test_some_errors(self):
mock = BZMock()
mock.mock_get.update({
'https://a.blazemeter.com/api/v4/tests?projectId=1&name=Taurus+Test': {"result": []},
'https://a.blazemeter.com/api/v4/projects?workspaceId=1&name=Proj+name': {"result": []},
'https://a.blazemeter.com/api/v4/sessions/1': {"result": {'id': 1, "note": "somenote"}},
'https://a.blazemeter.com/api/v4/masters/1': {"result": {'id': 1, "note": "somenote"}},
})
mock.mock_post.update({
'https://a.blazemeter.com/api/v4/projects': {"result": {'id': 1}},
'https://a.blazemeter.com/api/v4/tests': {"result": {'id': 1}},
'https://a.blazemeter.com/api/v4/tests/1/start-external': {"result": {
"session": {'id': 1, "testId": 1, "userId": 1},
"master": {'id': 1},
"signature": "sign"
}},
'https://data.blazemeter.com/api/v4/image/1/files?signature=sign': {"result": True},
'https://data.blazemeter.com/submit.php?session_id=1&signature=sign&test_id=1&user_id=1' +
'&pq=0&target=labels_bulk&update=1': {},
'https://a.blazemeter.com/api/v4/sessions/1/stop': {"result": True},
'https://data.blazemeter.com/submit.php?session_id=1&signature=sign&test_id=1&user_id=1&pq=0&target=engine_health&update=1': {
'result': {'session': {}}}
})
mock.mock_patch.update({
'https://a.blazemeter.com/api/v4/sessions/1': {"result": {"id": 1, "note": "somenote"}},
'https://a.blazemeter.com/api/v4/masters/1': {"result": {"id": 1, "note": "somenote"}},
})
obj = BlazeMeterUploader()
mock.apply(obj._user)
obj.parameters['project'] = 'Proj name'
obj.settings['token'] = '123'
obj.settings['browser-open'] = 'none'
obj.engine = EngineEmul()
obj.prepare()
obj.startup()
obj.engine.stopping_reason = ValueError('wrong value')
obj.aggregated_second(random_datapoint(10))
obj.kpi_buffer[-1][DataPoint.CUMULATIVE][''][KPISet.ERRORS] = [
{'msg': 'Forbidden', 'cnt': 10, 'type': KPISet.ERRTYPE_ASSERT, 'urls': [], KPISet.RESP_CODES: '111',
'tag': None},
{'msg': 'Allowed', 'cnt': 20, 'type': KPISet.ERRTYPE_ERROR, 'urls': [], KPISet.RESP_CODES: '222'},
{'msg': 'Not Found', 'cnt': 10, 'type': KPISet.ERRTYPE_SUBSAMPLE, 'urls': {'/non': '404'},
KPISet.RESP_CODES: '404', 'tag': None}
]
obj.post_process()
obj.log.info("Requests: %s", mock.requests)
# check for note appending in _postproc_phase3()
reqs = mock.requests[-4:]
self.assertIn('api/v4/sessions/1', reqs[0]['url'])
self.assertIn('api/v4/sessions/1', reqs[1]['url'])
self.assertIn('api/v4/masters/1', reqs[2]['url'])
self.assertIn('api/v4/masters/1', reqs[3]['url'])
self.assertIn('ValueError: wrong value', str(reqs[1]['data']))
self.assertIn('ValueError: wrong value', str(reqs[3]['data']))
labels = mock.requests[8]['data']
if not isinstance(labels, str):
labels = labels.decode("utf-8")
obj.log.info("Labels: %s", labels)
data = json.loads(str(labels))
self.assertEqual(1, len(data['labels']))
total_item = data['labels'][0]
self.assertEqual('ALL', total_item['name'])
self.assertEqual(total_item['assertions'],
[{'failureMessage': 'Forbidden', 'failures': 10, 'name': 'All Assertions'}])
self.assertEqual(total_item['errors'], [{'m': 'Allowed', 'count': 20, 'rc': '222'}])
self.assertEqual(total_item['failedEmbeddedResources'],
[{'url': '/non', 'count': 10, 'rc': '404', 'rm': 'Not Found'}])