Exemplo n.º 1
0
 def __init__(self, tsung_basedir, parent_logger):
     super(TsungStatsReader, self).__init__()
     self.log = parent_logger.getChild(self.__class__.__name__)
     self.tsung_basedir = tsung_basedir
     self.stats_file = FileReader(parent_logger=self.log, file_opener=self.open_stats)
     self.log_file = FileReader(parent_logger=self.log, file_opener=self.open_log)
     self.delimiter = ";"
     self.partial_buffer = ""
     self.skipped_header = False
     self.concurrency = 0
Exemplo n.º 2
0
    def startup(self):
        executable = self.settings.get("interpreter", sys.executable)

        report_type = ".ldjson" if self.engine.is_functional_mode() else ".csv"
        report_tpl = self.engine.create_artifact("apiritif",
                                                 ".") + "%s" + report_type
        cmdline = [
            executable, "-m", "apiritif.loadgen", '--result-file-template',
            report_tpl
        ]

        load = self.get_load()
        if load.concurrency:
            cmdline += ['--concurrency', str(load.concurrency)]

        if load.iterations:
            cmdline += ['--iterations', str(load.iterations)]

        if load.hold:
            cmdline += ['--hold-for', str(load.hold)]

        if load.ramp_up:
            cmdline += ['--ramp-up', str(load.ramp_up)]

        if load.steps:
            cmdline += ['--steps', str(load.steps)]

        if self.__is_verbose():
            cmdline += ['--verbose']

        cmdline += [self.script]
        self.process = self.execute(cmdline)
        self._tailer = FileReader(filename=self.stdout.name,
                                  parent_logger=self.log)
Exemplo n.º 3
0
    def __init__(self, load, payload_filename, parent_logger):
        super(Scheduler, self).__init__()
        self.need_start_loop = None
        self.log = parent_logger.getChild(self.__class__.__name__)
        self.load = load
        self.payload_file = FileReader(filename=payload_filename,
                                       parent_logger=self.log)
        if not load.duration and not load.iterations:
            self.iteration_limit = 1
        else:
            self.iteration_limit = load.iterations

        self.concurrency = load.concurrency if load.concurrency is not None else 1

        self.step_len = load.ramp_up / load.steps if load.steps and load.ramp_up else 0
        if load.throughput:
            self.ramp_up_slope = load.throughput / load.ramp_up if load.ramp_up else 0
            self.step_size = float(
                load.throughput) / load.steps if load.steps else 0
        else:
            self.ramp_up_slope = None
            self.step_size = float(
                self.concurrency) / load.steps if load.steps else 0

        self.count = 0.0
        self.time_offset = 0.0
        self.iterations = 0
Exemplo n.º 4
0
 def __init__(self, filename, parent_logger):
     super(PBenchStatsReader, self).__init__()
     self.log = parent_logger.getChild(self.__class__.__name__)
     self.file = FileReader(filename=filename, parent_logger=self.log)
     self.buffer = ''
     self.data = {}
     self.last_data = 0
Exemplo n.º 5
0
 def __init__(self):
     super(ApiritifNoseExecutor, self).__init__()
     self._tailer = FileReader(file_opener=lambda _: None,
                               parent_logger=self.log)
     self.apiritif = None
     self.selenium = None
     self.test_mode = None
Exemplo n.º 6
0
 def __init__(self, filename, parent_logger):
     super(TSVDataReader, self).__init__()
     self.log = parent_logger.getChild(self.__class__.__name__)
     self.file = FileReader(filename=filename, parent_logger=self.log)
     self.skipped_header = False
     self.concurrency = None
     self.url_label = None
Exemplo n.º 7
0
 def __init__(self):
     super(PyTestExecutor, self).__init__()
     self.runner_path = os.path.join(RESOURCES_DIR, "pytest_runner.py")
     self._tailer = FileReader('',
                               file_opener=lambda _: None,
                               parent_logger=self.log)
     self._additional_args = []
