Blazemeter / taurus

@@ -36,7 +36,6 @@
Loading
36 36
from bzt.modules.aggregator import AggregatorListener, DataPoint, KPISet, ResultsProvider, ConsolidatingAggregator
37 37
from bzt.modules.monitoring import Monitoring, MonitoringListener
38 38
from bzt.modules.blazemeter.project_finder import ProjectFinder
39 -
from bzt.modules.blazemeter.net_utils import send_with_retry
40 39
from bzt.modules.blazemeter.const import NOTE_SIZE_LIMIT
41 40
42 41
@@ -351,7 +350,6 @@
Loading
351 350
                self.__send_monitoring()
352 351
        return super(BlazeMeterUploader, self).check()
353 352
354 -
    @send_with_retry
355 353
    def __send_data(self, data, do_check=True, is_final=False):
356 354
        """
357 355
        :type data: list[bzt.modules.aggregator.DataPoint]
@@ -363,7 +361,6 @@
Loading
363 361
            self.__extend_reported_data(data)
364 362
        serialized = self._dpoint_serializer.get_kpi_body(data, is_final)
365 363
366 -
        # todo: send_with_retry only following (don't serialize many times):
367 364
        self._session.send_kpi_data(serialized, do_check)
368 365
369 366
    @staticmethod
@@ -396,7 +393,6 @@
Loading
396 393
        if self.send_monitoring:
397 394
            self.monitoring_buffer.record_data(data)
398 395
399 -
    @send_with_retry
400 396
    def __send_monitoring(self):
401 397
        engine_id = self.engine.config.get('modules').get('shellexec').get('env').get('TAURUS_INDEX_ALL', '')
402 398
        if not engine_id:

@@ -5,19 +5,61 @@
Loading
5 5
import base64
6 6
import json
7 7
import logging
8 +
import time
9 +
import traceback
8 10
from collections import OrderedDict
11 +
from functools import wraps
12 +
from ssl import SSLError
13 +
from urllib.error import URLError
9 14
from urllib.parse import urlencode
10 15
11 16
import requests
17 +
from requests.exceptions import ReadTimeout
12 18
13 -
from bzt import TaurusNetworkError, ManualShutdown, TaurusException
14 -
from bzt.utils import to_json, MultiPartForm
19 +
from bzt import ManualShutdown, TaurusException
20 +
from bzt import TaurusNetworkError
15 21
from bzt.resources.version import VERSION
22 +
from bzt.utils import to_json, MultiPartForm
23 +
24 +
NETWORK_PROBLEMS = (IOError, URLError, SSLError, ReadTimeout, TaurusNetworkError)
16 25
17 26
BZA_TEST_DATA_RECEIVED = 100
18 27
ENDED = 140
19 28
20 29
30 +
def send_with_retry(method):
31 +
    @wraps(method)
32 +
    def _impl(self, *args, **kwargs):
33 +
        try:
34 +
            method(self, *args, **kwargs)
35 +
        except (IOError, TaurusNetworkError):
36 +
            self.log.debug("Error sending data: %s", traceback.format_exc())
37 +
            self.log.warning("Failed to send data, will retry in %s sec...", self.timeout)
38 +
            try:
39 +
                time.sleep(self.timeout)
40 +
                method(self, *args, **kwargs)
41 +
                self.log.info("Succeeded with retry")
42 +
            except NETWORK_PROBLEMS:
43 +
                self.log.error("Fatal error sending data: %s", traceback.format_exc())
44 +
                self.log.warning("Will skip failed data and continue running")
45 +
46 +
    return _impl
47 +
48 +
49 +
def get_with_retry(method):
50 +
    @wraps(method)
51 +
    def _impl(self, *args, **kwargs):
52 +
        while True:
53 +
            try:
54 +
                return method(self, *args, **kwargs)
55 +
            except NETWORK_PROBLEMS:
56 +
                self.log.debug("Error making request: %s", traceback.format_exc())
57 +
                self.log.warning("Failed to make request, will retry in %s sec...", self.user.timeout)
58 +
                time.sleep(self.user.timeout)
59 +
60 +
    return _impl
61 +
62 +
21 63
class BZAObject(dict):
22 64
    def __init__(self, proto=None, data=None):
23 65
        """
@@ -482,6 +524,7 @@
Loading
482 524
        res = self._request(url, data, method='PATCH')
483 525
        self.update(res['result'])
