示例#1
0
def launch_fire(test_id, test_cfg, base_path, armorer_api_url=None,
                logs_path='/tmp'):
    logger = get_robo_logger(logs_path, test_id, is_debug=False)

    #wd = '%s/%s' % (base_path, test_id)
    if not os.path.exists(base_path):
        os.makedirs(base_path)
    os.chdir(base_path)

    try:
        validate(test_cfg)
    except validictory.validator.ValidationError, e:
        return 1, 'Error in parsing fire conf:\n%s' % e
示例#2
0
def build_test(test_cfg, args=None):
    '''Create dirs tree, phantom.cfg and ammo.stpd
    Args:
        test_cfg: dict, test config.
        default: dict, default settings and validation rules.
        args: argparse obj instance.
    '''
    logger = logging.getLogger('root')

    now = datetime.datetime.now()
    orig_wd = os.getcwd()
    ammo_from_arg = False
    test_http_cntx = None
    if 'ammo' in test_cfg:
        test_http_cntx = test_cfg['ammo'].get('http_context', None)

    for idx, f in enumerate(test_cfg['fire']):
        try:
            validate(f, tgt='fire')
        except validictory.validator.ValidationError, e:
            raise FireEmergencyExit('Error in parsing fire dict:\n%s' % e)

        # get absolute ammo path before chdir
        if not ammo_from_arg:
            if args and args.ammo_file:
                ammo_from_arg = os.path.abspath(args.ammo_file)
                ammo_path = ammo_from_arg
            else:
                ammo_path = f['input_file']

        if not os.path.isfile(ammo_path):
            raise FireEmergencyExit('No such ammo file: %s' % ammo_path)

        try:
            pbar_max = f['total_dur'] = fire_duration(f)
        except StepperSchemaFormat, e:
            msg = [
                'Malformed shcema format in fire: %s' % f['name'],
                'in \'%s\' > \'%s\'' % (f['name'], e.value['schema'])
            ]
            raise FireEmergencyExit(msg)