Fix incorrect counting of backends
Split tests for cinder services into two tests
Change-Id: I74137b4cc31a82718fc2a17f5abfd117aacf9963
Fix-Issue:#PROD-29913(PROD:29913)
diff --git a/test_set/cvp-sanity/fixtures/base.py b/test_set/cvp-sanity/fixtures/base.py
index 4858c83..8e3b130 100644
--- a/test_set/cvp-sanity/fixtures/base.py
+++ b/test_set/cvp-sanity/fixtures/base.py
@@ -80,6 +80,14 @@
are not found on this environment.")
+@pytest.fixture(scope='session')
+def check_cinder_backends(local_salt_client):
+ backends_cinder_available = local_salt_client.test_ping(tgt='cinder:controller')
+ if not backends_cinder_available or not any(backends_cinder_available.values()):
+ pytest.skip("Cinder service or cinder:controller:backend pillar \
+ are not found on this environment.")
+
+
def pytest_namespace():
return {'contrail': None}
diff --git a/test_set/cvp-sanity/tests/test_cinder_services.py b/test_set/cvp-sanity/tests/test_cinder_services.py
index 5d783f0..a83a3f9 100644
--- a/test_set/cvp-sanity/tests/test_cinder_services.py
+++ b/test_set/cvp-sanity/tests/test_cinder_services.py
@@ -1,26 +1,34 @@
import pytest
-def test_cinder_services(local_salt_client):
+def test_cinder_services_are_up(local_salt_client, check_cinder_backends):
"""
# Make sure that cinder backend exists with next command: `salt -C "I@cinder:controller" pillar.get cinder:controller:backend`
# Check that all services has 'Up' status in output of `cinder service-list` on keystone:server nodes
- # Check that quantity of backend in cinder:controller:backend pillar is similar to list of volumes in cinder service-list
"""
- backends_cinder = local_salt_client.test_ping(tgt='cinder:controller:backend')
- if not backends_cinder or not any(backends_cinder.values()):
- pytest.skip("Cinder service or cinder:controller:backend pillar \
- are not found on this environment.")
service_down = local_salt_client.cmd_any(
tgt='keystone:server',
param='. /root/keystonercv3; cinder service-list | grep "down\|disabled"')
- cinder_volume = local_salt_client.cmd_any(
- tgt='keystone:server',
- param='. /root/keystonercv3; cinder service-list | grep -c "volume"')
- backends_num = len(backends_cinder.keys())
assert service_down == '', \
'''Some cinder services are in wrong state'''
+
+
+def test_cinder_services_has_all_backends(local_salt_client, check_cinder_backends):
+ """
+ # Make sure that cinder backend exists with next command: `salt -C "I@cinder:controller" pillar.get cinder:controller:backend`
+ # Check that quantity of backend in cinder:controller:backend pillar is similar to list of volumes in cinder service-list
+ """
+ backends_cinder = local_salt_client.pillar_get(
+ tgt='cinder:controller',
+ param='cinder:controller:backend'
+ )
+ cinder_volume = local_salt_client.cmd_any(
+ tgt='keystone:server',
+ param='. /root/keystonercv3; cinder service-list | grep "volume" |grep -c -v -e "lvm"')
+ print(backends_cinder)
+ print(cinder_volume)
+ backends_num = len(backends_cinder.keys())
assert cinder_volume == str(backends_num), \
'Number of cinder-volume services ({0}) does not match ' \
'number of volume backends ({1})'.format(
- cinder_volume, str(backends_num))
+ cinder_volume, str(backends_num))
\ No newline at end of file