diff --git a/.zuul.yaml b/.zuul.yaml index 688648a..011f50e 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -5,15 +5,13 @@ - tempest-plugin-jobs check: jobs: - - trove-tempest-plugin: - voting: false + - trove-tempest-plugin - trove-tempest-ipv6-only: voting: false gate: queue: trove jobs: - - trove-tempest-plugin: - voting: false + - trove-tempest-plugin - trove-tempest-ipv6-only: voting: false diff --git a/trove_tempest_plugin/services/client.py b/trove_tempest_plugin/services/client.py index a748c33..a1e801e 100644 --- a/trove_tempest_plugin/services/client.py +++ b/trove_tempest_plugin/services/client.py @@ -70,3 +70,10 @@ class TroveClient(rest_client.RestClient): self.expected_success(expected_status_code, resp.status) return rest_client.ResponseBody(resp, json.loads(body)) + + def patch_resource(self, obj, id, req_body, expected_status_code=202): + url = '/{obj}/{id}'.format(obj=obj, id=id) + headers = {"Content-Type": "application/json"} + + resp, _ = self.patch(url, json.dumps(req_body), headers=headers) + self.expected_success(expected_status_code, resp.status) diff --git a/trove_tempest_plugin/tests/api/base.py b/trove_tempest_plugin/tests/api/base.py new file mode 100644 index 0000000..7e3bcb6 --- /dev/null +++ b/trove_tempest_plugin/tests/api/base.py @@ -0,0 +1,48 @@ +# Copyright 2019 Catalyst Cloud Ltd. +# +# 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. +import time + +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 TestInstanceActionsBase(trove_base.BaseTroveTest): + @decorators.idempotent_id("be6dd514-27d6-11ea-a56a-98f2b3cc23a0") + def test_instance_upgrade(self): + res = self.client.get_resource("instances", self.instance_id) + datastore = res["instance"]['datastore']['type'] + version = res["instance"]['datastore']['version'] + new_version = version + datastore = self.client.get_resource("datastores", datastore) + for v in datastore['datastore']['versions']: + if v['name'] != version: + new_version = v['name'] + break + + LOG.info('Using datastore %s for instance upgrading', new_version) + + body = { + "instance": { + "datastore_version": new_version + } + } + self.client.patch_resource('instances', self.instance_id, body) + + time.sleep(3) + self.wait_for_instance_status(self.instance_id, + expected_status="ACTIVE") diff --git a/trove_tempest_plugin/tests/api/test_instance_actions.py b/trove_tempest_plugin/tests/api/test_instance_actions.py new file mode 100644 index 0000000..668409e --- /dev/null +++ b/trove_tempest_plugin/tests/api/test_instance_actions.py @@ -0,0 +1,18 @@ +# Copyright 2019 Catalyst Cloud Ltd. +# +# 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.api import base + + +class TestInstanceActionsMySQL(base.TestInstanceActionsBase): + datastore = 'mysql' diff --git a/trove_tempest_plugin/tests/scenario/mysql/test_instance_basic.py b/trove_tempest_plugin/tests/scenario/base.py similarity index 90% rename from trove_tempest_plugin/tests/scenario/mysql/test_instance_basic.py rename to trove_tempest_plugin/tests/scenario/base.py index a4b2562..026a142 100644 --- a/trove_tempest_plugin/tests/scenario/mysql/test_instance_basic.py +++ b/trove_tempest_plugin/tests/scenario/base.py @@ -17,15 +17,13 @@ from oslo_log import log as logging from oslo_utils import netutils from tempest.lib import decorators -from trove_tempest_plugin.tests import base +from trove_tempest_plugin.tests import base as trove_base from trove_tempest_plugin.tests import utils LOG = logging.getLogger(__name__) -class TestMySQLInstanceBasic(base.BaseTroveTest): - datastore = 'mysql' - +class TestInstanceBasicMySQLBase(trove_base.BaseTroveTest): def _access_db(self, ip, username='test_user', password='password'): db_engine = utils.LocalSqlClient.init_engine(ip, username, password) db_client = utils.LocalSqlClient(db_engine) @@ -41,7 +39,7 @@ class TestMySQLInstanceBasic(base.BaseTroveTest): res = self.client.get_resource("instances", self.instance_id) ips = res["instance"].get('ip', []) - # TODO(lxkong): IPv6 needs to be supported. + # TODO(lxkong): IPv6 needs to be tested. v4_ip = None for ip in ips: if netutils.is_valid_ipv4(ip): diff --git a/trove_tempest_plugin/tests/scenario/mysql/__init__.py b/trove_tempest_plugin/tests/scenario/mysql/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/trove_tempest_plugin/tests/scenario/test_instance_basic.py b/trove_tempest_plugin/tests/scenario/test_instance_basic.py new file mode 100644 index 0000000..53f6b1d --- /dev/null +++ b/trove_tempest_plugin/tests/scenario/test_instance_basic.py @@ -0,0 +1,18 @@ +# Copyright 2019 Catalyst Cloud Ltd. +# +# 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 + + +class TestInstanceBasicMySQL(base.TestInstanceBasicMySQLBase): + datastore = 'mysql'