operation order for cloud: 1. create test 2. upload config 3. if passfail criteria found: a. run validation (remotely) b. asking for validation result (until it returned or timeout) 5. launch test
Showing 3 of 4 files from the diff.
@@ -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 |
@@ -1458,7 +1459,6 @@
Loading
1458 | 1459 | self._workspaces = [] |
|
1459 | 1460 | self.launch_existing_test = None |
|
1460 | 1461 | self.disallow_empty_execution = False |
|
1461 | - | self.validate_passfail = False # don't ask for validation by default |
|
1462 | 1462 | ||
1463 | 1463 | @staticmethod |
|
1464 | 1464 | def merge_with_blazemeter_config(module): |
@@ -1472,7 +1472,6 @@
Loading
1472 | 1472 | ||
1473 | 1473 | def prepare(self): |
|
1474 | 1474 | reporting = self.engine.config.get(Reporter.REP) |
|
1475 | - | self.validate_passfail = any(reporter.get('module') == 'passfail' for reporter in reporting) |
|
1476 | 1475 | ||
1477 | 1476 | CloudProvisioning.merge_with_blazemeter_config(self) |
|
1478 | 1477 | CloudProvisioning.configure_client(self) |
@@ -1542,6 +1541,21 @@
Loading
1542 | 1541 | self.results_reader.log = self.log |
|
1543 | 1542 | self.engine.aggregator.add_underling(self.results_reader) |
|
1544 | 1543 | ||
1544 | + | validate_passfail = any(reporter.get('module') == 'passfail' for reporter in reporting) |
|
1545 | + | ||
1546 | + | if validate_passfail: |
|
1547 | + | self.router._test.validate_passfail() |
|
1548 | + | timeout = 100 |
|
1549 | + | for i in range(timeout): |
|
1550 | + | validation_result = self.router._test.get_passfail_validation() |
|
1551 | + | if validation_result: |
|
1552 | + | return |
|
1553 | + | self.log.warning(f"Unsuccessful Passfail validation attempt [{i+1}]. Retrying...") |
|
1554 | + | if i % 10: |
|
1555 | + | self.log.warning("Please keep in mind that validation can take time.") |
|
1556 | + | sleep(1) |
|
1557 | + | self.log.error("Unable get Passfail validation!") |
|
1558 | + | ||
1545 | 1559 | @staticmethod |
|
1546 | 1560 | def _get_other_modules(config): |
|
1547 | 1561 | used_classes = LocalClient.__name__, BlazeMeterUploader.__name__ |
@@ -1677,9 +1691,6 @@
Loading
1677 | 1691 | return True |
|
1678 | 1692 | ||
1679 | 1693 | def check(self): |
|
1680 | - | if self.validate_passfail: |
|
1681 | - | self.validate_passfail = not self.router._test.passfail_validation() |
|
1682 | - | ||
1683 | 1694 | if self.detach: |
|
1684 | 1695 | self.log.warning('Detaching Taurus from started test...') |
|
1685 | 1696 | return True |
@@ -515,7 +515,13 @@
Loading
515 | 515 | res = self._request(url, data=coll, method="PATCH") |
|
516 | 516 | return res['result'] |
|
517 | 517 | ||
518 | - | def passfail_validation(self): |
|
518 | + | def validate_passfail(self): |
|
519 | + | # validate passfail configuration |
|
520 | + | url = f"{self.address}/api/v4/tests/{self['id']}/validate" |
|
521 | + | self._request(url, method='POST') |
|
522 | + | ||
523 | + | def get_passfail_validation(self): |
|
524 | + | # get passfail validation status and results, log warnings if present |
|
519 | 525 | url = f"{self.address}/api/v4/tests/{self['id']}/validations" |
|
520 | 526 | resp = self._request(url, method='GET') |
|
521 | 527 | if resp and resp['result'][0]['status'] == 100: |
@@ -1928,15 +1928,16 @@
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) |
@@ -1944,8 +1945,6 @@
Loading
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 |
@@ -1953,6 +1952,40 @@
Loading
1953 | 1952 | self.assertIn("Passfail Warning: passfail warning", warnings) |
|
1954 | 1953 | self.assertIn("Passfail Warning: passfail file warning", warnings) |
|
1955 | 1954 | ||
1955 | + | def test_nonstandard_env(self): |
|
1956 | + | self.obj.user.address = "https://some-bzm-link.com" |
|
1957 | + | self.obj.user.data_address = "https://some-bzm-link.com" |
|
1958 | + | self.configure( |
|
1959 | + | engine_cfg={EXEC: {"executor": "mock"}}, |
|
1960 | + | get={ |
|
1961 | + | 'https://some-bzm-link.com/api/v4/accounts': {"result": [{'id': 1, 'owner': {'id': 1}}]}, |
|
1962 | + | 'https://some-bzm-link.com/api/v4/workspaces?accountId=1&enabled=true&limit=100': { |
|
1963 | + | "result": [{'id': 1, 'enabled': True}]}, |
|
1964 | + | 'https://some-bzm-link.com/api/v4/user': {'id': 1, |
|
1965 | + | 'defaultProject': {'id': 1, 'accountId': 1, |
|
1966 | + | 'workspaceId': 1}}, |
|
1967 | + | 'https://some-bzm-link.com/api/v4/projects?workspaceId=1&limit=1000': {"result": []}, |
|
1968 | + | 'https://some-bzm-link.com/api/v4/multi-tests?projectId=1&name=Taurus+Cloud+Test': {"result": []}, |
|
1969 | + | 'https://some-bzm-link.com/api/v4/tests?projectId=1&name=Taurus+Cloud+Test': {"result": []}, |
|
1970 | + | 'https://some-bzm-link.com/api/v4/workspaces/1': {"result": {"locations": [ |
|
1971 | + | {'id': 'us-east-1', 'sandbox': False, 'title': 'East'}]}}, |
|
1972 | + | }, |
|
1973 | + | post={ |
|
1974 | + | 'https://some-bzm-link.com/api/v4/projects': {"result": {"id": 1, 'workspaceId': 1, 'limit': 1000}}, |
|
1975 | + | 'https://some-bzm-link.com/api/v4/tests': {"result": {"id": 1, "configuration": {"type": "taurus"}}}, |
|
1976 | + | 'https://some-bzm-link.com/api/v4/tests/1/files': {"result": {"id": 1}}, |
|
1977 | + | 'https://some-bzm-link.com/api/v4/tests/1/start': {"result": {"id": 1}}, |
|
1978 | + | }, |
|
1979 | + | patch={ |
|
1980 | + | 'https://some-bzm-link.com/api/v4/tests/1': {"result": {}}, |
|
1981 | + | }, |
|
1982 | + | ) |
|
1983 | + | ||
1984 | + | self.sniff_log(self.obj.log) |
|
1985 | + | self.obj.prepare() |
|
1986 | + | self.obj.startup() |
|
1987 | + | self.assertIn("https://some-bzm-link.com", self.log_recorder.info_buff.getvalue()) |
|
1988 | + | ||
1956 | 1989 | ||
1957 | 1990 | class TestResultsFromBZA(BZTestCase): |
|
1958 | 1991 | @staticmethod |
Files | Coverage |
---|---|
bzt | 90.36% |
tests/unit | 97.28% |
setup.py | 0.00% |
Project Totals (117 files) | 92.97% |
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.