Beispiel #1
0
def pytest_generate_tests(metafunc):
    # Filter out providers without multiple hosts defined
    argnames, argvalues, idlist = testgen.infra_providers(metafunc, 'hosts')
    argnames = argnames + ['host_list']

    new_argvalues = []
    new_idlist = []
    for i, argvalue_tuple in enumerate(argvalues):
        args = dict(zip(argnames, argvalue_tuple))
        if not args['hosts']:
            # No host data available
            continue

        if len(args['hosts']) < 2:
            continue

        host_list = [host['name'] for host in args['hosts']]

        new_idlist.append(idlist[i])
        argvalues[i].append(host_list)
        new_argvalues.append(argvalues[i])

    testgen.parametrize(metafunc,
                        argnames,
                        new_argvalues,
                        ids=new_idlist,
                        scope="module")
Beispiel #2
0
def pytest_generate_tests(metafunc):
    # Filter out providers without provisioning data or hosts defined
    argnames, argvalues, idlist = testgen.infra_providers(
        metafunc, 'provisioning', template_location=["provisioning", "template"])

    new_idlist = []
    new_argvalues = []
    for i, argvalue_tuple in enumerate(argvalues):
        args = dict(zip(argnames, argvalue_tuple))
        if not args['provisioning']:
            # No provisioning data available
            continue

        if args['provider'].type == "scvmm":
            continue

        # required keys should be a subset of the dict keys set
        if not {'template', 'host', 'datastore'}.issubset(args['provisioning'].viewkeys()):
            # Need all three for template provisioning
            continue

        new_idlist.append(idlist[i])
        new_argvalues.append(argvalues[i])

    testgen.parametrize(metafunc, argnames, new_argvalues, ids=new_idlist, scope="module")
Beispiel #3
0
def pytest_generate_tests(metafunc):
    argnames, argvalues, idlist = testgen.infra_providers(metafunc, 'hosts')
    argnames += ['host_type', 'host_name']

    new_idlist = []
    new_argvalues = []

    for i, argvalue_tuple in enumerate(argvalues):
        args = dict(zip(argnames, argvalue_tuple))

        if not args['hosts']:
            continue
        for test_host in args['hosts']:
            if not test_host.get('test_fleece', False):
                continue

            argvs = argvalues[i][:]
            argvs.pop(argnames.index('hosts'))
            new_argvalues.append(argvs +
                                 [test_host['type'], test_host['name']])
            test_id = '{}-{}-{}'.format(args['provider'].key,
                                        test_host['type'], test_host['name'])
            new_idlist.append(test_id)
    argnames.remove('hosts')
    testgen.parametrize(metafunc,
                        argnames,
                        new_argvalues,
                        ids=new_idlist,
                        scope="module")
def pytest_generate_tests(metafunc):
    # Filter out providers without provisioning data or hosts defined
    argnames, argvalues, idlist = testgen.infra_providers(metafunc, 'provisioning')
    argnames = argnames + ['cloud_init_template']

    new_idlist = []
    new_argvalues = []
    for i, argvalue_tuple in enumerate(argvalues):
        args = dict(zip(argnames, argvalue_tuple))
        if not args['provisioning']:
            # No provisioning data available
            continue

        if args['provider'].type == "scvmm" or args['provider'].type == 'virtualcenter':
            continue

        # required keys should be a subset of the dict keys set
        if not {'ci-template', 'ci-username', 'ci-pass', 'template'}.issubset(
                args['provisioning'].viewkeys()):
            continue

        cloud_init_template = args['provisioning']['ci-template']
        if cloud_init_template not in cfme_data.get('customization_templates', {}).keys():
            continue

        argvalues[i].append(get_template_from_config(cloud_init_template))

        new_idlist.append(idlist[i])
        new_argvalues.append(argvalues[i])

    testgen.parametrize(metafunc, argnames, new_argvalues, ids=new_idlist, scope="module")
def pytest_generate_tests(metafunc):
    # Filter out providers without provisioning data or hosts defined
    argnames, argvalues, idlist = testgen.infra_providers(
        metafunc,
        required_fields=[["provisioning", "template"], ["provisioning", "host"], ["provisioning", "datastore"]],
    )
    testgen.parametrize(metafunc, argnames, argvalues, ids=idlist, scope="module")
def pytest_generate_tests(metafunc):
    # Filter out providers without provisioning data or hosts defined
    argnames, argvalues, idlist = testgen.infra_providers(metafunc)
    if not idlist:
        return
    new_idlist = []
    new_argvalues = []
    if 'random_pwr_ctl_vm' in metafunc.fixturenames:
        if random_vm_test:
            argnames, new_argvalues, new_idlist = random_vm_test
        else:
            single_index = random.choice(range(len(idlist)))
            new_idlist = ['random_provider']
            new_argvalues = argvalues[single_index]
            argnames.append('random_pwr_ctl_vm')
            new_argvalues.append('')
            new_argvalues = [new_argvalues]
            random_vm_test.append(argnames)
            random_vm_test.append(new_argvalues)
            random_vm_test.append(new_idlist)
    else:
        new_idlist = idlist
        new_argvalues = argvalues
    testgen.parametrize(metafunc,
                        argnames,
                        new_argvalues,
                        ids=new_idlist,
                        scope="module")
def pytest_generate_tests(metafunc):
    # Filter out providers without provisioning data or hosts defined
    argnames, argvalues, idlist = testgen.infra_providers(metafunc, required_fields=[
        'iso_datastore',
        ['provisioning', 'host'],
        ['provisioning', 'datastore'],
        ['provisioning', 'iso_template'],
        ['provisioning', 'iso_file'],
        ['provisioning', 'iso_kickstart'],
        ['provisioning', 'iso_root_password'],
        ['provisioning', 'iso_image_type'],
        ['provisioning', 'vlan'],
    ])
    argnames = argnames + ['iso_cust_template', 'iso_datastore']

    new_idlist = []
    new_argvalues = []
    for i, argvalue_tuple in enumerate(argvalues):
        args = dict(zip(argnames, argvalue_tuple))

        iso_cust_template = args['provider'].data['provisioning']['iso_kickstart']
        if iso_cust_template not in cfme_data.get('customization_templates', {}).keys():
            continue

        argvalues[i].append(get_template_from_config(iso_cust_template))
        argvalues[i].append(ISODatastore(args['provider'].name))
        new_idlist.append(idlist[i])
        new_argvalues.append(argvalues[i])

    testgen.parametrize(metafunc, argnames, new_argvalues, ids=new_idlist, scope="module")
