How to use the bzt.utils.get_full_path function in bzt

To help you get started, we’ve selected a few bzt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Blazemeter / taurus / tests / test_jmx2yaml.py View on Github external
}, {
                'script-text': u'console.log("\u041f\u0420\u0418\u0412\u0415\u0422");\nline("2");',
                'execute': 'after', 'compile-cache': 'true', 'language': 'javascript', 'parameters': 'a b c'
            }, {
                'execute': 'after', 'compile-cache': 'true', 'language': 'javascript', 'parameters': None,
                'script-file': 'script.js'
            }, {
                'script-text': 'console.log("beanshell aka jsr223");', 'execute': 'before',
                'compile-cache': True, 'language': 'beanshell', 'parameters': None
            }, {
                'execute': 'before', 'compile-cache': 'true', 'language': 'java', 'parameters': None,
                'script-file': 'tests/resources/BlazeDemo.java'}]

            self.assertEqual(parsed_jsrs, target)

            js_script = os.path.join(get_full_path(self.obj.dst_file, step_up=1), 'script.js')
            self.assertTrue(os.path.exists(js_script))
        finally:
            os.remove(os.path.join(get_full_path(self.obj.dst_file, step_up=1), 'script.js'))
github Blazemeter / taurus / tests / modules / test_proxy2jmx.py View on Github external
def _check_windows(self):
        art_dir = self.obj.engine.artifacts_dir
        os.environ['LOCALAPPDATA'] = art_dir
        os.mkdir(join(art_dir, 'Chromium'))
        os.mkdir(join(art_dir, 'Chromium', 'Application'))
        os.mkdir(join(art_dir, 'chromedriver'))
        res_dir = join(get_full_path(__file__, step_up=3), 'bzt', 'resources')
        src = join(res_dir, 'chrome-loader.c')

        dst_chrome = join(art_dir, 'Chromium', 'Application', 'chrome.exe')
        dst_chromedriver = join(art_dir, 'chromedriver', 'chromedriver.exe')

        shutil.copy2(src, dst_chrome)
        shutil.copy2(src, dst_chromedriver)

        required_env = {
            'PATH_TO_CHROME': dst_chrome,
            'ADDITIONAL_CHROME_PARAMS': '--proxy-server="http://host1:port1"',
            'CHROME_LOADER_LOG': join(self.obj.engine.artifacts_dir, 'chrome-loader.log')}

        os.environ['PATH'] = join(art_dir, 'chromedriver') + os.pathsep + os.getenv('PATH')

        self.obj.startup()
github Blazemeter / taurus / tests / modules / test_Gatling.py View on Github external
def test_external_jar_wrong_launcher(self):
        modified_launcher = self.obj.engine.create_artifact('wrong-gatling', EXE_SUFFIX)
        origin_launcher = get_full_path(self.obj.settings['path'])
        with open(origin_launcher) as orig_file:
            with open(modified_launcher, 'w') as mod_file:
                for line in orig_file.readlines():
                    if 'COMPILATION_CLASSPATH' not in line:
                        mod_file.writelines([line])
        os.chmod(modified_launcher, 0o755)

        self.obj.settings.merge({"path": modified_launcher})

        self.obj.execution.merge({
            "scenario": {
                "script": "tests/resources/gatling/bs",
                "additional-classpath": ["tests/resources/grinder/fake_grinder.jar"]}})
        self.assertRaises(ToolError, self.obj.prepare)
github Blazemeter / taurus / bzt / modules / services.py View on Github external
def tool_is_started(self):
        adb_path = os.path.join(get_full_path(self.tool_path, step_up=2), 'platform-tools', 'adb')
        if not os.path.isfile(adb_path):
            self.log.debug('adb is not found in sdk, trying to use an external one..')
            adb_path = 'adb'
        cmd = [adb_path, "shell", "getprop", "sys.boot_completed"]
        self.log.debug("Trying: %s", cmd)
        try:
            proc = shell_exec(cmd)
            out, _ = communicate(proc)
            return out.strip() == '1'
        except BaseException as exc:
            raise ToolError('Checking if android emulator starts is impossible: %s', exc)
