Merge "Use unified function to check for TF backend" into mcp/caracal
diff --git a/releasenotes/notes/add-boot-from-volume-option-312d02c0c84f2092.yaml b/releasenotes/notes/add-boot-from-volume-option-312d02c0c84f2092.yaml
new file mode 100644
index 0000000..0a0b78e
--- /dev/null
+++ b/releasenotes/notes/add-boot-from-volume-option-312d02c0c84f2092.yaml
@@ -0,0 +1,7 @@
+---
+features:
+ - A new config option in group compute-feature-enabled
+ boot_from_volume which specifies if nova allow to boot
+ instances from volume. This functionality is not available
+ on some hypervisors and cinder backends like ironic and
+ ceph.
diff --git a/tempest/api/compute/servers/test_create_server.py b/tempest/api/compute/servers/test_create_server.py
index 6664e15..6f97b1f 100644
--- a/tempest/api/compute/servers/test_create_server.py
+++ b/tempest/api/compute/servers/test_create_server.py
@@ -182,6 +182,8 @@
if not utils.get_service_list()['volume']:
msg = "Volume service not enabled."
raise cls.skipException(msg)
+ if not CONF.compute_feature_enabled.boot_from_volume:
+ raise cls.skipException("Booting from volume is not enabled.")
class ServersTestFqdnHostnames(base.BaseV2ComputeTest):
diff --git a/tempest/api/volume/test_volumes_filters.py b/tempest/api/volume/test_volumes_filters.py
new file mode 100644
index 0000000..74ba9cb
--- /dev/null
+++ b/tempest/api/volume/test_volumes_filters.py
@@ -0,0 +1,50 @@
+# Copyright 2021 Mirantis Inc.
+#
+# 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 testtools
+
+from tempest.api.volume import base
+from tempest import config
+from tempest.lib import decorators
+
+
+CONF = config.CONF
+
+
+class VolumesFilter(base.BaseVolumeAdminTest):
+ @testtools.skipUnless(
+ "InstanceLocalityFilter" in CONF.volume.scheduler_default_filters,
+ "Cinder InstanceLocalityFilter is disabled",
+ )
+ @testtools.skipUnless(
+ CONF.volume_feature_enabled.instance_locality_enabled,
+ "InstanceLocalityFilter test is disabled",
+ )
+ @decorators.idempotent_id("5c13f4f7-5add-4fad-8ef7-dccca0f76295")
+ def test_instancelocalityfilter(self):
+ # 1. Create instance
+ # 2. Create volume by using local_to_instance hint
+ # 3. Compare server host and volume host are the same.
+ server = self.create_server()
+ server_host = self.admin_manager.servers_client.show_server(
+ server["id"])["server"]["OS-EXT-SRV-ATTR:host"]
+ volume = self.create_volume(hints={"local_to_instance": server["id"]})
+ fetched_volume = self.admin_volume_client.show_volume(volume["id"])[
+ "volume"]
+ self.assertEqual(
+ server_host, fetched_volume["os-vol-host-attr:host"].split("@")
+ [0],
+ "The fetched Volume host is different "
+ "from the created instance",)
diff --git a/tempest/config.py b/tempest/config.py
index 5dce260..b91acc5 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -622,6 +622,11 @@
cfg.BoolOpt('unified_limits',
default=False,
help='Does the test environment support unified limits?'),
+ cfg.BoolOpt('boot_from_volume',
+ default=True,
+ help='Does the test environment support booting instances '
+ 'from volume. This depends on hypervisor and volume '
+ 'backend/type.'),
]
@@ -1041,6 +1046,9 @@
"If both values are not specified, Tempest avoids tests "
"which require a microversion. Valid values are string "
"with format 'X.Y' or string 'latest'",),
+ cfg.ListOpt('scheduler_default_filters',
+ default=[],
+ help="The list of enabled scheduler filters.",),
]
volume_feature_group = cfg.OptGroup(name='volume-feature-enabled',
@@ -1093,7 +1101,11 @@
cfg.BoolOpt('cluster_active_active',
default=False,
help='The boolean flag to indicate if active-active mode '
- 'is used by volume backend.')
+ 'is used by volume backend.'),
+ cfg.BoolOpt('instance_locality_enabled',
+ default=False,
+ help='The boolean flag to run instance locality tests '
+ 'on environment.')
]
diff --git a/tempest/lib/services/volume/v3/volumes_client.py b/tempest/lib/services/volume/v3/volumes_client.py
index c6f8973..65dc258 100644
--- a/tempest/lib/services/volume/v3/volumes_client.py
+++ b/tempest/lib/services/volume/v3/volumes_client.py
@@ -105,14 +105,17 @@
self.validate_response(schema.show_volume, resp, body)
return rest_client.ResponseBody(resp, body)
- def create_volume(self, **kwargs):
+ def create_volume(self, hints=None, **kwargs):
"""Creates a new Volume.
For a full list of available parameters, please refer to the official
API reference:
https://docs.openstack.org/api-ref/block-storage/v3/index.html#create-a-volume
"""
- post_body = json.dumps({'volume': kwargs})
+ obj = {'volume': kwargs}
+ if hints is not None:
+ obj['OS-SCH-HNT:scheduler_hints'] = hints
+ post_body = json.dumps(obj)
resp, body = self.post('volumes', post_body)
body = json.loads(body)
schema = self.get_schema(self.schema_versions_info)