def pytest_generate_tests(metafunc):
    # Filter out providers without provisioning data or hosts defined
    argnames, argvalues, idlist = testgen.infra_providers(metafunc, 'provisioning')
    argnames = argnames + ['cloud_init_template']

    new_idlist = []
    new_argvalues = []
    for i, argvalue_tuple in enumerate(argvalues):
        args = dict(zip(argnames, argvalue_tuple))
        if not args['provisioning']:
            # No provisioning data available
            continue

        if args['provider_type'] == "scvmm" or args['provider_type'] == 'virtualcenter':
            continue

        # required keys should be a subset of the dict keys set
        if not {'ci-template', 'ci-username', 'ci-pass', 'template'}.issubset(
                args['provisioning'].viewkeys()):
            continue

        cloud_init_template = args['provisioning']['ci-template']
        if cloud_init_template not in cfme_data.get('customization_templates', {}).keys():
            continue

        argvalues[i].append(get_template_from_config(cloud_init_template))

        new_idlist.append(idlist[i])
        new_argvalues.append(argvalues[i])

    testgen.parametrize(metafunc, argnames, new_argvalues, ids=new_idlist, scope="module")
def pytest_generate_tests(metafunc):
    # Filter out providers without provisioning data or hosts defined
    argnames, argvalues, idlist = testgen.infra_providers(metafunc)
    if not idlist:
        return
    new_idlist = []
    new_argvalues = []
    if 'random_pwr_ctl_vm' in metafunc.fixturenames:
        if random_vm_test:
            # Reusing random vm for test
            argnames, new_argvalues, new_idlist = random_vm_test
        else:
            # Picking random VM for tests
            single_index = random.choice(range(len(idlist)))
            new_idlist = ['random_provider']
            new_argvalues = argvalues[single_index]
            argnames.append('random_pwr_ctl_vm')
            new_argvalues.append('')
            new_argvalues = [new_argvalues]
            random_vm_test.append(argnames)
            random_vm_test.append(new_argvalues)
            random_vm_test.append(new_idlist)
    else:
        new_idlist = idlist
        new_argvalues = argvalues
    testgen.parametrize(metafunc, argnames, new_argvalues, ids=new_idlist, scope="class")
Beispiel #10
0
def pytest_generate_tests(metafunc):
    # Filter out providers without provisioning data or hosts defined
    argnames, argvalues, idlist = testgen.infra_providers(metafunc, 'provider_key')
    for i, argvalue_tuple in enumerate(argvalues):
        provider_data = cfme_data['management_systems'][
            argvalue_tuple[argnames.index('provider_key')]]
        if provider_data.get('type', False) != 'virtualcenter':
            continue

    if 'random_snpsht_mgt_vm' in metafunc.fixturenames:
        if random_vm_test:
            argnames, new_argvalues, new_idlist = random_vm_test
        else:
            single_index = random.choice(range(len(idlist)))
            new_idlist = [idlist[single_index]]
            new_argvalues = argvalues[single_index]
            argnames.append('random_snpsht_mgt_vm')
            new_argvalues.append('')
            new_argvalues = [new_argvalues]
            random_vm_test.append(argnames)
            random_vm_test.append(new_argvalues)
            random_vm_test.append(new_idlist)
    else:
        new_idlist = idlist
        new_argvalues = argvalues
    testgen.parametrize(metafunc, argnames, new_argvalues, ids=new_idlist, scope="module")
def pytest_generate_tests(metafunc):
    argnames, argvalues, idlist = testgen.infra_providers(metafunc)
    argnames = argnames + ['host_type', 'host_name']
    new_argvalues = []
    new_idlist = []

    for i, argvalue_tuple in enumerate(argvalues):
        args = dict(zip(argnames, argvalue_tuple))

        prov_hosts = args['provider'].data['hosts']

        if not prov_hosts:
            continue
        for test_host in prov_hosts:
            if not test_host.get('test_fleece', False):
                continue
            assert test_host.get('type', None) in HOST_TYPES,\
                'host type must be set to [{}] for smartstate analysis tests'\
                .format('|'.join(HOST_TYPES))

            argvalues[i] = argvalues[i] + [test_host['type'], test_host['name']]
            test_id = '{}-{}-{}'.format(args['provider'].key, test_host['type'], test_host['name'])
            idlist.append(test_id)
            new_argvalues.append(argvalues[i])
            new_idlist.append(test_id)
    metafunc.parametrize(argnames, new_argvalues, ids=new_idlist, scope="module")
Beispiel #12
0
def pytest_generate_tests(metafunc):
    # Filter out providers without provisioning data or hosts defined
    argnames, argvalues, idlist = testgen.infra_providers(metafunc, required_fields=[
        ('iso_datastore', True),
        ['provisioning', 'host'],
        ['provisioning', 'datastore'],
        ['provisioning', 'iso_template'],
        ['provisioning', 'iso_file'],
        ['provisioning', 'iso_kickstart'],
        ['provisioning', 'iso_root_password'],
        ['provisioning', 'iso_image_type'],
        ['provisioning', 'vlan'],
    ])
    argnames = argnames + ['iso_cust_template', 'iso_datastore']

    new_idlist = []
    new_argvalues = []
    for i, argvalue_tuple in enumerate(argvalues):
        args = dict(zip(argnames, argvalue_tuple))
        if args['provider'].type == "scvmm":
            continue

        iso_cust_template = args['provider'].data['provisioning']['iso_kickstart']
        if iso_cust_template not in cfme_data.get('customization_templates', {}).keys():
            continue

        argvalues[i].append(get_template_from_config(iso_cust_template))
        argvalues[i].append(ISODatastore(args['provider'].name))
        new_idlist.append(idlist[i])
        new_argvalues.append(argvalues[i])

    testgen.parametrize(metafunc, argnames, new_argvalues, ids=new_idlist, scope="module")
