Example #1
0
def prepare_devstack(web=True, copy=False, remote=False, private=True):
    ''' Prepare tempest for devstack '''
    if remote:
        return
    init(private=private)
    conf_dir = os.path.join(TEMPEST_DIR, "etc")
    if copy:
        log.info("Copying tempest configuration from devstack")
        ip = get_lab_vm_ip()
        with settings(host_string=ip, abort_on_prompts=True, warn_only=True):
            get("/opt/stack/tempest/etc/tempest.conf", "./tempest.conf")
    if not web:
        log.info("Preparing tempest for devstack with ready file")
        local("mv ./tempest.conf %s/tempest.conf" % conf_dir)
    else:
        ip = get_lab_vm_ip()
        log.info("Preparing tempest for devstack with IP: %s" % ip)
        RETRY = 3
        for _ in xrange(RETRY):
            prepare(ip=ip)
            cmd = local("mv ./tempest.conf.jenkins %s/tempest.conf" % conf_dir)
            if cmd.failed:
                time.sleep(10)
            else:
                break
Example #2
0
def prepare_with_ip(private=True):
    ''' Prepare tempest with IP of Horizon: for RedHat, etc '''
    log.info("Preparing tempest configuration by downloading openrc from Horizon")
    init(private=private)
    ip = get_lab_vm_ip()
    prepare(ip=ip)
    conf_dir = os.path.join(TEMPEST_DIR, "etc")
    local("mv ./tempest.conf.jenkins %s/tempest.conf" % conf_dir)
Example #3
0
def set_branch(component="neutron", branch="master"):
    """ Set Openstack component for particular branch or commit """
    ip = get_lab_vm_ip()
    with settings(host_string=ip, abort_on_prompts=True, warn_only=True):
        stack_file = '~/devstack/stack-screenrc'
        run("screen -S stack -X quit")
        path = os.path.join("/opt", "stack", component)
        with cd(path):
            run("git fetch --all; git checkout {br}".format(br=branch))
        run("screen -c {0} -d -m && sleep 1".format(stack_file))
Example #4
0
def set_branch(component="neutron", branch="master"):
    """ Set Openstack component for particular branch or commit """
    ip = get_lab_vm_ip()
    with settings(host_string=ip, abort_on_prompts=True, warn_only=True):
        stack_file = '~/devstack/stack-screenrc'
        run("screen -S stack -X quit")
        path = os.path.join("/opt", "stack", component)
        with cd(path):
            run("git fetch --all; git checkout {br}".format(br=branch))
        run("screen -c {0} -d -m && sleep 1".format(stack_file))
Example #5
0
def prepare_coi(topology=None, copy=False, private=True):
    ''' Prepare tempest especially for COI '''
    log.info("Preparing tempest for COI")
    init(private=private)
    if copy:
        ip = get_lab_vm_ip()
        with settings(host_string=ip, user='******',
                      abort_on_prompts=True, warn_only=True):
            get("/root/openrc", "./openrc")
    prepare(openrc="./openrc")
    if topology == "2role":
        local("sed -i 's/.*[sS]wift.*\=.*[Tt]rue.*/swift=false/g' ./tempest.conf.jenkins")
    conf_dir = os.path.join(TEMPEST_DIR, "etc")
    local("mv ./tempest.conf.jenkins %s/tempest.conf" % conf_dir)
Example #6
0
def start(ip=None, user="******", password="******"):
    if not ip:
        ip = get_lab_vm_ip()
    JOB.update({"host_string": ip, "user": user, "password": password})
    with settings(**JOB):
        sudo("apt-get install -y python-coverage")
        run("screen -S stack -X quit")
        time.sleep(8)
        run("rm -rf coverage.* .coverage*")
        stack_file = '~/devstack/stack-screenrc'
        stack_cov = '~/devstack/stackcov-screenrc'
        run("cp {orig} {cov}".format(orig=stack_file, cov=stack_cov))
        sed(stack_cov, 'stuff "python', 'stuff "python-coverage run -p')
        run("screen -c {0} -d -m && sleep 1".format(stack_cov))
Example #7
0
def patchset(component="neutron", patch_set=None):
    """ Set Openstack component for particular patchset of Gerrit """
    ip = get_lab_vm_ip()
    if not patch_set:
        raise Exception("Please provide patchset as 'refs/changes/44/129144/1'")
    with settings(host_string=ip, abort_on_prompts=True, warn_only=True):
        stack_file = '~/devstack/stack-screenrc'
        run("screen -S stack -X quit")
        path = os.path.join("/opt", "stack", component)
        with cd(path):
            run("git fetch https://review.openstack.org/openstack/{project}"
                " {patchset} && git checkout FETCH_HEAD".format(
                project=component,
                patchset=patch_set))
        run("screen -c {0} -d -m && sleep 1".format(stack_file))