Exemplo n.º 8
0
    def startup(self):
        """
        run python tests
        """
        executable = self.settings.get("interpreter", sys.executable)

        cmdline = [
            executable, self.runner_path, '--report-file', self.report_file
        ]

        load = self.get_load()
        if load.iterations:
            cmdline += ['-i', str(load.iterations)]

        if load.hold:
            cmdline += ['-d', str(load.hold)]

        cmdline += self._additional_args
        cmdline += [self.script]

        self.process = self._execute(cmdline)

        if self.__is_verbose():
            self._tailer = FileReader(filename=self.stdout.name,
                                      parent_logger=self.log)
Exemplo n.º 9
0
    def startup(self):
        """
        run python tests
        """
        executable = self.settings.get("interpreter", sys.executable)

        self.env.update({
            "PYTHONPATH":
            os.getenv("PYTHONPATH", "") + os.pathsep +
            get_full_path(__file__, step_up=3)
        })

        cmdline = [
            executable, self.runner_path, '--report-file', self.report_file
        ]
        cmdline += self._additional_args

        load = self.get_load()
        if load.iterations:
            cmdline += ['-i', str(load.iterations)]

        if load.hold:
            cmdline += ['-d', str(load.hold)]

        cmdline += [self.script]
        self._start_subprocess(cmdline)

        if self.__is_verbose():
            self._tailer = FileReader(filename=self.stdout_file,
                                      parent_logger=self.log)
Exemplo n.º 10
0
    def test_subscribe_to_transactions(self):
        dummy = DummyListener()

        self.configure({
            'execution': {
                "iterations": 5,
                'scenario': {
                    'script':
                    RESOURCES_DIR +
                    'selenium/python/test_selenium_transactions.py'
                },
                'executor': 'selenium'
            },
        })
        self.obj_prepare_runner()
        self.obj.subscribe_to_transactions(dummy)
        try:
            self.obj.engine.start_subprocess = self.start_subprocess
            self.obj.startup()
            fake_out = os.path.join(RESOURCES_DIR, 'apiritif/dummy-output.out')
            self.obj.runner._tailer = FileReader(filename=fake_out,
                                                 parent_logger=self.log)
        finally:
            self.obj.shutdown()
        self.obj.post_process()
        self.assertEqual(10, dummy.transactions['hello there'])
Exemplo n.º 11
0
 def __init__(self):
     super(PyTestExecutor, self).__init__()
     self.runner_path = os.path.join(get_full_path(__file__, step_up=2),
                                     "resources", "pytest_runner.py")
     self._tailer = FileReader('',
                               file_opener=lambda _: None,
                               parent_logger=self.log)
     self._additional_args = []
Exemplo n.º 12
0
    def test_jsr223(self):
        self.configure(RESOURCES_DIR + "jmeter/jmx/jsr223.jmx")
        try:
            self.obj.process()
            lines = FileReader(self.obj.dst_file).get_lines(last_pass=True)
            yml = yaml.full_load(''.join(lines))
            scenarios = yml.get("scenarios")
            scenario = scenarios["Thread Group"]
            requests = scenario["requests"]
            self.assertEqual(len(requests), 1)
            request = requests[0]
            self.assertIn("jsr223", request)
            parsed_jsrs = request["jsr223"]
            self.assertTrue(isinstance(parsed_jsrs, list))
            self.assertEqual(len(parsed_jsrs), 5)

            target = [{
                'script-text': 'scripty',
                'execute': 'before',
                'compile-cache': 'false',
                'language': 'beanshell',
                'parameters': 'paramssss'
            }, {
                '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'))
Exemplo n.º 13
0
 def __init__(self, basedir, parent_logger, dir_prefix):
     super(DataLogReader, self).__init__()
     self.concurrency = 0
     self.log = parent_logger.getChild(self.__class__.__name__)
     self.basedir = basedir
     self.file = FileReader(file_opener=self.open_fds, parent_logger=self.log)
     self.partial_buffer = ""
     self.delimiter = "\t"
     self.dir_prefix = dir_prefix
     self.guessed_gatling_version = None