def pytest_generate_tests(metafunc):
    argnames, argvalues, idlist = testgen.infra_providers(metafunc)
    testgen.parametrize(metafunc,
                        argnames,
                        argvalues,
                        ids=idlist,
                        scope="module")
def pytest_generate_tests(metafunc):
    argnames, argvalues, idlist = testgen.infra_providers(metafunc)
    argnames = argnames + ['host_type', 'host_name']
    new_argvalues = []
    new_idlist = []

    for i, argvalue_tuple in enumerate(argvalues):
        args = dict(zip(argnames, argvalue_tuple))

        prov_hosts = args['provider'].data['hosts']

        if not prov_hosts:
            continue
        for test_host in prov_hosts:
            if not test_host.get('test_fleece', False):
                continue
            assert test_host.get('type', None) in HOST_TYPES,\
                'host type must be set to [{}] for smartstate analysis tests'\
                .format('|'.join(HOST_TYPES))

            argvalues[i] = argvalues[i] + [
                test_host['type'], test_host['name']
            ]
            test_id = '{}-{}-{}'.format(args['provider'].key,
                                        test_host['type'], test_host['name'])
            idlist.append(test_id)
            new_argvalues.append(argvalues[i])
            new_idlist.append(test_id)
    metafunc.parametrize(argnames,
                         new_argvalues,
                         ids=new_idlist,
                         scope="module")
Beispiel #15
0
def pytest_generate_tests(metafunc):
    argnames, argvalues, idlist = testgen.infra_providers(
        metafunc, required_fields=["vm_analysis"])
    testgen.parametrize(metafunc,
                        argnames,
                        argvalues,
                        ids=idlist,
                        scope="module")
def pytest_generate_tests(metafunc):
    # Filter out providers without provisioning data or hosts defined
    argnames, argvalues, idlist = testgen.infra_providers(metafunc,
        required_fields=[
            ['provisioning', 'template'],
            ['provisioning', 'host'],
            ['provisioning', 'datastore']
        ])
    testgen.parametrize(metafunc, argnames, argvalues, ids=idlist, scope="module")
def pytest_generate_tests(metafunc):
    # Filter out providers without provisioning data or hosts defined
    argnames, argvalues, idlist = testgen.infra_providers(
        metafunc, required_fields=['iso_datastore'])
    testgen.parametrize(metafunc,
                        argnames,
                        argvalues,
                        ids=idlist,
                        scope="module")
def pytest_generate_tests(metafunc):
    # cfme.rest.services requires several provisioning tags
    argnames, argvalues, idlist = testgen.infra_providers(
        metafunc,
        required_fields=[['provisioning', 'template'],
                         ['provisioning', 'host'],
                         ['provisioning', 'datastore'],
                         ['provisioning', 'iso_file'],
                         ['provisioning', 'vlan'],
                         ['provisioning', 'catalog_item_type']])
    testgen.parametrize(metafunc, argnames, argvalues, ids=idlist, scope='module')
Beispiel #19
0
def pytest_generate_tests(metafunc):
    # Filter out providers without host provisioning data defined
    argnames, argvalues, idlist = testgen.infra_providers(
        metafunc, 'host_provisioning')
    pargnames, pargvalues, pidlist = testgen.pxe_servers(metafunc)
    argnames = argnames + ['pxe_server', 'pxe_cust_template']
    pxe_server_names = [pval[0] for pval in pargvalues]

    new_idlist = []
    new_argvalues = []
    for i, argvalue_tuple in enumerate(argvalues):
        args = dict(zip(argnames, argvalue_tuple))
        try:
            prov_data = args['host_provisioning']
        except KeyError:
            # No host provisioning data available
            continue

        stream = prov_data.get('runs_on_stream', '')
        if not version.current_version().is_in_series(str(stream)):
            continue

        # required keys should be a subset of the dict keys set
        if not {
                'pxe_server', 'pxe_image', 'pxe_image_type', 'pxe_kickstart',
                'datacenter', 'cluster', 'datastores', 'hostname',
                'root_password', 'ip_addr', 'subnet_mask', 'gateway', 'dns'
        }.issubset(prov_data.viewkeys()):
            # Need all  for host provisioning
            continue

        pxe_server_name = prov_data.get('pxe_server', '')
        if pxe_server_name not in pxe_server_names:
            continue

        pxe_cust_template = prov_data.get('pxe_kickstart', '')
        if pxe_cust_template not in cfme_data.get('customization_templates',
                                                  {}).keys():
            continue

        argvalues[i].append(get_pxe_server_from_config(pxe_server_name))
        argvalues[i].append(get_template_from_config(pxe_cust_template))
        new_idlist.append(idlist[i])
        new_argvalues.append(argvalues[i])

    testgen.parametrize(metafunc,
                        argnames,
                        new_argvalues,
                        ids=new_idlist,
                        scope="module")
Beispiel #20
0
def pytest_generate_tests(metafunc):
    argnames, argvalues, idlist = testgen.infra_providers(metafunc)
    new_idlist = []
    new_argvalues = []
    for i, argvalue_tuple in enumerate(argvalues):
        args = dict(zip(argnames, argvalue_tuple))

        if args["provider"].type in {"scvmm"}:
            continue

        new_idlist.append(idlist[i])
        new_argvalues.append(argvalues[i])

    testgen.parametrize(metafunc, argnames, new_argvalues, ids=new_idlist, scope="module")