Example #8
0
def patchset(component="neutron", patch_set=None):
    """ Set Openstack component for particular patchset of Gerrit """
    ip = get_lab_vm_ip()
    if not patch_set:
        raise Exception(
            "Please provide patchset as 'refs/changes/44/129144/1'")
    with settings(host_string=ip, abort_on_prompts=True, warn_only=True):
        stack_file = '~/devstack/stack-screenrc'
        run("screen -S stack -X quit")
        path = os.path.join("/opt", "stack", component)
        with cd(path):
            run("git fetch https://review.openstack.org/openstack/{project}"
                " {patchset} && git checkout FETCH_HEAD".format(
                    project=component, patchset=patch_set))
        run("screen -c {0} -d -m && sleep 1".format(stack_file))
Example #9
0
def stop(ip=None, user="******", password="******"):
    if not ip:
        ip = get_lab_vm_ip()
    JOB.update({"host_string": ip, "user": user, "password": password})
    with settings(**JOB):
        # Send SIGINT to all screen windows
        run('screen -S stack -X at "#" stuff $"\\003"')
        time.sleep(15)
        run("python-coverage combine")
        run("python-coverage xml --include '/opt/stack/neutron/*'")
        #run("python-coverage xml -o coverage_ml2.xml --include '/opt/stack/neutron/neutron/plugins/ml2/*'")
        get("coverage.xml", "./coverage.xml")
    new = reformat_xml("./coverage.xml")
    local("cp ./coverage.xml ./coverage.xml.bkp")
    with open("./coverage.xml", "w") as f:
        f.write(new)
Example #10
0
def start(ip=None, user="******", password="******"):
    if not ip:
        ip = get_lab_vm_ip()
    JOB.update({
        "host_string":ip,
        "user": user,
        "password": password
        })
    with settings(**JOB):
        sudo("apt-get install -y python-coverage")
        run("screen -S stack -X quit")
        run("rm -rf coverage.* .coverage*")
        stack_file = '~/devstack/stack-screenrc'
        stack_cov = '~/devstack/stackcov-screenrc'
        run("cp {orig} {cov}".format(orig=stack_file, cov=stack_cov))
        sed(stack_cov, 'stuff "python', 'stuff "python-coverage run -p')
        run("screen -c {0} -d -m && sleep 1".format(stack_cov))
Example #11
0
def stop(ip=None, user="******", password="******"):
    if not ip:
        ip = get_lab_vm_ip()
    JOB.update({
        "host_string":ip,
        "user": user,
        "password": password
        })
    with settings(**JOB):
        # Send SIGINT to all screen windows
        run('screen -S stack -X at "#" stuff $"\\003"')
        time.sleep(15)
        run("python-coverage combine")
        run("python-coverage xml --include '/opt/stack/neutron/*'")
        #run("python-coverage xml -o coverage_ml2.xml --include '/opt/stack/neutron/neutron/plugins/ml2/*'")
        get("coverage.xml", "./coverage.xml")
    new = reformat_xml("./coverage.xml")
    local("cp ./coverage.xml ./coverage.xml.bkp")
    with open("./coverage.xml", "w") as f:
        f.write(new)
Example #12
0
def run_remote_tests():
    ''' Run Tempest tests remotely'''
    log.info("Run Tempest tests remotely")
    tempest_repo = os.environ.get("TEMPEST_REPO", "")
    tempest_br = os.environ.get("TEMPEST_BRANCH", "")
    ip = get_lab_vm_ip()
    test_regex = os.environ.get('REG', "")
    args = ""
    if os.path.getsize(TESTS_FILE) > 0:
        log.info("Run tests from file %s" % TESTS_FILE)
        args = " -l %s " % TESTS_FILE
    elif test_regex:
        log.info("Run tests with regex: '%s'" % test_regex)
        args = " -f \"%s\" " % test_regex
    else:
        log.info("Run all tests for devstack")
    local('python {wrk}/openstack-sqe/tools/run_tempest.py -r {ip} '
          '{args} --repo {repo} --branch {br} --kill_time {kill_time} --wait_time {wait_time}'
          ' --test_time {test_time}'.format(
        wrk=WORKSPACE, ip=ip, args=args,
        repo=tempest_repo, br=tempest_br,
        kill_time=QA_KILLTIME, wait_time=QA_WAITTIME, test_time=OS_TEST_TIMEOUT))