github Blazemeter / taurus / bzt / modules / services.py View on Github external
def prepare(self):
        self.startup_timeout = self.settings.get('timeout', 30)
        config_tool_path = self.settings.get('path', '')
        if config_tool_path:
            self.tool_path = get_full_path(config_tool_path)
            os.environ['ANDROID_HOME'] = get_full_path(config_tool_path, step_up=2)
            self.settings['path'] = self.tool_path
        else:
            # try to read sdk path from env..
            sdk_path = os.environ.get('ANDROID_HOME')
            if sdk_path:
                env_tool_path = os.path.join(sdk_path, 'tools', 'emulator')
                self.tool_path = get_full_path(env_tool_path)
                self.settings['path'] = self.tool_path
            else:
                message = 'Taurus can''t find Android SDK automatically, you must point to emulator with modules.'
                message += 'android-emulator.path config parameter or set ANDROID_HOME environment variable'
                raise TaurusConfigError(message)

        tool = AndroidEmulator(tool_path=self.tool_path, log=self.log)
        if not tool.check_if_installed():
            tool.install()
github Blazemeter / taurus / bzt / modules / jmeter.py View on Github external
def _pmgr_path(self):
        dest = get_full_path(self.tool_path, step_up=2)
        return os.path.join(dest, 'bin', 'PluginsManagerCMD' + EXE_SUFFIX)
github Blazemeter / taurus / bzt / modules / java / executors.py View on Github external
def install_required_tools(self):
        path = get_full_path(self.settings.get("path"))
        if path:
            if os.path.isfile(get_full_path(path, "")):
                self.log.warning("JUnit path must point to directory.")
                path = get_full_path(path, step_up=1)

            path = os.path.join(path, "{tool_file}")

        config = BetterDict()
        if path:
            config["path"] = path

        self._add_jar_tool(JUnitJupiterApi, config=config)
        self._add_jar_tool(JUnitJupiterEngine, config=config)
        self._add_jar_tool(JUnitPlatformCommons, config=config)
        self._add_jar_tool(JUnitPlatformEngine, config=config)
        self._add_jar_tool(JUnitPlatformLauncher, config=config)
        self._add_jar_tool(JUnitPlatformRunner, config=config)
        self._add_jar_tool(JUnitPlatformSuiteApi, config=config)
        self._add_jar_tool(JUnitVintageEngine, config=config)
        self._add_jar_tool(ApiGuardian, config=config)
github Blazemeter / taurus / bzt / modules / pbench.py View on Github external
def __init__(self, executor, base_logger):
        """
        :param executor: ScenarioExecutor
        :type base_logger: logging.Logger
        """
        super(PBenchGenerator, self).__init__()
        self.log = base_logger.getChild(self.__class__.__name__)
        self.executor = executor
        self.engine = executor.engine
        self.settings = executor.settings
        self.execution = executor.execution
        self.tool = executor.tool
        self.modules_path = get_full_path(self.settings.get("modules-path"), default="/usr/lib/phantom")
        self.kpi_file = None
        self.stats_file = None
        self.config_file = None
        self.payload_file = None
        self.schedule_file = None
        self.use_ssl = False
        self.hostname = 'localhost'
        self.port = 80
        self._target = {"scheme": None, "netloc": None}
github Blazemeter / taurus / bzt / modules / reporting.py View on Github external
if self.first_ts < float("inf") and self.last_ts > 0:
            duration_elem = etree.Element("TestDuration")
            duration_elem.text = str(round(float(self.last_ts - self.first_ts), 3))
            root.append(duration_elem)

        report_info = get_bza_report_info(self.engine, self.log)
        if report_info:
            link, _ = report_info[0]
            report_element = etree.Element("ReportURL")
            report_element.text = link
            root.append(report_element)
        if self.last_sec:
            for label, kpiset in iteritems(self.last_sec[DataPoint.CUMULATIVE]):
                root.append(self.__get_xml_summary(label, kpiset))

        with open(get_full_path(filename), 'wb') as fhd:
            tree = etree.ElementTree(root)
            tree.write(fhd, pretty_print=True, encoding="UTF-8", xml_declaration=True)