def pytest_generate_tests(metafunc):
    # Filter out providers without host provisioning data defined
    argnames, argvalues, idlist = testgen.infra_providers(metafunc, required_fields=[
        ['host_provisioning', 'pxe_server'],
        ['host_provisioning', 'pxe_image'],
        ['host_provisioning', 'pxe_image_type'],
        ['host_provisioning', 'pxe_kickstart'],
        ['host_provisioning', 'datacenter'],
        ['host_provisioning', 'cluster'],
        ['host_provisioning', 'datastores'],
        ['host_provisioning', 'hostname'],
        ['host_provisioning', 'root_password'],
        ['host_provisioning', 'ip_addr'],
        ['host_provisioning', 'subnet_mask'],
        ['host_provisioning', 'gateway'],
        ['host_provisioning', 'dns'],
    ])
    pargnames, pargvalues, pidlist = testgen.pxe_servers(metafunc)
    argnames = argnames + ['pxe_server', 'pxe_cust_template']
    pxe_server_names = [pval[0] for pval in pargvalues]

    new_idlist = []
    new_argvalues = []
    for i, argvalue_tuple in enumerate(argvalues):
        args = dict(zip(argnames, argvalue_tuple))
        try:
            prov_data = args['provider'].data['host_provisioning']
        except KeyError:
            # No host provisioning data available
            continue

        stream = prov_data.get('runs_on_stream', '')
        if not version.current_version().is_in_series(str(stream)):
            continue

        pxe_server_name = prov_data.get('pxe_server', '')
        if pxe_server_name not in pxe_server_names:
            continue

        pxe_cust_template = prov_data.get('pxe_kickstart', '')
        if pxe_cust_template not in cfme_data.get('customization_templates', {}).keys():
            continue

        argvalues[i].append(get_pxe_server_from_config(pxe_server_name))
        argvalues[i].append(get_template_from_config(pxe_cust_template))
        new_idlist.append(idlist[i])
        new_argvalues.append(argvalues[i])

    testgen.parametrize(metafunc, argnames, new_argvalues, ids=new_idlist, scope="module")
def pytest_generate_tests(metafunc):
    # Filter out providers without provisioning data or hosts defined
    argnames, argvalues, idlist = testgen.infra_providers(metafunc, "iso_datastore")

    new_idlist = []
    new_argvalues = []
    for i, argvalue_tuple in enumerate(argvalues):
        args = dict(zip(argnames, argvalue_tuple))
        if not args["iso_datastore"]:
            # No provisioning data available
            continue

        new_idlist.append(idlist[i])
        new_argvalues.append(argvalues[i])

    testgen.parametrize(metafunc, argnames, new_argvalues, ids=new_idlist, scope="module")
Beispiel #23
0
def pytest_generate_tests(metafunc):
    # Filter out providers without multiple hosts defined
    argnames, argvalues, idlist = testgen.infra_providers(metafunc, required_fields=["hosts"])

    new_argvalues = []
    new_idlist = []
    for i, argvalue_tuple in enumerate(argvalues):
        args = dict(zip(argnames, argvalue_tuple))
        hosts = args['provider'].data.get('hosts', {})

        if len(hosts) < 2:
            continue

        new_idlist.append(idlist[i])
        new_argvalues.append(argvalues[i])

    testgen.parametrize(metafunc, argnames, new_argvalues, ids=new_idlist, scope="module")
def pytest_generate_tests(metafunc):
    # Filter out providers without provisioning data or hosts defined
    argnames, argvalues, idlist = testgen.infra_providers(
        metafunc, 'provisioning')
    argnames = argnames + ['iso_cust_template', 'iso_datastore']

    new_idlist = []
    new_argvalues = []
    for i, argvalue_tuple in enumerate(argvalues):
        args = dict(zip(argnames, argvalue_tuple))
        if not args['provisioning']:
            # No provisioning data available
            continue

        if args['provider'].type == "scvmm":
            continue

        provider_data = cfme_data.get(
            'management_systems',
            {})[argvalue_tuple[argnames.index('provider')].key]
        if not provider_data.get('iso_datastore', False):
            continue

        # required keys should be a subset of the dict keys set
        if not {
                'iso_template', 'host', 'datastore', 'iso_file',
                'iso_kickstart', 'iso_root_password', 'iso_image_type', 'vlan'
        }.issubset(args['provisioning'].viewkeys()):
            # Need all  for template provisioning
            continue

        iso_cust_template = args['provisioning']['iso_kickstart']
        if iso_cust_template not in cfme_data.get('customization_templates',
                                                  {}).keys():
            continue

        argvalues[i].append(get_template_from_config(iso_cust_template))
        argvalues[i].append(ISODatastore(provider_data['name']))
        new_idlist.append(idlist[i])
        new_argvalues.append(argvalues[i])

    testgen.parametrize(metafunc,
                        argnames,
                        new_argvalues,
                        ids=new_idlist,
                        scope="module")
Beispiel #25
0
def pytest_generate_tests(metafunc):
    # Filter out providers without multiple hosts defined
    argnames, argvalues, idlist = testgen.infra_providers(metafunc, required_fields=["hosts"])

    new_argvalues = []
    new_idlist = []
    for i, argvalue_tuple in enumerate(argvalues):
        args = dict(zip(argnames, argvalue_tuple))
        hosts = args['provider'].data.get('hosts', {})

        if len(hosts) < 2:
            continue

        new_idlist.append(idlist[i])
        new_argvalues.append(argvalues[i])

    testgen.parametrize(metafunc, argnames, new_argvalues, ids=new_idlist, scope="module")
def pytest_generate_tests(metafunc):
    # Filter out providers without provisioning data or hosts defined
    argnames, argvalues, idlist = testgen.infra_providers(
        metafunc, 'provisioning')
    pargnames, pargvalues, pidlist = testgen.pxe_servers(metafunc)
    argnames = argnames + ['pxe_server', 'pxe_cust_template']
    pxe_server_names = [pval[0] for pval in pargvalues]

    new_idlist = []
    new_argvalues = []
    for i, argvalue_tuple in enumerate(argvalues):
        args = dict(zip(argnames, argvalue_tuple))
        if not args['provisioning']:
            # No provisioning data available
            continue

        if args['provider'].type == "scvmm":
            continue

        # required keys should be a subset of the dict keys set
        if not {
                'pxe_template', 'host', 'datastore', 'pxe_server', 'pxe_image',
                'pxe_kickstart', 'pxe_root_password', 'pxe_image_type', 'vlan'
        }.issubset(args['provisioning'].viewkeys()):
            # Need all  for template provisioning
            continue

        pxe_server_name = args['provisioning']['pxe_server']
        if pxe_server_name not in pxe_server_names:
            continue

        pxe_cust_template = args['provisioning']['pxe_kickstart']
        if pxe_cust_template not in cfme_data.get('customization_templates',
                                                  {}).keys():
            continue

        argvalues[i].append(get_pxe_server_from_config(pxe_server_name))
        argvalues[i].append(get_template_from_config(pxe_cust_template))
        new_idlist.append(idlist[i])
        new_argvalues.append(argvalues[i])

    testgen.parametrize(metafunc,
                        argnames,
                        new_argvalues,
                        ids=new_idlist,
                        scope="module")
