Example #1
0
    def process_reply(self, message):
        result = super(FlentExecutor, self).process_reply(message)

        stdout = result['stdout']
        if not stdout:
            raise base.ExecutorException(
                result,
                'Flent returned no data, stderr: %s' % result['stderr'])

        data = json.loads(stdout)

        series_meta = data['metadata']['SERIES_META']
        columns = sorted(series_meta.keys())
        meta = ([['time', 's']] + [[utils.strict(k), series_meta[k]['UNITS']]
                                   for k in columns])
        samples = []

        for i in range(len(data['x_values'])):
            line = [data['x_values'][i]]
            for el in columns:
                line.append(data['results'][el][i])
            samples.append(line)

        result['meta'] = meta
        result['samples'] = samples

        return result
Example #2
0
    def process_reply(self, message):
        result = super(FlentExecutor, self).process_reply(message)

        stdout = result['stdout']
        if not stdout:
            raise base.ExecutorException(
                result,
                'Flent returned no data, stderr: %s' % result['stderr'])

        data = json.loads(stdout)

        series_meta = data['metadata']['SERIES_META']
        columns = sorted(series_meta.keys())
        meta = ([['time', 's']] +
                [[utils.strict(k), series_meta[k]['UNITS']] for k in columns])
        samples = []

        for i in range(len(data['x_values'])):
            line = [data['x_values'][i]]
            for el in columns:
                line.append(data['results'][el][i])
            samples.append(line)

        result['meta'] = meta
        result['samples'] = samples

        return result
Example #3
0
def main():
    utils.init_config_and_logging(
        config.COMMON_OPTS + config.OPENSTACK_OPTS + config.SERVER_OPTS +
        config.REPORT_OPTS + config.IMAGE_BUILDER_OPTS + config.CLEANUP_OPTS +
        config.ALL_IN_ONE_OPTS
    )

    artifacts_dir = cfg.CONF.artifacts_dir
    if artifacts_dir:
        _mkdir_p(artifacts_dir)
    else:
        artifacts_dir = tempfile.mkdtemp(prefix='shaker')

    # image-builder
    _configure_log_file(_make_filename(artifacts_dir, 'image_builder', 'log'))
    LOG.info('Building the image')
    image_builder.build_image()

    # core
    scenario = cfg.CONF.scenario
    prefix = utils.strict(scenario)

    _configure_log_file(_make_filename(artifacts_dir, prefix, 'log'))

    LOG.info('Executing scenario: %s', scenario)

    cfg.CONF.set_override('output',
                          _make_filename(artifacts_dir, prefix, 'json'))
    cfg.CONF.set_override('report',
                          _make_filename(artifacts_dir, prefix, 'html'))
    cfg.CONF.set_override('subunit',
                          _make_filename(artifacts_dir, prefix, 'subunit'))
    cfg.CONF.set_override('book', _make_filename(artifacts_dir, prefix))
    server.act()

    # cleanup
    _configure_log_file(_make_filename(artifacts_dir, 'cleanup', 'log'))
    LOG.info('Cleaning up')
    image_builder.cleanup()
Example #4
0
def act():
    outputs = []

    message_queue = None
    if 'server_endpoint' in cfg.CONF:
        message_queue = messaging.MessageQueue(cfg.CONF.server_endpoint)

    artifacts_dir = cfg.CONF.artifacts_dir
    if artifacts_dir:
        utils.mkdir_tree(artifacts_dir)

    for scenario_name in cfg.CONF.scenario:
        LOG.info('Play scenario: %s', scenario_name)

        scenario = read_scenario(scenario_name)

        play_output = play_scenario(message_queue, scenario)
        outputs.append(copy.deepcopy(play_output))

        # if requested make separate reports
        if artifacts_dir:
            prefix = utils.strict(scenario_name)
            report_name_fn = functools.partial(utils.join_folder_prefix_ext,
                                               artifacts_dir, prefix)
            utils.write_file(json.dumps(play_output, indent=2),
                             report_name_fn('json'))
            report.generate_report(play_output, cfg.CONF.report_template,
                                   report_name_fn('html'),
                                   report_name_fn('subunit'), report_name_fn())

    LOG.info('Generating aggregated report')
    aggregated = utils.merge_dicts(outputs)

    utils.write_file(json.dumps(aggregated, indent=2), cfg.CONF.output)
    LOG.info('Raw output is stored to: %s', cfg.CONF.output)

    report.generate_report(aggregated, cfg.CONF.report_template,
                           cfg.CONF.report, cfg.CONF.subunit, cfg.CONF.book)
Example #5
0
 def ref_label(self, text):
     self.index.write('.. _%s:\n\n' % utils.strict(text))
Example #6
0
 def test_strict(self):
     self.assertEqual('some_01_string_a',
                      utils.strict('Some 01-string (brr!) + %% A'))
Example #7
0
def generate_output_name():
    file_name = "shaker_%s.json" % utils.strict(str(datetime.datetime.now()))
    return os.path.join(tempfile.gettempdir(), file_name)
Example #8
0
 def test_strict(self):
     self.assertEqual('some_01_string_a',
                      utils.strict('Some 01-string (brr!) + %% A'))
Example #9
0
 def ref_label(self, text):
     self.index.write('.. _%s:\n\n' % utils.strict(text))