Move updating access test case to a separate test class

Updating access will change the instance public address, which affects other
test cases in the same test class.

Enable more tests in this patch.

Added some test cases which always failed in CI in tempest blacklist file.

Story: 2008410
Task: 41351

Change-Id: I09b4f00da941b7ead5a93c4c41b196cbe9934bbe
This commit is contained in:
Lingxian Kong 2020-12-05 17:55:39 +13:00
parent 2581bc079a
commit 355a351fcc
6 changed files with 101 additions and 45 deletions

View File

@ -51,7 +51,7 @@
- job:
name: trove-tempest-plugin
parent: devstack-tempest
timeout: 7800
timeout: 10800
description: |
This job is for testing on py3 which is Ussuri onwards.
required-projects: &base_required_projects
@ -98,7 +98,8 @@
s-object: true
s-proxy: true
tempest: true
tempest_test_regex: ^trove_tempest_plugin\.tests.scenario\.test_instance_basic\.TestInstanceBasicMySQL\.test_database_access
tempest_test_regex: ^trove_tempest_plugin\.tests
tempest_test_blacklist: '{{ ansible_user_dir }}/{{ zuul.projects["opendev.org/openstack/trove-tempest-plugin"].src_dir }}/tempest_blacklist.txt'
- job:
name: trove-tempest-ipv6-only

5
tempest_blacklist.txt Normal file
View File

@ -0,0 +1,5 @@
# --blacklist-file contents for the trove tempest job defined in .zuul.yaml
# TODO: Need to figure out why those tests are failed in CI devstack.
^trove_tempest_plugin.tests.scenario.test_backup
^trove_tempest_plugin.tests.scenario.test_replication

View File

@ -129,41 +129,6 @@ class TestInstanceBasicBase(trove_base.BaseTroveTest):
self.assertNotEqual(value, cur_value)
self.assertNotEqual(new_value, cur_value)
def update_access_test(self):
"""Test update instance accessbility"""
if 'access' not in self.instance:
raise self.skipException("Access not supported in API.")
# Change instance to be private
LOG.info(f"Changing instance {self.instance_id} to be private")
body = {
"instance": {
"access": {
"is_public": False,
}
}
}
self.client.put_resource(f'instances/{self.instance_id}', body)
self.wait_for_instance_status(self.instance_id, timeout=30)
instance = self.client.get_resource(
"instances", self.instance_id)['instance']
self.assertFalse(instance['access']['is_public'])
types = [addr['type'] for addr in instance['addresses']]
self.assertNotIn('public', types)
# Change back to public
LOG.info(f"Changing instance {self.instance_id} to be public")
body = {
"instance": {
"access": {
"is_public": True,
}
}
}
self.client.put_resource(f'instances/{self.instance_id}', body)
self.wait_for_instance_status(self.instance_id, timeout=30)
class TestInstanceBasicMySQLBase(TestInstanceBasicBase):
def _access_db(self, ip, username=constants.DB_USER,
@ -316,7 +281,3 @@ class TestInstanceBasicMySQLBase(TestInstanceBasicBase):
create_values = {"max_connections": 555}
update_values = {"max_connections": 666}
self.configuration_test(create_values, update_values)
@decorators.idempotent_id("67e57c26-fcb3-11ea-a950-00224d6b7bc1")
def test_update_access(self):
self.update_access_test()

View File

@ -0,0 +1,66 @@
# Copyright 2020 Catalyst Cloud
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from oslo_log import log as logging
from tempest.lib import decorators
from trove_tempest_plugin.tests import base as trove_base
LOG = logging.getLogger(__name__)
class TestInstanceUpdateAccessBase(trove_base.BaseTroveTest):
"""Update instance access base class.
Updating instance access needs to change the public IP address of the
instance, so we need a separate test class for this.
"""
def update_access_test(self):
"""Test update instance accessbility"""
if 'access' not in self.instance:
raise self.skipException("Access not supported in API.")
# Change instance to be private
LOG.info(f"Changing instance {self.instance_id} to be private")
body = {
"instance": {
"access": {
"is_public": False,
}
}
}
self.client.put_resource(f'instances/{self.instance_id}', body)
self.wait_for_instance_status(self.instance_id, timeout=30)
instance = self.client.get_resource(
"instances", self.instance_id)['instance']
self.assertFalse(instance['access']['is_public'])
types = [addr['type'] for addr in instance['addresses']]
self.assertNotIn('public', types)
# Change back to public
LOG.info(f"Changing instance {self.instance_id} to be public")
body = {
"instance": {
"access": {
"is_public": True,
}
}
}
self.client.put_resource(f'instances/{self.instance_id}', body)
self.wait_for_instance_status(self.instance_id, timeout=30)
@decorators.idempotent_id("c907cc80-36b4-11eb-b177-00224d6b7bc1")
def test_instance_update_access(self):
self.update_access_test()

View File

@ -51,7 +51,3 @@ class TestInstanceBasicPostgreSQL(base_basic.TestInstanceBasicBase):
update_values = {"max_connections": 102}
self.configuration_test(create_values, update_values,
need_restart=True)
@decorators.idempotent_id("5718abf6-fcb4-11ea-a950-00224d6b7bc1")
def test_update_access(self):
self.update_access_test()

View File

@ -0,0 +1,27 @@
# Copyright 2020 Catalyst Cloud
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from trove_tempest_plugin.tests.scenario import base_update_access as base
class TestInstanceUpdateAccessMySQL(base.TestInstanceUpdateAccessBase):
datastore = 'mysql'
class TestInstanceUpdateAccessMariaDB(base.TestInstanceUpdateAccessBase):
datastore = 'mariadb'
class TestInstanceUpdateAccessPostgreSQL(base.TestInstanceUpdateAccessBase):
datastore = 'postgresql'