#1432 Fix passfail validation in cloud

Merged Alla Levental corvustristis
Coverage Reach
bzt/modules/blazemeter.py bzt/modules/apiritif/generator.py bzt/modules/apiritif/executor.py bzt/modules/apiritif/jmeter_functions.py bzt/modules/apiritif/ast_helpers.py bzt/modules/apiritif/__init__.py bzt/modules/jmeter.py bzt/modules/console.py bzt/modules/gatling.py bzt/modules/aggregator.py bzt/modules/pbench.py bzt/modules/monitoring.py bzt/modules/reporting.py bzt/modules/grinder.py bzt/modules/java/executors.py bzt/modules/java/tools.py bzt/modules/java/__init__.py bzt/modules/tsung.py bzt/modules/passfail.py bzt/modules/locustio.py bzt/modules/services.py bzt/modules/selenium.py bzt/modules/javascript.py bzt/modules/functional.py bzt/modules/shellexec.py bzt/modules/siege.py bzt/modules/ab.py bzt/modules/molotov.py bzt/modules/proxy2jmx.py bzt/modules/provisioning.py bzt/modules/external.py bzt/modules/__init__.py bzt/modules/screen.py bzt/modules/robot.py bzt/modules/ruby.py bzt/modules/csharp.py bzt/modules/pytest.py bzt/modules/python/__init__.py bzt/modules/soapui.py bzt/jmx/base.py bzt/jmx/tools.py bzt/jmx/threadgroups.py bzt/jmx/rte.py bzt/jmx/http.py bzt/jmx/__init__.py bzt/utils.py bzt/jmx2yaml.py bzt/engine/engine.py bzt/engine/modules.py bzt/engine/dicts.py bzt/engine/templates.py bzt/engine/__init__.py bzt/engine/names.py bzt/bza.py bzt/swagger2yaml.py bzt/cli.py bzt/requests_model.py bzt/linter.py bzt/soapui2yaml.py bzt/__init__.py bzt/environment_helpers.py bzt/__main__.py tests/unit/modules/jmeter/test_JMeterExecutor.py tests/unit/modules/jmeter/test_JTLReader.py tests/unit/modules/jmeter/test_JMX.py tests/unit/modules/jmeter/test_ScenarioBuilder.py tests/unit/modules/jmeter/__init__.py tests/unit/modules/jmeter/test_JMeterTool.py tests/unit/modules/selenium/test_python_executors.py tests/unit/modules/selenium/test_java.py tests/unit/modules/selenium/test_apiritif_builder.py tests/unit/modules/selenium/test_selenium_builder.py tests/unit/modules/selenium/test_selenium_executor.py tests/unit/modules/selenium/test_javascript.py tests/unit/modules/selenium/test_csharp.py tests/unit/modules/selenium/test_ruby.py tests/unit/modules/selenium/__init__.py tests/unit/modules/test_cloudProvisioning.py tests/unit/modules/test_Gatling.py tests/unit/modules/test_blazeMeterUploader.py tests/unit/modules/test_consolidatingAggregator.py tests/unit/modules/test_passFailStatus.py tests/unit/modules/test_Tsung.py tests/unit/modules/test_shellexec.py tests/unit/modules/test_pbench.py tests/unit/modules/test_FinalStatusReporter.py tests/unit/modules/test_services.py tests/unit/modules/test_monitoring.py tests/unit/modules/test_Grinder.py tests/unit/modules/test_consoleStatusReporter.py tests/unit/modules/test_locustIOExecutor.py tests/unit/modules/test_JUnitXMLReporter.py tests/unit/modules/test_external.py tests/unit/modules/test_proxy2jmx.py tests/unit/modules/test_aggregator.py tests/unit/modules/test_SoapUI.py tests/unit/modules/test_LocalProvisioning.py tests/unit/modules/test_ApacheBenchmark.py tests/unit/modules/test_molotov.py tests/unit/modules/test_Siege.py tests/unit/modules/test_GUIScreen.py tests/unit/modules/test_functionalAggregator.py tests/unit/test_jmx2yaml.py tests/unit/test_engine.py tests/unit/mocks.py tests/unit/test_CLI.py tests/unit/test_utils.py tests/unit/test_swagger2yaml.py tests/unit/cases.py tests/unit/test_configuration.py tests/unit/test_soapui2yaml.py tests/unit/test_linter.py tests/unit/base.py tests/unit/test_bza.py tests/unit/test_multiPartForm.py tests/unit/__init__.py setup.py

No flags found

Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.

e.g., #unittest #integration

#production #enterprise

#frontend #backend

Learn more about Codecov Flags here.


@@ -30,6 +30,7 @@
Loading
30 30
from io import BytesIO
31 31
from ssl import SSLError
32 32
from urllib.error import HTTPError, URLError
33 +
from time import sleep
33 34
34 35
import requests
35 36
import yaml
@@ -1472,7 +1473,6 @@
Loading
1472 1473
1473 1474
    def prepare(self):
