Oleksii Zhurba | e592ed1 | 2018-06-21 18:01:09 -0500 | [diff] [blame] | 1 | import pytest |
| 2 | |
| 3 | |
Oleksii Zhurba | b9bf545 | 2018-03-26 14:27:41 -0500 | [diff] [blame] | 4 | def test_cinder_services(local_salt_client): |
Oleksii Zhurba | e502d66 | 2018-08-07 16:46:14 -0500 | [diff] [blame] | 5 | cinder_backends_info = local_salt_client.cmd( |
Oleksii Zhurba | e592ed1 | 2018-06-21 18:01:09 -0500 | [diff] [blame] | 6 | 'cinder:controller', |
Oleksii Zhurba | e502d66 | 2018-08-07 16:46:14 -0500 | [diff] [blame] | 7 | 'pillar.get', |
| 8 | ['cinder:controller:backend'], |
| 9 | expr_form='pillar') |
| 10 | if not cinder_backends_info: |
Oleksii Zhurba | 9848e21 | 2018-09-05 10:53:51 -0500 | [diff] [blame] | 11 | pytest.skip("Cinder service or cinder:controller pillar \ |
| 12 | are not found on this environment.") |
Oleksii Zhurba | e502d66 | 2018-08-07 16:46:14 -0500 | [diff] [blame] | 13 | service_down = local_salt_client.cmd( |
| 14 | 'keystone:server', |
Oleksii Zhurba | b9bf545 | 2018-03-26 14:27:41 -0500 | [diff] [blame] | 15 | 'cmd.run', |
Oleksii Zhurba | 5c56c24 | 2018-12-05 16:46:17 -0600 | [diff] [blame] | 16 | ['. /root/keystonercv3; cinder service-list | grep "down\|disabled"'], |
Oleksii Zhurba | b9bf545 | 2018-03-26 14:27:41 -0500 | [diff] [blame] | 17 | expr_form='pillar') |
| 18 | cinder_volume = local_salt_client.cmd( |
| 19 | 'keystone:server', |
| 20 | 'cmd.run', |
Oleksii Zhurba | 5c56c24 | 2018-12-05 16:46:17 -0600 | [diff] [blame] | 21 | ['. /root/keystonercv3; cinder service-list | grep -c "volume"'], |
Oleksii Zhurba | b9bf545 | 2018-03-26 14:27:41 -0500 | [diff] [blame] | 22 | expr_form='pillar') |
Oleksii Zhurba | e502d66 | 2018-08-07 16:46:14 -0500 | [diff] [blame] | 23 | backends_cinder = cinder_backends_info[cinder_backends_info.keys()[0]] |
| 24 | backends_num = len(backends_cinder.keys()) |
Oleksii Zhurba | b9bf545 | 2018-03-26 14:27:41 -0500 | [diff] [blame] | 25 | assert service_down[service_down.keys()[0]] == '', \ |
| 26 | '''Some cinder services are in wrong state''' |
Oleksii Zhurba | e502d66 | 2018-08-07 16:46:14 -0500 | [diff] [blame] | 27 | assert cinder_volume[cinder_volume.keys()[0]] == str(backends_num), \ |
| 28 | 'Number of cinder-volume services ({0}) does not match ' \ |
| 29 | 'number of volume backends ({1})'.format( |
| 30 | cinder_volume[cinder_volume.keys()[0]], str(backends_num)) |