Blazemeter / taurus

Compare 1b24eab ... +4 ... 34d7fa5

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.


@@ -50,12 +50,8 @@
Loading
50 50
            self.engine.aggregator.add_underling(self.reader)
51 51
52 52
    def install_required_tools(self):
53 -
        self.molotov = self._get_tool(Molotov, engine=self.engine, version=self.settings.get("version", None),
53 +
        self.molotov = self._get_tool(Molotov, engine=self.engine, settings=self.settings,
54 54
                                      path=self.settings.get('path', None))
55 -
56 -
        if not self.parameters.get("temp", True):
57 -
            self.molotov.installer.settings['temp'] = False
58 -
59 55
        if not self.molotov.check_if_installed():
60 56
            self.molotov.install()
61 57
@@ -118,6 +114,7 @@
Loading
118 114
119 115
    def post_process(self):
120 116
        self.molotov.post_process()
117 +
        super(MolotovExecutor, self).post_process()
121 118
122 119
    def get_error_diagnostics(self):
123 120
        diagnostics = []
@@ -138,8 +135,8 @@
Loading
138 135
139 136
140 137
class Molotov(PythonTool):
141 -
    def __init__(self, engine, version, path, **kwargs):
142 -
        super(Molotov, self).__init__(packages=["molotov"], version=version, engine=engine, **kwargs)
138 +
    def __init__(self, engine, settings, path, **kwargs):
139 +
        super(Molotov, self).__init__(packages=["molotov"], engine=engine, settings=settings, **kwargs)
143 140
        self.tool_path = os.path.join(self.tool_path, "bin", self.tool_name.lower())
144 141
        self.user_tool_path = path
145 142

@@ -41,11 +41,13 @@
Loading
41 41
42 42
43 43
class PipInstaller(Service):
44 -
    def __init__(self):
44 +
    def __init__(self, engine, packages=None, temp_flag=True):
45 45
        super(PipInstaller, self).__init__()
46 -
        self.packages = []
46 +
        self.packages = packages or []
47 +
        self.has_installed_packages = False
47 48
        self.versions = BetterDict()
48 -
        self.temp = True
49 +
        self.engine = engine
50 +
        self.temp = temp_flag
49 51
        self.target_dir = None
50 52
        self.interpreter = sys.executable
51 53
        self.pip_cmd = [self.interpreter, "-m", "pip"]
@@ -54,6 +56,8 @@
Loading
54 56
        if not packages:
55 57
            self.log.debug("Nothing to install")
56 58
            return
59 +
        # workaround for PythonTool, remove after expanding check logic from prepare() to PythonTool
60 +
        self.has_installed_packages = True
57 61
        cmdline = self.pip_cmd + ["install", "-t", self.target_dir]
58 62
        for package in packages:
59 63
            version = self.versions.get(package, None)
@@ -90,10 +94,10 @@
Loading
90 94
        return missed
91 95
92 96
    def _uninstall(self, packages):
93 -
        pass     # todo:
97 +
        pass  # todo:
94 98
95 99
    def _reload(self, packages):
96 -
        pass     # todo:
100 +
        pass  # todo:
97 101
98 102
    def prepare(self):
99 103
        """
@@ -117,7 +121,7 @@
Loading
117 121
        if not os.path.exists(self.target_dir):
118 122
            os.makedirs(get_full_path(self.target_dir), exist_ok=True)
119 123
120 -
        if self._missed(["pip"]):   # extend to windows (bzt-pip)
124 +
        if self._missed(["pip"]):  # extend to windows (bzt-pip)
121 125
            raise TaurusInternalException("pip module not found for interpreter %s" % self.interpreter)
122 126
        self.packages = self._missed(self.packages)
123 127
        if not self.packages:
@@ -126,21 +130,23 @@
Loading
126 130
        self._install(self.packages)
127 131
128 132
    def post_process(self):
129 -
        if self.packages and self.temp and not is_windows() and os.path.exists(self.target_dir):    # might be forbidden on win as tool still work
133 +
        # might be forbidden on win as tool still work
134 +
        if self.has_installed_packages and self.temp and not is_windows():
130 135
            self.log.debug("remove packages: %s" % self.packages)
131 136
132 137
            shutil.rmtree(self.target_dir)  # it removes all content of directory in reality, not only self.packages
133 138
134 139
135 140
class PythonTool(RequiredTool):
136 -
    def __init__(self, packages, version, engine, **kwargs):
137 -
        self.installer = PipInstaller()
138 -
        self.installer.engine = engine
139 -
        self.installer.parameters['packages'] = packages
141 +
    def __init__(self, packages, engine, settings, **kwargs):
142 +
        tool_path = engine.temp_pythonpath
143 +
        super(PythonTool, self).__init__(tool_path=tool_path, **kwargs)
144 +
145 +
        temp_flag = settings.get("temp", True)
146 +
        version = settings.get("version", None)
147 +
        self.installer = PipInstaller(engine, packages=packages, temp_flag=temp_flag)
140 148
        if version:
141 149
            self.installer.versions[packages[0]] = version
142 -
        self.tool_path = self.installer.engine.temp_pythonpath
143 -
        super(PythonTool, self).__init__(tool_path=self.tool_path, **kwargs)
144 150
145 151
    def check_if_installed(self):
146 152
        self.log.debug(f"Checking {self.tool_name}.")
@@ -232,7 +238,7 @@
Loading
232 238
            return
233 239
234 240
        self.log.info("Checking installation needs for: %s", mod_name)
235 -
        mod.parameters["temp"] = False
241 +
        mod.settings.get("temp", default=False, force_set=True)
236 242
        mod.install_required_tools()
237 243
        self.log.info("Module is fine: %s", mod_name)
238 244
@@ -447,7 +453,7 @@
Loading
447 453
            self.log.info(msg, (width, height), self.virtual_display.new_display_var)
448 454
            VirtualDisplay.SHARED_VIRTUAL_DISPLAY = self.virtual_display
449 455
450 -
            self.engine.shared_env.set({'DISPLAY': os.environ['DISPLAY']})   # backward compatibility
456 +
            self.engine.shared_env.set({'DISPLAY': os.environ['DISPLAY']})  # backward compatibility
451 457
452 458
    def free_virtual_display(self):
453 459
        if self.virtual_display and self.virtual_display.is_alive():

@@ -78,9 +78,7 @@
Loading
78 78
                raise TaurusConfigError("`tags` is not a string or text")
79 79
80 80
    def install_required_tools(self):
81 -
        self.robot = self._get_tool(Robot, engine=self.engine, version=self.settings.get("version", None))
82 -
        if not self.parameters.get("temp", True):
83 -
            self.robot.installer.settings['temp'] = False
81 +
        self.robot = self._get_tool(Robot, engine=self.engine, settings=self.settings)
84 82
        self._check_tools([self.robot, self._get_tool(TaurusRobotRunner, tool_path=self.runner_path)])
85 83
86 84
    def startup(self):
@@ -114,11 +112,12 @@
Loading
114 112
115 113
    def post_process(self):
116 114
        self.robot.post_process()
115 +
        super(RobotExecutor, self).post_process()
117 116
118 117
119 118
class Robot(PythonTool):
120 -
    def __init__(self, engine, version, **kwargs):
121 -
        super(Robot, self).__init__(packages=["robotframework", "apiritif"], version=version, engine=engine, **kwargs)
119 +
    def __init__(self, engine, settings, **kwargs):
120 +
        super(Robot, self).__init__(packages=["robotframework", "apiritif"], engine=engine, settings=settings, **kwargs)
122 121
123 122
124 123
class TaurusRobotRunner(RequiredTool):

@@ -73,11 +73,7 @@
Loading
73 73
            self.engine.aggregator.add_underling(self.reader)
74 74
75 75
    def install_required_tools(self):
76 -
        self.locust = self._get_tool(Locust, engine=self.engine, version=self.settings.get("version", None))
77 -
78 -
        if not self.parameters.get("temp", True):
79 -
            self.locust.installer.settings['temp'] = False
80 -
76 +
        self.locust = self._get_tool(Locust, engine=self.engine, settings=self.settings)
81 77
        if not self.locust.check_if_installed():
82 78
            self.locust.install()
83 79
@@ -173,6 +169,7 @@
Loading
173 169
174 170
    def post_process(self):
175 171
        self.locust.post_process()
172 +
        super(LocustIOExecutor, self).post_process()
176 173
177 174
    def has_results(self):
178 175
        master_results = self.is_master and self.reader.cumulative
@@ -203,8 +200,8 @@
Loading
203 200
204 201
205 202
class Locust(PythonTool):
206 -
    def __init__(self, engine, version, **kwargs):
207 -
        super(Locust, self).__init__(packages=["locust"], version=version, engine=engine, **kwargs)
203 +
    def __init__(self, engine, settings, **kwargs):
204 +
        super(Locust, self).__init__(packages=["locust"], engine=engine, settings=settings, **kwargs)
208 205
209 206
210 207
class WorkersReader(ResultsProvider):

@@ -18,7 +18,7 @@
Loading
18 18
import sys
19 19
20 20
from bzt import TaurusConfigError
21 -
from bzt.engine import SETTINGS
21 +
from bzt.engine import SETTINGS, HavingInstallableTools
22 22
from bzt.modules import SubprocessedExecutor, ConsolidatingAggregator, FuncSamplesReader
23 23
from bzt.modules.functional import FunctionalResultsReader
24 24
from bzt.modules.jmeter import JTLReader
@@ -29,7 +29,7 @@
Loading
29 29
IGNORED_LINE = re.compile(r"[^,]+,Total:\d+ Passed:\d+ Failed:\d+")
30 30
31 31
32 -
class ApiritifNoseExecutor(SubprocessedExecutor):
32 +
class ApiritifNoseExecutor(SubprocessedExecutor, HavingInstallableTools):
33 33
    """
34 34
    :type _tailer: FileReader
35 35
    """
@@ -152,11 +152,7 @@
Loading
152 152
        return iterations
153 153
154 154
    def install_required_tools(self):
155 -
        self.apiritif = self._get_tool(Apiritif, engine=self.engine, version=self.settings.get("version", None))
156 -
157 -
        if not self.parameters.get("temp", True):
158 -
            self.apiritif.installer.settings['temp'] = False
159 -
155 +
        self.apiritif = self._get_tool(Apiritif, engine=self.engine, settings=self.settings)
160 156
        if not self.apiritif.check_if_installed():
161 157
            self.apiritif.install()
162 158
@@ -265,10 +261,10 @@
Loading
265 261
class Apiritif(PythonTool):
266 262
    VERSION = "0.9.8"
267 263
268 -
    def __init__(self, engine, version, **kwargs):
269 -
        if not version:
270 -
            version = self.VERSION
271 -
        super(Apiritif, self).__init__(packages=["apiritif"], version=version, engine=engine, **kwargs)
264 +
    def __init__(self, engine, settings, **kwargs):
265 +
        if not settings.get("version", None):
266 +
            settings["version"] = self.VERSION
267 +
        super(Apiritif, self).__init__(packages=["apiritif"], engine=engine, settings=settings, **kwargs)
272 268
273 269
274 270
class ApiritifLoadReader(ConsolidatingAggregator):

Click to load this diff.
Loading diff...

Learn more Showing 7 files with coverage changes found.

Changes in bzt/modules/robot.py
+3
+6
Loading file...
Changes in bzt/engine/modules.py
-2
+2
Loading file...
Changes in bzt/modules/external.py
-3
Loading file...
Changes in bzt/utils.py
-3
+3
Loading file...
Changes in bzt/modules/blazemeter/cloud_provisioning.py
New
Loading file...
bzt/modules/grinder.py
Loading file...
Changes in bzt/modules/monitoring.py
-1
+1
Loading file...
Files Coverage
bzt -0.13% 90.29%
Project Totals (68 files) 90.29%
Loading