Skip to content

Commit aaef6ce

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Repro gen conflict in COMPUTE_STATUS_DISABLED handling"
2 parents f2b2f48 + f167891 commit aaef6ce

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
2+
# not use this file except in compliance with the License. You may obtain
3+
# a copy of the License at
4+
#
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
#
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10+
# License for the specific language governing permissions and limitations
11+
# under the License.
12+
13+
from nova.tests.functional import integrated_helpers
14+
15+
16+
class TestServices(integrated_helpers._IntegratedTestBase):
17+
api_major_version = 'v2.1'
18+
microversion = 'latest'
19+
20+
def setUp(self):
21+
super(TestServices, self).setUp()
22+
self.compute_rp_uuid = self.admin_api.api_get(
23+
'os-hypervisors?hypervisor_hostname_pattern=fake-mini'
24+
).body['hypervisors'][0]['id']
25+
self.compute_service_id = self.admin_api.get_services(
26+
host='compute', binary='nova-compute')[0]['id']
27+
28+
def _get_traits_on_compute(self):
29+
return self.placement_api.get(
30+
'/resource_providers/%s/traits' % self.compute_rp_uuid,
31+
version='1.6'
32+
).body['traits']
33+
34+
def _disable_compute(self):
35+
self.api.put_service(
36+
self.compute_service_id, {'status': 'disabled'})
37+
38+
def _enable_compute(self):
39+
self.api.put_service(
40+
self.compute_service_id, {'status': 'enabled'})
41+
42+
def _has_disabled_trait(self):
43+
return "COMPUTE_STATUS_DISABLED" in self._get_traits_on_compute()
44+
45+
def test_compute_disable_after_server_create(self):
46+
# Check that COMPUTE_STATUS_DISABLED is not on the compute
47+
self.assertFalse(self._has_disabled_trait())
48+
49+
self._disable_compute()
50+
# Check that COMPUTE_STATUS_DISABLED is now on the compute
51+
self.assertTrue(self._has_disabled_trait())
52+
53+
self._enable_compute()
54+
# Check that COMPUTE_STATUS_DISABLED is not on the compute
55+
self.assertFalse(self._has_disabled_trait())
56+
57+
# Create a server.
58+
self._create_server(networks=[])
59+
60+
self._disable_compute()
61+
# FIXME(gibi): Check that COMPUTE_STATUS_DISABLED is now on the
62+
# compute. Unfortunately it is not true as the compute manager failed
63+
# to update the traits in placement due to a stale provide tree cache.
64+
# It is stale because a server is booted on the compute since the last
65+
# update_available_resource periodic was run.
66+
self.assertIn(
67+
'An error occurred while updating COMPUTE_STATUS_DISABLED trait '
68+
'on compute node resource provider',
69+
self.stdlog.logger.output)
70+
self.assertFalse(self._has_disabled_trait())
71+
72+
# This would be the expected behavior
73+
#
74+
# self.assertTrue(self._has_disabled_trait())
75+
#
76+
# Alternatively the test could wait for the periodic to run or trigger
77+
# it manually.
78+
79+
# This passes now but not because enabling works but because the
80+
# above fault caused that COMPUTE_STATUS_DISABLED is not on the compute
81+
# RP in the first place.
82+
self._enable_compute()
83+
# Check that COMPUTE_STATUS_DISABLED is removed from the compute
84+
self.assertFalse(self._has_disabled_trait())

0 commit comments

Comments
 (0)