484 526
527 +
    @get_with_retry
485 528
    def get_status(self):
486 529
        sess = self._request(self.address + '/api/v4/masters/%s/status' % self['id'])
487 530
        return sess['result']
@@ -591,6 +634,7 @@
Loading
591 634
        data = {"signature": self.data_signature, "testId": self['testId'], "sessionId": self['id']}
592 635
        self._request(url, data)
593 636
637 +
    @send_with_retry
594 638
    def send_kpi_data(self, data, is_check_response=True, submit_target=None):
595 639
        """
596 640
        Sends online data
@@ -625,6 +669,7 @@
Loading
625 669
            self.notify_monitoring_file(file_name)
626 670
            self.monitoring_upload_notified = True
627 671
672 +
    @send_with_retry
628 673
    def upload_file(self, filename, contents=None):
629 674
        """
630 675
        Upload single artifact

@@ -42,7 +42,6 @@
Loading
42 42
from bzt.requests_model import has_variable_pattern
43 43
from bzt.utils import iteritems, open_browser, BetterDict, ExceptionalDownloader, ProgressBarContext
44 44
from bzt.utils import to_json, dehumanize_time, get_full_path, get_files_recursive, replace_in_config
45 -
from bzt.modules.blazemeter.net_utils import get_with_retry
46 45
from bzt.modules.blazemeter.blazemeter_reporter import BlazeMeterUploader
47 46
from bzt.modules.blazemeter.cloud_test import FUNC_API_TEST_TYPE, FUNC_GUI_TEST_TYPE, TAURUS_TEST_TYPE
48 47
from bzt.modules.blazemeter.project_finder import ProjectFinder
@@ -472,7 +471,6 @@
Loading
472 471
        self.widget.update()
473 472
        return super(CloudProvisioning, self).check()
474 473
475 -
    @get_with_retry
476 474
    def _check_master_status(self):
477 475
        return self.router.get_master_status()
478 476

@@ -16,10 +16,7 @@
Loading
16 16
limitations under the License.
17 17
"""
18 18
import re
19 -
import time
20 -
import traceback
21 19
from collections import namedtuple
22 -
from functools import wraps
23 20
from ssl import SSLError
24 21
from urllib.error import URLError
25 22
@@ -30,39 +27,6 @@
Loading
30 27
NETWORK_PROBLEMS = (IOError, URLError, SSLError, ReadTimeout, TaurusNetworkError)
31 28
32 29
33 -
def send_with_retry(method):
34 -
    @wraps(method)
35 -
    def _impl(self, *args, **kwargs):
36 -
        try:
37 -
            method(self, *args, **kwargs)
38 -
        except (IOError, TaurusNetworkError):
39 -
            self.log.debug("Error sending data: %s", traceback.format_exc())
40 -
            self.log.warning("Failed to send data, will retry in %s sec...", self._user.timeout)
41 -
            try:
42 -
                time.sleep(self._user.timeout)
43 -
                method(self, *args, **kwargs)
44 -
                self.log.info("Succeeded with retry")
45 -
            except NETWORK_PROBLEMS:
46 -
                self.log.error("Fatal error sending data: %s", traceback.format_exc())
47 -
                self.log.warning("Will skip failed data and continue running")
48 -
49 -
    return _impl
50 -
51 -
52 -
def get_with_retry(method):
53 -
    @wraps(method)
54 -
    def _impl(self, *args, **kwargs):
55 -
        while True:
56 -
            try:
57 -
                return method(self, *args, **kwargs)
58 -
            except NETWORK_PROBLEMS:
59 -
                self.log.debug("Error making request: %s", traceback.format_exc())
60 -
                self.log.warning("Failed to make request, will retry in %s sec...", self.user.timeout)
61 -
                time.sleep(self.user.timeout)
62 -
63 -
    return _impl
64 -
65 -
66 30
def parse_blazemeter_test_link(link):
67 31
    """
68 32
    https://a.blazemeter.com/app/#/accounts/97961/workspaces/89846/projects/229969/tests/5823512
Files Coverage
bzt 90.30%
Project Totals (70 files) 90.30%
9262.2
TRAVIS_PYTHON_VERSION=3.8
TRAVIS_OS_NAME=linux
1
codecov:
2
  notify:
3
    require_ci_to_pass: yes
4

5
coverage:
6
  round: up
7

8
ignore:
9
  - bzt/resources
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading