blob: 471e5dd97d70d9879cdbeacb7cf6e1a8b64c5387 [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):
6 result = local_salt_client.cmd(
7 'keystone:server',
8 'cmd.run',
Ievgeniia Zadorozhnaf139db42019-03-05 11:18:48 +03009 ['. /root/keystonercv3;'
10 'nova service-list | grep "down\|disabled" | grep -v "Forced down"'],
Oleksii Zhurba5dc7dc72017-10-31 19:10:32 +000011 expr_form='pillar')
Oleksii Zhurba9848e212018-09-05 10:53:51 -050012
Oleksii Zhurba5dc7dc72017-10-31 19:10:32 +000013 assert result[result.keys()[0]] == '', \
14 '''Some nova services are in wrong state'''
Ievgeniia Zadorozhnaf139db42019-03-05 11:18:48 +030015
16
17@pytest.mark.usefixtures('check_openstack')
18def 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)