コード例 #1
0
 def test_cmd_under_dir(self):
     shell.local("mkdir -p /tmp/test")
     with shell.cd("/tmp"):
         with shell.cd("/tmp/test"):
             code, output = shell.local("pwd")
             self.assertEqual(output, '/tmp/test\n')
         code, output = shell.local("pwd")
         self.assertEqual(output, '/tmp\n')
コード例 #2
0
ファイル: tempest_utils.py プロジェクト: vmware-archive/vio
def install_tempest(repository='github.com/openstack/tempest.git',
                    branch='11.0.0',
                    nsx_repo='github.com/openstack/vmware-nsx',
                    nsx_branch='stable/mitaka',
                    protocol='http',
                    conf_template=None):
    if os.path.exists(TEMPEST_DIR):
        LOG.info('Tempest already exists, skip cloning.')
    else:
        LOG.info('Clone tempest from repository.')
        clone_url = '%s://%s' % (protocol, repository)
        shell.local('%s -b %s %s' % (GIT_CLONE, branch, clone_url),
                    raise_error=True)
    # Get vmware_nsx plugin
    if os.path.exists(VMWARE_NSX_DIR):
        LOG.info('vmware-nsx already exists, skip cloning.')
    else:
        LOG.info('Clone vmware-nsx from repository.')
        clone_url = '%s://%s' % (protocol, nsx_repo)
        shell.local('%s -b %s %s' % (GIT_CLONE, nsx_branch, clone_url),
                    raise_error=True)
    with shell.cd(TEMPEST_DIR):
        shell.local("sed -i 's/-500/-1500/g' .testr.conf")
        LOG.info('Copy template to etc/tempest.conf')
        conf_template = conf_template or os.path.join(get_data_path(),
                                                      'tempest.conf.template')
        shell.local('cp %s etc/tempest.conf' % conf_template, raise_error=True)
        LOG.info('Install tempest dependencies.')
        cmd = 'python tools/install_venv.py --no-site-packages'
        task_utils.safe_run(cmd, 'install tempest dependency')
    LOG.info('Install vmware-nsx.')
    cmd = './%s/tools/with_venv.sh pip install -e %s' % (TEMPEST_DIR,
                                                         VMWARE_NSX_DIR)
    task_utils.safe_run(cmd, 'install vmware-nsx')
    LOG.info('Tempest has been successfully installed.')
コード例 #3
0
ファイル: tempest_utils.py プロジェクト: vmware-archive/vio
def run_test(component, report_dir, parallel=False, rerun_failed=False):
    testr_opts = ''
    if parallel:
        testr_opts += '--parallel'
    if not os.path.isabs(report_dir):
        report_dir = os.path.abspath(report_dir)
    with shell.cd(TEMPEST_DIR):
        LOG.info('Start to run %s tests' % component)
        start = time.time()
        shell.local("./tools/with_venv.sh testr run %s --subunit --load-list="
                    "%s.txt | subunit2pyunit" % (testr_opts, component))
        end = time.time()
        LOG.info('%s tests took %s seconds', component, (end - start))
        make_reports(report_dir, component)
        failed_tests = shell.local('./tools/with_venv.sh testr failing '
                                   '--subunit | subunit-ls')[1]
        if failed_tests.strip():
            LOG.info('Failed tests:\n%s', failed_tests)
            if rerun_failed:
                LOG.info('Rerun above failed tests.')
                start = time.time()
                shell.local('./tools/with_venv.sh testr run --failing '
                            '--subunit | subunit2pyunit')
                end = time.time()
                LOG.info('Rerun %s failed tests took %s seconds', component,
                         (end - start))
                make_reports(report_dir, '%s_rerun' % component)
コード例 #4
0
ファイル: tempest_utils.py プロジェクト: rajeev1689/vio
def run_vmware_test(report_dir):
    if not os.path.isabs(report_dir):
        report_dir = os.path.abspath(report_dir)
    LOG.info('Start to run VMware tempest.')
    with shell.cd(VMWARE_TEMPEST_DIR):
        shell.local('source .venv/bin/activate && testr run --subunit '
                    '--load-list run-tests.txt | subunit2pyunit')
        failed_tests = shell.local('./tools/with_venv.sh testr failing '
                                   '--subunit | subunit-ls')[1]
        make_reports(report_dir, 'vmware')
        if failed_tests.strip():
            LOG.info('Failed tests:\n%s', failed_tests)
