Enabled F403 flake8 rule
Reasons: - F403 is disabled. - code contains "import *" statements. Changes: - Updates tox.ini to enable F403 rules. - Updates code for F403 violation. Change-Id: If932a910c073ae7bffb74908495f35dbc4f4d1f9 Closes-Bug: #1264724
This commit is contained in:
parent
84dbe87c22
commit
167c0ceb7a
2
tox.ini
2
tox.ini
@ -37,7 +37,7 @@ commands = {posargs}
|
|||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
show-source = True
|
show-source = True
|
||||||
ignore = F403,F821,H301,H306,H402,H404
|
ignore = F821,H301,H306,H402,H404
|
||||||
builtins = _
|
builtins = _
|
||||||
exclude=.venv,.tox,dist,doc,openstack,*egg,rsdns,tools,etc,build
|
exclude=.venv,.tox,dist,doc,openstack,*egg,rsdns,tools,etc,build
|
||||||
filename=*.py,trove-*
|
filename=*.py,trove-*
|
||||||
|
@ -19,7 +19,10 @@
|
|||||||
Standard openstack.common.rpc.impl_fake with nonblocking cast
|
Standard openstack.common.rpc.impl_fake with nonblocking cast
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from trove.openstack.common.rpc.impl_fake import *
|
import eventlet
|
||||||
|
|
||||||
|
from trove.openstack.common.rpc.impl_fake import cast
|
||||||
|
from trove.openstack.common.rpc.impl_fake import create_connection
|
||||||
|
|
||||||
|
|
||||||
original_cast = cast
|
original_cast = cast
|
||||||
@ -30,3 +33,7 @@ def non_blocking_cast(*args, **kwargs):
|
|||||||
|
|
||||||
|
|
||||||
cast = non_blocking_cast
|
cast = non_blocking_cast
|
||||||
|
|
||||||
|
|
||||||
|
# Asserting create_connection, workaround for pep8-F401 for unused import.
|
||||||
|
assert create_connection
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
from proboscis import test
|
from proboscis import test
|
||||||
from proboscis.asserts import *
|
from proboscis import asserts
|
||||||
from proboscis import SkipTest
|
from proboscis import SkipTest
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ def must_work_with_blank_accept_headers():
|
|||||||
versions.test_list_versions_index()
|
versions.test_list_versions_index()
|
||||||
# now change headers to XML to make sure the test fails
|
# now change headers to XML to make sure the test fails
|
||||||
morph_content_type_to('application/xml')
|
morph_content_type_to('application/xml')
|
||||||
assert_raises(exceptions.ResponseFormatError,
|
asserts.assert_raises(exceptions.ResponseFormatError,
|
||||||
versions.test_list_versions_index)
|
versions.test_list_versions_index)
|
||||||
finally:
|
finally:
|
||||||
client.client.morph_request = original_morph_request
|
client.client.morph_request = original_morph_request
|
||||||
|
@ -18,7 +18,7 @@ import time
|
|||||||
from proboscis import after_class
|
from proboscis import after_class
|
||||||
from proboscis import before_class
|
from proboscis import before_class
|
||||||
from proboscis import test
|
from proboscis import test
|
||||||
from proboscis.asserts import *
|
from proboscis import asserts
|
||||||
from proboscis.decorators import time_out
|
from proboscis.decorators import time_out
|
||||||
from proboscis import SkipTest
|
from proboscis import SkipTest
|
||||||
|
|
||||||
@ -185,7 +185,7 @@ def create_user():
|
|||||||
except BadRequest:
|
except BadRequest:
|
||||||
pass # Ignore this if the user already exists.
|
pass # Ignore this if the user already exists.
|
||||||
helper.connection.connect()
|
helper.connection.connect()
|
||||||
assert_true(helper.connection.is_connected(),
|
asserts.assert_true(helper.connection.is_connected(),
|
||||||
"Test user must be able to connect to MySQL.")
|
"Test user must be able to connect to MySQL.")
|
||||||
|
|
||||||
|
|
||||||
@ -211,7 +211,7 @@ class RebootTestBase(ActionTestBase):
|
|||||||
instance = self.instance
|
instance = self.instance
|
||||||
if instance.status == "REBOOT":
|
if instance.status == "REBOOT":
|
||||||
return False
|
return False
|
||||||
assert_equal("ACTIVE", instance.status)
|
asserts.assert_equal("ACTIVE", instance.status)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
poll_until(is_finished_rebooting, time_out=TIME_OUT_TIME)
|
poll_until(is_finished_rebooting, time_out=TIME_OUT_TIME)
|
||||||
@ -220,7 +220,7 @@ class RebootTestBase(ActionTestBase):
|
|||||||
if not USE_IP:
|
if not USE_IP:
|
||||||
return
|
return
|
||||||
new_proc_id = self.find_mysql_proc_on_instance()
|
new_proc_id = self.find_mysql_proc_on_instance()
|
||||||
assert_not_equal(new_proc_id, self.proc_id,
|
asserts.assert_not_equal(new_proc_id, self.proc_id,
|
||||||
"MySQL process ID should be different!")
|
"MySQL process ID should be different!")
|
||||||
|
|
||||||
def successful_restart(self):
|
def successful_restart(self):
|
||||||
@ -259,7 +259,7 @@ class RebootTestBase(ActionTestBase):
|
|||||||
# The reason we check for BLOCKED as well as SHUTDOWN is because
|
# The reason we check for BLOCKED as well as SHUTDOWN is because
|
||||||
# Upstart might try to bring mysql back up after the borked
|
# Upstart might try to bring mysql back up after the borked
|
||||||
# connection and the guest status can be either
|
# connection and the guest status can be either
|
||||||
assert_true(instance.status in ("SHUTDOWN", "BLOCKED"))
|
asserts.assert_true(instance.status in ("SHUTDOWN", "BLOCKED"))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
poll_until(is_finished_rebooting, time_out=TIME_OUT_TIME)
|
poll_until(is_finished_rebooting, time_out=TIME_OUT_TIME)
|
||||||
@ -285,7 +285,7 @@ class RestartTests(RebootTestBase):
|
|||||||
|
|
||||||
def call_reboot(self):
|
def call_reboot(self):
|
||||||
self.instance.restart()
|
self.instance.restart()
|
||||||
assert_equal(202, self.dbaas.last_http_code)
|
asserts.assert_equal(202, self.dbaas.last_http_code)
|
||||||
|
|
||||||
@before_class
|
@before_class
|
||||||
def test_set_up(self):
|
def test_set_up(self):
|
||||||
@ -368,8 +368,8 @@ class RebootTests(RebootTestBase):
|
|||||||
@before_class
|
@before_class
|
||||||
def test_set_up(self):
|
def test_set_up(self):
|
||||||
self.set_up()
|
self.set_up()
|
||||||
assert_true(hasattr(self, 'dbaas'))
|
asserts.assert_true(hasattr(self, 'dbaas'))
|
||||||
assert_true(self.dbaas is not None)
|
asserts.assert_true(self.dbaas is not None)
|
||||||
|
|
||||||
@test
|
@test
|
||||||
def test_ensure_mysql_is_running(self):
|
def test_ensure_mysql_is_running(self):
|
||||||
@ -412,7 +412,7 @@ class ResizeInstanceTest(ActionTestBase):
|
|||||||
instance = self.instance
|
instance = self.instance
|
||||||
if instance.status == "RESIZE":
|
if instance.status == "RESIZE":
|
||||||
return False
|
return False
|
||||||
assert_equal("ACTIVE", instance.status)
|
asserts.assert_equal("ACTIVE", instance.status)
|
||||||
return True
|
return True
|
||||||
poll_until(is_finished_resizing, time_out=TIME_OUT_TIME)
|
poll_until(is_finished_resizing, time_out=TIME_OUT_TIME)
|
||||||
|
|
||||||
@ -421,13 +421,13 @@ class ResizeInstanceTest(ActionTestBase):
|
|||||||
self.set_up()
|
self.set_up()
|
||||||
if USE_IP:
|
if USE_IP:
|
||||||
self.connection.connect()
|
self.connection.connect()
|
||||||
assert_true(self.connection.is_connected(),
|
asserts.assert_true(self.connection.is_connected(),
|
||||||
"Should be able to connect before resize.")
|
"Should be able to connect before resize.")
|
||||||
self.user_was_deleted = False
|
self.user_was_deleted = False
|
||||||
|
|
||||||
@test
|
@test
|
||||||
def test_instance_resize_same_size_should_fail(self):
|
def test_instance_resize_same_size_should_fail(self):
|
||||||
assert_raises(BadRequest, self.dbaas.instances.resize_instance,
|
asserts.assert_raises(BadRequest, self.dbaas.instances.resize_instance,
|
||||||
self.instance_id, self.flavor_id)
|
self.instance_id, self.flavor_id)
|
||||||
|
|
||||||
@test(enabled=VOLUME_SUPPORT)
|
@test(enabled=VOLUME_SUPPORT)
|
||||||
@ -439,11 +439,12 @@ class ResizeInstanceTest(ActionTestBase):
|
|||||||
def is_active():
|
def is_active():
|
||||||
return self.instance.status == 'ACTIVE'
|
return self.instance.status == 'ACTIVE'
|
||||||
poll_until(is_active, time_out=TIME_OUT_TIME)
|
poll_until(is_active, time_out=TIME_OUT_TIME)
|
||||||
assert_equal(self.instance.status, 'ACTIVE')
|
asserts.assert_equal(self.instance.status, 'ACTIVE')
|
||||||
|
|
||||||
self.get_flavor_href(
|
self.get_flavor_href(
|
||||||
flavor_id=self.expected_old_flavor_id)
|
flavor_id=self.expected_old_flavor_id)
|
||||||
assert_raises(HTTPNotImplemented, self.dbaas.instances.resize_instance,
|
asserts.assert_raises(HTTPNotImplemented,
|
||||||
|
self.dbaas.instances.resize_instance,
|
||||||
self.instance_id, flavors[0].id)
|
self.instance_id, flavors[0].id)
|
||||||
|
|
||||||
@test(enabled=EPHEMERAL_SUPPORT)
|
@test(enabled=EPHEMERAL_SUPPORT)
|
||||||
@ -451,7 +452,7 @@ class ResizeInstanceTest(ActionTestBase):
|
|||||||
flavor_name = CONFIG.values.get('instance_bigger_flavor_name',
|
flavor_name = CONFIG.values.get('instance_bigger_flavor_name',
|
||||||
'm1-small')
|
'm1-small')
|
||||||
flavors = self.dbaas.find_flavors_by_name(flavor_name)
|
flavors = self.dbaas.find_flavors_by_name(flavor_name)
|
||||||
assert_raises(BadRequest, self.dbaas.instances.resize_instance,
|
asserts.assert_raises(BadRequest, self.dbaas.instances.resize_instance,
|
||||||
self.instance_id, flavors[0].id)
|
self.instance_id, flavors[0].id)
|
||||||
|
|
||||||
def obtain_flavor_ids(self):
|
def obtain_flavor_ids(self):
|
||||||
@ -466,14 +467,17 @@ class ResizeInstanceTest(ActionTestBase):
|
|||||||
flavor_name = CONFIG.values.get('instance_bigger_flavor_name',
|
flavor_name = CONFIG.values.get('instance_bigger_flavor_name',
|
||||||
'm1.small')
|
'm1.small')
|
||||||
flavors = self.dbaas.find_flavors_by_name(flavor_name)
|
flavors = self.dbaas.find_flavors_by_name(flavor_name)
|
||||||
assert_equal(len(flavors), 1, "Number of flavors with name '%s' "
|
asserts.assert_equal(len(flavors), 1,
|
||||||
"found was '%d'." % (flavor_name, len(flavors)))
|
"Number of flavors with name '%s' "
|
||||||
|
"found was '%d'." % (flavor_name,
|
||||||
|
len(flavors)))
|
||||||
flavor = flavors[0]
|
flavor = flavors[0]
|
||||||
self.old_dbaas_flavor = instance_info.dbaas_flavor
|
self.old_dbaas_flavor = instance_info.dbaas_flavor
|
||||||
instance_info.dbaas_flavor = flavor
|
instance_info.dbaas_flavor = flavor
|
||||||
assert_true(flavor is not None, "Flavor '%s' not found!" % flavor_name)
|
asserts.assert_true(flavor is not None,
|
||||||
|
"Flavor '%s' not found!" % flavor_name)
|
||||||
flavor_href = self.dbaas.find_flavor_self_href(flavor)
|
flavor_href = self.dbaas.find_flavor_self_href(flavor)
|
||||||
assert_true(flavor_href is not None,
|
asserts.assert_true(flavor_href is not None,
|
||||||
"Flavor href '%s' not found!" % flavor_name)
|
"Flavor href '%s' not found!" % flavor_name)
|
||||||
self.expected_new_flavor_id = flavor.id
|
self.expected_new_flavor_id = flavor.id
|
||||||
|
|
||||||
@ -484,7 +488,7 @@ class ResizeInstanceTest(ActionTestBase):
|
|||||||
self.dbaas.instances.resize_instance(
|
self.dbaas.instances.resize_instance(
|
||||||
self.instance_id,
|
self.instance_id,
|
||||||
self.get_flavor_href(flavor_id=self.expected_new_flavor_id))
|
self.get_flavor_href(flavor_id=self.expected_new_flavor_id))
|
||||||
assert_equal(202, self.dbaas.last_http_code)
|
asserts.assert_equal(202, self.dbaas.last_http_code)
|
||||||
|
|
||||||
#(WARNING) IF THE RESIZE IS WAY TOO FAST THIS WILL FAIL
|
#(WARNING) IF THE RESIZE IS WAY TOO FAST THIS WILL FAIL
|
||||||
assert_unprocessable(
|
assert_unprocessable(
|
||||||
@ -535,7 +539,7 @@ class ResizeInstanceTest(ActionTestBase):
|
|||||||
def test_instance_has_new_flavor_after_resize(self):
|
def test_instance_has_new_flavor_after_resize(self):
|
||||||
actual = self.get_flavor_href(self.instance.flavor['id'])
|
actual = self.get_flavor_href(self.instance.flavor['id'])
|
||||||
expected = self.get_flavor_href(flavor_id=self.expected_new_flavor_id)
|
expected = self.get_flavor_href(flavor_id=self.expected_new_flavor_id)
|
||||||
assert_equal(actual, expected)
|
asserts.assert_equal(actual, expected)
|
||||||
|
|
||||||
@test(depends_on=[test_instance_has_new_flavor_after_resize])
|
@test(depends_on=[test_instance_has_new_flavor_after_resize])
|
||||||
@time_out(TIME_OUT_TIME)
|
@time_out(TIME_OUT_TIME)
|
||||||
@ -545,17 +549,17 @@ class ResizeInstanceTest(ActionTestBase):
|
|||||||
def is_active():
|
def is_active():
|
||||||
return self.instance.status == 'ACTIVE'
|
return self.instance.status == 'ACTIVE'
|
||||||
poll_until(is_active, time_out=TIME_OUT_TIME)
|
poll_until(is_active, time_out=TIME_OUT_TIME)
|
||||||
assert_equal(self.instance.status, 'ACTIVE')
|
asserts.assert_equal(self.instance.status, 'ACTIVE')
|
||||||
|
|
||||||
old_flavor_href = self.get_flavor_href(
|
old_flavor_href = self.get_flavor_href(
|
||||||
flavor_id=self.expected_old_flavor_id)
|
flavor_id=self.expected_old_flavor_id)
|
||||||
|
|
||||||
self.dbaas.instances.resize_instance(self.instance_id, old_flavor_href)
|
self.dbaas.instances.resize_instance(self.instance_id, old_flavor_href)
|
||||||
assert_equal(202, self.dbaas.last_http_code)
|
asserts.assert_equal(202, self.dbaas.last_http_code)
|
||||||
self.old_dbaas_flavor = instance_info.dbaas_flavor
|
self.old_dbaas_flavor = instance_info.dbaas_flavor
|
||||||
instance_info.dbaas_flavor = expected_dbaas_flavor
|
instance_info.dbaas_flavor = expected_dbaas_flavor
|
||||||
self.wait_for_resize()
|
self.wait_for_resize()
|
||||||
assert_equal(str(self.instance.flavor['id']),
|
asserts.assert_equal(str(self.instance.flavor['id']),
|
||||||
str(self.expected_old_flavor_id))
|
str(self.expected_old_flavor_id))
|
||||||
|
|
||||||
@test(depends_on=[test_resize_down],
|
@test(depends_on=[test_resize_down],
|
||||||
@ -617,7 +621,7 @@ class ResizeInstanceVolume(ActionTestBase):
|
|||||||
|
|
||||||
poll_until(check_resize_status, sleep_time=2, time_out=300)
|
poll_until(check_resize_status, sleep_time=2, time_out=300)
|
||||||
instance = instance_info.dbaas.instances.get(instance_info.id)
|
instance = instance_info.dbaas.instances.get(instance_info.id)
|
||||||
assert_equal(instance.volume['size'], self.new_volume_size)
|
asserts.assert_equal(instance.volume['size'], self.new_volume_size)
|
||||||
|
|
||||||
@test(depends_on=[test_volume_resize_success], groups=["dbaas.usage"])
|
@test(depends_on=[test_volume_resize_success], groups=["dbaas.usage"])
|
||||||
def test_resize_volume_usage_event_sent(self):
|
def test_resize_volume_usage_event_sent(self):
|
||||||
@ -663,7 +667,7 @@ class UpdateGuest(object):
|
|||||||
"""Make sure we have the old version before proceeding."""
|
"""Make sure we have the old version before proceeding."""
|
||||||
self.old_version = self.get_version()
|
self.old_version = self.get_version()
|
||||||
self.next_version = UPDATE_GUEST_CONF["next-version"]
|
self.next_version = UPDATE_GUEST_CONF["next-version"]
|
||||||
assert_not_equal(self.old_version, self.next_version)
|
asserts.assert_not_equal(self.old_version, self.next_version)
|
||||||
|
|
||||||
@test(enabled=UPDATE_GUEST_CONF is not None)
|
@test(enabled=UPDATE_GUEST_CONF is not None)
|
||||||
def upload_update_to_repo(self):
|
def upload_update_to_repo(self):
|
||||||
|
@ -20,7 +20,7 @@ import time
|
|||||||
|
|
||||||
from proboscis import before_class
|
from proboscis import before_class
|
||||||
from proboscis import test
|
from proboscis import test
|
||||||
from proboscis.asserts import *
|
from proboscis import asserts
|
||||||
from proboscis.decorators import time_out
|
from proboscis.decorators import time_out
|
||||||
|
|
||||||
from troveclient.compat import exceptions
|
from troveclient.compat import exceptions
|
||||||
@ -74,12 +74,12 @@ class TestBase(object):
|
|||||||
instance = self.dbaas.instances.get(instance_id)
|
instance = self.dbaas.instances.get(instance_id)
|
||||||
instance.delete()
|
instance.delete()
|
||||||
if assert_deleted:
|
if assert_deleted:
|
||||||
assert_true(self.is_instance_deleted(instance_id))
|
asserts.assert_true(self.is_instance_deleted(instance_id))
|
||||||
|
|
||||||
def delete_errored_instance(self, instance_id):
|
def delete_errored_instance(self, instance_id):
|
||||||
self.wait_for_instance_status(instance_id, 'ERROR')
|
self.wait_for_instance_status(instance_id, 'ERROR')
|
||||||
status, desc = self.get_task_info(instance_id)
|
status, desc = self.get_task_info(instance_id)
|
||||||
assert_equal(status, "ERROR")
|
asserts.assert_equal(status, "ERROR")
|
||||||
self.delete_instance(instance_id)
|
self.delete_instance(instance_id)
|
||||||
|
|
||||||
|
|
||||||
@ -130,13 +130,15 @@ class ErroredInstanceDelete(TestBase):
|
|||||||
self.wait_for_instance_status(id, 'ACTIVE')
|
self.wait_for_instance_status(id, 'ACTIVE')
|
||||||
self.wait_for_instance_task_status(id, 'No tasks for the instance.')
|
self.wait_for_instance_task_status(id, 'No tasks for the instance.')
|
||||||
instance = self.dbaas.management.show(id)
|
instance = self.dbaas.management.show(id)
|
||||||
assert_equal(instance.status, "ACTIVE")
|
asserts.assert_equal(instance.status, "ACTIVE")
|
||||||
assert_equal(instance.task_description, 'No tasks for the instance.')
|
asserts.assert_equal(instance.task_description,
|
||||||
|
'No tasks for the instance.')
|
||||||
# Try to delete the instance. This fails the first time due to how
|
# Try to delete the instance. This fails the first time due to how
|
||||||
# the test fake is setup.
|
# the test fake is setup.
|
||||||
self.delete_instance(id, assert_deleted=False)
|
self.delete_instance(id, assert_deleted=False)
|
||||||
instance = self.dbaas.management.show(id)
|
instance = self.dbaas.management.show(id)
|
||||||
assert_equal(instance.status, "SHUTDOWN")
|
asserts.assert_equal(instance.status, "SHUTDOWN")
|
||||||
assert_equal(instance.task_description, "Deleting the instance.")
|
asserts.assert_equal(instance.task_description,
|
||||||
|
"Deleting the instance.")
|
||||||
# Try a second time. This will succeed.
|
# Try a second time. This will succeed.
|
||||||
self.delete_instance(id)
|
self.delete_instance(id)
|
||||||
|
@ -19,7 +19,7 @@ Extra tests to create an instance, shut down MySQL, and delete it.
|
|||||||
from proboscis.decorators import time_out
|
from proboscis.decorators import time_out
|
||||||
from proboscis import before_class
|
from proboscis import before_class
|
||||||
from proboscis import test
|
from proboscis import test
|
||||||
from proboscis.asserts import *
|
from proboscis import asserts
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
@ -56,7 +56,7 @@ class TestBase(object):
|
|||||||
# Get the resize to flavor.
|
# Get the resize to flavor.
|
||||||
flavors2 = self.client.find_flavors_by_name(flavor2_name)
|
flavors2 = self.client.find_flavors_by_name(flavor2_name)
|
||||||
self.new_flavor_id = flavors2[0].id
|
self.new_flavor_id = flavors2[0].id
|
||||||
assert_not_equal(self.flavor_id, self.new_flavor_id)
|
asserts.assert_not_equal(self.flavor_id, self.new_flavor_id)
|
||||||
|
|
||||||
def _wait_for_active(self):
|
def _wait_for_active(self):
|
||||||
poll_until(lambda: self.client.instances.get(self.id),
|
poll_until(lambda: self.client.instances.get(self.id),
|
||||||
@ -115,7 +115,7 @@ class TestBase(object):
|
|||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
instance = self.client.instances.get(self.id)
|
instance = self.client.instances.get(self.id)
|
||||||
assert_equal("SHUTDOWN", instance.status)
|
asserts.assert_equal("SHUTDOWN", instance.status)
|
||||||
except exceptions.NotFound:
|
except exceptions.NotFound:
|
||||||
break
|
break
|
||||||
time.sleep(0.25)
|
time.sleep(0.25)
|
||||||
|
@ -19,7 +19,7 @@ from nose.plugins.skip import SkipTest
|
|||||||
from proboscis import after_class
|
from proboscis import after_class
|
||||||
from proboscis import before_class
|
from proboscis import before_class
|
||||||
from proboscis import test
|
from proboscis import test
|
||||||
from proboscis.asserts import *
|
from proboscis import asserts
|
||||||
from proboscis.decorators import time_out
|
from proboscis.decorators import time_out
|
||||||
|
|
||||||
from trove import tests
|
from trove import tests
|
||||||
@ -46,29 +46,29 @@ class AccountsBeforeInstanceCreation(object):
|
|||||||
@test
|
@test
|
||||||
def test_invalid_account(self):
|
def test_invalid_account(self):
|
||||||
raise SkipTest("Don't have a good way to know if accounts are valid.")
|
raise SkipTest("Don't have a good way to know if accounts are valid.")
|
||||||
assert_raises(exceptions.NotFound, self.client.accounts.show,
|
asserts.assert_raises(exceptions.NotFound, self.client.accounts.show,
|
||||||
"asd#4#@fasdf")
|
"asd#4#@fasdf")
|
||||||
|
|
||||||
@test
|
@test
|
||||||
def test_invalid_account_fails(self):
|
def test_invalid_account_fails(self):
|
||||||
account_info = self.client.accounts.show("badaccount")
|
account_info = self.client.accounts.show("badaccount")
|
||||||
assert_not_equal(self.user.tenant_id, account_info.id)
|
asserts.assert_not_equal(self.user.tenant_id, account_info.id)
|
||||||
|
|
||||||
@test
|
@test
|
||||||
def test_account_zero_instances(self):
|
def test_account_zero_instances(self):
|
||||||
account_info = self.client.accounts.show(self.user.tenant_id)
|
account_info = self.client.accounts.show(self.user.tenant_id)
|
||||||
expected_instances = 0 if not existing_instance() else 1
|
expected_instances = 0 if not existing_instance() else 1
|
||||||
assert_equal(expected_instances, len(account_info.instances))
|
asserts.assert_equal(expected_instances, len(account_info.instances))
|
||||||
expected = self.user.tenant_id
|
expected = self.user.tenant_id
|
||||||
if expected is None:
|
if expected is None:
|
||||||
expected = "None"
|
expected = "None"
|
||||||
assert_equal(expected, account_info.id)
|
asserts.assert_equal(expected, account_info.id)
|
||||||
|
|
||||||
@test
|
@test
|
||||||
def test_list_empty_accounts(self):
|
def test_list_empty_accounts(self):
|
||||||
accounts_info = self.client.accounts.index()
|
accounts_info = self.client.accounts.index()
|
||||||
expected_accounts = 0 if not existing_instance() else 1
|
expected_accounts = 0 if not existing_instance() else 1
|
||||||
assert_equal(expected_accounts, len(accounts_info.accounts))
|
asserts.assert_equal(expected_accounts, len(accounts_info.accounts))
|
||||||
|
|
||||||
|
|
||||||
@test(groups=[tests.INSTANCES, GROUP], depends_on_groups=["dbaas.listing"])
|
@test(groups=[tests.INSTANCES, GROUP], depends_on_groups=["dbaas.listing"])
|
||||||
@ -90,27 +90,27 @@ class AccountsAfterInstanceCreation(object):
|
|||||||
expected = "None"
|
expected = "None"
|
||||||
print("account_id.id = '%s'" % account_info.id)
|
print("account_id.id = '%s'" % account_info.id)
|
||||||
print("expected = '%s'" % expected)
|
print("expected = '%s'" % expected)
|
||||||
assert_equal(account_info.id, expected)
|
asserts.assert_equal(account_info.id, expected)
|
||||||
# Instances: Here we know we've only created one instance.
|
# Instances: Here we know we've only created one instance.
|
||||||
assert_equal(1, len(account_info.instances))
|
asserts.assert_equal(1, len(account_info.instances))
|
||||||
assert_is_not_none(account_info.instances[0]['host'])
|
asserts.assert_is_not_none(account_info.instances[0]['host'])
|
||||||
# We know the there's only 1 instance
|
# We know the there's only 1 instance
|
||||||
instance = account_info.instances[0]
|
instance = account_info.instances[0]
|
||||||
print("instances in account: %s" % instance)
|
print("instances in account: %s" % instance)
|
||||||
assert_equal(instance['id'], instance_info.id)
|
asserts.assert_equal(instance['id'], instance_info.id)
|
||||||
assert_equal(instance['name'], instance_info.name)
|
asserts.assert_equal(instance['name'], instance_info.name)
|
||||||
assert_equal(instance['status'], "ACTIVE")
|
asserts.assert_equal(instance['status'], "ACTIVE")
|
||||||
assert_is_not_none(instance['host'])
|
asserts.assert_is_not_none(instance['host'])
|
||||||
|
|
||||||
@test
|
@test
|
||||||
def test_list_accounts(self):
|
def test_list_accounts(self):
|
||||||
if test_config.auth_strategy == "fake":
|
if test_config.auth_strategy == "fake":
|
||||||
raise SkipTest("Skipping this as auth is faked anyway.")
|
raise SkipTest("Skipping this as auth is faked anyway.")
|
||||||
accounts_info = self.client.accounts.index()
|
accounts_info = self.client.accounts.index()
|
||||||
assert_equal(1, len(accounts_info.accounts))
|
asserts.assert_equal(1, len(accounts_info.accounts))
|
||||||
account = accounts_info.accounts[0]
|
account = accounts_info.accounts[0]
|
||||||
assert_equal(1, account['num_instances'])
|
asserts.assert_equal(1, account['num_instances'])
|
||||||
assert_equal(instance_info.user.tenant_id, account['id'])
|
asserts.assert_equal(instance_info.user.tenant_id, account['id'])
|
||||||
|
|
||||||
|
|
||||||
@test(groups=[tests.POST_INSTANCES, GROUP],
|
@test(groups=[tests.POST_INSTANCES, GROUP],
|
||||||
@ -125,7 +125,7 @@ class AccountsAfterInstanceDeletion(object):
|
|||||||
@test
|
@test
|
||||||
def test_no_details_empty_account(self):
|
def test_no_details_empty_account(self):
|
||||||
account_info = self.client.accounts.show(instance_info.user.tenant_id)
|
account_info = self.client.accounts.show(instance_info.user.tenant_id)
|
||||||
assert_equal(0, len(account_info.instances))
|
asserts.assert_equal(0, len(account_info.instances))
|
||||||
|
|
||||||
|
|
||||||
@test(groups=["fake.dbaas.api.mgmt.allaccounts"],
|
@test(groups=["fake.dbaas.api.mgmt.allaccounts"],
|
||||||
@ -170,8 +170,8 @@ class AllAccounts(object):
|
|||||||
def test_list_accounts_with_multiple_users(self):
|
def test_list_accounts_with_multiple_users(self):
|
||||||
accounts_info = self.admin_client.accounts.index()
|
accounts_info = self.admin_client.accounts.index()
|
||||||
for account in accounts_info.accounts:
|
for account in accounts_info.accounts:
|
||||||
assert_true(account['id'] in self.user_tenant_ids)
|
asserts.assert_true(account['id'] in self.user_tenant_ids)
|
||||||
assert_equal(self.max, account['num_instances'])
|
asserts.assert_equal(self.max, account['num_instances'])
|
||||||
|
|
||||||
@after_class(always_run=True)
|
@after_class(always_run=True)
|
||||||
@time_out(60)
|
@time_out(60)
|
||||||
@ -203,7 +203,7 @@ class AccountWithBrokenInstance(object):
|
|||||||
self.instance = self.client.instances.get(self.response.id)
|
self.instance = self.client.instances.get(self.response.id)
|
||||||
print("Status: %s" % self.instance.status)
|
print("Status: %s" % self.instance.status)
|
||||||
msg = "Instance did not drop to error after server prov failure."
|
msg = "Instance did not drop to error after server prov failure."
|
||||||
assert_equal(self.instance.status, "ERROR", msg)
|
asserts.assert_equal(self.instance.status, "ERROR", msg)
|
||||||
|
|
||||||
@test
|
@test
|
||||||
def no_compute_instance_no_problem(self):
|
def no_compute_instance_no_problem(self):
|
||||||
@ -213,12 +213,12 @@ class AccountWithBrokenInstance(object):
|
|||||||
account_info = self.client.accounts.show(self.user.tenant_id)
|
account_info = self.client.accounts.show(self.user.tenant_id)
|
||||||
# All we care about is that accounts.show doesn't 500 on us
|
# All we care about is that accounts.show doesn't 500 on us
|
||||||
# for having a broken instance in the roster.
|
# for having a broken instance in the roster.
|
||||||
assert_equal(len(account_info.instances), 1)
|
asserts.assert_equal(len(account_info.instances), 1)
|
||||||
instance = account_info.instances[0]
|
instance = account_info.instances[0]
|
||||||
assert_true(isinstance(instance['id'], basestring))
|
asserts.assert_true(isinstance(instance['id'], basestring))
|
||||||
assert_equal(len(instance['id']), 36)
|
asserts.assert_equal(len(instance['id']), 36)
|
||||||
assert_equal(instance['name'], self.name)
|
asserts.assert_equal(instance['name'], self.name)
|
||||||
assert_equal(instance['status'], "ERROR")
|
asserts.assert_equal(instance['status'], "ERROR")
|
||||||
assert_is_none(instance['host'])
|
assert_is_none(instance['host'])
|
||||||
|
|
||||||
@after_class
|
@after_class
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
from collections import deque
|
from collections import deque
|
||||||
from proboscis import test
|
from proboscis import test
|
||||||
from proboscis.asserts import *
|
from proboscis import asserts
|
||||||
from proboscis import after_class
|
from proboscis import after_class
|
||||||
from proboscis import before_class
|
from proboscis import before_class
|
||||||
import troveclient.compat
|
import troveclient.compat
|
||||||
@ -63,19 +63,20 @@ class MalformedJson(object):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
resp, body = self.dbaas.client.last_response
|
resp, body = self.dbaas.client.last_response
|
||||||
httpCode = resp.status
|
httpCode = resp.status
|
||||||
assert_equal(httpCode, 400,
|
asserts.assert_equal(httpCode, 400,
|
||||||
"Create instance failed with code %s, exception %s"
|
"Create instance failed with code %s,"
|
||||||
% (httpCode, e))
|
" exception %s" % (httpCode, e))
|
||||||
if not isinstance(self.dbaas.client,
|
if not isinstance(self.dbaas.client,
|
||||||
troveclient.compat.xml.TroveXmlClient):
|
troveclient.compat.xml.TroveXmlClient):
|
||||||
databases = "u'foo'"
|
databases = "u'foo'"
|
||||||
users = "u'bar'"
|
users = "u'bar'"
|
||||||
assert_equal(e.message,
|
asserts.assert_equal(e.message,
|
||||||
"Validation error: "
|
"Validation error: "
|
||||||
"instance['databases'] %s is not of type 'array';"
|
"instance['databases'] %s is not of type"
|
||||||
" instance['users'] %s is not of type 'array'; "
|
" 'array'; instance['users'] %s is not of"
|
||||||
"instance['volume'] 3 is not of type 'object'" %
|
" type 'array'; instance['volume'] 3 is "
|
||||||
(databases, users))
|
"not of type 'object'"
|
||||||
|
% (databases, users))
|
||||||
|
|
||||||
@test
|
@test
|
||||||
def test_bad_database_data(self):
|
def test_bad_database_data(self):
|
||||||
@ -86,13 +87,13 @@ class MalformedJson(object):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
resp, body = self.dbaas.client.last_response
|
resp, body = self.dbaas.client.last_response
|
||||||
httpCode = resp.status
|
httpCode = resp.status
|
||||||
assert_equal(httpCode, 400,
|
asserts.assert_equal(httpCode, 400,
|
||||||
"Create database failed with code %s, exception %s"
|
"Create database failed with code %s, "
|
||||||
% (httpCode, e))
|
"exception %s" % (httpCode, e))
|
||||||
if not isinstance(self.dbaas.client,
|
if not isinstance(self.dbaas.client,
|
||||||
troveclient.compat.xml.TroveXmlClient):
|
troveclient.compat.xml.TroveXmlClient):
|
||||||
_bad_db_data = "u'{foo}'"
|
_bad_db_data = "u'{foo}'"
|
||||||
assert_equal(e.message,
|
asserts.assert_equal(e.message,
|
||||||
"Validation error: "
|
"Validation error: "
|
||||||
"databases %s is not of type 'array'" %
|
"databases %s is not of type 'array'" %
|
||||||
_bad_db_data)
|
_bad_db_data)
|
||||||
@ -115,15 +116,15 @@ class MalformedJson(object):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
resp, body = self.dbaas.client.last_response
|
resp, body = self.dbaas.client.last_response
|
||||||
httpCode = resp.status
|
httpCode = resp.status
|
||||||
assert_equal(httpCode, 400,
|
asserts.assert_equal(httpCode, 400,
|
||||||
"Create user failed with code %s, exception %s"
|
"Create user failed with code %s, "
|
||||||
% (httpCode, e))
|
"exception %s" % (httpCode, e))
|
||||||
err_1 = format_path(deque(('users', 0)))
|
err_1 = format_path(deque(('users', 0)))
|
||||||
assert_equal(e.message,
|
asserts.assert_equal(e.message,
|
||||||
"Validation error: "
|
"Validation error: "
|
||||||
"%(err_1)s 'name' is a required property; "
|
"%(err_1)s 'name' is a required property; "
|
||||||
"%(err_1)s 'password' is a required property" %
|
"%(err_1)s 'password' is a required property"
|
||||||
{'err_1': err_1})
|
% {'err_1': err_1})
|
||||||
|
|
||||||
@test
|
@test
|
||||||
def test_bad_resize_instance_data(self):
|
def test_bad_resize_instance_data(self):
|
||||||
@ -140,9 +141,9 @@ class MalformedJson(object):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
resp, body = self.dbaas.client.last_response
|
resp, body = self.dbaas.client.last_response
|
||||||
httpCode = resp.status
|
httpCode = resp.status
|
||||||
assert_equal(httpCode, 400,
|
asserts.assert_equal(httpCode, 400,
|
||||||
"Resize instance failed with code %s, exception %s"
|
"Resize instance failed with code %s, "
|
||||||
% (httpCode, e))
|
"exception %s" % (httpCode, e))
|
||||||
|
|
||||||
@test
|
@test
|
||||||
def test_bad_resize_vol_data(self):
|
def test_bad_resize_vol_data(self):
|
||||||
@ -160,15 +161,15 @@ class MalformedJson(object):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
resp, body = self.dbaas.client.last_response
|
resp, body = self.dbaas.client.last_response
|
||||||
httpCode = resp.status
|
httpCode = resp.status
|
||||||
assert_equal(httpCode, 400,
|
asserts.assert_equal(httpCode, 400,
|
||||||
"Resize instance failed with code %s, exception %s"
|
"Resize instance failed with code %s, "
|
||||||
% (httpCode, e))
|
"exception %s" % (httpCode, e))
|
||||||
data = "u'bad data'"
|
data = "u'bad data'"
|
||||||
assert_equal(e.message,
|
asserts.assert_equal(e.message,
|
||||||
"Validation error: "
|
"Validation error: "
|
||||||
"resize['volume']['size'] %s "
|
"resize['volume']['size'] %s "
|
||||||
"is not valid under any of the given schemas; "
|
"is not valid under any of the given schemas;"
|
||||||
"%s is not of type 'integer'; "
|
" %s is not of type 'integer'; "
|
||||||
"%s does not match '[0-9]+'" %
|
"%s does not match '[0-9]+'" %
|
||||||
(data, data, data))
|
(data, data, data))
|
||||||
|
|
||||||
@ -190,19 +191,19 @@ class MalformedJson(object):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
resp, body = self.dbaas.client.last_response
|
resp, body = self.dbaas.client.last_response
|
||||||
httpCode = resp.status
|
httpCode = resp.status
|
||||||
assert_equal(httpCode, 400,
|
asserts.assert_equal(httpCode, 400,
|
||||||
"Change usr/passwd failed with code %s, exception %s"
|
"Change usr/passwd failed with code %s, "
|
||||||
% (httpCode, e))
|
"exception %s" % (httpCode, e))
|
||||||
if not isinstance(self.dbaas.client,
|
if not isinstance(self.dbaas.client,
|
||||||
troveclient.compat.xml.TroveXmlClient):
|
troveclient.compat.xml.TroveXmlClient):
|
||||||
password = "u''"
|
password = "u''"
|
||||||
assert_equal(e.message,
|
asserts.assert_equal(e.message,
|
||||||
"Validation error: "
|
"Validation error: users[0] 'password' is"
|
||||||
"users[0] 'password' is a required property; "
|
" a required property; "
|
||||||
"users[0]['name'] %s is too short; "
|
"users[0]['name'] %s is too short; "
|
||||||
"users[0]['name'] %s does not match "
|
"users[0]['name'] %s does not match "
|
||||||
"'^.*[0-9a-zA-Z]+.*$'" %
|
"'^.*[0-9a-zA-Z]+.*$'"
|
||||||
(password, password))
|
% (password, password))
|
||||||
|
|
||||||
@test
|
@test
|
||||||
def test_bad_grant_user_access(self):
|
def test_bad_grant_user_access(self):
|
||||||
@ -221,10 +222,9 @@ class MalformedJson(object):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
resp, body = self.dbaas.client.last_response
|
resp, body = self.dbaas.client.last_response
|
||||||
httpCode = resp.status
|
httpCode = resp.status
|
||||||
assert_equal(httpCode, 400,
|
asserts.assert_equal(httpCode, 400,
|
||||||
"Grant user access failed with code %s, exception "
|
"Grant user access failed with code %s, "
|
||||||
"%s" %
|
"exception %s" % (httpCode, e))
|
||||||
(httpCode, e))
|
|
||||||
|
|
||||||
@test
|
@test
|
||||||
def test_bad_revoke_user_access(self):
|
def test_bad_revoke_user_access(self):
|
||||||
@ -243,10 +243,10 @@ class MalformedJson(object):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
resp, body = self.dbaas.client.last_response
|
resp, body = self.dbaas.client.last_response
|
||||||
httpCode = resp.status
|
httpCode = resp.status
|
||||||
assert_equal(httpCode, 404,
|
asserts.assert_equal(httpCode, 404,
|
||||||
"Revoke user access failed w/code %s, exception %s" %
|
"Revoke user access failed w/code %s, "
|
||||||
(httpCode, e))
|
"exception %s" % (httpCode, e))
|
||||||
assert_equal(e.message, "The resource could not be found.")
|
asserts.assert_equal(e.message, "The resource could not be found.")
|
||||||
|
|
||||||
@test
|
@test
|
||||||
def test_bad_body_flavorid_create_instance(self):
|
def test_bad_body_flavorid_create_instance(self):
|
||||||
@ -260,21 +260,21 @@ class MalformedJson(object):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
resp, body = self.dbaas.client.last_response
|
resp, body = self.dbaas.client.last_response
|
||||||
httpCode = resp.status
|
httpCode = resp.status
|
||||||
assert_equal(httpCode, 400,
|
asserts.assert_equal(httpCode, 400,
|
||||||
"Create instance failed with code %s, exception %s" %
|
"Create instance failed with code %s, "
|
||||||
(httpCode, e))
|
"exception %s" % (httpCode, e))
|
||||||
|
|
||||||
if not isinstance(self.dbaas.client,
|
if not isinstance(self.dbaas.client,
|
||||||
troveclient.compat.xml.TroveXmlClient):
|
troveclient.compat.xml.TroveXmlClient):
|
||||||
flavorId = [u'?']
|
flavorId = [u'?']
|
||||||
assert_equal(e.message,
|
asserts.assert_equal(e.message,
|
||||||
"Validation error: "
|
"Validation error: "
|
||||||
"instance['flavorRef'] %s is not valid under any "
|
"instance['flavorRef'] %s is not valid "
|
||||||
"of the given schemas; "
|
"under any of the given schemas; %s is "
|
||||||
"%s is not of type 'string'; "
|
"not of type 'string'; %s is not of type"
|
||||||
"%s is not of type 'string'; "
|
" 'string'; %s is not of type 'integer'; "
|
||||||
"%s is not of type 'integer'; "
|
"instance['volume'] 2 is not of"
|
||||||
"instance['volume'] 2 is not of type 'object'" %
|
" type 'object'" %
|
||||||
(flavorId, flavorId, flavorId, flavorId))
|
(flavorId, flavorId, flavorId, flavorId))
|
||||||
|
|
||||||
@test
|
@test
|
||||||
@ -291,17 +291,19 @@ class MalformedJson(object):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
resp, body = self.dbaas.client.last_response
|
resp, body = self.dbaas.client.last_response
|
||||||
httpCode = resp.status
|
httpCode = resp.status
|
||||||
assert_equal(httpCode, 400,
|
asserts.assert_equal(httpCode, 400,
|
||||||
"Create instance failed with code %s, exception %s" %
|
"Create instance failed with code %s, "
|
||||||
(httpCode, e))
|
"exception %s" % (httpCode, e))
|
||||||
|
|
||||||
if not isinstance(self.dbaas.client,
|
if not isinstance(self.dbaas.client,
|
||||||
troveclient.compat.xml.TroveXmlClient):
|
troveclient.compat.xml.TroveXmlClient):
|
||||||
assert_equal(e.message,
|
asserts.assert_equal(e.message,
|
||||||
"Validation error: instance['datastore']['type']"
|
"Validation error: "
|
||||||
" u'%s' does not match '^.*[0-9a-zA-Z]+.*$'; "
|
"instance['datastore']['type']"
|
||||||
"instance['datastore']['version'] u'%s' does not"
|
" u'%s' does not match"
|
||||||
" match '^.*[0-9a-zA-Z]+.*$'" %
|
" '^.*[0-9a-zA-Z]+.*$'; "
|
||||||
|
"instance['datastore']['version'] u'%s' "
|
||||||
|
"does not match '^.*[0-9a-zA-Z]+.*$'" %
|
||||||
(datastore, datastore_version))
|
(datastore, datastore_version))
|
||||||
|
|
||||||
@test
|
@test
|
||||||
@ -314,13 +316,13 @@ class MalformedJson(object):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
resp, body = self.dbaas.client.last_response
|
resp, body = self.dbaas.client.last_response
|
||||||
httpCode = resp.status
|
httpCode = resp.status
|
||||||
assert_equal(httpCode, 400,
|
asserts.assert_equal(httpCode, 400,
|
||||||
"Create instance failed with code %s, exception %s" %
|
"Create instance failed with code %s, "
|
||||||
(httpCode, e))
|
"exception %s" % (httpCode, e))
|
||||||
if not isinstance(self.dbaas.client,
|
if not isinstance(self.dbaas.client,
|
||||||
troveclient.compat.xml.TroveXmlClient):
|
troveclient.compat.xml.TroveXmlClient):
|
||||||
volsize = "u'h3ll0'"
|
volsize = "u'h3ll0'"
|
||||||
assert_equal(e.message,
|
asserts.assert_equal(e.message,
|
||||||
"Validation error: "
|
"Validation error: "
|
||||||
"instance['volume'] %s is not of type 'object'" %
|
"instance['volume'] %s is not of "
|
||||||
volsize)
|
"type 'object'" % volsize)
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
from proboscis import test
|
from proboscis import test
|
||||||
from proboscis.asserts import *
|
from proboscis import asserts
|
||||||
from proboscis import after_class
|
from proboscis import after_class
|
||||||
from proboscis import before_class
|
from proboscis import before_class
|
||||||
from proboscis.asserts import Check
|
from proboscis.asserts import Check
|
||||||
@ -34,8 +34,9 @@ class QuotasBase(object):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.user1 = CONFIG.users.find_user(Requirements(is_admin=False))
|
self.user1 = CONFIG.users.find_user(Requirements(is_admin=False))
|
||||||
self.user2 = CONFIG.users.find_user(Requirements(is_admin=False))
|
self.user2 = CONFIG.users.find_user(Requirements(is_admin=False))
|
||||||
assert_not_equal(self.user1.tenant, self.user2.tenant,
|
asserts.assert_not_equal(self.user1.tenant, self.user2.tenant,
|
||||||
"Not enough users to run QuotasTest. Needs >=2.")
|
"Not enough users to run QuotasTest."
|
||||||
|
+ " Needs >=2.")
|
||||||
self.client1 = create_dbaas_client(self.user1)
|
self.client1 = create_dbaas_client(self.user1)
|
||||||
self.client2 = create_dbaas_client(self.user2)
|
self.client2 = create_dbaas_client(self.user2)
|
||||||
self.mgmt_client = create_client(is_admin=True)
|
self.mgmt_client = create_client(is_admin=True)
|
||||||
@ -71,7 +72,7 @@ class DefaultQuotasTest(QuotasBase):
|
|||||||
quotas["instances"])
|
quotas["instances"])
|
||||||
check.equal(CONFIG.trove_max_volumes_per_user,
|
check.equal(CONFIG.trove_max_volumes_per_user,
|
||||||
quotas["volumes"])
|
quotas["volumes"])
|
||||||
assert_equal(len(quotas), 2)
|
asserts.assert_equal(len(quotas), 2)
|
||||||
|
|
||||||
|
|
||||||
@test(groups=["dbaas.api.mgmt.quotas"])
|
@test(groups=["dbaas.api.mgmt.quotas"])
|
||||||
@ -81,7 +82,7 @@ class ChangeInstancesQuota(QuotasBase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(ChangeInstancesQuota, self).setUp()
|
super(ChangeInstancesQuota, self).setUp()
|
||||||
self.mgmt_client.quota.update(self.user1.tenant, {"instances": 0})
|
self.mgmt_client.quota.update(self.user1.tenant, {"instances": 0})
|
||||||
assert_equal(200, self.mgmt_client.last_http_code)
|
asserts.assert_equal(200, self.mgmt_client.last_http_code)
|
||||||
|
|
||||||
@after_class
|
@after_class
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
@ -90,8 +91,9 @@ class ChangeInstancesQuota(QuotasBase):
|
|||||||
@test
|
@test
|
||||||
def check_user2_is_not_affected_on_instances_quota_change(self):
|
def check_user2_is_not_affected_on_instances_quota_change(self):
|
||||||
user2_current_quota = self.mgmt_client.quota.show(self.user2.tenant)
|
user2_current_quota = self.mgmt_client.quota.show(self.user2.tenant)
|
||||||
assert_equal(self.original_quotas2, user2_current_quota,
|
asserts.assert_equal(self.original_quotas2, user2_current_quota,
|
||||||
"Changing one user's quota affected another user's quota."
|
"Changing one user's quota affected another"
|
||||||
|
+ "user's quota."
|
||||||
+ " Original: %s. After Quota Change: %s" %
|
+ " Original: %s. After Quota Change: %s" %
|
||||||
(self.original_quotas2, user2_current_quota))
|
(self.original_quotas2, user2_current_quota))
|
||||||
|
|
||||||
@ -102,17 +104,16 @@ class ChangeInstancesQuota(QuotasBase):
|
|||||||
check.equal(0, quotas["instances"])
|
check.equal(0, quotas["instances"])
|
||||||
check.equal(CONFIG.trove_max_volumes_per_user,
|
check.equal(CONFIG.trove_max_volumes_per_user,
|
||||||
quotas["volumes"])
|
quotas["volumes"])
|
||||||
assert_equal(len(quotas), 2)
|
asserts.assert_equal(len(quotas), 2)
|
||||||
|
|
||||||
@test
|
@test
|
||||||
def create_too_many_instances(self):
|
def create_too_many_instances(self):
|
||||||
flavor, flavor_href = get_standby_instance_flavor(self.client1)
|
flavor, flavor_href = get_standby_instance_flavor(self.client1)
|
||||||
assert_raises(exceptions.OverLimit,
|
asserts.assert_raises(exceptions.OverLimit,
|
||||||
self.client1.instances.create,
|
self.client1.instances.create,
|
||||||
"too_many_instances",
|
"too_many_instances",
|
||||||
flavor_href,
|
flavor_href, {'size': 1})
|
||||||
{'size': 1})
|
asserts.assert_equal(413, self.client1.last_http_code)
|
||||||
assert_equal(413, self.client1.last_http_code)
|
|
||||||
|
|
||||||
|
|
||||||
@test(groups=["dbaas.api.mgmt.quotas"])
|
@test(groups=["dbaas.api.mgmt.quotas"])
|
||||||
@ -122,7 +123,7 @@ class ChangeVolumesQuota(QuotasBase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(ChangeVolumesQuota, self).setUp()
|
super(ChangeVolumesQuota, self).setUp()
|
||||||
self.mgmt_client.quota.update(self.user1.tenant, {"volumes": 0})
|
self.mgmt_client.quota.update(self.user1.tenant, {"volumes": 0})
|
||||||
assert_equal(200, self.mgmt_client.last_http_code)
|
asserts.assert_equal(200, self.mgmt_client.last_http_code)
|
||||||
|
|
||||||
@after_class
|
@after_class
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
@ -131,18 +132,20 @@ class ChangeVolumesQuota(QuotasBase):
|
|||||||
@test
|
@test
|
||||||
def check_volumes_overlimit(self):
|
def check_volumes_overlimit(self):
|
||||||
flavor, flavor_href = get_standby_instance_flavor(self.client1)
|
flavor, flavor_href = get_standby_instance_flavor(self.client1)
|
||||||
assert_raises(exceptions.OverLimit,
|
asserts.assert_raises(exceptions.OverLimit,
|
||||||
self.client1.instances.create,
|
self.client1.instances.create,
|
||||||
"too_large_volume",
|
"too_large_volume",
|
||||||
flavor_href,
|
flavor_href,
|
||||||
{'size': CONFIG.trove_max_accepted_volume_size + 1})
|
{'size': CONFIG.trove_max_accepted_volume_size
|
||||||
assert_equal(413, self.client1.last_http_code)
|
+ 1})
|
||||||
|
asserts.assert_equal(413, self.client1.last_http_code)
|
||||||
|
|
||||||
@test
|
@test
|
||||||
def check_user2_is_not_affected_on_volumes_quota_change(self):
|
def check_user2_is_not_affected_on_volumes_quota_change(self):
|
||||||
user2_current_quota = self.mgmt_client.quota.show(self.user2.tenant)
|
user2_current_quota = self.mgmt_client.quota.show(self.user2.tenant)
|
||||||
assert_equal(self.original_quotas2, user2_current_quota,
|
asserts.assert_equal(self.original_quotas2, user2_current_quota,
|
||||||
"Changing one user's quota affected another user's quota."
|
"Changing one user's quota affected another"
|
||||||
|
+ "user's quota."
|
||||||
+ " Original: %s. After Quota Change: %s" %
|
+ " Original: %s. After Quota Change: %s" %
|
||||||
(self.original_quotas2, user2_current_quota))
|
(self.original_quotas2, user2_current_quota))
|
||||||
|
|
||||||
@ -153,17 +156,18 @@ class ChangeVolumesQuota(QuotasBase):
|
|||||||
check.equal(CONFIG.trove_max_instances_per_user,
|
check.equal(CONFIG.trove_max_instances_per_user,
|
||||||
quotas["instances"])
|
quotas["instances"])
|
||||||
check.equal(0, quotas["volumes"])
|
check.equal(0, quotas["volumes"])
|
||||||
assert_equal(len(quotas), 2)
|
asserts.assert_equal(len(quotas), 2)
|
||||||
|
|
||||||
@test
|
@test
|
||||||
def create_too_large_volume(self):
|
def create_too_large_volume(self):
|
||||||
flavor, flavor_href = get_standby_instance_flavor(self.client1)
|
flavor, flavor_href = get_standby_instance_flavor(self.client1)
|
||||||
assert_raises(exceptions.OverLimit,
|
asserts.assert_raises(exceptions.OverLimit,
|
||||||
self.client1.instances.create,
|
self.client1.instances.create,
|
||||||
"too_large_volume",
|
"too_large_volume",
|
||||||
flavor_href,
|
flavor_href,
|
||||||
{'size': CONFIG.trove_max_accepted_volume_size + 1})
|
{'size': CONFIG.trove_max_accepted_volume_size
|
||||||
assert_equal(413, self.client1.last_http_code)
|
+ 1})
|
||||||
|
asserts.assert_equal(413, self.client1.last_http_code)
|
||||||
|
|
||||||
#create an instance when I set the limit back to
|
#create an instance when I set the limit back to
|
||||||
#multiple updates to the quota and it should do what you expect
|
#multiple updates to the quota and it should do what you expect
|
||||||
|
@ -17,7 +17,7 @@ from nose.plugins.skip import SkipTest
|
|||||||
|
|
||||||
from proboscis import before_class
|
from proboscis import before_class
|
||||||
from proboscis import test
|
from proboscis import test
|
||||||
from proboscis.asserts import *
|
from proboscis import asserts
|
||||||
|
|
||||||
from trove import tests
|
from trove import tests
|
||||||
from trove.tests.api.instances import CheckInstance
|
from trove.tests.api.instances import CheckInstance
|
||||||
@ -46,29 +46,31 @@ class StorageBeforeInstanceCreation(object):
|
|||||||
storage = self.client.storage.index()
|
storage = self.client.storage.index()
|
||||||
print("storage : %r" % storage)
|
print("storage : %r" % storage)
|
||||||
for device in storage:
|
for device in storage:
|
||||||
assert_true(hasattr(device, 'name'),
|
asserts.assert_true(hasattr(device, 'name'),
|
||||||
"device.name: %r" % device.name)
|
"device.name: %r" % device.name)
|
||||||
assert_true(hasattr(device, 'type'),
|
asserts.assert_true(hasattr(device, 'type'),
|
||||||
"device.type: %r" % device.name)
|
"device.type: %r" % device.name)
|
||||||
assert_true(hasattr(device, 'used'),
|
asserts.assert_true(hasattr(device, 'used'),
|
||||||
"device.used: %r" % device.used)
|
"device.used: %r" % device.used)
|
||||||
|
|
||||||
assert_true(hasattr(device, 'provision'),
|
asserts.assert_true(hasattr(device, 'provision'),
|
||||||
"device.provision: %r" % device.provision)
|
"device.provision: %r" % device.provision)
|
||||||
provision = device.provision
|
provision = device.provision
|
||||||
assert_true('available' in provision,
|
asserts.assert_true('available' in provision,
|
||||||
"provision.available: %r" % provision['available'])
|
"provision.available: "
|
||||||
assert_true('percent' in provision,
|
+ "%r" % provision['available'])
|
||||||
|
asserts.assert_true('percent' in provision,
|
||||||
"provision.percent: %r" % provision['percent'])
|
"provision.percent: %r" % provision['percent'])
|
||||||
assert_true('total' in provision,
|
asserts.assert_true('total' in provision,
|
||||||
"provision.total: %r" % provision['total'])
|
"provision.total: %r" % provision['total'])
|
||||||
|
|
||||||
assert_true(hasattr(device, 'capacity'),
|
asserts.assert_true(hasattr(device, 'capacity'),
|
||||||
"device.capacity: %r" % device.capacity)
|
"device.capacity: %r" % device.capacity)
|
||||||
capacity = device.capacity
|
capacity = device.capacity
|
||||||
assert_true('available' in capacity,
|
asserts.assert_true('available' in capacity,
|
||||||
"capacity.available: %r" % capacity['available'])
|
"capacity.available: "
|
||||||
assert_true('total' in capacity,
|
+ "%r" % capacity['available'])
|
||||||
|
asserts.assert_true('total' in capacity,
|
||||||
"capacity.total: %r" % capacity['total'])
|
"capacity.total: %r" % capacity['total'])
|
||||||
instance_info.storage = storage
|
instance_info.storage = storage
|
||||||
|
|
||||||
@ -93,15 +95,21 @@ class StorageAfterInstanceCreation(object):
|
|||||||
for index, device in enumerate(storage):
|
for index, device in enumerate(storage):
|
||||||
CheckInstance(None).attrs_exist(device._info, expected_attrs,
|
CheckInstance(None).attrs_exist(device._info, expected_attrs,
|
||||||
msg="Storage")
|
msg="Storage")
|
||||||
assert_equal(device.name, instance_info.storage[index].name)
|
asserts.assert_equal(device.name,
|
||||||
assert_equal(device.used, instance_info.storage[index].used)
|
instance_info.storage[index].name)
|
||||||
assert_equal(device.type, instance_info.storage[index].type)
|
asserts.assert_equal(device.used,
|
||||||
|
instance_info.storage[index].used)
|
||||||
|
asserts.assert_equal(device.type,
|
||||||
|
instance_info.storage[index].type)
|
||||||
|
|
||||||
provision = instance_info.storage[index].provision
|
provision = instance_info.storage[index].provision
|
||||||
assert_equal(device.provision['available'], provision['available'])
|
asserts.assert_equal(device.provision['available'],
|
||||||
assert_equal(device.provision['percent'], provision['percent'])
|
provision['available'])
|
||||||
assert_equal(device.provision['total'], provision['total'])
|
asserts.assert_equal(device.provision['percent'],
|
||||||
|
provision['percent'])
|
||||||
|
asserts.assert_equal(device.provision['total'], provision['total'])
|
||||||
|
|
||||||
capacity = instance_info.storage[index].capacity
|
capacity = instance_info.storage[index].capacity
|
||||||
assert_equal(device.capacity['available'], capacity['available'])
|
asserts.assert_equal(device.capacity['available'],
|
||||||
assert_equal(device.capacity['total'], capacity['total'])
|
capacity['available'])
|
||||||
|
asserts.assert_equal(device.capacity['total'], capacity['total'])
|
||||||
|
@ -19,7 +19,7 @@ from troveclient.compat import exceptions
|
|||||||
from proboscis import after_class
|
from proboscis import after_class
|
||||||
from proboscis import before_class
|
from proboscis import before_class
|
||||||
from proboscis import test
|
from proboscis import test
|
||||||
from proboscis.asserts import *
|
from proboscis import asserts
|
||||||
|
|
||||||
from trove import tests
|
from trove import tests
|
||||||
from trove.tests.api.instances import instance_info
|
from trove.tests.api.instances import instance_info
|
||||||
@ -58,13 +58,13 @@ class UserAccessBase(object):
|
|||||||
try:
|
try:
|
||||||
self.dbaas.users.grant(instance_info.id, user, databases)
|
self.dbaas.users.grant(instance_info.id, user, databases)
|
||||||
except exceptions.BadRequest:
|
except exceptions.BadRequest:
|
||||||
assert_equal(400, expected_response)
|
asserts.assert_equal(400, expected_response)
|
||||||
except exceptions.NotFound:
|
except exceptions.NotFound:
|
||||||
assert_equal(404, expected_response)
|
asserts.assert_equal(404, expected_response)
|
||||||
except exceptions.ClientException:
|
except exceptions.ClientException:
|
||||||
assert_equal(500, expected_response)
|
asserts.assert_equal(500, expected_response)
|
||||||
finally:
|
finally:
|
||||||
assert_equal(expected_response, self.dbaas.last_http_code)
|
asserts.assert_equal(expected_response, self.dbaas.last_http_code)
|
||||||
|
|
||||||
def _grant_access_plural(self, users, databases, expected_response=202):
|
def _grant_access_plural(self, users, databases, expected_response=202):
|
||||||
"""Grant each user in the list access to all the databases listed.
|
"""Grant each user in the list access to all the databases listed.
|
||||||
@ -79,11 +79,11 @@ class UserAccessBase(object):
|
|||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
self.dbaas.users.revoke(instance_info.id, user, database)
|
self.dbaas.users.revoke(instance_info.id, user, database)
|
||||||
assert_true(expected_response, self.dbaas.last_http_code)
|
asserts.assert_true(expected_response, self.dbaas.last_http_code)
|
||||||
except exceptions.BadRequest:
|
except exceptions.BadRequest:
|
||||||
assert_equal(400, self.dbaas.last_http_code)
|
asserts.assert_equal(400, self.dbaas.last_http_code)
|
||||||
except exceptions.NotFound:
|
except exceptions.NotFound:
|
||||||
assert_equal(404, self.dbaas.last_http_code)
|
asserts.assert_equal(404, self.dbaas.last_http_code)
|
||||||
|
|
||||||
def _revoke_access_plural(self, users, databases, expected_response=202):
|
def _revoke_access_plural(self, users, databases, expected_response=202):
|
||||||
"""Revoke from each user access to each database.
|
"""Revoke from each user access to each database.
|
||||||
@ -101,16 +101,17 @@ class UserAccessBase(object):
|
|||||||
"""
|
"""
|
||||||
for user in users:
|
for user in users:
|
||||||
access = self.dbaas.users.list_access(instance_info.id, user)
|
access = self.dbaas.users.list_access(instance_info.id, user)
|
||||||
assert_equal(expected_response, self.dbaas.last_http_code)
|
asserts.assert_equal(expected_response, self.dbaas.last_http_code)
|
||||||
access = [db.name for db in access]
|
access = [db.name for db in access]
|
||||||
assert_equal(set(access), set(databases))
|
asserts.assert_equal(set(access), set(databases))
|
||||||
|
|
||||||
def _reset_access(self):
|
def _reset_access(self):
|
||||||
for user in self.users:
|
for user in self.users:
|
||||||
for database in self.databases + self.ghostdbs:
|
for database in self.databases + self.ghostdbs:
|
||||||
try:
|
try:
|
||||||
self.dbaas.users.revoke(instance_info.id, user, database)
|
self.dbaas.users.revoke(instance_info.id, user, database)
|
||||||
assert_true(self.dbaas.last_http_code in [202, 404])
|
asserts.assert_true(self.dbaas.last_http_code in [202, 404]
|
||||||
|
)
|
||||||
except exceptions.NotFound:
|
except exceptions.NotFound:
|
||||||
# This is all right here, since we're resetting.
|
# This is all right here, since we're resetting.
|
||||||
pass
|
pass
|
||||||
@ -150,31 +151,31 @@ class TestUserAccessPasswordChange(UserAccessBase):
|
|||||||
def test_change_password_bogus_user(self):
|
def test_change_password_bogus_user(self):
|
||||||
user = self._pick_a_user()
|
user = self._pick_a_user()
|
||||||
user["name"] = "thisuserhasanamethatstoolong"
|
user["name"] = "thisuserhasanamethatstoolong"
|
||||||
assert_raises(exceptions.BadRequest,
|
asserts.assert_raises(exceptions.BadRequest,
|
||||||
self.dbaas.users.change_passwords,
|
self.dbaas.users.change_passwords,
|
||||||
instance_info.id, [user])
|
instance_info.id, [user])
|
||||||
assert_equal(400, self.dbaas.last_http_code)
|
asserts.assert_equal(400, self.dbaas.last_http_code)
|
||||||
|
|
||||||
@test()
|
@test()
|
||||||
def test_change_password_nonexistent_user(self):
|
def test_change_password_nonexistent_user(self):
|
||||||
user = self._pick_a_user()
|
user = self._pick_a_user()
|
||||||
user["name"] = "thisuserDNE"
|
user["name"] = "thisuserDNE"
|
||||||
assert_raises(exceptions.NotFound,
|
asserts.assert_raises(exceptions.NotFound,
|
||||||
self.dbaas.users.change_passwords,
|
self.dbaas.users.change_passwords,
|
||||||
instance_info.id, [user])
|
instance_info.id, [user])
|
||||||
assert_equal(404, self.dbaas.last_http_code)
|
asserts.assert_equal(404, self.dbaas.last_http_code)
|
||||||
|
|
||||||
@test()
|
@test()
|
||||||
def test_create_user_and_dbs(self):
|
def test_create_user_and_dbs(self):
|
||||||
users = self._user_list_from_names(self.users)
|
users = self._user_list_from_names(self.users)
|
||||||
# Default password for everyone is 'password'.
|
# Default password for everyone is 'password'.
|
||||||
self.dbaas.users.create(instance_info.id, users)
|
self.dbaas.users.create(instance_info.id, users)
|
||||||
assert_equal(202, self.dbaas.last_http_code)
|
asserts.assert_equal(202, self.dbaas.last_http_code)
|
||||||
|
|
||||||
databases = [{"name": db}
|
databases = [{"name": db}
|
||||||
for db in self.databases]
|
for db in self.databases]
|
||||||
self.dbaas.databases.create(instance_info.id, databases)
|
self.dbaas.databases.create(instance_info.id, databases)
|
||||||
assert_equal(202, self.dbaas.last_http_code)
|
asserts.assert_equal(202, self.dbaas.last_http_code)
|
||||||
|
|
||||||
@test(depends_on=[test_create_user_and_dbs])
|
@test(depends_on=[test_create_user_and_dbs])
|
||||||
def test_initial_connection(self):
|
def test_initial_connection(self):
|
||||||
@ -219,7 +220,7 @@ class TestUserAccessPasswordChange(UserAccessBase):
|
|||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
for database in self.databases:
|
for database in self.databases:
|
||||||
self.dbaas.databases.delete(instance_info.id, database)
|
self.dbaas.databases.delete(instance_info.id, database)
|
||||||
assert_equal(202, self.dbaas.last_http_code)
|
asserts.assert_equal(202, self.dbaas.last_http_code)
|
||||||
for username in self.users:
|
for username in self.users:
|
||||||
self.dbaas.users.delete(instance_info.id, username)
|
self.dbaas.users.delete(instance_info.id, username)
|
||||||
|
|
||||||
@ -246,22 +247,22 @@ class TestUserAccessPositive(UserAccessBase):
|
|||||||
databases = self.dbaas.databases.list(instance_info.id)
|
databases = self.dbaas.databases.list(instance_info.id)
|
||||||
database_names = [db.name for db in databases]
|
database_names = [db.name for db in databases]
|
||||||
for ghost in self.ghostdbs:
|
for ghost in self.ghostdbs:
|
||||||
assert_true(ghost not in database_names)
|
asserts.assert_true(ghost not in database_names)
|
||||||
users = self.dbaas.users.list(instance_info.id)
|
users = self.dbaas.users.list(instance_info.id)
|
||||||
user_names = [user.name for user in users]
|
user_names = [user.name for user in users]
|
||||||
for ghost in self.ghostusers:
|
for ghost in self.ghostusers:
|
||||||
assert_true(ghost not in user_names)
|
asserts.assert_true(ghost not in user_names)
|
||||||
|
|
||||||
@test()
|
@test()
|
||||||
def test_create_user_and_dbs(self):
|
def test_create_user_and_dbs(self):
|
||||||
users = self._user_list_from_names(self.users)
|
users = self._user_list_from_names(self.users)
|
||||||
self.dbaas.users.create(instance_info.id, users)
|
self.dbaas.users.create(instance_info.id, users)
|
||||||
assert_equal(202, self.dbaas.last_http_code)
|
asserts.assert_equal(202, self.dbaas.last_http_code)
|
||||||
|
|
||||||
databases = [{"name": db}
|
databases = [{"name": db}
|
||||||
for db in self.databases]
|
for db in self.databases]
|
||||||
self.dbaas.databases.create(instance_info.id, databases)
|
self.dbaas.databases.create(instance_info.id, databases)
|
||||||
assert_equal(202, self.dbaas.last_http_code)
|
asserts.assert_equal(202, self.dbaas.last_http_code)
|
||||||
|
|
||||||
@test(depends_on=[test_create_user_and_dbs])
|
@test(depends_on=[test_create_user_and_dbs])
|
||||||
def test_no_access(self):
|
def test_no_access(self):
|
||||||
@ -346,7 +347,7 @@ class TestUserAccessPositive(UserAccessBase):
|
|||||||
self._reset_access()
|
self._reset_access()
|
||||||
for database in self.databases:
|
for database in self.databases:
|
||||||
self.dbaas.databases.delete(instance_info.id, database)
|
self.dbaas.databases.delete(instance_info.id, database)
|
||||||
assert_equal(202, self.dbaas.last_http_code)
|
asserts.assert_equal(202, self.dbaas.last_http_code)
|
||||||
for username in self.users:
|
for username in self.users:
|
||||||
self.dbaas.users.delete(instance_info.id, username)
|
self.dbaas.users.delete(instance_info.id, username)
|
||||||
|
|
||||||
@ -370,10 +371,10 @@ class TestUserAccessNegative(UserAccessBase):
|
|||||||
user_list = self._user_list_from_names(users)
|
user_list = self._user_list_from_names(users)
|
||||||
try:
|
try:
|
||||||
self.dbaas.users.create(instance_info.id, user_list)
|
self.dbaas.users.create(instance_info.id, user_list)
|
||||||
assert_equal(self.dbaas.last_http_code, 202)
|
asserts.assert_equal(self.dbaas.last_http_code, 202)
|
||||||
except exceptions.BadRequest:
|
except exceptions.BadRequest:
|
||||||
assert_equal(self.dbaas.last_http_code, 400)
|
asserts.assert_equal(self.dbaas.last_http_code, 400)
|
||||||
assert_equal(expected_response, self.dbaas.last_http_code)
|
asserts.assert_equal(expected_response, self.dbaas.last_http_code)
|
||||||
|
|
||||||
@test()
|
@test()
|
||||||
def test_create_duplicate_user_and_dbs(self):
|
def test_create_duplicate_user_and_dbs(self):
|
||||||
@ -382,10 +383,10 @@ class TestUserAccessNegative(UserAccessBase):
|
|||||||
"""
|
"""
|
||||||
users = self._user_list_from_names(self.users)
|
users = self._user_list_from_names(self.users)
|
||||||
self.dbaas.users.create(instance_info.id, users)
|
self.dbaas.users.create(instance_info.id, users)
|
||||||
assert_equal(202, self.dbaas.last_http_code)
|
asserts.assert_equal(202, self.dbaas.last_http_code)
|
||||||
databases = [{"name": db} for db in self.databases]
|
databases = [{"name": db} for db in self.databases]
|
||||||
self.dbaas.databases.create(instance_info.id, databases)
|
self.dbaas.databases.create(instance_info.id, databases)
|
||||||
assert_equal(202, self.dbaas.last_http_code)
|
asserts.assert_equal(202, self.dbaas.last_http_code)
|
||||||
|
|
||||||
@test(depends_on=[test_create_duplicate_user_and_dbs])
|
@test(depends_on=[test_create_duplicate_user_and_dbs])
|
||||||
def test_neg_duplicate_useraccess(self):
|
def test_neg_duplicate_useraccess(self):
|
||||||
@ -410,7 +411,7 @@ class TestUserAccessNegative(UserAccessBase):
|
|||||||
# drop the user temporarily
|
# drop the user temporarily
|
||||||
self.dbaas.users.delete(instance_info.id, user_list[0])
|
self.dbaas.users.delete(instance_info.id, user_list[0])
|
||||||
# check his access - user should not be found
|
# check his access - user should not be found
|
||||||
assert_raises(exceptions.NotFound,
|
asserts.assert_raises(exceptions.NotFound,
|
||||||
self.dbaas.users.list_access,
|
self.dbaas.users.list_access,
|
||||||
instance_info.id,
|
instance_info.id,
|
||||||
user_list[0])
|
user_list[0])
|
||||||
@ -434,16 +435,16 @@ class TestUserAccessNegative(UserAccessBase):
|
|||||||
access = None
|
access = None
|
||||||
try:
|
try:
|
||||||
access = self.dbaas.users.list_access(instance_info.id, username)
|
access = self.dbaas.users.list_access(instance_info.id, username)
|
||||||
assert_equal(200, self.dbaas.last_http_code)
|
asserts.assert_equal(200, self.dbaas.last_http_code)
|
||||||
except exceptions.BadRequest:
|
except exceptions.BadRequest:
|
||||||
assert_equal(400, self.dbaas.last_http_code)
|
asserts.assert_equal(400, self.dbaas.last_http_code)
|
||||||
except exceptions.NotFound:
|
except exceptions.NotFound:
|
||||||
assert_equal(404, self.dbaas.last_http_code)
|
asserts.assert_equal(404, self.dbaas.last_http_code)
|
||||||
finally:
|
finally:
|
||||||
assert_equal(access_response, self.dbaas.last_http_code)
|
asserts.assert_equal(access_response, self.dbaas.last_http_code)
|
||||||
if access is not None:
|
if access is not None:
|
||||||
access = [db.name for db in access]
|
access = [db.name for db in access]
|
||||||
assert_equal(set(access), set(self.databases))
|
asserts.assert_equal(set(access), set(self.databases))
|
||||||
|
|
||||||
self._revoke_access_plural([username], databases, revoke_response)
|
self._revoke_access_plural([username], databases, revoke_response)
|
||||||
|
|
||||||
@ -465,23 +466,24 @@ class TestUserAccessNegative(UserAccessBase):
|
|||||||
# Try and fail to create the user.
|
# Try and fail to create the user.
|
||||||
empty_user = {"name": "", "host": "%",
|
empty_user = {"name": "", "host": "%",
|
||||||
"password": "password", "databases": []}
|
"password": "password", "databases": []}
|
||||||
assert_raises(exceptions.BadRequest,
|
asserts.assert_raises(exceptions.BadRequest,
|
||||||
self.dbaas.users.create,
|
self.dbaas.users.create,
|
||||||
instance_info.id,
|
instance_info.id,
|
||||||
[empty_user])
|
[empty_user])
|
||||||
assert_equal(400, self.dbaas.last_http_code)
|
asserts.assert_equal(400, self.dbaas.last_http_code)
|
||||||
|
|
||||||
assert_raises(exceptions.BadRequest, self.dbaas.users.grant,
|
asserts.assert_raises(exceptions.BadRequest, self.dbaas.users.grant,
|
||||||
instance_info.id, "", [], "%")
|
instance_info.id, "", [], "%")
|
||||||
assert_equal(400, self.dbaas.last_http_code)
|
asserts.assert_equal(400, self.dbaas.last_http_code)
|
||||||
|
|
||||||
assert_raises(exceptions.BadRequest, self.dbaas.users.list_access,
|
asserts.assert_raises(exceptions.BadRequest,
|
||||||
|
self.dbaas.users.list_access,
|
||||||
instance_info.id, "", "%")
|
instance_info.id, "", "%")
|
||||||
assert_equal(400, self.dbaas.last_http_code)
|
asserts.assert_equal(400, self.dbaas.last_http_code)
|
||||||
|
|
||||||
assert_raises(exceptions.BadRequest, self.dbaas.users.revoke,
|
asserts.assert_raises(exceptions.BadRequest, self.dbaas.users.revoke,
|
||||||
instance_info.id, "", "db", "%")
|
instance_info.id, "", "db", "%")
|
||||||
assert_equal(400, self.dbaas.last_http_code)
|
asserts.assert_equal(400, self.dbaas.last_http_code)
|
||||||
|
|
||||||
@test
|
@test
|
||||||
def test_user_nametoolong(self):
|
def test_user_nametoolong(self):
|
||||||
@ -500,6 +502,6 @@ class TestUserAccessNegative(UserAccessBase):
|
|||||||
|
|
||||||
for database in self.databases:
|
for database in self.databases:
|
||||||
self.dbaas.databases.delete(instance_info.id, database)
|
self.dbaas.databases.delete(instance_info.id, database)
|
||||||
assert_equal(202, self.dbaas.last_http_code)
|
asserts.assert_equal(202, self.dbaas.last_http_code)
|
||||||
for username in self.users:
|
for username in self.users:
|
||||||
self.dbaas.users.delete(instance_info.id, username)
|
self.dbaas.users.delete(instance_info.id, username)
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
from mockito import mock, when, unstub
|
from mockito import mock, when, unstub
|
||||||
import testtools
|
import testtools
|
||||||
from testtools.matchers import *
|
from testtools import matchers
|
||||||
|
|
||||||
import swiftclient.client
|
import swiftclient.client
|
||||||
|
|
||||||
@ -59,18 +59,19 @@ class TestRemote(testtools.TestCase):
|
|||||||
# interact
|
# interact
|
||||||
conn = swiftclient.client.Connection()
|
conn = swiftclient.client.Connection()
|
||||||
account_info = conn.get_account()
|
account_info = conn.get_account()
|
||||||
self.assertThat(account_info, Not(Is(None)))
|
self.assertThat(account_info, matchers.Not(matchers.Is(None)))
|
||||||
self.assertThat(len(account_info), Is(2))
|
self.assertThat(len(account_info), matchers.Is(2))
|
||||||
self.assertThat(account_info, IsInstance(tuple))
|
self.assertThat(account_info, matchers.IsInstance(tuple))
|
||||||
self.assertThat(account_info[0], IsInstance(dict))
|
self.assertThat(account_info[0], matchers.IsInstance(dict))
|
||||||
self.assertThat(account_info[0],
|
self.assertThat(account_info[0],
|
||||||
KeysEqual('content-length', 'accept-ranges',
|
matchers.KeysEqual('content-length', 'accept-ranges',
|
||||||
'x-timestamp', 'x-trans-id', 'date',
|
'x-timestamp', 'x-trans-id', 'date',
|
||||||
'x-account-bytes-used',
|
'x-account-bytes-used',
|
||||||
'x-account-container-count', 'content-type',
|
'x-account-container-count',
|
||||||
|
'content-type',
|
||||||
'x-account-object-count'))
|
'x-account-object-count'))
|
||||||
self.assertThat(account_info[1], IsInstance(list))
|
self.assertThat(account_info[1], matchers.IsInstance(list))
|
||||||
self.assertThat(len(account_info[1]), Is(0))
|
self.assertThat(len(account_info[1]), matchers.Is(0))
|
||||||
|
|
||||||
def test_one_container(self):
|
def test_one_container(self):
|
||||||
"""
|
"""
|
||||||
@ -86,29 +87,27 @@ class TestRemote(testtools.TestCase):
|
|||||||
conn.get_auth()
|
conn.get_auth()
|
||||||
conn.put_container(cont_name)
|
conn.put_container(cont_name)
|
||||||
# get headers plus container metadata
|
# get headers plus container metadata
|
||||||
self.assertThat(len(conn.get_account()), Is(2))
|
self.assertThat(len(conn.get_account()), matchers.Is(2))
|
||||||
# verify container details
|
# verify container details
|
||||||
account_containers = conn.get_account()[1]
|
account_containers = conn.get_account()[1]
|
||||||
self.assertThat(len(account_containers), Is(1))
|
self.assertThat(len(account_containers), matchers.Is(1))
|
||||||
self.assertThat(account_containers[0],
|
self.assertThat(account_containers[0],
|
||||||
KeysEqual('count', 'bytes', 'name'))
|
matchers.KeysEqual('count', 'bytes', 'name'))
|
||||||
self.assertThat(account_containers[0]['name'], Is(cont_name))
|
self.assertThat(account_containers[0]['name'], matchers.Is(cont_name))
|
||||||
# get container details
|
# get container details
|
||||||
cont_info = conn.get_container(cont_name)
|
cont_info = conn.get_container(cont_name)
|
||||||
self.assertIsNotNone(cont_info)
|
self.assertIsNotNone(cont_info)
|
||||||
self.assertThat(cont_info[0], KeysEqual('content-length',
|
self.assertThat(cont_info[0], matchers.KeysEqual('content-length',
|
||||||
"x-container-object-count",
|
'x-container-object-count', 'accept-ranges',
|
||||||
'accept-ranges',
|
'x-container-bytes-used', 'x-timestamp',
|
||||||
'x-container-bytes-used',
|
'x-trans-id', 'date', 'content-type'))
|
||||||
'x-timestamp', 'x-trans-id',
|
self.assertThat(len(cont_info[1]), matchers.Equals(0))
|
||||||
'date', 'content-type'))
|
|
||||||
self.assertThat(len(cont_info[1]), Equals(0))
|
|
||||||
# remove container
|
# remove container
|
||||||
swift_stub.without_container(cont_name)
|
swift_stub.without_container(cont_name)
|
||||||
with testtools.ExpectedException(swiftclient.ClientException):
|
with testtools.ExpectedException(swiftclient.ClientException):
|
||||||
conn.get_container(cont_name)
|
conn.get_container(cont_name)
|
||||||
# ensure there are no more containers in account
|
# ensure there are no more containers in account
|
||||||
self.assertThat(len(conn.get_account()[1]), Is(0))
|
self.assertThat(len(conn.get_account()[1]), matchers.Is(0))
|
||||||
|
|
||||||
def test_one_object(self):
|
def test_one_object(self):
|
||||||
swift_stub = SwiftClientStub()
|
swift_stub = SwiftClientStub()
|
||||||
@ -121,19 +120,22 @@ class TestRemote(testtools.TestCase):
|
|||||||
cont_info = conn.get_container('bob')
|
cont_info = conn.get_container('bob')
|
||||||
self.assertIsNotNone(cont_info)
|
self.assertIsNotNone(cont_info)
|
||||||
self.assertThat(cont_info[0],
|
self.assertThat(cont_info[0],
|
||||||
KeysEqual('content-length', 'x-container-object-count',
|
matchers.KeysEqual('content-length',
|
||||||
'accept-ranges', 'x-container-bytes-used',
|
'x-container-object-count',
|
||||||
|
'accept-ranges',
|
||||||
|
'x-container-bytes-used',
|
||||||
'x-timestamp', 'x-trans-id', 'date',
|
'x-timestamp', 'x-trans-id', 'date',
|
||||||
'content-type'))
|
'content-type'))
|
||||||
cont_objects = cont_info[1]
|
cont_objects = cont_info[1]
|
||||||
self.assertThat(len(cont_objects), Equals(1))
|
self.assertThat(len(cont_objects), matchers.Equals(1))
|
||||||
obj_1 = cont_objects[0]
|
obj_1 = cont_objects[0]
|
||||||
self.assertThat(obj_1, Equals(
|
self.assertThat(obj_1, matchers.Equals(
|
||||||
{'bytes': 13, 'last_modified': '2013-03-15T22:10:49.361950',
|
{'bytes': 13, 'last_modified': '2013-03-15T22:10:49.361950',
|
||||||
'hash': 'ccc55aefbf92aa66f42b638802c5e7f6', 'name': 'test',
|
'hash': 'ccc55aefbf92aa66f42b638802c5e7f6', 'name': 'test',
|
||||||
'content_type': 'application/octet-stream'}))
|
'content_type': 'application/octet-stream'}))
|
||||||
# test object api - not much to do here
|
# test object api - not much to do here
|
||||||
self.assertThat(conn.get_object('bob', 'test')[1], Is('test_contents'))
|
self.assertThat(conn.get_object('bob', 'test')[1],
|
||||||
|
matchers.Is('test_contents'))
|
||||||
|
|
||||||
# test remove object
|
# test remove object
|
||||||
swift_stub.without_object('bob', 'test')
|
swift_stub.without_object('bob', 'test')
|
||||||
@ -141,7 +143,7 @@ class TestRemote(testtools.TestCase):
|
|||||||
conn.delete_object('bob', 'test')
|
conn.delete_object('bob', 'test')
|
||||||
with testtools.ExpectedException(swiftclient.ClientException):
|
with testtools.ExpectedException(swiftclient.ClientException):
|
||||||
conn.delete_object('bob', 'test')
|
conn.delete_object('bob', 'test')
|
||||||
self.assertThat(len(conn.get_container('bob')[1]), Is(0))
|
self.assertThat(len(conn.get_container('bob')[1]), matchers.Is(0))
|
||||||
|
|
||||||
def test_two_objects(self):
|
def test_two_objects(self):
|
||||||
swift_stub = SwiftClientStub()
|
swift_stub = SwiftClientStub()
|
||||||
@ -157,30 +159,33 @@ class TestRemote(testtools.TestCase):
|
|||||||
cont_info = conn.get_container('bob')
|
cont_info = conn.get_container('bob')
|
||||||
self.assertIsNotNone(cont_info)
|
self.assertIsNotNone(cont_info)
|
||||||
self.assertThat(cont_info[0],
|
self.assertThat(cont_info[0],
|
||||||
KeysEqual('content-length', 'x-container-object-count',
|
matchers.KeysEqual('content-length',
|
||||||
'accept-ranges', 'x-container-bytes-used',
|
'x-container-object-count',
|
||||||
|
'accept-ranges',
|
||||||
|
'x-container-bytes-used',
|
||||||
'x-timestamp', 'x-trans-id', 'date',
|
'x-timestamp', 'x-trans-id', 'date',
|
||||||
'content-type'))
|
'content-type'))
|
||||||
self.assertThat(len(cont_info[1]), Equals(2))
|
self.assertThat(len(cont_info[1]), matchers.Equals(2))
|
||||||
self.assertThat(cont_info[1][0], Equals(
|
self.assertThat(cont_info[1][0], matchers.Equals(
|
||||||
{'bytes': 13, 'last_modified': '2013-03-15T22:10:49.361950',
|
{'bytes': 13, 'last_modified': '2013-03-15T22:10:49.361950',
|
||||||
'hash': 'ccc55aefbf92aa66f42b638802c5e7f6', 'name': 'test',
|
'hash': 'ccc55aefbf92aa66f42b638802c5e7f6', 'name': 'test',
|
||||||
'content_type': 'application/octet-stream'}))
|
'content_type': 'application/octet-stream'}))
|
||||||
self.assertThat(conn.get_object('bob', 'test')[1], Is('test_contents'))
|
self.assertThat(conn.get_object('bob', 'test')[1],
|
||||||
|
matchers.Is('test_contents'))
|
||||||
self.assertThat(conn.get_object('bob', 'test2')[1],
|
self.assertThat(conn.get_object('bob', 'test2')[1],
|
||||||
Is('test_contents2'))
|
matchers.Is('test_contents2'))
|
||||||
|
|
||||||
swift_stub.without_object('bob', 'test')
|
swift_stub.without_object('bob', 'test')
|
||||||
conn.delete_object('bob', 'test')
|
conn.delete_object('bob', 'test')
|
||||||
with testtools.ExpectedException(swiftclient.ClientException):
|
with testtools.ExpectedException(swiftclient.ClientException):
|
||||||
conn.delete_object('bob', 'test')
|
conn.delete_object('bob', 'test')
|
||||||
self.assertThat(len(conn.get_container('bob')[1]), Is(1))
|
self.assertThat(len(conn.get_container('bob')[1]), matchers.Is(1))
|
||||||
|
|
||||||
swift_stub.without_container('bob')
|
swift_stub.without_container('bob')
|
||||||
with testtools.ExpectedException(swiftclient.ClientException):
|
with testtools.ExpectedException(swiftclient.ClientException):
|
||||||
conn.get_container('bob')
|
conn.get_container('bob')
|
||||||
|
|
||||||
self.assertThat(len(conn.get_account()), Is(2))
|
self.assertThat(len(conn.get_account()), matchers.Is(2))
|
||||||
|
|
||||||
def test_nonexisting_container(self):
|
def test_nonexisting_container(self):
|
||||||
"""
|
"""
|
||||||
@ -212,9 +217,9 @@ class TestRemote(testtools.TestCase):
|
|||||||
|
|
||||||
conn.put_object('new-container', 'new-object', 'new-object-contents')
|
conn.put_object('new-container', 'new-object', 'new-object-contents')
|
||||||
obj_resp = conn.get_object('new-container', 'new-object')
|
obj_resp = conn.get_object('new-container', 'new-object')
|
||||||
self.assertThat(obj_resp, Not(Is(None)))
|
self.assertThat(obj_resp, matchers.Not(matchers.Is(None)))
|
||||||
self.assertThat(len(obj_resp), Is(2))
|
self.assertThat(len(obj_resp), matchers.Is(2))
|
||||||
self.assertThat(obj_resp[1], Is('new-object-contents'))
|
self.assertThat(obj_resp[1], matchers.Is('new-object-contents'))
|
||||||
|
|
||||||
# set expected behavior - trivial here since it is the intended
|
# set expected behavior - trivial here since it is the intended
|
||||||
# behavior however keep in mind this is just to support testing of
|
# behavior however keep in mind this is just to support testing of
|
||||||
@ -225,8 +230,9 @@ class TestRemote(testtools.TestCase):
|
|||||||
conn.put_object('new-container', 'new-object',
|
conn.put_object('new-container', 'new-object',
|
||||||
'updated-object-contents')
|
'updated-object-contents')
|
||||||
obj_resp = conn.get_object('new-container', 'new-object')
|
obj_resp = conn.get_object('new-container', 'new-object')
|
||||||
self.assertThat(obj_resp, Not(Is(None)))
|
self.assertThat(obj_resp, matchers.Not(matchers.Is(None)))
|
||||||
self.assertThat(len(obj_resp), Is(2))
|
self.assertThat(len(obj_resp), matchers.Is(2))
|
||||||
self.assertThat(obj_resp[1], Is('updated-object-contents'))
|
self.assertThat(obj_resp[1], matchers.Is('updated-object-contents'))
|
||||||
# ensure object count has not increased
|
# ensure object count has not increased
|
||||||
self.assertThat(len(conn.get_container('new-container')[1]), Is(1))
|
self.assertThat(len(conn.get_container('new-container')[1]),
|
||||||
|
matchers.Is(1))
|
||||||
|
@ -27,7 +27,8 @@
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
from proboscis.asserts import *
|
from proboscis import asserts
|
||||||
|
|
||||||
from trove.tests.config import CONFIG
|
from trove.tests.config import CONFIG
|
||||||
from troveclient.compat.xml import TroveXmlClient
|
from troveclient.compat.xml import TroveXmlClient
|
||||||
from trove.openstack.common import processutils
|
from trove.openstack.common import processutils
|
||||||
@ -65,7 +66,7 @@ class TestClient(object):
|
|||||||
|
|
||||||
def assert_http_code(self, expected_http_code):
|
def assert_http_code(self, expected_http_code):
|
||||||
resp, body = self.real_client.client.last_response
|
resp, body = self.real_client.client.last_response
|
||||||
assert_equal(resp.status, expected_http_code)
|
asserts.assert_equal(resp.status, expected_http_code)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def last_http_code(self):
|
def last_http_code(self):
|
||||||
@ -75,9 +76,10 @@ class TestClient(object):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def find_flavor_self_href(flavor):
|
def find_flavor_self_href(flavor):
|
||||||
self_links = [link for link in flavor.links if link['rel'] == 'self']
|
self_links = [link for link in flavor.links if link['rel'] == 'self']
|
||||||
assert_true(len(self_links) > 0, "Flavor had no self href!")
|
asserts.assert_true(len(self_links) > 0, "Flavor had no self href!")
|
||||||
flavor_href = self_links[0]['href']
|
flavor_href = self_links[0]['href']
|
||||||
assert_false(flavor_href is None, "Flavor link self href missing.")
|
asserts.assert_false(flavor_href is None,
|
||||||
|
"Flavor link self href missing.")
|
||||||
return flavor_href
|
return flavor_href
|
||||||
|
|
||||||
def find_flavors_by(self, condition, flavor_manager=None):
|
def find_flavors_by(self, condition, flavor_manager=None):
|
||||||
@ -96,9 +98,9 @@ class TestClient(object):
|
|||||||
def find_flavor_and_self_href(self, flavor_id, flavor_manager=None):
|
def find_flavor_and_self_href(self, flavor_id, flavor_manager=None):
|
||||||
"""Given an ID, returns flavor and its self href."""
|
"""Given an ID, returns flavor and its self href."""
|
||||||
flavor_manager = flavor_manager or self.flavors
|
flavor_manager = flavor_manager or self.flavors
|
||||||
assert_false(flavor_id is None)
|
asserts.assert_false(flavor_id is None)
|
||||||
flavor = flavor_manager.get(flavor_id)
|
flavor = flavor_manager.get(flavor_id)
|
||||||
assert_false(flavor is None)
|
asserts.assert_false(flavor is None)
|
||||||
flavor_href = self.find_flavor_self_href(flavor)
|
flavor_href = self.find_flavor_self_href(flavor)
|
||||||
return flavor, flavor_href
|
return flavor, flavor_href
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user