Oleksii Zhurba | 9848e21 | 2018-09-05 10:53:51 -0500 | [diff] [blame] | 1 | import pytest |
| 2 | |
| 3 | |
Oleksii Zhurba | 5b15b9b | 2019-05-09 18:53:40 -0500 | [diff] [blame] | 4 | @pytest.mark.sl_dup |
| 5 | @pytest.mark.full |
Ievgeniia Zadorozhna | f139db4 | 2019-03-05 11:18:48 +0300 | [diff] [blame] | 6 | @pytest.mark.usefixtures('check_openstack') |
Oleksii Zhurba | 5dc7dc7 | 2017-10-31 19:10:32 +0000 | [diff] [blame] | 7 | def test_nova_services_status(local_salt_client): |
Oleksii Zhurba | 4bfd2ee | 2019-04-10 21:56:58 -0500 | [diff] [blame] | 8 | result = local_salt_client.cmd_any( |
| 9 | tgt='keystone:server', |
| 10 | param='. /root/keystonercv3;' |
| 11 | 'nova service-list | grep "down\|disabled" | grep -v "Forced down"') |
Oleksii Zhurba | 9848e21 | 2018-09-05 10:53:51 -0500 | [diff] [blame] | 12 | |
Dmitriy Kruglov | a34a304 | 2019-08-20 11:45:35 +0200 | [diff] [blame] | 13 | assert result == '', ( |
| 14 | "Some Nova services are in wrong state:\n{}".format(result)) |
Ievgeniia Zadorozhna | f139db4 | 2019-03-05 11:18:48 +0300 | [diff] [blame] | 15 | |
| 16 | |
Oleksii Zhurba | 5b15b9b | 2019-05-09 18:53:40 -0500 | [diff] [blame] | 17 | @pytest.mark.smoke |
Ievgeniia Zadorozhna | f139db4 | 2019-03-05 11:18:48 +0300 | [diff] [blame] | 18 | @pytest.mark.usefixtures('check_openstack') |
| 19 | def test_nova_hosts_consistent(local_salt_client): |
Ievgeniia Zadorozhna | 7111c8b | 2019-12-04 12:46:04 +0300 | [diff] [blame] | 20 | # exclude bmt* nodes because they also have nova-compute running |
| 21 | # but they are not the hypervisors |
Ievgeniia Zadorozhna | fe47c28 | 2019-12-16 12:07:27 +0300 | [diff] [blame] | 22 | ironic = local_salt_client.test_ping(tgt='ironic:conductor') |
Ievgeniia Zadorozhna | 7111c8b | 2019-12-04 12:46:04 +0300 | [diff] [blame] | 23 | if ironic: |
| 24 | ironic_nodes = [i.split('.')[0] for i in ironic] |
| 25 | grep_exclude_ironic = "| egrep -v '{}'".format("|".join(ironic_nodes)) |
| 26 | else: |
| 27 | grep_exclude_ironic = "" |
| 28 | |
Oleksii Zhurba | 4bfd2ee | 2019-04-10 21:56:58 -0500 | [diff] [blame] | 29 | all_cmp_services = local_salt_client.cmd_any( |
| 30 | tgt='keystone:server', |
| 31 | param='. /root/keystonercv3;' |
Ievgeniia Zadorozhna | 7111c8b | 2019-12-04 12:46:04 +0300 | [diff] [blame] | 32 | 'nova service-list | grep "nova-compute" ' |
| 33 | '{} | wc -l'.format(grep_exclude_ironic)) |
Oleksii Zhurba | 4bfd2ee | 2019-04-10 21:56:58 -0500 | [diff] [blame] | 34 | enabled_cmp_services = local_salt_client.cmd_any( |
| 35 | tgt='keystone:server', |
| 36 | param='. /root/keystonercv3;' |
Ievgeniia Zadorozhna | 7111c8b | 2019-12-04 12:46:04 +0300 | [diff] [blame] | 37 | 'nova service-list | grep "nova-compute" | grep "enabled" ' |
| 38 | '{} | wc -l'.format(grep_exclude_ironic)) |
Oleksii Zhurba | 4bfd2ee | 2019-04-10 21:56:58 -0500 | [diff] [blame] | 39 | hosts = local_salt_client.cmd_any( |
| 40 | tgt='keystone:server', |
| 41 | param='. /root/keystonercv3;' |
Ievgeniia Zadorozhna | 7111c8b | 2019-12-04 12:46:04 +0300 | [diff] [blame] | 42 | 'openstack host list | grep "compute" ' |
| 43 | '{} | wc -l'.format(grep_exclude_ironic)) |
Oleksii Zhurba | 4bfd2ee | 2019-04-10 21:56:58 -0500 | [diff] [blame] | 44 | hypervisors = local_salt_client.cmd_any( |
| 45 | tgt='keystone:server', |
| 46 | param='. /root/keystonercv3;' |
Ievgeniia Zadorozhna | 7111c8b | 2019-12-04 12:46:04 +0300 | [diff] [blame] | 47 | 'openstack hypervisor list | egrep -v "\-----|ID" ' |
| 48 | '{} | wc -l'.format(grep_exclude_ironic)) |
Ievgeniia Zadorozhna | f139db4 | 2019-03-05 11:18:48 +0300 | [diff] [blame] | 49 | |
Dmitriy Kruglov | a34a304 | 2019-08-20 11:45:35 +0200 | [diff] [blame] | 50 | assert all_cmp_services == hypervisors, ( |
| 51 | "Number of nova-compute services ({}) does not match number of " |
Ievgeniia Zadorozhna | f139db4 | 2019-03-05 11:18:48 +0300 | [diff] [blame] | 52 | "hypervisors ({}).".format(all_cmp_services, hypervisors) |
Dmitriy Kruglov | a34a304 | 2019-08-20 11:45:35 +0200 | [diff] [blame] | 53 | ) |
| 54 | assert enabled_cmp_services == hosts, ( |
| 55 | "Number of enabled nova-compute services ({}) does not match number " |
| 56 | "of hosts ({}).".format(enabled_cmp_services, hosts) |
| 57 | ) |