本文整理汇总了Python中utils.wait.wait_for函数的典型用法代码示例。如果您正苦于以下问题:Python wait_for函数的具体用法?Python wait_for怎么用?Python wait_for使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wait_for函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: resume_vm
def resume_vm(self, instance_name):
if self.is_vm_running(instance_name):
return True
instance = self._find_instance_by_name(instance_name)
instance.resume()
wait_for(self.is_vm_running, [instance_name])
开发者ID:jwadkins,项目名称:cfme_tests,代码行数:7,代码来源:mgmt_system.py
示例2: test_action_untag
def test_action_untag(request, assign_policy_for_testing, vm, vm_off, vm_crud_refresh):
""" Tests action untag
Metadata:
test_flag: actions, provision
"""
tag_unassign_action = explorer.Action(
fauxfactory.gen_alphanumeric(),
action_type="Remove Tags",
action_values={"cat_service_level": True}
)
assign_policy_for_testing.assign_actions_to_event("VM Power On", [tag_unassign_action])
def finalize():
assign_policy_for_testing.assign_events()
tag_unassign_action.delete()
request.addfinalizer(finalize)
vm.start_vm()
vm_crud_refresh()
try:
wait_for(
lambda: not any(
[tag.category == "service_level" and tag.tag_name == "gold" for tag in vm.soap.tags]
),
num_sec=600,
message="tag presence check"
)
except TimedOutError:
pytest.fail("Tags were not unassigned!")
开发者ID:seandst,项目名称:cfme_tests,代码行数:30,代码来源:test_actions.py
示例3: test_power_on_or_off_after_provision
def test_power_on_or_off_after_provision(provisioner, prov_data, provider, started):
""" Tests setting the desired power state after provisioning.
Prerequisities:
* A provider set up, supporting provisioning in CFME
Steps:
* Open the provisioning dialog.
* Apart from the usual provisioning settings, set whether you want or not the VM to be
powered on after provisioning.
* Submit the provisioning request and wait for it to finish.
* The VM should become steady in the desired VM power state.
Metadata:
test_flag: provision
"""
vm_name = "test_prov_dlg_{}".format(fauxfactory.gen_alphanumeric())
prov_data["vm_name"] = vm_name
prov_data["power_on"] = started
template_name = provider.data['provisioning']['template']
provisioner(template_name, prov_data)
wait_for(
lambda: provider.mgmt.does_vm_exist(vm_name) and
(provider.mgmt.is_vm_running if started else provider.mgmt.is_vm_stopped)(vm_name),
num_sec=240, delay=5
)
开发者ID:sakthivelramakrishnan,项目名称:cfme_tests,代码行数:28,代码来源:test_provisioning_dialog.py
示例4: test_ssa_users
def test_ssa_users(provider, instance, soft_assert):
""" Tests SSA fetches correct results for users list
Metadata:
test_flag: vm_analysis
"""
username = fauxfactory.gen_alphanumeric()
expected = None
# In windows case we can't add new users (yet)
# So we simply check that user list doesn't cause any Rails errors
if instance.system_type != WINDOWS:
# Add a new user
instance.ssh.run_command("userdel {0} || useradd {0}".format(username))
expected = instance.ssh.run_command("cat /etc/passwd | wc -l").output.strip('\n')
instance.smartstate_scan()
wait_for(lambda: is_vm_analysis_finished(instance.name),
delay=15, timeout="15m", fail_func=lambda: toolbar.select('Reload'))
# Check that all data has been fetched
current = instance.get_detail(properties=('Security', 'Users'))
if instance.system_type != WINDOWS:
assert current == expected
# Make sure created user is in the list
instance.open_details(("Security", "Users"))
if instance.system_type != WINDOWS:
if not instance.paged_table.find_row_on_all_pages('Name', username):
pytest.fail("User {0} was not found".format(username))
开发者ID:anewmanRH,项目名称:cfme_tests,代码行数:30,代码来源:test_instance_analysis.py
示例5: test_action_power_on_audit
def test_action_power_on_audit(
request, assign_policy_for_testing, vm, vm_off, ssh_client, vm_crud_refresh):
""" This test tests action 'Generate Audit Event'.
This test sets the policy that it logs powering on of the VM. Then it powers up the vm and
checks whether audit logs contain message about that.
Metadata:
test_flag: actions, provision
"""
# Set up the policy and prepare finalizer
assign_policy_for_testing.assign_actions_to_event("VM Power On", ["Generate Audit Event"])
request.addfinalizer(lambda: assign_policy_for_testing.assign_events())
# Start the VM
vm.start_vm()
vm_crud_refresh()
policy_desc = assign_policy_for_testing.description
# Search the logs
def search_logs():
rc, stdout = ssh_client.run_command(
"cat /var/www/miq/vmdb/log/audit.log | grep '%s'" % policy_desc
)
if rc != 0: # Nothing found, so shortcut
return False
for line in stdout.strip().split("\n"):
if "Policy success" not in line or "MiqAction.action_audit" not in line:
continue
match_string = "policy: [%s], event: [VM Power On]" % (policy_desc)
if match_string in line:
logger.info("Found corresponding log message: %s" % line.strip())
return True
else:
return False
wait_for(search_logs, num_sec=180, message="log search")
开发者ID:seandst,项目名称:cfme_tests,代码行数:35,代码来源:test_actions.py
示例6: queue_canned_report
def queue_canned_report(*path):
"""Queue report from selection of pre-prepared reports.
Args:
*path: Path in tree after All Reports
Returns: Value of Run At in the table so the run can be then checked.
"""
sel.force_navigate("report_canned_info", context={"path": path})
toolbar.select("Queue")
flash.assert_no_errors()
tabstrip.select_tab("Saved Reports")
def _get_state():
try:
first_row = list(records_table.rows())[0]
except IndexError:
return False
return sel.text(first_row.status).strip().lower() == "finished"
wait_for(
_get_state,
delay=1,
message="wait for report generation finished",
fail_func=reload_view
)
return sel.text(list(records_table.rows())[0].run_at).encode("utf-8")
开发者ID:slouderm,项目名称:cfme_tests,代码行数:26,代码来源:reports.py
示例7: _filter
def _filter(
zone=None,
user=None,
time_period=None,
task_status_queued=None,
task_status_running=None,
task_status_ok=None,
task_status_error=None,
task_status_warn=None,
task_state=None):
""" Does filtering of the results in table. Needs to be on the correct page before called.
If there was no change in the form and the apply button does not appear, nothing happens.
Args:
zone: Value for 'Zone' select
user: Value for 'User' select
time_period: Value for 'Time period' select.
task_status_*: :py:class:`bool` values for checkboxes
task_state: Value for 'Task State' select.
"""
fill(filter_form, locals())
try:
wait_for(lambda: sel.is_displayed(buttons.apply), num_sec=5)
sel.click(buttons.apply)
except TimedOutError:
pass
开发者ID:quarckster,项目名称:cfme_tests,代码行数:27,代码来源:tasks.py
示例8: test_edit_multiple_services
def test_edit_multiple_services(rest_api, services):
"""Tests editing multiple service catalogs at time.
Prerequisities:
* An appliance with ``/api`` available.
Steps:
* POST /api/services (method ``edit``) with the list of dictionaries used to edit
* Check if the services with ``new_name`` each exists
Metadata:
test_flag: rest
"""
new_names = []
services_data_edited = []
for ser in services:
new_name = fauxfactory.gen_alphanumeric()
new_names.append(new_name)
services_data_edited.append({
"href": ser.href,
"name": new_name,
})
rest_api.collections.services.action.edit(*services_data_edited)
for new_name in new_names:
wait_for(
lambda: rest_api.collections.service_templates.find_by(name=new_name),
num_sec=180,
delay=10,
)
开发者ID:pombredanne,项目名称:cfme_tests,代码行数:26,代码来源:test_rest.py
示例9: test_retire_service_future
def test_retire_service_future(rest_api, services):
"""Test retiring a service
Prerequisities:
* An appliance with ``/api`` available.
Steps:
* Retrieve list of entities using GET /api/services , pick the first one
* POST /api/service/<id> (method ``retire``) with the ``retire_date``
Metadata:
test_flag: rest
"""
assert "retire" in rest_api.collections.services.action.all
retire_service = services[0]
date = (datetime.datetime.now() + datetime.timedelta(days=5)).strftime('%m/%d/%y')
future = {
"date": date,
"warn": "4",
}
date_before = retire_service.updated_at
retire_service.action.retire(future)
def _finished():
retire_service.reload()
if retire_service.updated_at > date_before:
return True
return False
wait_for(_finished, num_sec=600, delay=5, message="REST automation_request finishes")
开发者ID:pombredanne,项目名称:cfme_tests,代码行数:28,代码来源:test_rest.py
示例10: test_edit_rates
def test_edit_rates(rest_api, rates, multiple):
if multiple:
new_descriptions = []
rates_data_edited = []
for rate in rates:
new_description = fauxfactory.gen_alphanumeric().lower()
new_descriptions.append(new_description)
rate.reload()
rates_data_edited.append({
"href": rate.href,
"description": "test_category_{}".format(new_description),
})
rest_api.collections.rates.action.edit(*rates_data_edited)
for new_description in new_descriptions:
wait_for(
lambda: rest_api.collections.rates.find_by(description=new_description),
num_sec=180,
delay=10,
)
else:
rate = rest_api.collections.rates.find_by(description=rates[0].description)[0]
new_description = 'test_rate_{}'.format(fauxfactory.gen_alphanumeric().lower())
rate.action.edit(description=new_description)
wait_for(
lambda: rest_api.collections.categories.find_by(description=new_description),
num_sec=180,
delay=10,
)
开发者ID:pombredanne,项目名称:cfme_tests,代码行数:28,代码来源:test_rest.py
示例11: test_provision
def test_provision(request, provision_data, provider, rest_api):
"""Tests provision via REST API.
Prerequisities:
* Have a provider set up with templates suitable for provisioning.
Steps:
* POST /api/provision_requests (method ``create``) the JSON with provisioning data. The
request is returned.
* Query the request by its id until the state turns to ``finished`` or ``provisioned``.
Metadata:
test_flag: rest, provision
"""
vm_name = provision_data["vm_fields"]["vm_name"]
request.addfinalizer(
lambda: provider.mgmt.delete_vm(vm_name) if provider.mgmt.does_vm_exist(vm_name) else None)
request = rest_api.collections.provision_requests.action.create(**provision_data)[0]
def _finished():
request.reload()
if request.status.lower() in {"error"}:
pytest.fail("Error when provisioning: `{}`".format(request.message))
return request.request_state.lower() in {"finished", "provisioned"}
wait_for(_finished, num_sec=600, delay=5, message="REST provisioning finishes")
assert provider.mgmt.does_vm_exist(vm_name), "The VM {} does not exist!".format(vm_name)
开发者ID:pombredanne,项目名称:cfme_tests,代码行数:25,代码来源:test_rest.py
示例12: register_appliances
def register_appliances(appliance_set, appliances_to_register):
with appliance_set.primary.browser_session():
red_hat_updates.register_appliances(*appliances_to_register)
logger.info('Waiting for appliance statuses to change to Registered')
wait_for(red_hat_updates.are_registered,
func_args=appliances_to_register,
num_sec=120,
delay=REFRESH_SEC,
fail_func=red_hat_updates.refresh)
logger.info('Done')
logger.info('Waiting for implicit update check after registration')
# The update check doesnt have to find any available updates, but it still has to run
wait_for(red_hat_updates.checked_updates,
func_args=appliances_to_register,
num_sec=300,
delay=REFRESH_SEC,
fail_func=red_hat_updates.refresh)
logger.info('Done')
# And all registered appliances should be registered and subscribed
assert red_hat_updates.are_registered(appliances_to_register),\
'Failed to register all specified appliances'
assert red_hat_updates.are_subscribed(appliances_to_register),\
'Failed to subscribe all specified appliances'
开发者ID:jkrocil,项目名称:cfme_tests,代码行数:26,代码来源:test_update_appliances.py
示例13: test_appliance_replicate_database_disconnection_with_backlog
def test_appliance_replicate_database_disconnection_with_backlog(request, provider):
"""Tests a database disconnection with backlog
Metadata:
test_flag: replication
"""
appl1, appl2 = get_replication_appliances()
def finalize():
appl1.destroy()
appl2.destroy()
request.addfinalizer(finalize)
appl1.ipapp.browser_steal = True
with appl1.ipapp:
configure_db_replication(appl2.address)
# Replication is up and running, now stop the DB on the replication parent
provider.create()
stop_db_process(appl2.address)
sleep(60)
start_db_process(appl2.address)
sel.force_navigate("cfg_diagnostics_region_replication")
wait_for(lambda: conf.get_replication_status(navigate=False), fail_condition=False,
num_sec=360, delay=10, fail_func=sel.refresh, message="get_replication_status")
assert conf.get_replication_status()
wait_for_a_provider()
appl2.ipapp.browser_steal = True
with appl2.ipapp:
wait_for_a_provider()
assert provider.exists
开发者ID:pombredanne,项目名称:cfme_tests,代码行数:30,代码来源:test_appliance_replication.py
示例14: test_appliance_replicate_sync_role_change_with_backlog
def test_appliance_replicate_sync_role_change_with_backlog(request, provider):
"""Tests that a role change is replicated with backlog
Metadata:
test_flag: replication
"""
appl1, appl2 = get_replication_appliances()
def finalize():
appl1.destroy()
appl2.destroy()
request.addfinalizer(finalize)
appl1.ipapp.browser_steal = True
with appl1.ipapp:
configure_db_replication(appl2.address)
# Replication is up and running, now disable DB sync role
provider.create()
conf.set_server_roles(database_synchronization=False)
sel.force_navigate("cfg_diagnostics_region_replication")
wait_for(lambda: conf.get_replication_status(navigate=False), fail_condition=True,
num_sec=360, delay=10, fail_func=sel.refresh, message="get_replication_status")
conf.set_server_roles(database_synchronization=True)
sel.force_navigate("cfg_diagnostics_region_replication")
wait_for(lambda: conf.get_replication_status(navigate=False), fail_condition=False,
num_sec=360, delay=10, fail_func=sel.refresh, message="get_replication_status")
assert conf.get_replication_status()
wait_for_a_provider()
appl2.ipapp.browser_steal = True
with appl2.ipapp:
wait_for_a_provider()
assert provider.exists
开发者ID:pombredanne,项目名称:cfme_tests,代码行数:32,代码来源:test_appliance_replication.py
示例15: validate_stats
def validate_stats(self, ui=False):
""" Validates that the detail page matches the Providers information.
This method logs into the provider using the mgmt_system interface and collects
a set of statistics to be matched against the UI. The details page is then refreshed
continuously until the matching of all items is complete. A error will be raised
if the match is not complete within a certain defined time period.
"""
# If we're not using db, make sure we are on the provider detail page
if ui:
self.load_details()
# Initial bullet check
if self._do_stats_match(self.mgmt, self.STATS_TO_MATCH, ui=ui):
self.mgmt.disconnect()
return
else:
# Set off a Refresh Relationships
method = 'ui' if ui else None
self.refresh_provider_relationships(method=method)
refresh_timer = RefreshTimer(time_for_refresh=300)
wait_for(self._do_stats_match,
[self.mgmt, self.STATS_TO_MATCH, refresh_timer],
{'ui': ui},
message="do_stats_match_db",
num_sec=1000,
delay=60)
self.mgmt.disconnect()
开发者ID:rananda,项目名称:cfme_tests,代码行数:31,代码来源:provider.py
示例16: service_catalogs
def service_catalogs(request, rest_api):
name = fauxfactory.gen_alphanumeric()
rest_api.collections.service_catalogs.action.add(
name=name,
description="description_{}".format(name),
service_templates=[]
)[0]
wait_for(
lambda: rest_api.collections.service_catalogs.find_by(name=name),
num_sec=180,
delay=10,
)
scls_data = [{
"name": "name_{}_{}".format(name, index),
"description": "description_{}_{}".format(name, index),
"service_templates": []
} for index in range(1, 5)]
scls = rest_api.collections.service_catalogs.action.add(*scls_data)
@request.addfinalizer
def _finished():
scls = [_ for _ in rest_api.collections.service_catalogs]
if len(scls) != 0:
rest_api.collections.service_catalogs.action.delete(*scls)
return scls
开发者ID:pombredanne,项目名称:cfme_tests,代码行数:27,代码来源:test_rest.py
示例17: create
def create(self, cancel=False, wait=False):
view = navigate_to(self, 'Add')
view.form.fill({
'cloud_provider': self.provider.name,
'name': self.name
})
if cancel:
view.form.cancel_button.click()
else:
view.form.save_button.click()
all_view = self.create_view(TenantAllView)
wait_for(lambda: all_view.is_displayed, fail_condition=False, num_sec=120, delay=3,
fail_func=lambda: all_view.flush_widget_cache(), handle_exception=True)
if cancel:
if self.appliance.version >= '5.8':
msg = 'Add of Cloud Tenant was cancelled by the user'
else:
msg = 'Add of new Cloud Tenant was cancelled by the user'
all_view.entities.flash.assert_success_message(msg)
else:
all_view.entities.flash.assert_success_message(
'Cloud Tenant "{}" created'.format(self.name))
if wait:
def refresh():
"""Refresh a few things"""
self.provider.refresh_provider_relationships()
all_view.flush_widget_cache()
self.browser.refresh()
wait_for(lambda: self.exists, timeout=600, message='Wait for cloud tenant to appear',
delay=10, fail_func=refresh)
开发者ID:dajohnso,项目名称:cfme_tests,代码行数:32,代码来源:tenant.py
示例18: test_automation_requests
def test_automation_requests(request, rest_api, automation_requests_data, multiple):
"""Test adding the automation request
Prerequisities:
* An appliance with ``/api`` available.
Steps:
* POST /api/automation_request - (method ``create``) add request
* Retrieve list of entities using GET /api/automation_request and find just added request
Metadata:
test_flag: rest, requests
"""
if "automation_requests" not in rest_api.collections:
pytest.skip("automation request collection is not implemented in this version")
if multiple:
requests = rest_api.collections.automation_requests.action.create(*automation_requests_data)
else:
requests = rest_api.collections.automation_requests.action.create(
automation_requests_data[0])
def _finished():
for request in requests:
request.reload()
if request.status.lower() not in {"error"}:
return False
return True
wait_for(_finished, num_sec=600, delay=5, message="REST automation_request finishes")
开发者ID:pombredanne,项目名称:cfme_tests,代码行数:28,代码来源:test_rest.py
示例19: test_action_tag
def test_action_tag(request, assign_policy_for_testing, vm, vm_off, vm_crud_refresh):
""" Tests action tag
Metadata:
test_flag: actions, provision
"""
if any(tag.category.display_name == "Service Level" and tag.display_name == "Gold"
for tag in vm.crud.get_tags()):
vm.crud.remove_tag(("Service Level", "Gold"))
tag_assign_action = actions.Action(
fauxfactory.gen_alphanumeric(),
action_type="Tag",
action_values={"tag": ("My Company Tags", "Service Level", "Gold")}
)
assign_policy_for_testing.assign_actions_to_event("VM Power On", [tag_assign_action])
@request.addfinalizer
def finalize():
assign_policy_for_testing.assign_events()
tag_assign_action.delete()
vm.start_vm()
vm_crud_refresh()
try:
wait_for(
lambda: any(tag.category.display_name == "Service Level" and tag.display_name == "Gold"
for tag in vm.crud.get_tags()),
num_sec=600,
message="tag presence check"
)
except TimedOutError:
pytest.fail("Tags were not assigned!")
开发者ID:ManageIQ,项目名称:integration_tests,代码行数:33,代码来源:test_actions.py
示例20: test_edit_categories
def test_edit_categories(rest_api, categories, multiple):
if "edit" not in rest_api.collections.categories.action.all:
pytest.skip("Edit categories action is not implemented in this version")
if multiple:
new_names = []
ctgs_data_edited = []
for ctg in categories:
new_name = fauxfactory.gen_alphanumeric().lower()
new_names.append(new_name)
ctg.reload()
ctgs_data_edited.append({
"href": ctg.href,
"description": "test_category_{}".format(new_name),
})
rest_api.collections.categories.action.edit(*ctgs_data_edited)
for new_name in new_names:
wait_for(
lambda: rest_api.collections.categories.find_by(description=new_name),
num_sec=180,
delay=10,
)
else:
ctg = rest_api.collections.categories.find_by(description=categories[0].description)[0]
new_name = 'test_category_{}'.format(fauxfactory.gen_alphanumeric().lower())
ctg.action.edit(description=new_name)
wait_for(
lambda: rest_api.collections.categories.find_by(description=new_name),
num_sec=180,
delay=10,
)
开发者ID:pombredanne,项目名称:cfme_tests,代码行数:31,代码来源:test_rest.py
注:本文中的utils.wait.wait_for函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论