Exemplo n.º 14
0
 def test_requests(self):
     self.configure(yaml.load(open(RESOURCES_DIR + "yaml/selenium_executor_requests.yml").read()))
     self.obj.prepare()
     self.obj.get_widget()
     self.obj.startup()
     while not self.obj.check():
         time.sleep(1)
     self.obj.shutdown()
     reader = FileReader(os.path.join(self.obj.engine.artifacts_dir, "apiritif-0.csv"))
     lines = reader.get_lines(last_pass=True)
     self.assertEquals(4, len(list(lines)))
Exemplo n.º 15
0
    def startup(self):
        executable = self.settings.get("interpreter", sys.executable)

        report_type = ".ldjson" if self.engine.is_functional_mode() else ".csv"
        report_tpl = self.engine.create_artifact("apiritif",
                                                 ".") + "%s" + report_type
        cmdline = [
            executable, "-m", "apiritif.loadgen", '--result-file-template',
            report_tpl
        ]

        load = self.get_load()
        if load.concurrency:
            cmdline += ['--concurrency', str(load.concurrency)]

        iterations = self.get_raw_load().iterations
        if iterations is None:  # defaults:
            msg = "No iterations limit in config, choosing anything... set "
            if load.duration or self.engine.is_functional_mode() and list(
                    self.get_scenario().get_data_sources()):
                iterations = 0  # infinite for func mode and ds
                msg += "0 (infinite) as "
                if load.duration:
                    msg += "duration found (hold-for + ramp-up)"
                elif self.engine.is_functional_mode():
                    msg += "taurus works in functional mode"
                else:
                    msg += "data-sources found"

            else:
                iterations = 1  # run once otherwise
                msg += "1"

            self.log.debug(msg)

        if iterations:
            cmdline += ['--iterations', str(iterations)]

        if load.hold:
            cmdline += ['--hold-for', str(load.hold)]

        if load.ramp_up:
            cmdline += ['--ramp-up', str(load.ramp_up)]

        if load.steps:
            cmdline += ['--steps', str(load.steps)]

        if self.__is_verbose():
            cmdline += ['--verbose']

        cmdline += [self.script]
        self.process = self._execute(cmdline)
        self._tailer = FileReader(filename=self.stdout.name,
                                  parent_logger=self.log)
Exemplo n.º 16
0
 def __init__(self, filename, num_slaves, parent_logger):
     """
     :type filename: str
     :type num_slaves: int
     :type parent_logger: logging.Logger
     """
     super(SlavesReader, self).__init__()
     self.log = parent_logger.getChild(self.__class__.__name__)
     self.join_buffer = {}
     self.num_slaves = num_slaves
     self.file = FileReader(filename=filename, parent_logger=self.log)
     self.read_buffer = ""
Exemplo n.º 17
0
 def __init__(self, filename, parent_logger):
     super(DataLogReader, self).__init__()
     self.report_by_url = False
     self.log = parent_logger.getChild(self.__class__.__name__)
     self.file = FileReader(filename=filename, parent_logger=self.log)
     self.idx = {}
     self.partial_buffer = ""
     self.start_time = 0
     self.end_time = 0
     self.concurrency = 0
     self.test_names = {}
     self.known_threads = set()
Exemplo n.º 18
0
 def __init__(self, filename, parent_logger):
     super(K6LogReader, self).__init__()
     self.log = parent_logger.getChild(self.__class__.__name__)
     self.file = FileReader(filename=filename, parent_logger=self.log)
     self.data = {
         'timestamp': [],
         'label': [],
         'r_code': [],
         'error_msg': [],
         'http_req_duration': [],
         'http_req_connecting': [],
         'http_req_tls_handshaking': [],
         'http_req_waiting': [],
         'vus': [],
         'data_received': []
     }