コード例 #5
0
ファイル: tempest_utils.py プロジェクト: vmware/vio
def run_vmware_test(report_dir):
    if not os.path.isabs(report_dir):
        report_dir = os.path.abspath(report_dir)
    LOG.info('Start to run VMware tempest.')
    with shell.cd(VMWARE_TEMPEST_DIR):
        shell.local('source .venv/bin/activate && testr run --subunit '
                    '--load-list run-tests.txt | subunit2pyunit')
        failed_tests = shell.local('./tools/with_venv.sh testr failing '
                                   '--subunit | subunit-ls')[1]
        make_reports(report_dir, 'vmware')
        if failed_tests.strip():
            LOG.info('Failed tests:\n%s', failed_tests)
コード例 #6
0
ファイル: tempest_utils.py プロジェクト: vmware-archive/vio
def generate_run_list(neutron_backend):
    with shell.cd(TEMPEST_DIR):
        if not os.path.exists('%s/.testrepository' % TEMPEST_DIR):
            shell.local('./tools/with_venv.sh testr init', raise_error=True)
        lines = shell.local('./tools/with_venv.sh testr list-tests',
                            raise_error=True)[1]
    # Obtain all tests into a dict {test_name: test_id}
    all_tests = dict([split_name_and_id(line) for line in lines.split('\n')
                     if line.startswith('tempest.') or
                     line.startswith('vmware_nsx_tempest.')])

    # Get excluded tests into a list [test_name]
    exclude_file = '%s/%s-excluded-tests.txt' % (get_data_path(),
                                                 neutron_backend)
    if os.path.exists(exclude_file):
        LOG.debug('Found %s, tests in it will be excluded.', exclude_file)
        excluded_tests = [strip_id(line) for line in open(exclude_file)
                          if (line.strip() != '') and
                          (not line.strip().startswith('#'))]
    else:
        excluded_tests = []
        LOG.debug('Excluded list not found, all tests will be included')
    # Get all tests minus excluded tests [test_name + test_id]
    exec_tests = [test_name + test_id for (test_name, test_id)
                  in all_tests.items() if test_name not in excluded_tests]

    # Get test case and exclude metrics
    num_all_tests = len(all_tests)
    num_excluded = len(excluded_tests)
    num_tests = len(exec_tests)

    LOG.debug('Total number of available tests: %s' % num_all_tests)
    LOG.debug('Total number of excluded tests: %s' % num_excluded)
    LOG.debug('Total number of tests to run: %s' % num_tests)

    outdated_tests = []
    if num_tests != num_all_tests - num_excluded:
        all_tests_list = all_tests.keys()
        outdated_tests = [test_name for test_name in excluded_tests
                          if test_name not in all_tests_list]
    if outdated_tests:
        LOG.debug('Below tests in exclude-tests.txt are outdated.')
        for test in outdated_tests:
            LOG.debug(test)

    write_suite_file('included-tests', exec_tests)
    test_list = [test_name + test_id for (test_name, test_id)
                 in all_tests.items()]
    write_suite_file('all-tests', test_list)
    for key in PACKAGE_MAP:
        test_list = [test for test in exec_tests
                     if test.startswith(PACKAGE_MAP[key])]
        write_suite_file(key, test_list)
コード例 #7
0
ファイル: tempest_utils.py プロジェクト: rajeev1689/vio
def install_tempest(repository='http://p3-review.eng.vmware.com/tempest',
                    branch='master',
                    conf_template=None):
    if os.path.exists(TEMPEST_DIR):
        LOG.info('Tempest already exists, skip cloning.')
    else:
        LOG.info('Clone tempest from repository.')
        shell.local('git clone -b %s %s' % (branch, repository),
                    raise_error=True)
    with shell.cd(TEMPEST_DIR):
        shell.local("sed -i 's/-500/-1500/g' .testr.conf")
        LOG.info('Copy template to etc/tempest.conf')
        conf_template = conf_template or os.path.join(get_data_path(),
                                                      'tempest.conf.template')
        shell.local('cp %s etc/tempest.conf' % conf_template, raise_error=True)
        LOG.info('Install tempest dependencies.')
        cmd = 'python tools/install_venv.py --no-site-packages'
        exit_code = shell.local(cmd)[0]
        if exit_code:
            LOG.warning('Failed to install dependencies. Retry it after 3 '
                        'minutes.')
            time.sleep(60 * 3)
            shell.local(cmd, raise_error=True)
    LOG.info('Tempest has been successfully installed.')