Oleksii Zhurba | 9848e21 | 2018-09-05 10:53:51 -0500 | [diff] [blame] | 1 | import pytest |
| 2 | |
| 3 | |
Ievgeniia Zadorozhna | f139db4 | 2019-03-05 11:18:48 +0300 | [diff] [blame] | 4 | @pytest.mark.usefixtures('check_openstack') |
Oleksii Zhurba | 5dc7dc7 | 2017-10-31 19:10:32 +0000 | [diff] [blame] | 5 | def test_nova_services_status(local_salt_client): |
| 6 | result = local_salt_client.cmd( |
| 7 | 'keystone:server', |
| 8 | 'cmd.run', |
Ievgeniia Zadorozhna | f139db4 | 2019-03-05 11:18:48 +0300 | [diff] [blame] | 9 | ['. /root/keystonercv3;' |
| 10 | 'nova service-list | grep "down\|disabled" | grep -v "Forced down"'], |
Oleksii Zhurba | 5dc7dc7 | 2017-10-31 19:10:32 +0000 | [diff] [blame] | 11 | expr_form='pillar') |
Oleksii Zhurba | 9848e21 | 2018-09-05 10:53:51 -0500 | [diff] [blame] | 12 | |
Oleksii Zhurba | 5dc7dc7 | 2017-10-31 19:10:32 +0000 | [diff] [blame] | 13 | assert result[result.keys()[0]] == '', \ |
| 14 | '''Some nova services are in wrong state''' |
Ievgeniia Zadorozhna | f139db4 | 2019-03-05 11:18:48 +0300 | [diff] [blame] | 15 | |
| 16 | |
| 17 | @pytest.mark.usefixtures('check_openstack') |
| 18 | def test_nova_hosts_consistent(local_salt_client): |
| 19 | all_cmp_services = local_salt_client.cmd( |
| 20 | 'keystone:server', |
| 21 | 'cmd.run', |
| 22 | ['. /root/keystonercv3;' |
| 23 | 'nova service-list | grep "nova-compute" | wc -l'], |
| 24 | expr_form='pillar').values()[0] |
| 25 | enabled_cmp_services = local_salt_client.cmd( |
| 26 | 'keystone:server', |
| 27 | 'cmd.run', |
| 28 | ['. /root/keystonercv3;' |
| 29 | 'nova service-list | grep "nova-compute" | grep "enabled" | wc -l'], |
| 30 | expr_form='pillar').values()[0] |
| 31 | hosts = local_salt_client.cmd( |
| 32 | 'keystone:server', |
| 33 | 'cmd.run', |
| 34 | ['. /root/keystonercv3;' |
| 35 | 'openstack host list | grep "compute" | wc -l'], |
| 36 | expr_form='pillar').values()[0] |
| 37 | hypervisors = local_salt_client.cmd( |
| 38 | 'keystone:server', |
| 39 | 'cmd.run', |
| 40 | ['. /root/keystonercv3;' |
| 41 | 'openstack hypervisor list | egrep -v "\-----|ID" | wc -l'], |
| 42 | expr_form='pillar').values()[0] |
| 43 | |
| 44 | assert all_cmp_services == hypervisors, \ |
| 45 | "Number of nova-compute services ({}) does not match number of " \ |
| 46 | "hypervisors ({}).".format(all_cmp_services, hypervisors) |
| 47 | assert enabled_cmp_services == hosts, \ |
| 48 | "Number of enabled nova-compute services ({}) does not match number \ |
| 49 | of hosts ({}).".format(enabled_cmp_services, hosts) |