Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_etime = float(log_vals[3]) # 3. elapsed time (total time - connection time)
_rsize = int(log_vals[4]) # 4. size of response
_url = log_vals[5] # 6. long or short URL value
# _url_id = int(log_vals[7]) # 7. url number
_tstamp = time.strptime(log_vals[7], "%Y-%m-%d %H:%M:%S")
_tstamp = int(time.mktime(_tstamp)) # 8. moment of request sending
_con_time = 0
_latency = 0
_error = None
_concur = self.concurrency
yield _tstamp, _url, _concur, _etime, _con_time, _latency, _rstatus, _error, '', _rsize
class Siege(RequiredTool):
def __init__(self, config=None, **kwargs):
settings = config or {}
tool_path = settings.get("path", "siege")
super(Siege, self).__init__(tool_path=tool_path, installable=False, **kwargs)
def check_if_installed(self):
self.log.debug("Trying %s: %s", self.tool_name, self.tool_path)
try:
out, err = self.call([self.tool_path, "-h"])
except CALL_PROBLEMS as exc:
self.log.warning("%s check failed: %s", self.tool_name, exc)
return False
if err:
out += err
self.log.debug("%s output: %s", self.tool_name, out)
def _get_tool(self, tool, **kwargs):
instance = tool(env=self.env, log=self.log, http_client=self.engine.get_http_client(), **kwargs)
assert isinstance(instance, RequiredTool)
return instance
super(Newman, self).__init__(tool_path=tool_path, tools_dir=tools_dir, **kwargs)
class TaurusMochaPlugin(RequiredTool):
def __init__(self, **kwargs):
tool_path = os.path.join(RESOURCES_DIR, "mocha-taurus-plugin.js")
super(TaurusMochaPlugin, self).__init__(tool_path=tool_path, installable=False, **kwargs)
class TaurusWDIOPlugin(RequiredTool):
def __init__(self, **kwargs):
tool_path = os.path.join(RESOURCES_DIR, "wdio-taurus-plugin.js")
super(TaurusWDIOPlugin, self).__init__(tool_path=tool_path, installable=False, **kwargs)
class TaurusNewmanPlugin(RequiredTool):
def __init__(self, **kwargs):
tool_path = os.path.join(RESOURCES_DIR, "newman-reporter-taurus.js")
super(TaurusNewmanPlugin, self).__init__(tool_path=tool_path, installable=False, **kwargs)
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
from bzt.utils import RequiredTool, CALL_PROBLEMS
class TaurusPytestRunner(RequiredTool):
def __init__(self, tool_path, **kwargs):
super(TaurusPytestRunner, self).__init__(tool_path=tool_path, installable=False, **kwargs)
class TaurusRobotRunner(RequiredTool):
def __init__(self, tool_path, **kwargs):
super(TaurusRobotRunner, self).__init__(tool_path=tool_path, installable=False, **kwargs)
class Robot(RequiredTool):
def __init__(self, python, **kwargs):
super(Robot, self).__init__(installable=False, **kwargs)
self.python = python
def check_if_installed(self):
self.log.debug('Checking Robot Framework: %s' % self.tool_path)
links = self.mirror_manager.mirrors()
downloader = ExceptionalDownloader(self.http_client)
for link in links:
self.log.info("Downloading: %s", link)
with ProgressBarContext() as pbar:
try:
return downloader.get(link, reporthook=pbar.download_callback, suffix=suffix)[0]
except KeyboardInterrupt:
raise
except BaseException as exc:
self.log.error("Error while downloading %s: %s" % (link, exc))
raise TaurusInternalException("%s download failed: No more links to try" % self.tool_name)
class JavaVM(RequiredTool):
def __init__(self, **kwargs):
if "mandatory" not in kwargs:
kwargs["mandatory"] = False
super(JavaVM, self).__init__(installable=False, tool_path="java", **kwargs)
def _get_version(self, output):
versions = re.findall("version\ \"([_\d\.]*)", output)
version = parse_java_version(versions)
if not version:
self.log.warning("Tool version parsing error: %s", output)
return version
def check_if_installed(self):
cmd = [self.tool_path, '-version']
with open(self.stdout.name) as fds:
contents = fds.read().strip()
if contents.strip():
diagnostics.append("molotov STDOUT:\n" + contents)
if self.stderr is not None:
with open(self.stderr.name) as fds:
contents = fds.read().strip()
if contents.strip():
diagnostics.append("molotov STDERR:\n" + contents)
return diagnostics
def resource_files(self):
return [self.get_script_path(required=True)]
class Molotov(RequiredTool):
def __init__(self, config=None, **kwargs):
settings = config or {}
tool_path = settings.get('path', 'molotov')
super(Molotov, self).__init__(tool_path=tool_path, installable=False, **kwargs)
def check_if_installed(self):
self.log.debug("Trying %s: %s", self.tool_name, self.tool_path)
try:
out, err = self.call([self.tool_path, "--version"])
except CALL_PROBLEMS as exc:
self.log.warning("%s check failed: %s", self.tool_name, exc)
return False
version = out.strip()
if LooseVersion(version) < LooseVersion("1.4"):
raise ToolError("You must install molotov>=1.4 to use this executor (version %s detected)" % version)
"--report-file",
self.report_file,
"--test-suite",
self.script
]
load = self.get_load()
if load.iterations:
rspec_cmdline += ['--iterations', str(load.iterations)]
if load.hold:
rspec_cmdline += ['--hold-for', str(load.hold)]
self.process = self._execute(rspec_cmdline)
class Ruby(RequiredTool):
def __init__(self, config=None, **kwargs):
settings = config or {}
tool_path = settings.get("interpreter", "ruby")
super(Ruby, self).__init__(tool_path=tool_path, installable=False, **kwargs)
def check_if_installed(self):
self.log.debug("Trying %s...", self.tool_name)
try:
out, err = self.call([self.tool_path, '--version'])
except CALL_PROBLEMS as exc:
self.log.warning("%s check failed: %s", self.tool_name, exc)
return False
if err:
out += err
self.log.debug("%s output: %s", self.tool_name, out)
class Newman(NPMPackage):
PACKAGE_NAME = "newman"
def __init__(self, tools_dir="", **kwargs):
tool_path = "%s/node_modules/%s/bin/newman.js" % (tools_dir, self.PACKAGE_NAME)
super(Newman, self).__init__(tool_path=tool_path, tools_dir=tools_dir, **kwargs)
class TaurusMochaPlugin(RequiredTool):
def __init__(self, **kwargs):
tool_path = os.path.join(RESOURCES_DIR, "mocha-taurus-plugin.js")
super(TaurusMochaPlugin, self).__init__(tool_path=tool_path, installable=False, **kwargs)
class TaurusWDIOPlugin(RequiredTool):
def __init__(self, **kwargs):
tool_path = os.path.join(RESOURCES_DIR, "wdio-taurus-plugin.js")
super(TaurusWDIOPlugin, self).__init__(tool_path=tool_path, installable=False, **kwargs)
class TaurusNewmanPlugin(RequiredTool):
def __init__(self, **kwargs):
tool_path = os.path.join(RESOURCES_DIR, "newman-reporter-taurus.js")
super(TaurusNewmanPlugin, self).__init__(tool_path=tool_path, installable=False, **kwargs)
super(IncrementableProgressBar, self).__init__(maxval=maxval)
def increment(self):
incremented = self.currval + 1
if incremented < self.maxval:
super(IncrementableProgressBar, self).update(incremented)
def catchup(self, started_time=None, current_value=None):
super(IncrementableProgressBar, self).start()
if started_time:
self.start_time = started_time
if current_value and current_value < self.maxval:
self.update(current_value)
class TclLibrary(RequiredTool):
ENV_NAME = "TCL_LIBRARY"
INIT_TCL = "init.tcl"
FOLDER = "tcl"
def check_if_installed(self):
"""
Check if tcl is available
:return:
"""
if is_windows():
self.log.debug("Checking if %s variable is present in environment", TclLibrary.ENV_NAME)
if not os.environ.get(TclLibrary.ENV_NAME, None):
self.log.debug("%s environment variable is not present", TclLibrary.ENV_NAME)
return False
else:
self.log.debug("%s environment variable is present", TclLibrary.ENV_NAME)
meth_obj = benchmark[method]
if "mmtasks" in meth_obj:
self.data[date] += meth_obj["mmtasks"][2]
self.log.debug("Active instances stats for %s: %s", date, self.data[date])
def get_data(self, tstmp):
if tstmp in self.data:
self.last_data = self.data[tstmp]
return self.data[tstmp]
else:
self.log.debug("No active instances info for %s", tstmp)
return self.last_data
class PBench(RequiredTool):
def __init__(self, config=None, **kwargs):
settings = config or {}
# don't extend system-wide default
tool_path = get_full_path(settings.get("path"), default="phantom")
super(PBench, self).__init__(tool_path=tool_path, installable=False, **kwargs)
def check_if_installed(self):
self.log.debug("Trying phantom: %s", self.tool_path)
try:
out, err = self.call([self.tool_path])
except CALL_PROBLEMS as exc:
self.log.info("Phantom check failed: %s", exc)
return False