check the task state after creating image

The operation is not really done while the status of image is ACTIVE, nova
would update the properties of new image and do some operation on server,
so it is better to check the task state.

Change-Id: I2c54cb4406849d412706f0faf1f7cbff5f31a772
This commit is contained in:
chenhb 2019-07-31 16:06:04 +08:00
parent 975ec75381
commit 0470f7ffbe
2 changed files with 26 additions and 7 deletions

View File

@ -514,6 +514,15 @@ class NovaScenario(scenario.OpenStackScenario):
timeout=CONF.openstack.nova_server_image_create_timeout,
check_interval=check_interval
)
with atomic.ActionTimer(self, "nova.wait_for_server"):
utils.wait_for_status(
server,
ready_statuses=["None"],
status_attr="OS-EXT-STS:task_state",
update_resource=utils.get_from_manager(),
timeout=CONF.openstack.nova_server_image_create_timeout,
check_interval=check_interval
)
return image
@atomic.action_timer("nova.get_keypair")

View File

@ -236,13 +236,23 @@ class NovaScenarioTestCase(test.ScenarioTestCase):
glance.get_image.return_value = self.image
nova_scenario = utils.NovaScenario(context=self.context)
return_image = nova_scenario._create_image(self.server)
self.mock_wait_for_status.mock.assert_called_once_with(
self.image,
ready_statuses=["ACTIVE"],
update_resource=glance.get_image,
check_interval=CONF.openstack.
nova_server_image_create_poll_interval,
timeout=CONF.openstack.nova_server_image_create_timeout)
self.mock_wait_for_status.mock.assert_has_calls([
mock.call(
self.image,
ready_statuses=["ACTIVE"],
update_resource=glance.get_image,
check_interval=CONF.openstack.
nova_server_image_create_poll_interval,
timeout=CONF.openstack.nova_server_image_create_timeout),
mock.call(
self.server,
ready_statuses=["None"],
status_attr="OS-EXT-STS:task_state",
update_resource=self.mock_get_from_manager.mock.return_value,
check_interval=CONF.openstack.
nova_server_image_create_poll_interval,
timeout=CONF.openstack.nova_server_image_create_timeout)
])
self.assertEqual(self.mock_wait_for_status.mock.return_value,
return_image)
self._test_atomic_action_timer(nova_scenario.atomic_actions(),