Tests for exposing conductors
Add tests for the API change of exposed conductors.
Story: 1724474
Task: 28565
Change-Id: Ib0c3855ce8a65a530a2530094d11f497fb2e3023
diff --git a/ironic_tempest_plugin/services/baremetal/v1/json/baremetal_client.py b/ironic_tempest_plugin/services/baremetal/v1/json/baremetal_client.py
index 81682f8..f60361a 100644
--- a/ironic_tempest_plugin/services/baremetal/v1/json/baremetal_client.py
+++ b/ironic_tempest_plugin/services/baremetal/v1/json/baremetal_client.py
@@ -104,6 +104,11 @@
return self._list_request('drivers')
@base.handle_errors
+ def list_conductors(self, **kwargs):
+ """List all registered conductors."""
+ return self._list_request('conductors', **kwargs)
+
+ @base.handle_errors
def show_node(self, uuid, api_version=None):
"""Gets a specific node.
@@ -199,6 +204,14 @@
"""
return self._show_request('drivers', driver_name)
+ def show_conductor(self, hostname):
+ """Gets a specific conductor.
+
+ :param hostname: Hostname of conductor.
+ :return: Serialized conductor as a dictionary.
+ """
+ return self._show_request('conductors', hostname)
+
@base.handle_errors
def create_node(self, chassis_id=None, **kwargs):
"""Create a baremetal node with the specified parameters.
diff --git a/ironic_tempest_plugin/tests/api/admin/test_conductor.py b/ironic_tempest_plugin/tests/api/admin/test_conductor.py
new file mode 100644
index 0000000..ee9f439
--- /dev/null
+++ b/ironic_tempest_plugin/tests/api/admin/test_conductor.py
@@ -0,0 +1,56 @@
+# 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 tempest import config
+from tempest.lib import decorators
+
+from ironic_tempest_plugin.tests.api.admin import base
+
+CONF = config.CONF
+
+
+class TestConductors(base.BaseBaremetalTest):
+ """Tests for conductors."""
+
+ min_microversion = '1.49'
+
+ @decorators.idempotent_id('b6d62be4-53a6-43c6-ae78-bff9d1b4efc1')
+ def test_list_conductors(self):
+ _, conductors = self.client.list_conductors()
+ self.assertTrue(len(conductors['conductors']) > 0)
+ cond = conductors['conductors'].pop()
+ self.assertIn('hostname', cond)
+ self.assertIn('conductor_group', cond)
+ self.assertIn('alive', cond)
+ self.assertNotIn('drivers', cond)
+
+ @decorators.idempotent_id('ca3de366-d80a-4e97-b19b-42d594e8d148')
+ def test_list_conductors_detail(self):
+ _, conductors = self.client.list_conductors(detail=True)
+ self.assertTrue(len(conductors['conductors']) > 0)
+ cond = conductors['conductors'].pop()
+ self.assertIn('hostname', cond)
+ self.assertIn('conductor_group', cond)
+ self.assertIn('alive', cond)
+ self.assertIn('drivers', cond)
+
+ @decorators.idempotent_id('7e1829e2-3945-4508-a3d9-c8ebe9463fd8')
+ def test_show_conductor(self):
+ _, conductors = self.client.list_conductors()
+ self.assertTrue(len(conductors['conductors']) > 0)
+ conductor = conductors['conductors'].pop()
+
+ _, conductor = self.client.show_conductor(conductor['hostname'])
+ self.assertIn('hostname', conductor)
+ self.assertIn('conductor_group', conductor)
+ self.assertIn('alive', conductor)
+ self.assertIn('drivers', conductor)
diff --git a/ironic_tempest_plugin/tests/api/admin/test_nodes.py b/ironic_tempest_plugin/tests/api/admin/test_nodes.py
index f3ba2bd..31a9d61 100644
--- a/ironic_tempest_plugin/tests/api/admin/test_nodes.py
+++ b/ironic_tempest_plugin/tests/api/admin/test_nodes.py
@@ -170,6 +170,11 @@
_, loaded_node = self.client.show_node(self.node['uuid'])
self.assertNotIn('fault', loaded_node)
+ @decorators.idempotent_id('e5470656-bb65-4173-be83-2df3fc9aed24')
+ def test_conductor_hidden(self):
+ _, loaded_node = self.client.show_node(self.node['uuid'])
+ self.assertNotIn('conductor', loaded_node)
+
class TestNodesResourceClass(base.BaseBaremetalTest):
@@ -944,3 +949,29 @@
self.client.update_node, self.node['uuid'], protected=True)
# 400 for old ironic, 406 for new ironic with old microversion.
self.assertIn(exc.resp.status, (400, 406))
+
+
+class TestNodeConductor(base.BaseBaremetalTest):
+ """Tests for conductor field of baremetal nodes."""
+
+ min_microversion = '1.49'
+
+ def setUp(self):
+ super(TestNodeConductor, self).setUp()
+
+ _, self.chassis = self.create_chassis()
+ _, self.node = self.create_node(self.chassis['uuid'])
+
+ @decorators.idempotent_id('1af888b2-2a19-43da-8181-a5381d6ff536')
+ def test_conductor_exposed(self):
+ _, loaded_node = self.client.show_node(self.node['uuid'])
+ self.assertIn('conductor', loaded_node)
+
+ @decorators.idempotent_id('53bcef99-2989-4755-aa8f-c31037cd15de')
+ def test_list_nodes_by_conductor(self):
+ _, loaded_node = self.client.show_node(self.node['uuid'])
+ hostname = loaded_node['conductor']
+
+ _, nodes = self.client.list_nodes(conductor=hostname)
+ self.assertIn(self.node['uuid'],
+ [n['uuid'] for n in nodes['nodes']])