Beispiel #27
0
def pytest_generate_tests(metafunc):
    # Filter out providers without provisioning data or hosts defined
    global test_list

    new_idlist = []
    new_argvalues = []

    argnames, argvalues, idlist = testgen.infra_providers(metafunc,
                                                          'vm_analysis',
                                                          require_fields=True)
    argnames = argnames + ['vm_template_name', 'os', 'fs_type']

    if 'by_vm_state' in metafunc.function.meta.args:
        for i, argvalue_tuple in enumerate(argvalues):
            args = dict(zip(argnames, argvalue_tuple))
            idx = random.choice(range(len(args['vm_analysis'])))
            vm_template_name = args['vm_analysis'].keys()[idx]
            os = args['vm_analysis'][vm_template_name]['os']
            fs_type = args['vm_analysis'][vm_template_name]['fs_type']
            new_idlist = idlist
            argvs = argvalues[i][:]
            argvs.pop(argnames.index('vm_analysis'))
            new_argvalues.append(argvs + [vm_template_name, os, fs_type])
            test_list.append(
                [args['provider'].key, vm_template_name, os, fs_type])
    elif 'by_fs_type' in metafunc.function.meta.args:
        for i, argvalue_tuple in enumerate(argvalues):
            args = dict(zip(argnames, argvalue_tuple))

            for vm_template_name in args['vm_analysis'].keys():
                os = args['vm_analysis'][vm_template_name]['os']
                fs_type = args['vm_analysis'][vm_template_name]['fs_type']
                argvs = argvalues[i][:]
                argvs.pop(argnames.index('vm_analysis'))
                new_argvalues.append(argvs + [vm_template_name, os, fs_type])
                new_idlist.append(args['provider'].key + "-" + fs_type)
                test_list.append(
                    [args['provider'].key, vm_template_name, os, fs_type])

    argnames.remove('vm_analysis')
    testgen.parametrize(metafunc,
                        argnames,
                        new_argvalues,
                        ids=new_idlist,
                        scope="class")
Beispiel #28
0
def pytest_generate_tests(metafunc):
    argnames, argvalues, idlist = testgen.infra_providers(metafunc)
    new_idlist = []
    new_argvalues = []
    for i, argvalue_tuple in enumerate(argvalues):
        args = dict(zip(argnames, argvalue_tuple))

        if args["provider"].type in {"scvmm"}:
            continue

        new_idlist.append(idlist[i])
        new_argvalues.append(argvalues[i])

    testgen.parametrize(metafunc,
                        argnames,
                        new_argvalues,
                        ids=new_idlist,
                        scope="module")
def pytest_generate_tests(metafunc):
    p_argn, p_argv, p_ids = testgen.infra_providers(metafunc, "hosts")
    argnames = ["provider_key", "host_type", "host_name"]
    argvalues = []
    idlist = []
    for argv in p_argv:
        prov_hosts, prov_key = argv[0], argv[1]
        if not prov_hosts:
            continue
        for test_host in prov_hosts:
            if not test_host.get("test_fleece", False):
                continue

            argvalues.append([prov_key, test_host["type"], test_host["name"]])
            test_id = "{}-{}-{}".format(prov_key, test_host["type"], test_host["name"])
            idlist.append(test_id)

    testgen.parametrize(metafunc, argnames, argvalues, ids=idlist, scope="module")
def pytest_generate_tests(metafunc):
    # Filter out providers without provisioning data or hosts defined
    argnames, argvalues, idlist = testgen.infra_providers(metafunc, "provisioning")
    argnames = argnames + ["iso_cust_template", "iso_datastore"]

    new_idlist = []
    new_argvalues = []
    for i, argvalue_tuple in enumerate(argvalues):
        args = dict(zip(argnames, argvalue_tuple))
        if not args["provisioning"]:
            # No provisioning data available
            continue

        if args["provider_type"] == "scvmm":
            continue

        provider_data = cfme_data.get("management_systems", {})[argvalue_tuple[argnames.index("provider_key")]]
        if not provider_data.get("iso_datastore", False):
            continue

        # required keys should be a subset of the dict keys set
        if not {
            "iso_template",
            "host",
            "datastore",
            "iso_file",
            "iso_kickstart",
            "iso_root_password",
            "iso_image_type",
            "vlan",
        }.issubset(args["provisioning"].viewkeys()):
            # Need all  for template provisioning
            continue

        iso_cust_template = args["provisioning"]["iso_kickstart"]
        if iso_cust_template not in cfme_data.get("customization_templates", {}).keys():
            continue

        argvalues[i].append(get_template_from_config(iso_cust_template))
        argvalues[i].append(ISODatastore(provider_data["name"]))
        new_idlist.append(idlist[i])
        new_argvalues.append(argvalues[i])

    testgen.parametrize(metafunc, argnames, new_argvalues, ids=new_idlist, scope="module")
def pytest_generate_tests(metafunc):
    # Filter out providers without provisioning data or hosts defined
    argnames, argvalues, idlist = testgen.infra_providers(metafunc)

    argnames.append('remove_test')
    new_idlist = []
    new_argvalues = []

    for i, argvalue_tuple in enumerate(argvalues):
        args = dict(zip(argnames, argvalue_tuple))
        if 'remove_test' not in args['provider'].data:
            # No provisioning data available
            continue

        new_idlist.append(idlist[i])
        argvalues[i].append(args['provider'].data['remove_test'])
        new_argvalues.append(argvalues[i])

    testgen.parametrize(metafunc, argnames, new_argvalues, ids=new_idlist, scope="module")
