本文整理汇总了Python中trove.tests.util.poll_until函数的典型用法代码示例。如果您正苦于以下问题:Python poll_until函数的具体用法?Python poll_until怎么用?Python poll_until使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了poll_until函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_bad_resize_vol_data
def test_bad_resize_vol_data(self):
def _check_instance_status():
inst = self.dbaas.instances.get(self.instance)
if inst.status == "ACTIVE":
return True
else:
return False
poll_until(_check_instance_status)
data = "bad data"
try:
self.dbaas.instances.resize_volume(self.instance.id, data)
except Exception as e:
resp, body = self.dbaas.client.last_response
httpCode = resp.status
assert_equal(httpCode, 400,
"Resize instance failed with code %s, exception %s"
% (httpCode, e))
data = "u'bad data'"
assert_equal(e.message,
"Validation error: "
"resize['volume']['size'] %s "
"is not valid under any of the given schemas; "
"%s is not of type 'integer'; "
"%s does not match '[0-9]+'" %
(data, data, data))
开发者ID:CiscoSystems,项目名称:openstack-trove,代码行数:26,代码来源:malformed_json.py
示例2: test_backup_delete
def test_backup_delete(self):
"""test delete"""
# Test to make sure that user in other tenant is not able
# to DELETE this backup
reqs = Requirements(is_admin=False)
other_user = CONFIG.users.find_user(
reqs,
black_list=[instance_info.user.auth_user])
other_client = create_dbaas_client(other_user)
assert_raises(exceptions.NotFound, other_client.backups.delete,
backup_info.id)
instance_info.dbaas.backups.delete(backup_info.id)
assert_equal(202, instance_info.dbaas.last_http_code)
def backup_is_gone():
result = instance_info.dbaas.instances.backups(instance_info.id)
if len(result) == 0:
return True
else:
return False
poll_until(backup_is_gone)
assert_raises(exceptions.NotFound, instance_info.dbaas.backups.get,
backup_info.id)
开发者ID:krast,项目名称:trove,代码行数:25,代码来源:backups.py
示例3: test_create_backup_with_instance_not_active
def test_create_backup_with_instance_not_active(self):
name = "spare_instance"
flavor = 2
self.databases.append({"name": "db2"})
self.users.append({"name": "lite", "password": "litepass",
"databases": [{"name": "db2"}]})
volume = {'size': 2}
self.xtra_instance = instance_info.dbaas.instances.create(
name,
flavor,
volume,
self.databases,
self.users)
assert_equal(200, instance_info.dbaas.last_http_code)
# immediately create the backup while instance is still in "BUILD"
try:
self.xtra_backup = self._create_backup(
BACKUP_NAME, BACKUP_DESC, inst_id=self.xtra_instance.id)
assert_true(False, "Expected 422 from create backup")
except exceptions.UnprocessableEntity:
assert_equal(422, instance_info.dbaas.last_http_code)
assert_equal(422, instance_info.dbaas.last_http_code)
# make sure the instance status goes back to "ACTIVE"
poll_until(lambda: self._verify_instance_status(self.xtra_instance.id,
"ACTIVE"),
time_out=120, sleep_time=2)
# Now that it's active, create the backup
self.xtra_backup = self._create_backup(BACKUP_NAME, BACKUP_DESC)
assert_equal(202, instance_info.dbaas.last_http_code)
poll_until(lambda: self._verify_backup_status(self.xtra_backup.id,
'COMPLETED'),
time_out=120, sleep_time=2)
开发者ID:plodronio,项目名称:trove,代码行数:32,代码来源:backups.py
示例4: test_bad_change_user_password
def test_bad_change_user_password(self):
password = ""
users = [{"name": password}]
def _check_instance_status():
inst = self.dbaas.instances.get(self.instance)
if inst.status == "ACTIVE":
return True
else:
return False
poll_until(_check_instance_status)
try:
self.dbaas.users.change_passwords(self.instance, users)
except Exception as e:
resp, body = self.dbaas.client.last_response
httpCode = resp.status
assert_equal(httpCode, 400,
"Change usr/passwd failed with code %s, exception %s"
% (httpCode, e))
if not isinstance(self.dbaas.client,
troveclient.xml.TroveXmlClient):
password = "u''"
assert_equal(e.message,
"Validation error: "
"users[0] 'password' is a required property; "
"users[0]['name'] %s is too short; "
"users[0]['name'] %s does not match "
"'^.*[0-9a-zA-Z]+.*$'" %
(password, password))
开发者ID:CiscoSystems,项目名称:openstack-trove,代码行数:30,代码来源:malformed_json.py
示例5: wait_for_resize
def wait_for_resize(self):
def is_finished_resizing():
instance = self.instance
if instance.status == "RESIZE":
return False
assert_equal("ACTIVE", instance.status)
return True
testsutil.poll_until(is_finished_resizing, time_out=TIME_OUT_TIME)
开发者ID:VinodKrGupta,项目名称:trove,代码行数:8,代码来源:instances_actions.py
示例6: restart_compute_service
def restart_compute_service(extra_args=None):
extra_args = extra_args or []
test_config.compute_service.restart(extra_args=extra_args)
# Be absolutely certain the compute manager is ready before passing control
# back to caller.
poll_until(lambda: hosts_up('compute'),
sleep_time=1, time_out=60)
wait_for_compute_service()
开发者ID:hub-cap,项目名称:trove-integration,代码行数:8,代码来源:__init__.py
示例7: wait_for_compute_service
def wait_for_compute_service():
pid = test_config.compute_service.find_proc_id()
line = "Creating Consumer connection for Service compute from (pid=%d)" % \
pid
try:
poll_until(lambda: check_logs_for_message(line),
sleep_time=1, time_out=60)
except exception.PollTimeOut:
raise RuntimeError("Could not find the line %s in the logs." % line)
开发者ID:hub-cap,项目名称:trove-integration,代码行数:9,代码来源:__init__.py
示例8: wait_for_broken_connection
def wait_for_broken_connection(self):
"""Wait until our connection breaks."""
if not USE_IP:
return
if not hasattr(self, "connection"):
return
testsutil.poll_until(self.connection.is_connected,
lambda connected: not connected,
time_out=TIME_OUT_TIME)
开发者ID:VinodKrGupta,项目名称:trove,代码行数:9,代码来源:instances_actions.py
示例9: test_instance_action_right_after_backup_create
def test_instance_action_right_after_backup_create(self):
"""test any instance action while backup is running"""
backup = self._create_backup("modify_during_create",
"modify instance while creating backup")
assert_equal(202, instance_info.dbaas.last_http_code)
# Dont wait for backup to complete, try to delete it
assert_unprocessable(instance_info.dbaas.instances.resize_instance,
instance_info.id, 1)
poll_until(lambda: self._verify_backup_status(backup.id, 'COMPLETED'),
time_out=120, sleep_time=2)
开发者ID:plodronio,项目名称:trove,代码行数:10,代码来源:backups.py
示例10: wait_for_successful_restart
def wait_for_successful_restart(self):
"""Wait until status becomes running."""
def is_finished_rebooting():
instance = self.instance
if instance.status == "REBOOT":
return False
assert_equal("ACTIVE", instance.status)
return True
testsutil.poll_until(is_finished_rebooting, time_out=TIME_OUT_TIME)
开发者ID:VinodKrGupta,项目名称:trove,代码行数:10,代码来源:instances_actions.py
示例11: test_clean_up_backups
def test_clean_up_backups(self):
backup_list = instance_info.dbaas.backups.list()
for backup in backup_list:
print("Cleanup backup: %r and status: %r" % (backup.id, backup.status))
if backup.status == 'COMPLETED':
try:
self._delete_backup(backup.id)
assert_equal(202, instance_info.dbaas.last_http_code)
poll_until(lambda: self._backup_is_gone(backup.id))
except exceptions.NotFound:
assert_equal(404, instance_info.dbaas.last_http_code)
开发者ID:plodronio,项目名称:trove,代码行数:11,代码来源:backups.py
示例12: update_and_wait_to_finish
def update_and_wait_to_finish(self):
instance_info.dbaas_admin.management.update(instance_info.id)
def finished():
current_version = self.get_version()
if current_version == self.next_version:
return True
# The only valid thing for it to be aside from next_version is
# old version.
assert_equal(current_version, self.old_version)
testsutil.poll_until(finished, sleep_time=1, time_out=3 * 60)
开发者ID:VinodKrGupta,项目名称:trove,代码行数:11,代码来源:instances_actions.py
示例13: test_backup_created
def test_backup_created(self):
# This version just checks the REST API status.
def result_is_active():
backup = instance_info.dbaas.backups.get(backup_info.id)
if backup.status == "COMPLETED":
return True
else:
assert_not_equal("FAILED", backup.status)
return False
poll_until(result_is_active)
开发者ID:dfecker,项目名称:trove,代码行数:11,代码来源:backups.py
示例14: test_delete_deleted_backup
def test_delete_deleted_backup(self):
backup = self._create_backup("del_backup", "delete a deleted backup")
assert_equal(202, instance_info.dbaas.last_http_code)
poll_until(lambda: self._verify_backup_status(backup.id, 'COMPLETED'),
time_out=120, sleep_time=1)
self._delete_backup(backup.id)
poll_until(lambda: self._backup_is_gone(backup.id))
try:
self._delete_backup(backup.id)
assert_true(False, "Expected 404 from delete backup")
except exceptions.NotFound:
assert_equal(404, instance_info.dbaas.last_http_code)
开发者ID:plodronio,项目名称:trove,代码行数:12,代码来源:backups.py
示例15: wait_for_failure_status
def wait_for_failure_status(self):
"""Wait until status becomes running."""
def is_finished_rebooting():
instance = self.instance
if instance.status == "REBOOT" or instance.status == "ACTIVE":
return False
# The reason we check for BLOCKED as well as SHUTDOWN is because
# Upstart might try to bring mysql back up after the borked
# connection and the guest status can be either
assert_true(instance.status in ("SHUTDOWN", "BLOCKED"))
return True
testsutil.poll_until(is_finished_rebooting, time_out=TIME_OUT_TIME)
开发者ID:VinodKrGupta,项目名称:trove,代码行数:13,代码来源:instances_actions.py
示例16: test_backup_delete
def test_backup_delete(self):
"""test delete"""
instance_info.dbaas.backups.delete(backup_info.id)
assert_equal(202, instance_info.dbaas.last_http_code)
def backup_is_gone():
result = instance_info.dbaas.instances.backups(instance_info.id)
if len(result) == 0:
return True
else:
return False
poll_until(backup_is_gone)
assert_raises(exceptions.NotFound, instance_info.dbaas.backups.get,
backup_info.id)
开发者ID:dfecker,项目名称:trove,代码行数:14,代码来源:backups.py
示例17: test_instance_resize_to_ephemeral_in_volume_support_should_fail
def test_instance_resize_to_ephemeral_in_volume_support_should_fail(self):
flavor_name = CONFIG.values.get('instance_bigger_eph_flavor_name',
'eph.rd-smaller')
flavors = self.dbaas.find_flavors_by_name(flavor_name)
def is_active():
return self.instance.status == 'ACTIVE'
testsutil.poll_until(is_active, time_out=TIME_OUT_TIME)
assert_equal(self.instance.status, 'ACTIVE')
self.get_flavor_href(
flavor_id=self.expected_old_flavor_id)
assert_raises(HTTPNotImplemented, self.dbaas.instances.resize_instance,
self.instance_id, flavors[0].id)
开发者ID:VinodKrGupta,项目名称:trove,代码行数:14,代码来源:instances_actions.py
示例18: test_volume_resize_success
def test_volume_resize_success(self):
def check_resize_status():
instance = instance_info.dbaas.instances.get(instance_info.id)
if instance.status == "ACTIVE":
return True
elif instance.status == "RESIZE":
return False
else:
fail("Status should not be %s" % instance.status)
testsutil.poll_until(check_resize_status, sleep_time=2, time_out=300)
instance = instance_info.dbaas.instances.get(instance_info.id)
assert_equal(instance.volume['size'], self.new_volume_size)
开发者ID:VinodKrGupta,项目名称:trove,代码行数:14,代码来源:instances_actions.py
示例19: test_create_backup
def test_create_backup(self):
databases = []
databases.append({"name": BACKUP_DB_NAME, "charset": "latin2",
"collate": "latin2_general_ci"})
instance_info.dbaas.databases.create(instance_info.id, databases)
assert_equal(202, instance_info.dbaas.last_http_code)
backup = self._create_backup(BACKUP_NAME, BACKUP_DESC,
instance_info.id)
self.backup_id = backup.id
assert_equal(backup.name, BACKUP_NAME)
assert_equal(backup.description, BACKUP_DESC)
assert_equal(backup.instance_id, instance_info.id)
assert_equal(backup.status, 'NEW')
assert_is_not_none(backup.id, 'backup.id does not exist')
assert_is_not_none(backup.created, 'backup.created does not exist')
assert_is_not_none(backup.updated, 'backup.updated does not exist')
instance = instance_info.dbaas.instances.get(instance_info.id)
assert_true(instance.status in ('ACTIVE', 'BACKUP'))
# Get Backup status by backup id during and after backup creation
poll_until(lambda: self._verify_instance_status(instance.id,
'BACKUP'),
time_out=120, sleep_time=2)
poll_until(lambda: self._verify_backup_status(backup.id, 'BUILDING'),
time_out=120, sleep_time=2)
poll_until(lambda: self._verify_backup_status(backup.id, 'COMPLETED'),
time_out=120, sleep_time=2)
poll_until(lambda: self._verify_instance_status(instance.id,
'ACTIVE'),
time_out=120, sleep_time=2)
开发者ID:plodronio,项目名称:trove,代码行数:29,代码来源:backups.py
示例20: create_user
def create_user(self):
"""Create a MySQL user we can use for this test."""
users = [{"name": MYSQL_USERNAME, "password": MYSQL_PASSWORD,
"databases": [{"name": MYSQL_USERNAME}]}]
self.dbaas.users.create(instance_info.id, users)
def has_user():
users = self.dbaas.users.list(instance_info.id)
return any([user.name == MYSQL_USERNAME for user in users])
testsutil.poll_until(has_user, time_out=30)
if not FAKE_MODE:
time.sleep(5)
开发者ID:VinodKrGupta,项目名称:trove,代码行数:14,代码来源:instances_actions.py
注:本文中的trove.tests.util.poll_until函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论