Exemplo n.º 19
0
 def test_jsr223(self):
     self.configure(RESOURCES_DIR + "jmeter/jmx/jsr223.jmx")
     try:
         self.obj.process()
         lines = FileReader(self.obj.dst_file).get_lines(last_pass=True)
         yml = yaml.load(''.join(lines))
         scenarios = yml.get("scenarios")
         scenario = scenarios["Thread Group"]
         requests = scenario["requests"]
         self.assertEqual(len(requests), 1)
         request = requests[0]
         self.assertIn("jsr223", request)
         jsrs = request["jsr223"]
         self.assertTrue(isinstance(jsrs, list))
         self.assertEqual(len(jsrs), 5)
         self.assertEqual(jsrs[0]["language"], "beanshell")
         self.assertEqual(jsrs[0]["script-text"], "scripty")
         self.assertEqual(jsrs[0]["parameters"], "parames")
         self.assertNotIn('script-file', jsrs[0])
         self.assertEqual(jsrs[1]["language"], "javascript")
         self.assertEqual(jsrs[1]["script-text"],
                          u'console.log("ПРИВЕТ");\nline("2");')
         self.assertEqual(jsrs[1]["parameters"], "a b c")
         self.assertNotIn('script-file', jsrs[1])
         self.assertEqual(jsrs[2]["language"], "javascript")
         self.assertEqual(jsrs[2]["script-file"], "script.js")
         self.assertEqual(jsrs[2]["parameters"], None)
         self.assertNotIn('script-text', jsrs[2])
         self.assertEqual(jsrs[3]["language"], "beanshell")
         self.assertEqual(jsrs[3]["execute"], "before")
         self.assertEqual(jsrs[3]["parameters"], None)
         self.assertEqual(jsrs[3]['script-text'],
                          'console.log("beanshell aka jsr223");')
         self.assertNotIn('script-file', jsrs[3])
         self.assertEqual(jsrs[4]["language"], "java")
         self.assertEqual(jsrs[4]["execute"], "before")
         self.assertEqual(jsrs[4]["parameters"], None)
         self.assertIn('BlazeDemo.java', jsrs[4]['script-file'])
         self.assertNotIn('script-text', jsrs[4])
         self.assertTrue(
             os.path.exists(
                 os.path.join(get_full_path(self.obj.dst_file, step_up=1),
                              'script.js')))
     finally:
         os.remove(
             os.path.join(get_full_path(self.obj.dst_file, step_up=1),
                          'script.js'))
Exemplo n.º 20
0
    def startup(self):
        executable = self.settings.get("interpreter", sys.executable)

        py_path = os.getenv("PYTHONPATH")
        taurus_dir = get_full_path(__file__, step_up=3)
        if py_path:
            py_path = os.pathsep.join((py_path, taurus_dir))
        else:
            py_path = taurus_dir

        self.env["PYTHONPATH"] = py_path

        report_type = ".ldjson" if self.engine.is_functional_mode() else ".csv"
        report_tpl = self.engine.create_artifact("apiritif-",
                                                 "") + "%s" + report_type
        cmdline = [
            executable, "-m", "apiritif.loadgen", '--result-file-template',
            report_tpl
        ]

        load = self.get_load()
        if load.concurrency:
            cmdline += ['--concurrency', str(load.concurrency)]

        if load.iterations:
            cmdline += ['--iterations', str(load.iterations)]

        if load.hold:
            cmdline += ['--hold-for', str(load.hold)]

        if load.ramp_up:
            cmdline += ['--ramp-up', str(load.ramp_up)]

        if load.steps:
            cmdline += ['--steps', str(load.steps)]

        if self.__is_verbose():
            cmdline += ['--verbose']

        cmdline += [self.script]
        self.start_time = time.time()
        self._start_subprocess(cmdline)
        self._tailer = FileReader(filename=self.stdout_file,
                                  parent_logger=self.log)
Exemplo n.º 21
0
 def __init__(self, filename, parent_logger):
     super(DataLogReader, self).__init__()
     self.log = parent_logger.getChild(self.__class__.__name__)
     self.file = FileReader(filename=filename, parent_logger=self.log)
     self.concurrency = None
Exemplo n.º 22
0
 def __init__(self, filename, parent_logger, stats_filename):
     super(PBenchKPIReader, self).__init__()
     self.log = parent_logger.getChild(self.__class__.__name__)
     self.file = FileReader(filename=filename, parent_logger=self.log)
     self.stats_reader = PBenchStatsReader(stats_filename, parent_logger)
Exemplo n.º 23
0
 def __init__(self):
     super(ApiritifNoseExecutor, self).__init__()
     self._tailer = FileReader(file_opener=lambda _: None,
                               parent_logger=self.log)