blob: 20bd17d5c3be96e27475fbfd396bff37f4938f07 [file] [log] [blame]
Oleksii Zhurbae592ed12018-06-21 18:01:09 -05001import pytest
2
3
Oleksii Zhurbab9bf5452018-03-26 14:27:41 -05004def test_cinder_services(local_salt_client):
Oleksii Zhurbae502d662018-08-07 16:46:14 -05005 cinder_backends_info = local_salt_client.cmd(
Oleksii Zhurbae592ed12018-06-21 18:01:09 -05006 'cinder:controller',
Oleksii Zhurbae502d662018-08-07 16:46:14 -05007 'pillar.get',
8 ['cinder:controller:backend'],
9 expr_form='pillar')
10 if not cinder_backends_info:
11 pytest.skip("Cinder is not found on this environment")
12 service_down = local_salt_client.cmd(
13 'keystone:server',
Oleksii Zhurbab9bf5452018-03-26 14:27:41 -050014 'cmd.run',
15 ['. /root/keystonerc; cinder service-list | grep "down\|disabled"'],
16 expr_form='pillar')
17 cinder_volume = local_salt_client.cmd(
18 'keystone:server',
19 'cmd.run',
Oleksii Zhurbae502d662018-08-07 16:46:14 -050020 ['. /root/keystonerc; cinder service-list | grep -c "volume"'],
Oleksii Zhurbab9bf5452018-03-26 14:27:41 -050021 expr_form='pillar')
Oleksii Zhurbae502d662018-08-07 16:46:14 -050022 backends_cinder = cinder_backends_info[cinder_backends_info.keys()[0]]
23 backends_num = len(backends_cinder.keys())
Oleksii Zhurbab9bf5452018-03-26 14:27:41 -050024 assert service_down[service_down.keys()[0]] == '', \
25 '''Some cinder services are in wrong state'''
Oleksii Zhurbae502d662018-08-07 16:46:14 -050026 assert cinder_volume[cinder_volume.keys()[0]] == str(backends_num), \
27 'Number of cinder-volume services ({0}) does not match ' \
28 'number of volume backends ({1})'.format(
29 cinder_volume[cinder_volume.keys()[0]], str(backends_num))