Clean up object storage for test user
Change-Id: I9d7632575cabd64c69ee5511a6e38e2921e95118
This commit is contained in:
parent
2970fb81dc
commit
96c552f557
@ -89,4 +89,11 @@ DatabaseGroup = [
|
||||
help='The datastore versions used to create instances that need to be '
|
||||
'upgrade.',
|
||||
),
|
||||
cfg.BoolOpt(
|
||||
'remove_swift_account',
|
||||
default=True,
|
||||
help='If clean up the Swift account for test users after backup '
|
||||
'function test. ResellerAdmin should be added to tempest config '
|
||||
'option "tempest_roles".'
|
||||
)
|
||||
]
|
||||
|
@ -62,6 +62,7 @@ class BaseTroveTest(test.BaseTestCase):
|
||||
cls.client = cls.os_primary.database.TroveClient()
|
||||
cls.admin_client = cls.os_admin.database.TroveClient()
|
||||
cls.admin_server_client = cls.os_admin.servers_client
|
||||
cls.account_client = cls.os_primary.account_client
|
||||
|
||||
@classmethod
|
||||
def setup_credentials(cls):
|
||||
@ -231,6 +232,14 @@ class BaseTroveTest(test.BaseTestCase):
|
||||
|
||||
return filtered_items
|
||||
|
||||
@classmethod
|
||||
def delete_swift_account(cls):
|
||||
LOG.info(f"Cleaning up Swift account")
|
||||
try:
|
||||
cls.account_client.delete('')
|
||||
except exceptions.NotFound:
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def create_instance(cls, name=None, datastore_version=None,
|
||||
database=constants.DB_NAME, username=constants.DB_USER,
|
||||
|
@ -12,12 +12,14 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
from oslo_log import log as logging
|
||||
from tempest import config
|
||||
from tempest.lib import decorators
|
||||
|
||||
from trove_tempest_plugin.tests import base as trove_base
|
||||
from trove_tempest_plugin.tests import constants
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
CONF = config.CONF
|
||||
|
||||
|
||||
class TestBackupBase(trove_base.BaseTroveTest):
|
||||
@ -39,6 +41,12 @@ class TestBackupBase(trove_base.BaseTroveTest):
|
||||
def resource_setup(cls):
|
||||
super(TestBackupBase, cls).resource_setup()
|
||||
|
||||
# Trove will automatically create a swift container for backup. We need
|
||||
# to make sure there is no swift container left for test user after
|
||||
# testing.
|
||||
if CONF.database.remove_swift_account:
|
||||
cls.addClassResourceCleanup(cls.delete_swift_account)
|
||||
|
||||
# Insert some data to the current db instance
|
||||
cls.insert_data(cls.instance_ip, constants.DB_USER, constants.DB_PASS,
|
||||
constants.DB_NAME)
|
||||
|
Loading…
Reference in New Issue
Block a user