def pytest_generate_tests(metafunc):
    # Filter out providers without provisioning data or hosts defined
    argnames, argvalues, idlist = testgen.infra_providers(metafunc)

    argnames.append('remove_test')
    new_idlist = []
    new_argvalues = []

    for i, argvalue_tuple in enumerate(argvalues):
        args = dict(zip(argnames, argvalue_tuple))
        if 'remove_test' not in args['provider_crud'].get_yaml_data():
            # No provisioning data available
            continue

        new_idlist.append(idlist[i])
        argvalues[i].append(args['provider_crud'].get_yaml_data()['remove_test'])
        new_argvalues.append(argvalues[i])

    testgen.parametrize(metafunc, argnames, new_argvalues, ids=new_idlist, scope="module")
def pytest_generate_tests(metafunc):
    argnames, argvalues, idlist = testgen.infra_providers(metafunc, required_fields=['hosts'])
    argnames += ['host']

    new_idlist = []
    new_argvalues = []

    for i, argvalue_tuple in enumerate(argvalues):
        args = dict(zip(argnames, argvalue_tuple))

        for test_host in args['provider'].data['hosts']:
            if not test_host.get('test_fleece', False):
                continue

            argvs = argvalues[i][:]
            new_argvalues.append(argvs + [test_host])
            test_id = '{}-{}'.format(args['provider'].key, test_host['type'])
            new_idlist.append(test_id)
    testgen.parametrize(metafunc, argnames, new_argvalues, ids=new_idlist, scope="module")
Beispiel #34
0
def pytest_generate_tests(metafunc):
    # Filter out providers without provisioning data or hosts defined
    argnames, argvalues, idlist = testgen.infra_providers(metafunc,
        'small_template', scope="module", template_location=["small_template"])

    new_idlist = []
    new_argvalues = []
    for i, argvalue_tuple in enumerate(argvalues):
        args = dict(zip(argnames, argvalue_tuple))

        if ((metafunc.function is test_action_create_snapshot_and_delete_last)
            or
            (metafunc.function is test_action_create_snapshots_and_delete_them)) \
                and isinstance(args['provider_crud'], RHEVMProvider):
            continue

        new_idlist.append(idlist[i])
        new_argvalues.append(argvalues[i])

    testgen.parametrize(metafunc, argnames, new_argvalues, ids=new_idlist, scope="module")
def pytest_generate_tests(metafunc):
    p_argn, p_argv, p_ids = testgen.infra_providers(metafunc, "hosts", "version")
    argnames = ["provider_key", "provider_type", "provider_ver", "host_type", "host_name"]
    argvalues = []
    idlist = []
    for argv in p_argv:
        prov_hosts, prov_ver, prov_key, prov_type = argv[:4]
        if not prov_hosts:
            continue
        for test_host in prov_hosts:
            if not test_host.get("test_fleece", False):
                continue
            assert (
                test_host.get("type", None) in HOST_TYPES
            ), "host type must be set to [{}] for smartstate analysis tests".format("|".join(HOST_TYPES))

            argvalues.append([prov_key, prov_type, str(prov_ver), test_host["type"], test_host["name"]])
            test_id = "{}-{}-{}".format(prov_key, test_host["type"], test_host["name"])
            idlist.append(test_id)

    metafunc.parametrize(argnames, argvalues, ids=idlist, scope="module")
def pytest_generate_tests(metafunc):
    p_argn, p_argv, p_ids = testgen.infra_providers(metafunc, 'hosts')
    argnames = ['provider_key', 'host_type', 'host_name']
    argvalues = []
    idlist = []
    for argv in p_argv:
        prov_hosts, prov_key = argv[0], argv[1]
        if not prov_hosts:
            continue
        for test_host in prov_hosts:
            if not test_host.get('test_fleece', False):
                continue
            assert test_host.get('type', None) in HOST_TYPES,\
                'host type must be set to [{}] for smartstate analysis tests'\
                .format('|'.join(HOST_TYPES))

            argvalues.append([prov_key, test_host['type'], test_host['name']])
            test_id = '{}-{}-{}'.format(prov_key, test_host['type'], test_host['name'])
            idlist.append(test_id)

    metafunc.parametrize(argnames, argvalues, ids=idlist, scope="module")
def pytest_generate_tests(metafunc):
    # Filter out providers without provisioning data or hosts defined
    argnames, argvalues, idlist = testgen.infra_providers(metafunc, 'provisioning')
    pargnames, pargvalues, pidlist = testgen.pxe_servers(metafunc)
    argnames = argnames + ['pxe_server', 'pxe_cust_template']
    pxe_server_names = [pval[0] for pval in pargvalues]

    new_idlist = []
    new_argvalues = []
    for i, argvalue_tuple in enumerate(argvalues):
        args = dict(zip(argnames, argvalue_tuple))
        if not args['provisioning']:
            # No provisioning data available
            continue

        if args['provider'].type == "scvmm":
            continue

        # required keys should be a subset of the dict keys set
        if not {'pxe_template', 'host', 'datastore',
                'pxe_server', 'pxe_image', 'pxe_kickstart',
                'pxe_root_password',
                'pxe_image_type', 'vlan'}.issubset(args['provisioning'].viewkeys()):
            # Need all  for template provisioning
            continue

        pxe_server_name = args['provisioning']['pxe_server']
        if pxe_server_name not in pxe_server_names:
            continue

        pxe_cust_template = args['provisioning']['pxe_kickstart']
        if pxe_cust_template not in cfme_data.get('customization_templates', {}).keys():
            continue

        argvalues[i].append(get_pxe_server_from_config(pxe_server_name))
        argvalues[i].append(get_template_from_config(pxe_cust_template))
        new_idlist.append(idlist[i])
        new_argvalues.append(argvalues[i])

    testgen.parametrize(metafunc, argnames, new_argvalues, ids=new_idlist, scope="module")
