blob: 6505d30ede2696feed3af11abb339c437ee49c33 [file] [log] [blame]
Oleksii Zhurba9848e212018-09-05 10:53:51 -05001import pytest
2
3
Ievgeniia Zadorozhnaf139db42019-03-05 11:18:48 +03004@pytest.mark.usefixtures('check_openstack')
Oleksii Zhurba5dc7dc72017-10-31 19:10:32 +00005def test_nova_services_status(local_salt_client):
Oleksii Zhurba4bfd2ee2019-04-10 21:56:58 -05006 result = local_salt_client.cmd_any(
7 tgt='keystone:server',
8 param='. /root/keystonercv3;'
9 'nova service-list | grep "down\|disabled" | grep -v "Forced down"')
Oleksii Zhurba9848e212018-09-05 10:53:51 -050010
Oleksii Zhurba4bfd2ee2019-04-10 21:56:58 -050011 assert result == '', \
Oleksii Zhurba5dc7dc72017-10-31 19:10:32 +000012 '''Some nova services are in wrong state'''
Ievgeniia Zadorozhnaf139db42019-03-05 11:18:48 +030013
14
15@pytest.mark.usefixtures('check_openstack')
16def test_nova_hosts_consistent(local_salt_client):
Oleksii Zhurba4bfd2ee2019-04-10 21:56:58 -050017 all_cmp_services = local_salt_client.cmd_any(
18 tgt='keystone:server',
19 param='. /root/keystonercv3;'
20 'nova service-list | grep "nova-compute" | wc -l')
21 enabled_cmp_services = local_salt_client.cmd_any(
22 tgt='keystone:server',
23 param='. /root/keystonercv3;'
24 'nova service-list | grep "nova-compute" | grep "enabled" | wc -l')
25 hosts = local_salt_client.cmd_any(
26 tgt='keystone:server',
27 param='. /root/keystonercv3;'
28 'openstack host list | grep "compute" | wc -l')
29 hypervisors = local_salt_client.cmd_any(
30 tgt='keystone:server',
31 param='. /root/keystonercv3;'
32 'openstack hypervisor list | egrep -v "\-----|ID" | wc -l')
Ievgeniia Zadorozhnaf139db42019-03-05 11:18:48 +030033
34 assert all_cmp_services == hypervisors, \
35 "Number of nova-compute services ({}) does not match number of " \
36 "hypervisors ({}).".format(all_cmp_services, hypervisors)
37 assert enabled_cmp_services == hosts, \
38 "Number of enabled nova-compute services ({}) does not match number \
39 of hosts ({}).".format(enabled_cmp_services, hosts)