blob: 62a3428a0d513fc7e5447e3ad621a7072ccf11b9 [file] [log] [blame]
Oleksii Zhurba9848e212018-09-05 10:53:51 -05001import pytest
2
3
Oleksii Zhurba5b15b9b2019-05-09 18:53:40 -05004@pytest.mark.sl_dup
5@pytest.mark.full
Ievgeniia Zadorozhnaf139db42019-03-05 11:18:48 +03006@pytest.mark.usefixtures('check_openstack')
Oleksii Zhurba5dc7dc72017-10-31 19:10:32 +00007def test_nova_services_status(local_salt_client):
Oleksii Zhurba4bfd2ee2019-04-10 21:56:58 -05008 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 Zhurba9848e212018-09-05 10:53:51 -050012
Dmitriy Kruglova34a3042019-08-20 11:45:35 +020013 assert result == '', (
14 "Some Nova services are in wrong state:\n{}".format(result))
Ievgeniia Zadorozhnaf139db42019-03-05 11:18:48 +030015
16
Oleksii Zhurba5b15b9b2019-05-09 18:53:40 -050017@pytest.mark.smoke
Ievgeniia Zadorozhnaf139db42019-03-05 11:18:48 +030018@pytest.mark.usefixtures('check_openstack')
19def test_nova_hosts_consistent(local_salt_client):
Ievgeniia Zadorozhna7111c8b2019-12-04 12:46:04 +030020 # exclude bmt* nodes because they also have nova-compute running
21 # but they are not the hypervisors
Ievgeniia Zadorozhnafe47c282019-12-16 12:07:27 +030022 ironic = local_salt_client.test_ping(tgt='ironic:conductor')
Ievgeniia Zadorozhna7111c8b2019-12-04 12:46:04 +030023 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 Zhurba4bfd2ee2019-04-10 21:56:58 -050029 all_cmp_services = local_salt_client.cmd_any(
30 tgt='keystone:server',
31 param='. /root/keystonercv3;'
Ievgeniia Zadorozhna7111c8b2019-12-04 12:46:04 +030032 'nova service-list | grep "nova-compute" '
33 '{} | wc -l'.format(grep_exclude_ironic))
Oleksii Zhurba4bfd2ee2019-04-10 21:56:58 -050034 enabled_cmp_services = local_salt_client.cmd_any(
35 tgt='keystone:server',
36 param='. /root/keystonercv3;'
Ievgeniia Zadorozhna7111c8b2019-12-04 12:46:04 +030037 'nova service-list | grep "nova-compute" | grep "enabled" '
38 '{} | wc -l'.format(grep_exclude_ironic))
Oleksii Zhurba4bfd2ee2019-04-10 21:56:58 -050039 hosts = local_salt_client.cmd_any(
40 tgt='keystone:server',
41 param='. /root/keystonercv3;'
Ievgeniia Zadorozhna7111c8b2019-12-04 12:46:04 +030042 'openstack host list | grep "compute" '
43 '{} | wc -l'.format(grep_exclude_ironic))
Oleksii Zhurba4bfd2ee2019-04-10 21:56:58 -050044 hypervisors = local_salt_client.cmd_any(
45 tgt='keystone:server',
46 param='. /root/keystonercv3;'
Ievgeniia Zadorozhna7111c8b2019-12-04 12:46:04 +030047 'openstack hypervisor list | egrep -v "\-----|ID" '
48 '{} | wc -l'.format(grep_exclude_ironic))
Ievgeniia Zadorozhnaf139db42019-03-05 11:18:48 +030049
Dmitriy Kruglova34a3042019-08-20 11:45:35 +020050 assert all_cmp_services == hypervisors, (
51 "Number of nova-compute services ({}) does not match number of "
Ievgeniia Zadorozhnaf139db42019-03-05 11:18:48 +030052 "hypervisors ({}).".format(all_cmp_services, hypervisors)
Dmitriy Kruglova34a3042019-08-20 11:45:35 +020053 )
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 )