1474 1475
        reporting = self.engine.config.get(Reporter.REP)
1475 -
        self.validate_passfail = any(reporter.get('module') == 'passfail' for reporter in reporting)
1476 1476
1477 1477
        CloudProvisioning.merge_with_blazemeter_config(self)
1478 1478
        CloudProvisioning.configure_client(self)
@@ -1542,6 +1542,21 @@
Loading
1542 1542
            self.results_reader.log = self.log
1543 1543
            self.engine.aggregator.add_underling(self.results_reader)
1544 1544
1545 +
        self.validate_passfail = any(reporter.get('module') == 'passfail' for reporter in reporting)
1546 +
1547 +
        if self.validate_passfail:
1548 +
            self.router._test.passfail_validate()
1549 +
            timeout = 100
1550 +
            for i in range(timeout):
1551 +
                validation_result = self.router._test.passfail_validation()
1552 +
                if validation_result:
1553 +
                    return
1554 +
                self.log.warning(f"Unsuccessful Passfail validation attempt [{i+1}]. Retrying...")
1555 +
                if i % 10:
1556 +
                    self.log.warning("Please keep in mind that validation can take time.")
1557 +
                sleep(1)
1558 +
            self.log.error("Unable get Passfail validation!")
1559 +
1545 1560
    @staticmethod
1546 1561
    def _get_other_modules(config):
1547 1562
        used_classes = LocalClient.__name__, BlazeMeterUploader.__name__
@@ -1677,9 +1692,6 @@
Loading
1677 1692
            return True
1678 1693
1679 1694
    def check(self):
1680 -
        if self.validate_passfail:
1681 -
            self.validate_passfail = not self.router._test.passfail_validation()
1682 -
1683 1695
        if self.detach:
1684 1696
            self.log.warning('Detaching Taurus from started test...')
1685 1697
            return True

@@ -515,6 +515,10 @@
Loading
515 515
        res = self._request(url, data=coll, method="PATCH")
516 516
        return res['result']
517 517
518 +
    def passfail_validate(self):
519 +
        url = f"{self.address}/api/v4/tests/{self['id']}/validate"
520 +
        self._request(url, method='POST')
521 +
518 522
    def passfail_validation(self):
519 523
        url = f"{self.address}/api/v4/tests/{self['id']}/validations"
520 524
        resp = self._request(url, method='GET')

@@ -1928,24 +1928,23 @@
Loading
1928 1928
                "reporting": [{"module": "passfail", "criteria": criteria}],
1929 1929
            },
1930 1930
            get={
1931 -
                'https://some-bzm-link.com/api/v4/tests/1/validations': {'result': [
1931 +
                'https://a.blazemeter.com/api/v4/tests/1/validations': {'result': [
1932 1932
                    {'status': 100,
1933 1933
                     'warnings': ["passfail warning"],
1934 1934
                     'fileWarnings': ["passfail file warning"]}]},
1935 -
                'https://some-bzm-link.com/api/v4/masters/1/status': {'result': {"status": "CREATED", "progress": 100}},
1936 -
                'https://some-bzm-link.com/api/v4/masters/1/sessions': {"result": {"sessions": []}},
1935 +
                'https://a.blazemeter.com/api/v4/masters/1/status': {'result': {"status": "CREATED", "progress": 100}},
1936 +
                'https://a.blazemeter.com/api/v4/masters/1/sessions': {"result": {"sessions": []}},
1937 1937
            },
1938 1938
            post={
1939 -
                'https://some-bzm-link.com/api/v4/tests/1/start': {"result": {"id": 1}},
1939 +
                'https://a.blazemeter.com/api/v4/tests/1/start': {"result": {"id": 1}},
1940 +
                'https://a.blazemeter.com/api/v4/tests/1/validate': {},
1940 1941
            },
1941 1942
        )
1942 1943
        self.sniff_log(self.obj.log)
1943 1944
1944 1945
        self.obj.prepare()
1945 1946
        self.assertEqual(self.obj.engine.config['reporting'][0]['criteria'], criteria)
1946 1947
1947 -
        bzm_link = "https://some-bzm-link.com"
1948 -
        self.obj.router._test.address = bzm_link
1949 1948
        self.obj.startup()
1950 1949
        self.obj.check()
1951 1950

Learn more Showing 2 files with coverage changes found.

Changes in bzt/modules/monitoring.py
-1
+1
Loading file...
Changes in tests/unit/modules/test_Siege.py
-1
+1
Loading file...
Files Coverage
bzt -0.02% 90.37%
tests/unit 0.01% 97.30%
setup.py 0.00%
Project Totals (117 files) 92.98%
Loading