def pytest_generate_tests(metafunc):
    # Filter out providers without provisioning data or hosts defined
    argnames, argvalues, idlist = testgen.infra_providers(metafunc, 'provisioning')
    argnames = argnames + ['iso_cust_template', 'iso_datastore']

    new_idlist = []
    new_argvalues = []
    for i, argvalue_tuple in enumerate(argvalues):
        args = dict(zip(argnames, argvalue_tuple))
        if not args['provisioning']:
            # No provisioning data available
            continue

        if args['provider_type'] == "scvmm":
            continue

        provider_data = cfme_data.get('management_systems', {})[
            argvalue_tuple[argnames.index('provider_key')]]
        if not provider_data.get('iso_datastore', False):
            continue

        # required keys should be a subset of the dict keys set
        if not {'iso_template', 'host', 'datastore',
                'iso_file', 'iso_kickstart',
                'iso_root_password',
                'iso_image_type', 'vlan'}.issubset(args['provisioning'].viewkeys()):
            # Need all  for template provisioning
            continue

        iso_cust_template = args['provisioning']['iso_kickstart']
        if iso_cust_template not in cfme_data.get('customization_templates', {}).keys():
            continue

        argvalues[i].append(get_template_from_config(iso_cust_template))
        argvalues[i].append(ISODatastore(provider_data['name']))
        new_idlist.append(idlist[i])
        new_argvalues.append(argvalues[i])

    testgen.parametrize(metafunc, argnames, new_argvalues, ids=new_idlist, scope="module")
Beispiel #39
0
def pytest_generate_tests(metafunc):
    p_argn, p_argv, p_ids = testgen.infra_providers(metafunc, 'hosts')
    argnames = ['provider_key', 'host_type', 'host_name']
    argvalues = []
    idlist = []
    for argv in p_argv:
        prov_hosts, prov_key = argv[0], argv[1]
        if not prov_hosts:
            continue
        for test_host in prov_hosts:
            if not test_host.get('test_fleece', False):
                continue
            assert test_host.get('type', None) in HOST_TYPES,\
                'host type must be set to [{}] for smartstate analysis tests'\
                .format('|'.join(HOST_TYPES))

            argvalues.append([prov_key, test_host['type'], test_host['name']])
            test_id = '{}-{}-{}'.format(prov_key, test_host['type'],
                                        test_host['name'])
            idlist.append(test_id)

    metafunc.parametrize(argnames, argvalues, ids=idlist, scope="module")
def pytest_generate_tests(metafunc):
    # Filter out providers without provisioning data or hosts defined
    global test_list

    new_idlist = []
    new_argvalues = []

    argnames, argvalues, idlist = testgen.infra_providers(
        metafunc, 'vm_analysis', require_fields=True)
    argnames = argnames + ['vm_template_name', 'os', 'fs_type']

    if 'by_vm_state' in metafunc.function.meta.args:
        for i, argvalue_tuple in enumerate(argvalues):
            args = dict(zip(argnames, argvalue_tuple))
            idx = random.choice(range(len(args['vm_analysis'])))
            vm_template_name = args['vm_analysis'].keys()[idx]
            os = args['vm_analysis'][vm_template_name]['os']
            fs_type = args['vm_analysis'][vm_template_name]['fs_type']
            new_idlist = idlist
            argvs = argvalues[i][:]
            argvs.pop(argnames.index('vm_analysis'))
            new_argvalues.append(argvs + [vm_template_name, os, fs_type])
            test_list.append([args['provider'].key, vm_template_name, os, fs_type])
    elif 'by_fs_type' in metafunc.function.meta.args:
        for i, argvalue_tuple in enumerate(argvalues):
            args = dict(zip(argnames, argvalue_tuple))

            for vm_template_name in args['vm_analysis'].keys():
                os = args['vm_analysis'][vm_template_name]['os']
                fs_type = args['vm_analysis'][vm_template_name]['fs_type']
                argvs = argvalues[i][:]
                argvs.pop(argnames.index('vm_analysis'))
                new_argvalues.append(argvs + [vm_template_name, os, fs_type])
                new_idlist.append(args['provider'].key + "-" + fs_type)
                test_list.append([args['provider'].key, vm_template_name, os, fs_type])

    argnames.remove('vm_analysis')
    testgen.parametrize(metafunc, argnames, new_argvalues, ids=new_idlist, scope="class")
def pytest_generate_tests(metafunc):
    argnames, argvalues, idlist = testgen.infra_providers(metafunc, 'hosts')
    argnames += ['host_type', 'host_name']

    new_idlist = []
    new_argvalues = []

    for i, argvalue_tuple in enumerate(argvalues):
        args = dict(zip(argnames, argvalue_tuple))

        if not args['hosts']:
            continue
        for test_host in args['hosts']:
            if not test_host.get('test_fleece', False):
                continue

            argvs = argvalues[i][:]
            argvs.pop(argnames.index('hosts'))
            new_argvalues.append(argvs + [test_host['type'], test_host['name']])
            test_id = '{}-{}-{}'.format(args['provider'].key, test_host['type'], test_host['name'])
            new_idlist.append(test_id)
    argnames.remove('hosts')
    testgen.parametrize(metafunc, argnames, new_argvalues, ids=new_idlist, scope="module")
Beispiel #42
0
def pytest_generate_tests(metafunc):
    # Filter out providers without multiple hosts defined
    argnames, argvalues, idlist = testgen.infra_providers(metafunc, 'hosts')
    argnames = argnames + ['host_list']

    new_argvalues = []
    new_idlist = []
    for i, argvalue_tuple in enumerate(argvalues):
        args = dict(zip(argnames, argvalue_tuple))
        if not args['hosts']:
            # No host data available
            continue

        if len(args['hosts']) < 2:
            continue

        host_list = [host['name'] for host in args['hosts']]

        new_idlist.append(idlist[i])
        argvalues[i].append(host_list)
        new_argvalues.append(argvalues[i])

    testgen.parametrize(metafunc, argnames, new_argvalues, ids=new_idlist, scope="module")
