本文整理汇总了Python中utils.testgen.provider_by_type函数的典型用法代码示例。如果您正苦于以下问题:Python provider_by_type函数的具体用法?Python provider_by_type怎么用?Python provider_by_type使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了provider_by_type函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pytest_generate_tests
def pytest_generate_tests(metafunc):
types = ['virtualcenter', 'rhevm', 'scvmm']
argnames, argvalues, idlist = testgen.provider_by_type(
metafunc, types)
argnames = ['providers_for_discover', 'start_ip', 'max_range']
new_id_list = []
providers_complete = []
providers_final = []
for x in idlist:
providers_complete.append(get_crud(x))
provider_combinations = sorted(
find_neighbour_provider_combinations(providers_complete, len(types)), key=len)
signatures_seen = set()
for prov_comb in provider_combinations:
sig = generate_signature(prov_comb)
if sig in signatures_seen:
continue
signatures_seen.add(sig)
start_ip, max_range = minmax_ip(prov_comb)
providers_final.append([prov_comb, start_ip, max_range])
new_id_list.append(sig)
testgen.parametrize(metafunc, argnames, providers_final, ids=new_id_list, scope="module")
示例2: pytest_generate_tests
def pytest_generate_tests(metafunc):
new_idlist = []
new_argvalues = []
argnames, argvalues, idlist = testgen.provider_by_type(
metafunc, PROVIDER_TYPES, required_fields=['datastores'])
argnames += ['datastore']
for i, argvalue_tuple in enumerate(argvalues):
args = dict(zip(argnames, argvalue_tuple))
datastores = args['provider'].data.get('datastores', {})
if not datastores:
continue
for ds in datastores:
if not ds.get('test_fleece', False):
continue
assert ds.get('type', None) in DATASTORE_TYPES,\
'datastore type must be set to [{}] for smartstate analysis tests'\
.format('|'.join(DATASTORE_TYPES))
argvs = argvalues[i][:]
new_argvalues.append(argvs + [datastore.Datastore(ds['name'], args['provider'].key,
ds['type'])])
test_id = '{}-{}'.format(args['provider'].key, ds['type'])
new_idlist.append(test_id)
testgen.parametrize(metafunc, argnames, new_argvalues, ids=new_idlist, scope="module")
示例3: pytest_generate_tests
def pytest_generate_tests(metafunc):
verpicked_prov_types = version.pick(PROVIDER_TYPES)
new_idlist = []
new_argvalues = []
argnames, argvalues, idlist = testgen.provider_by_type(
metafunc, verpicked_prov_types, 'datastores')
argnames += ['datastore_type', 'datastore_name']
for i, argvalue_tuple in enumerate(argvalues):
args = dict(zip(argnames, argvalue_tuple))
if not args['datastores']:
continue
for ds in args['datastores']:
if not ds.get('test_fleece', False):
continue
assert ds.get('type', None) in DATASTORE_TYPES,\
'datastore type must be set to [{}] for smartstate analysis tests'\
.format('|'.join(DATASTORE_TYPES))
argvs = argvalues[i][:]
argvs.pop(argnames.index('datastores'))
new_argvalues.append(argvs + [ds['type'], ds['name']])
test_id = '{}-{}-{}'.format(args['provider'].key, ds['type'], ds['name'])
new_idlist.append(test_id)
argnames.remove('datastores')
metafunc.parametrize(argnames, new_argvalues, ids=new_idlist, scope="module")
示例4: pytest_generate_tests
def pytest_generate_tests(metafunc):
argnames, argvalues, idlist = testgen.provider_by_type(metafunc, ['virtualcenter'])
argnames = argnames + ["_host_provider"]
new_idlist = []
new_argvalues = []
for i, argvalue_tuple in enumerate(argvalues):
args = dict(zip(argnames, argvalue_tuple))
if args['provider'].type != "virtualcenter":
continue
hosts = args['provider'].data.get("hosts", [])
if not hosts:
continue
version = args['provider'].data.get("version", None)
if version is None:
# No version, no test
continue
if Version(version) < "5.0":
# Ignore lesser than 5
continue
host = hosts[0]
creds = credentials[host["credentials"]]
ip_address = resolve_hostname(host["name"])
cred = VMwareProvider.Credential(
principal=creds["username"],
secret=creds["password"],
verify_secret=creds["password"]
)
# Mock provider data
provider_data = {}
provider_data.update(args['provider'].data)
provider_data["name"] = host["name"]
provider_data["hostname"] = host["name"]
provider_data["ipaddress"] = ip_address
provider_data["credentials"] = host["credentials"]
provider_data.pop("host_provisioning", None)
provider_data["hosts"] = [host]
provider_data["discovery_range"] = {}
provider_data["discovery_range"]["start"] = ip_address
provider_data["discovery_range"]["end"] = ip_address
host_provider = VMwareProvider(
name=host["name"],
hostname=host["name"],
ip_address=ip_address,
credentials={'default': cred},
provider_data=provider_data,
)
argvalues[i].append(host_provider)
idlist[i] = "{}/{}".format(args['provider'].key, host["name"])
new_idlist.append(idlist[i])
new_argvalues.append(argvalues[i])
testgen.parametrize(metafunc, argnames, new_argvalues, ids=new_idlist, scope="module")
示例5: pytest_generate_tests
def pytest_generate_tests(metafunc):
# Filter out providers without provisioning data or hosts defined
argnames, argvalues, idlist = testgen.provider_by_type(metafunc, ['rhevm'],
required_fields=[
['provisioning', 'ci-template'],
['provisioning', 'ci-username'],
['provisioning', 'ci-pass'],
['provisioning', 'image']
])
testgen.parametrize(metafunc, argnames, argvalues, ids=idlist, scope="module")
示例6: pytest_generate_tests
def pytest_generate_tests(metafunc):
# Filter out providers not meant for Chargeback Testing
argnames, argvalues, idlist = testgen.provider_by_type(metafunc, ['virtualcenter', 'rhevm'],
required_fields=[(['cap_and_util', 'test_chargeback'], True)]
)
new_argvalues = []
new_idlist = []
for i, argvalue_tuple in enumerate(argvalues):
new_idlist.append(idlist[i])
new_argvalues.append(argvalues[i])
testgen.parametrize(metafunc, argnames, new_argvalues, ids=new_idlist, scope="module")
示例7: pytest_generate_tests
def pytest_generate_tests(metafunc):
final_argv, final_ids = [], []
# Get all providers and pick those, that have power control test enabled
argnames, argvalues, idlist = testgen.provider_by_type(
metafunc, ['ec2', 'openstack'], 'test_power_control')
for argn, argv, single_id in zip(argnames, argvalues, idlist):
test_pwr_ctl_i = argnames.index('test_power_control')
provider = argnames.index('provider')
if argv[test_pwr_ctl_i] is True:
final_argv.append(argv)
final_ids.append(argv[provider].key)
testgen.parametrize(metafunc, argnames, final_argv, ids=final_ids, scope="function")
示例8: pytest_generate_tests
def pytest_generate_tests(metafunc):
# Filter out providers without templates defined
argnames, argvalues, idlist = testgen.provider_by_type(metafunc, 'ec2', 'provisioning')
new_argvalues = []
new_idlist = []
for i, argvalue_tuple in enumerate(argvalues):
args = dict(zip(argnames, argvalue_tuple))
if not args['provisioning']:
# Don't know what type of instance to provision, move on
continue
# required keys should be a subset of the dict keys set
if not {'image'}.issubset(args['provisioning'].viewkeys()):
# Need image for image -> instance provisioning
continue
new_idlist.append(idlist[i])
new_argvalues.append([args[argname] for argname in argnames])
testgen.parametrize(metafunc, argnames, new_argvalues, ids=new_idlist, scope="module")
示例9: pytest_generate_tests
def pytest_generate_tests(metafunc):
p_argn, p_argv, p_ids = testgen.provider_by_type(metafunc, PROVIDER_TYPES, 'datastores')
argnames = ['provider_key', 'datastore_type', 'datastore_name']
argvalues = []
idlist = []
for argv in p_argv:
prov_datastores, prov_key = argv[0], argv[1]
if not prov_datastores:
continue
for test_datastore in prov_datastores:
if not test_datastore.get('test_fleece', False):
continue
assert test_datastore.get('type', None) in DATASTORE_TYPES,\
'datastore type must be set to [{}] for smartstate analysis tests'\
.format('|'.join(DATASTORE_TYPES))
argvalues.append([prov_key, test_datastore['type'], test_datastore['name']])
test_id = '{}-{}-{}'.format(prov_key, test_datastore['type'], test_datastore['name'])
idlist.append(test_id)
metafunc.parametrize(argnames, argvalues, ids=idlist, scope="module")
示例10: pytest_generate_tests
def pytest_generate_tests(metafunc):
# Filter out providers not meant for Chargeback Testing
argnames, argvalues, idlist = testgen.provider_by_type(metafunc, ['virtualcenter', 'rhevm'],
required_fields=[(['cap_and_util', 'test_chargeback'], True)]
)
new_argvalues = []
new_idlist = []
for i, argvalue_tuple in enumerate(argvalues):
args = dict(zip(argnames, argvalue_tuple))
capandu_data = args['provider'].data['cap_and_util']
stream = capandu_data.get('chargeback_runs_on_stream', '')
if not version.current_version().is_in_series(str(stream)):
continue
new_idlist.append(idlist[i])
new_argvalues.append(argvalues[i])
testgen.parametrize(metafunc, argnames, new_argvalues, ids=new_idlist, scope="module")
示例11: pytest_generate_tests
def pytest_generate_tests(metafunc):
argnames, argvalues, idlist = testgen.provider_by_type(
metafunc, ['virtualcenter'], choose_random=True)
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
metafunc.parametrize(argnames, argvalues, ids=idlist, scope='module')
示例12: pytest_generate_tests
def pytest_generate_tests(metafunc):
argnames, argvalues, idlist = testgen.provider_by_type(
metafunc, ['virtualcenter'], 'provisioning')
metafunc.parametrize(argnames, argvalues, ids=idlist, scope='module')
示例13: pytest_generate_tests
def pytest_generate_tests(metafunc):
argnames, argvalues, idlist = testgen.provider_by_type(
metafunc, ['azure', 'ec2', 'openstack'], required_fields=[('test_power_control', True)])
testgen.parametrize(metafunc, argnames, argvalues, ids=idlist, scope="function")
示例14: pytest_generate_tests
def pytest_generate_tests(metafunc):
argnames, argvalues, idlist = testgen.provider_by_type(metafunc, ['virtualcenter', 'rhevm'])
testgen.parametrize(metafunc, argnames, argvalues, ids=idlist, scope="module")
示例15: pytest_generate_tests
def pytest_generate_tests(metafunc):
argnames, argvalues, idlist = testgen.provider_by_type(metafunc, ["ec2"], "provisioning")
metafunc.parametrize(argnames, argvalues, ids=idlist, scope="module")