diff --git a/novaclient/tests/functional/v2/__init__.py b/novaclient/tests/functional/v2/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/novaclient/tests/functional/fake_crypto.py b/novaclient/tests/functional/v2/fake_crypto.py similarity index 100% rename from novaclient/tests/functional/fake_crypto.py rename to novaclient/tests/functional/v2/fake_crypto.py diff --git a/novaclient/tests/functional/v2/legacy/__init__.py b/novaclient/tests/functional/v2/legacy/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/novaclient/tests/functional/test_fixedips.py b/novaclient/tests/functional/v2/legacy/test_fixedips.py similarity index 89% rename from novaclient/tests/functional/test_fixedips.py rename to novaclient/tests/functional/v2/legacy/test_fixedips.py index 095492470..7082c110d 100644 --- a/novaclient/tests/functional/test_fixedips.py +++ b/novaclient/tests/functional/v2/legacy/test_fixedips.py @@ -52,12 +52,3 @@ class TestFixedIPsNovaClient(base.ClientTestBase): def test_fixedip_get(self): self._test_fixedip_get() - - -class TestFixedIPsNovaClientV24(TestFixedIPsNovaClient): - """FixedIPs functional tests for v2.4 nova-api microversion.""" - - COMPUTE_API_VERSION = '2.4' - - def test_fixedip_get(self): - self._test_fixedip_get(expect_reserved=True) diff --git a/novaclient/tests/functional/test_instances.py b/novaclient/tests/functional/v2/legacy/test_instances.py similarity index 100% rename from novaclient/tests/functional/test_instances.py rename to novaclient/tests/functional/v2/legacy/test_instances.py diff --git a/novaclient/tests/functional/test_keypairs.py b/novaclient/tests/functional/v2/legacy/test_keypairs.py similarity index 72% rename from novaclient/tests/functional/test_keypairs.py rename to novaclient/tests/functional/v2/legacy/test_keypairs.py index f980349bb..3b7efefcf 100644 --- a/novaclient/tests/functional/test_keypairs.py +++ b/novaclient/tests/functional/v2/legacy/test_keypairs.py @@ -16,7 +16,7 @@ import uuid from tempest_lib import exceptions from novaclient.tests.functional import base -from novaclient.tests.functional import fake_crypto +from novaclient.tests.functional.v2 import fake_crypto class TestKeypairsNovaClient(base.ClientTestBase): @@ -92,33 +92,3 @@ class TestKeypairsNovaClient(base.ClientTestBase): # keypair-show should fail if no keypair with given name is found. self.assertRaises(exceptions.CommandFailed, self._show_keypair, key_name) - - -class TestKeypairsNovaClientV22(TestKeypairsNovaClient): - """Keypairs functional tests for v2.2 nova-api microversion. - """ - - COMPUTE_API_VERSION = "2.2" - - def test_create_keypair(self): - keypair = super(TestKeypairsNovaClientV22, self).test_create_keypair() - self.assertIn('ssh', keypair) - - def test_create_keypair_x509(self): - key_name = self._create_keypair(key_type='x509') - keypair = self._show_keypair(key_name) - self.assertIn(key_name, keypair) - self.assertIn('x509', keypair) - - def test_import_keypair(self): - pub_key, fingerprint = fake_crypto.get_ssh_pub_key_and_fingerprint() - pub_key_file = self._create_public_key_file(pub_key) - keypair = self._test_import_keypair(fingerprint, pub_key=pub_key_file) - self.assertIn('ssh', keypair) - - def test_import_keypair_x509(self): - certif, fingerprint = fake_crypto.get_x509_cert_and_fingerprint() - pub_key_file = self._create_public_key_file(certif) - keypair = self._test_import_keypair(fingerprint, key_type='x509', - pub_key=pub_key_file) - self.assertIn('x509', keypair) diff --git a/novaclient/tests/functional/test_quotas.py b/novaclient/tests/functional/v2/legacy/test_quotas.py similarity index 100% rename from novaclient/tests/functional/test_quotas.py rename to novaclient/tests/functional/v2/legacy/test_quotas.py diff --git a/novaclient/tests/functional/test_readonly_nova.py b/novaclient/tests/functional/v2/legacy/test_readonly_nova.py similarity index 100% rename from novaclient/tests/functional/test_readonly_nova.py rename to novaclient/tests/functional/v2/legacy/test_readonly_nova.py diff --git a/novaclient/tests/functional/test_servers.py b/novaclient/tests/functional/v2/legacy/test_servers.py similarity index 100% rename from novaclient/tests/functional/test_servers.py rename to novaclient/tests/functional/v2/legacy/test_servers.py diff --git a/novaclient/tests/functional/test_volumes_api.py b/novaclient/tests/functional/v2/legacy/test_volumes_api.py similarity index 100% rename from novaclient/tests/functional/test_volumes_api.py rename to novaclient/tests/functional/v2/legacy/test_volumes_api.py diff --git a/novaclient/tests/functional/v2/test_fixedips.py b/novaclient/tests/functional/v2/test_fixedips.py new file mode 100644 index 000000000..15d530d59 --- /dev/null +++ b/novaclient/tests/functional/v2/test_fixedips.py @@ -0,0 +1,23 @@ +# Copyright 2015 IBM Corp. +# 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 novaclient.tests.functional.v2.legacy import test_fixedips + + +class TestFixedIPsNovaClientV24(test_fixedips.TestFixedIPsNovaClient): + """FixedIPs functional tests for v2.4 nova-api microversion.""" + + COMPUTE_API_VERSION = '2.4' + + def test_fixedip_get(self): + self._test_fixedip_get(expect_reserved=True) diff --git a/novaclient/tests/functional/v2/test_instances.py b/novaclient/tests/functional/v2/test_instances.py new file mode 100644 index 000000000..289c53df4 --- /dev/null +++ b/novaclient/tests/functional/v2/test_instances.py @@ -0,0 +1,18 @@ +# 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 novaclient.tests.functional.v2.legacy import test_instances + + +class TestInstanceCLI(test_instances.TestInstanceCLI): + + COMPUTE_API_VERSION = "2.latest" diff --git a/novaclient/tests/functional/v2/test_keypairs.py b/novaclient/tests/functional/v2/test_keypairs.py new file mode 100644 index 000000000..35768de7b --- /dev/null +++ b/novaclient/tests/functional/v2/test_keypairs.py @@ -0,0 +1,44 @@ +# 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 novaclient.tests.functional.v2 import fake_crypto +from novaclient.tests.functional.v2.legacy import test_keypairs + + +class TestKeypairsNovaClientV22(test_keypairs.TestKeypairsNovaClient): + """Keypairs functional tests for v2.2 nova-api microversion. + """ + + COMPUTE_API_VERSION = "2.2" + + def test_create_keypair(self): + keypair = super(TestKeypairsNovaClientV22, self).test_create_keypair() + self.assertIn('ssh', keypair) + + def test_create_keypair_x509(self): + key_name = self._create_keypair(key_type='x509') + keypair = self._show_keypair(key_name) + self.assertIn(key_name, keypair) + self.assertIn('x509', keypair) + + def test_import_keypair(self): + pub_key, fingerprint = fake_crypto.get_ssh_pub_key_and_fingerprint() + pub_key_file = self._create_public_key_file(pub_key) + keypair = self._test_import_keypair(fingerprint, pub_key=pub_key_file) + self.assertIn('ssh', keypair) + + def test_import_keypair_x509(self): + certif, fingerprint = fake_crypto.get_x509_cert_and_fingerprint() + pub_key_file = self._create_public_key_file(certif) + keypair = self._test_import_keypair(fingerprint, key_type='x509', + pub_key=pub_key_file) + self.assertIn('x509', keypair) diff --git a/novaclient/tests/functional/v2/test_quotas.py b/novaclient/tests/functional/v2/test_quotas.py new file mode 100644 index 000000000..14b5bdfef --- /dev/null +++ b/novaclient/tests/functional/v2/test_quotas.py @@ -0,0 +1,52 @@ +# 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 novaclient.tests.functional.v2.legacy import test_quotas + + +class TestQuotasNovaClient(test_quotas.TestQuotasNovaClient): + """Nova quotas functional tests. + """ + + COMPUTE_API_VERSION = "2.latest" + + _quota_resources = ['instances', 'cores', 'ram', + 'floating_ips', 'fixed_ips', 'metadata_items', + 'injected_files', 'injected_file_content_bytes', + 'injected_file_path_bytes', 'key_pairs', + 'security_groups', 'security_group_rules', + 'server_groups', 'server_group_members'] + + def test_quotas_update(self): + # `nova quota-update` requires tenant-id. + tenant_info = self.cli_clients.keystone( + "tenant-get", params=self.cli_clients.tenant_name) + tenant_id = self._get_value_from_the_table(tenant_info, "id") + + self.addCleanup(self.client.quotas.delete, tenant_id) + + original_quotas = self.client.quotas.get(tenant_id) + + difference = 10 + params = [tenant_id] + for quota_name in self._quota_resources: + params.append("--%(name)s %(value)s" % { + "name": quota_name.replace("_", "-"), + "value": getattr(original_quotas, quota_name) + difference}) + + self.nova("quota-update", params=" ".join(params)) + + updated_quotas = self.client.quotas.get(tenant_id) + + for quota_name in self._quota_resources: + self.assertEqual(getattr(original_quotas, quota_name), + getattr(updated_quotas, quota_name) - difference) diff --git a/novaclient/tests/functional/v2/test_readonly_nova.py b/novaclient/tests/functional/v2/test_readonly_nova.py new file mode 100644 index 000000000..cfe91635a --- /dev/null +++ b/novaclient/tests/functional/v2/test_readonly_nova.py @@ -0,0 +1,25 @@ +# 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 novaclient.tests.functional.v2.legacy import test_readonly_nova + + +class SimpleReadOnlyNovaClientTest( + test_readonly_nova.SimpleReadOnlyNovaClientTest): + + """ + read only functional python-novaclient tests. + + This only exercises client commands that are read only. + """ + + COMPUTE_API_VERSION = "2.latest" diff --git a/novaclient/tests/functional/v2/test_servers.py b/novaclient/tests/functional/v2/test_servers.py new file mode 100644 index 000000000..c3b2fdcd2 --- /dev/null +++ b/novaclient/tests/functional/v2/test_servers.py @@ -0,0 +1,27 @@ +# 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 novaclient.tests.functional.v2.legacy import test_servers + + +class TestServersBootNovaClient(test_servers.TestServersBootNovaClient): + """Servers boot functional tests. + """ + + COMPUTE_API_VERSION = "2.latest" + + +class TestServersListNovaClient(test_servers.TestServersListNovaClient): + """Servers list functional tests. + """ + + COMPUTE_API_VERSION = "2.latest" diff --git a/novaclient/tests/functional/v2/test_volumes_api.py b/novaclient/tests/functional/v2/test_volumes_api.py new file mode 100644 index 000000000..8bf35d508 --- /dev/null +++ b/novaclient/tests/functional/v2/test_volumes_api.py @@ -0,0 +1,18 @@ +# 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 novaclient.tests.functional.v2.legacy import test_volumes_api + + +class TestVolumesAPI(test_volumes_api.TestVolumesAPI): + + COMPUTE_API_VERSION = "2.latest"