blob: 54ed76efd495c4789fe2a24f269e165670f5e2f3 [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
Oleksii Zhurba4bfd2ee2019-04-10 21:56:58 -050013 assert result == '', \
Oleksii Zhurba5dc7dc72017-10-31 19:10:32 +000014 '''Some nova services are in wrong state'''
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):
Oleksii Zhurba4bfd2ee2019-04-10 21:56:58 -050020 all_cmp_services = local_salt_client.cmd_any(
21 tgt='keystone:server',
22 param='. /root/keystonercv3;'
23 'nova service-list | grep "nova-compute" | wc -l')
24 enabled_cmp_services = local_salt_client.cmd_any(
25 tgt='keystone:server',
26 param='. /root/keystonercv3;'
27 'nova service-list | grep "nova-compute" | grep "enabled" | wc -l')
28 hosts = local_salt_client.cmd_any(
29 tgt='keystone:server',
30 param='. /root/keystonercv3;'
31 'openstack host list | grep "compute" | wc -l')
32 hypervisors = local_salt_client.cmd_any(
33 tgt='keystone:server',
34 param='. /root/keystonercv3;'
35 'openstack hypervisor list | egrep -v "\-----|ID" | wc -l')
Ievgeniia Zadorozhnaf139db42019-03-05 11:18:48 +030036
37 assert all_cmp_services == hypervisors, \
38 "Number of nova-compute services ({}) does not match number of " \
39 "hypervisors ({}).".format(all_cmp_services, hypervisors)
40 assert enabled_cmp_services == hosts, \
41 "Number of enabled nova-compute services ({}) does not match number \
42 of hosts ({}).".format(enabled_cmp_services, hosts)