Added Ironic test to check nodes are available/active
Added Ironic test to check nodes are available/active.
All other states are not expected. The full list of
states with description, see here:
https://docs.openstack.org/ironic/latest/contributor/states.html
Change-Id: I23c97ceb615b0fc1a7629445677d1f3ae3ecd889
Realated: PROD-30572
(cherry picked from commit 2f7a2a1c4468e8c209b6ac450c079969e227b49e)
diff --git a/test_set/cvp-sanity/fixtures/base.py b/test_set/cvp-sanity/fixtures/base.py
index 560f906..754f872 100644
--- a/test_set/cvp-sanity/fixtures/base.py
+++ b/test_set/cvp-sanity/fixtures/base.py
@@ -59,6 +59,14 @@
@pytest.fixture(scope='session')
+def check_ironic(local_salt_client):
+ salt_output = local_salt_client.test_ping(tgt='ironic:client')
+ if not salt_output:
+ pytest.skip("Ironic service is not found or ironic:client pillar is "
+ "not found on this environment.")
+
+
+@pytest.fixture(scope='session')
def check_drivetrain(local_salt_client):
salt_output = local_salt_client.test_ping(tgt='I@jenkins:client and not I@salt:master',
expr_form='compound')
diff --git a/test_set/cvp-sanity/tests/test_ironic_services.py b/test_set/cvp-sanity/tests/test_ironic_services.py
new file mode 100644
index 0000000..f2d3c90
--- /dev/null
+++ b/test_set/cvp-sanity/tests/test_ironic_services.py
@@ -0,0 +1,20 @@
+import pytest
+
+
+@pytest.mark.full
+@pytest.mark.usefixtures('check_ironic')
+@pytest.mark.usefixtures('check_openstack')
+def test_ironic_nodes_are_available_or_active(local_salt_client):
+ """
+ Make sure that ironic nodes are available or active - check that all
+ nodes have 'active' or 'available' state in output of
+ `openstack baremetal node list` on 'keystone:server' nodes.
+ The other states are not expected. See full states description:
+ https://docs.openstack.org/ironic/latest/contributor/states.html
+ """
+ result = local_salt_client.cmd_any(
+ tgt='keystone:server',
+ param='. /root/keystonercv3; openstack baremetal node list | '
+ 'grep -v "\-------\|UUID\|active\|available"')
+ assert result == '', (
+ "Some Ironic nodes are in wrong state:\n{}".format(result))