Пример #1
0
def _setup_a_cannon(hostname):
    """Connects to the hostname and installs all the tools required for the
    load test.

    Returns a boolean for successful setup.
    """
    ssh_conn = ssh_connect(hostname)

    # copy script to cannon and make it executable
    script_path = env_scripts_dir + '/' + CANNON_INIT_SCRIPT
    put_file(ssh_conn, script_path, CANNON_INIT_SCRIPT)
    response = exec_command(ssh_conn, 'chmod 755 ~/%s' % CANNON_INIT_SCRIPT)
    if response:  # response would be error output
        print 'Unable to chmod cannon script: %s' % (CANNON_INIT_SCRIPT)
        print response
        return False

    # copy the projectile script, for later execution
    script_path = env_scripts_dir + '/' + CANNON_PROJECTILE_SCRIPT
    put_file(ssh_conn, script_path, CANNON_PROJECTILE_SCRIPT)
    response = exec_command(ssh_conn, 'chmod 755 ~/%s' % CANNON_PROJECTILE_SCRIPT)
    if response:  # response would be error output
        print 'Unable to chmod projectile script: %s' % (CANNON_PROJECTILE_SCRIPT)
        print response
        return False

    # execute the setup script (expect this call to take a while)
    response = exec_command(ssh_conn, 'sudo ./%s' % CANNON_INIT_SCRIPT)
    print response
    return (hostname, response)
Пример #2
0
def fire_cannon(cannon_host, target):
    """Handles the details of telling a host to fire"""
    ssh_conn = ssh_connect(cannon_host)
    remote_command = 'siege -c200 -t10s %s' % (target)
    # Siege writes stats to stderr
    response = exec_command(ssh_conn, remote_command, return_stderr=True)
    return response
Пример #3
0
def fire_cannon(cannon_host):
    """Handles the details of telling a host to fire"""
    ssh_conn = ssh_connect(cannon_host)
    remote_command = '~/%s' % (CANNON_PROJECTILE_SCRIPT)

    # Siege writes stats to stderr
    response = exec_command(ssh_conn, remote_command)
    return response
Пример #4
0
def _setup_a_cannon(hostname):
    """Connects to the hostname and installs all the tools required for the
    load test.

    Returns a boolean for successful setup.
    """
    ssh_conn = ssh_connect(hostname)

    # copy script to cannon and make it executable
    script_path = env_scripts_dir + '/' + CANNON_INIT_SCRIPT
    put_file(ssh_conn, script_path, CANNON_INIT_SCRIPT)
    response = exec_command(ssh_conn, 'chmod 755 ~/%s' % CANNON_INIT_SCRIPT)
    if response:  # response would be error output
        print 'Unable to chmod cannon script: %s' % (CANNON_INIT_SCRIPT)
        print response
        return False

    # execute the setup script (expect this call to take a while)
    response = exec_command(ssh_conn, 'sudo ./%s' % CANNON_INIT_SCRIPT)
    return (hostname, response)
Пример #5
0
def fire_cannon(cannon_host, target):
    """Handles the details of telling a host to fire"""
    ssh_conn = ssh_connect(cannon_host)

    # check to see if the siege file has been created, if not fire the canon
    # with some reasonable defaults. os.path.expanduser will return the ec2
    # user's homedir, most likely /home/ubuntu
    if os.path.isfile("%s/.siegerc" % (os.path.expanduser('~' + ec2_ssh_username)) ):
        siege_options = '--rc %s/.siegerc' % (os.path.expanduser('~' + ec2_ssh_username))
    else:
        siege_options = '-c200 -t60s'

    # run the siege command
    if target:
        remote_command = 'siege %s %s' % (siege_options, target)
    else:
        remote_command = 'siege %s -f ~/urls.txt' % (siege_options)

    # Siege writes stats to stderr
    response = exec_command(ssh_conn, remote_command, return_stderr=True)
    return response
Пример #6
0
def fire_cannon(cannon_host, target):
    """Handles the details of telling a host to fire"""
    ssh_conn = ssh_connect(cannon_host)

    # check to see if the siege file has been created, if not fire the canon
    # with some reasonable defaults. os.path.expanduser will return the ec2
    # user's homedir, most likely /home/ubuntu
    if os.path.isfile("%s/.siegerc" %
                      (os.path.expanduser('~' + ec2_ssh_username))):
        siege_options = '--rc %s/.siegerc' % (
            os.path.expanduser('~' + ec2_ssh_username))
    else:
        siege_options = '-c200 -t60s'

    # run the siege command
    if target:
        remote_command = 'siege %s %s' % (siege_options, target)
    else:
        remote_command = 'siege %s -f ~/urls.txt' % (siege_options)

    # Siege writes stats to stderr
    response = exec_command(ssh_conn, remote_command, return_stderr=True)
    return response