Example #1
0
def _bootstrap_master(bootstrap_dir_path):
    abs_bootstrap_dir_path = get_abs_path(bootstrap_dir_path)
    _bootstrap(abs_bootstrap_dir_path)

    dir_name = os.path.basename(abs_bootstrap_dir_path)
    run("nohup locust -f /tmp/locust/{0}/locustfile.py \
        --master >~/locust-log.txt 2>&1 < /dev/null &".format(dir_name), pty=False)
Example #2
0
def _bootstrap_master(bootstrap_dir_path):
    abs_bootstrap_dir_path = get_abs_path(bootstrap_dir_path)
    _bootstrap(abs_bootstrap_dir_path)

    dir_name = os.path.basename(abs_bootstrap_dir_path)
    run("nohup locust -f /tmp/locust/{0}/locustfile.py \
        --master >& /dev/null < /dev/null &".format(dir_name),
        pty=False)
Example #3
0
def _bootstrap_slave(bootstrap_dir_path, master_ip_address):
    abs_bootstrap_dir_path = get_abs_path(bootstrap_dir_path)
    _bootstrap(abs_bootstrap_dir_path)

    dir_name = os.path.basename(abs_bootstrap_dir_path)
    run("nohup locust -f /tmp/locust/{0}/locustfile.py --slave \
        --master-host={1} >& /dev/null < /dev/null &".
        format(dir_name, master_ip_address), pty=False)
Example #4
0
def _bootstrap_slave(bootstrap_dir_path, master_ip_address):
    abs_bootstrap_dir_path = get_abs_path(bootstrap_dir_path)
    _bootstrap(abs_bootstrap_dir_path)

    dir_name = os.path.basename(abs_bootstrap_dir_path)
    run("nohup locust -f /tmp/locust/{0}/locustfile.py --slave \
        --master-host={1} >& /dev/null < /dev/null &".format(
        dir_name, master_ip_address),
        pty=False)
Example #5
0
def _parse(path_to_config=DEFAULT_CFG_FILEPATH):
    config = ConfigParser.SafeConfigParser()
    config_path = get_abs_path(path_to_config)
    try:
        with open(config_path, 'r') as f:
            config.readfp(f)
    except IOError:
        raise Exception("Unable to open locust-swarm configuration file @ {0}"
                        .format(config_path))
    return config
Example #6
0
def _parse(path_to_config=DEFAULT_CFG_FILEPATH):
    config = ConfigParser.SafeConfigParser()
    config_path = get_abs_path(path_to_config)
    try:
        with open(config_path, 'r') as f:
            config.readfp(f)
    except IOError:
        raise Exception("Unable to open locust-swarm configuration file @ {0}"
                        .format(config_path))
    return config
Example #7
0
def _bootstrap_slave(bootstrap_dir_path, master_ip_address):
    abs_bootstrap_dir_path = get_abs_path(bootstrap_dir_path)

    print 'Slave sleeping'
    time.sleep(60)
    _bootstrap(abs_bootstrap_dir_path)

    dir_name = os.path.basename(abs_bootstrap_dir_path)
    run('echo "{0}" > /tmp/locust/{1}/host_id_mapping.txt'.format(env.host_id_mapping, dir_name))

    run("nohup locust -f /tmp/locust/{0}/locustfile.py --slave \
        --master-host={1} >~/locust-log.txt 2>&1 < /dev/null &".
        format(dir_name, master_ip_address), pty=False)
Example #8
0
def _validate_dirs(args):
    logging.info("Validating proper directories are present")

    bootstrap_dir_path = get_abs_path(args.directory)

    if os.path.exists(bootstrap_dir_path):
        bootstrap_file = os.path.join(bootstrap_dir_path, 'bootstrap.sh')
        if os.path.exists(bootstrap_file):
            locustfile = os.path.join(bootstrap_dir_path, 'locustfile.py')
            if os.path.exists(locustfile):
                logging.info("All proper directories present")
                return

    raise Exception("Unable to validate bootstrap.sh and locustfile.py are "
                    "present in the directory {0}".format(bootstrap_dir_path))
Example #9
0
def _validate_dirs(args):
    logging.info("Validating proper directories are present")

    bootstrap_dir_path = get_abs_path(args.directory)

    if os.path.exists(bootstrap_dir_path):
        bootstrap_file = os.path.join(bootstrap_dir_path, 'bootstrap.sh')
        if os.path.exists(bootstrap_file):
            locustfile = os.path.join(bootstrap_dir_path, 'locustfile.py')
            if os.path.exists(locustfile):
                logging.info("All proper directories present")
                return

    raise Exception("Unable to validate bootstrap.sh and locustfile.py are "
                    "present in the directory {0}".format(bootstrap_dir_path))