def pytest_generate_tests(metafunc):
    # Filter out providers without provisioning data or hosts defined
    argnames, argvalues, idlist = testgen.infra_providers(metafunc)
    if not idlist:
        return
    new_idlist = []
    new_argvalues = []
    if "random_pwr_ctl_vm" in metafunc.fixturenames:
        if random_vm_test:
            argnames, new_argvalues, new_idlist = random_vm_test
        else:
            single_index = random.choice(range(len(idlist)))
            new_idlist = ["random_provider"]
            new_argvalues = argvalues[single_index]
            argnames.append("random_pwr_ctl_vm")
            new_argvalues.append("")
            new_argvalues = [new_argvalues]
            random_vm_test.append(argnames)
            random_vm_test.append(new_argvalues)
            random_vm_test.append(new_idlist)
    else:
        new_idlist = idlist
        new_argvalues = argvalues
    testgen.parametrize(metafunc, argnames, new_argvalues, ids=new_idlist, scope="module")
Beispiel #44
0
def pytest_generate_tests(metafunc):
    argnames, argvalues, idlist = testgen.infra_providers(
        metafunc, required_fields=['hosts'])
    argnames += ['host']

    new_idlist = []
    new_argvalues = []

    for i, argvalue_tuple in enumerate(argvalues):
        args = dict(zip(argnames, argvalue_tuple))

        for test_host in args['provider'].data['hosts']:
            if not test_host.get('test_fleece', False):
                continue

            argvs = argvalues[i][:]
            new_argvalues.append(argvs + [test_host])
            test_id = '{}-{}'.format(args['provider'].key, test_host['type'])
            new_idlist.append(test_id)
    testgen.parametrize(metafunc,
                        argnames,
                        new_argvalues,
                        ids=new_idlist,
                        scope="module")
def pytest_generate_tests(metafunc):
    # Filter out providers without provisioning data or hosts defined
    argnames, argvalues, idlist = testgen.infra_providers(metafunc)
    if not idlist:
        return
    testgen.parametrize(metafunc, argnames, argvalues, ids=idlist, scope="class")
Beispiel #46
0
def pytest_generate_tests(metafunc):
    argnames, argvalues, idlist = testgen.infra_providers(metafunc)
    testgen.parametrize(metafunc, argnames, argvalues, ids=idlist, scope="module")
Beispiel #47
0
def pytest_generate_tests(metafunc):
    # Filter out providers without provisioning data or hosts defined
    global test_list
    global by_state_tests

    new_idlist = []
    new_argvalues = []
    if 'by_vm_state' in metafunc.fixturenames:
        argnames, argvalues, idlist = testgen.infra_providers(
            metafunc, 'vm_analysis', require_fields=True)

        for i, provider in enumerate(idlist):
            if provider not in by_state_tests:
                single_index = random.choice(range(len(argvalues[i][0])))
                vm_template_name = argvalues[i][0].keys()[single_index]
                os = argvalues[i][0][argvalues[i][0].keys()[single_index]]['os']
                fs_type = argvalues[i][0][argvalues[i][0].keys()[single_index]]['fs_type']
                provider_crud = argvalues[i][1]
                provider_mgmt = argvalues[i][2]
                argnames = ['by_vm_state', 'provider_crud', 'provider_mgmt',
                            'vm_template_name', 'os', 'fs_type']
                new_argvalues.append(
                    ['', provider_crud, provider_mgmt, vm_template_name, os, fs_type])
                new_idlist = idlist
                by_state_tests[provider] = [argnames, new_argvalues, new_idlist,
                                            provider_crud, vm_template_name, os, fs_type]
                test_list.append([provider_crud.key, vm_template_name, os, fs_type])
            else:
                argnames = by_state_tests[provider][0]
                new_argvalues = by_state_tests[provider][1]
                new_idlist = by_state_tests[provider][2]
                provider_crud = by_state_tests[provider][3]
                vm_template_name = by_state_tests[provider][4]
                os = by_state_tests[provider][5]
                fs_type = by_state_tests[provider][6]

    # elif 'by_template' in metafunc.fixturenames:
    #     for i, argvalue_tuple in enumerate(argvalues):
    #         args = dict(zip(argnames, argvalue_tuple))
    #         if not args['vm_analysis']:
    #             # No analysis data available
    #             continue
    #         for vm_name in argvalue_tuple[0].keys():
    #             fs_type = argvalue_tuple[0][vm_name]['fs_type']
    #             os = argvalue_tuple[0][vm_name]['os']
    #             provider_key = idlist[i]
    #             provider_crud = get_infra_provider(provider_key)
    #             provider_mgmt = provider_factory(provider_key)
    #             new_argvalues.append(['', provider_crud, provider_mgmt, vm_name, os, fs_type])
    #             new_idlist.append(provider_key + "-" + fs_type)
    #             test_list.append([provider_crud.key, vm_name, os, fs_type])
    #     argnames = [
    #         'by_template', 'provider_crud', 'provider_mgmt', 'vm_template_name', 'os', 'fs_type']

    elif 'by_fs_type' in metafunc.fixturenames:
        argnames, argvalues, idlist = testgen.infra_providers(
            metafunc, 'vm_analysis', require_fields=True)

        for i, provider in enumerate(idlist):
            for vm_template_name in argvalues[i][0].keys():
                os = argvalues[i][0].get(vm_template_name).get('os')
                fs_type = argvalues[i][0].get(vm_template_name).get('fs_type')
                provider_crud = argvalues[i][1]
                provider_mgmt = argvalues[i][2]
                argnames = ['by_fs_type', 'provider_crud', 'provider_mgmt',
                            'vm_template_name', 'os', 'fs_type']
                new_argvalues.append(
                    ['', provider_crud, provider_mgmt, vm_template_name, os, fs_type])
                new_idlist.append(provider_crud.key + "-" + fs_type)
                test_list.append([provider_crud.key, vm_template_name, os, fs_type])
    testgen.parametrize(metafunc, argnames, new_argvalues, ids=new_idlist, scope="class")
def pytest_generate_tests(metafunc):
    # Filter out providers without provisioning data or hosts defined
    argnames, argvalues, idlist = testgen.infra_providers(metafunc)
    if not idlist:
        return
    testgen.parametrize(metafunc, argnames, argvalues, ids=idlist, scope="class")
Beispiel #49
0
def pytest_generate_tests(metafunc):
    argnames, argvalues, idlist = testgen.infra_providers(
        metafunc, required_fields=["vm_analysis"])
    testgen.parametrize(metafunc, argnames, argvalues, ids=idlist, scope="module")