Merge "Get/put archive works when container is paused or stopped"

This commit is contained in:
Jenkins 2017-03-10 05:53:53 +00:00 committed by Gerrit Code Review
commit b9e21fdd77
2 changed files with 22 additions and 2 deletions

View File

@ -49,8 +49,8 @@ VALID_STATES = {
'attach': ['Running'],
'resize': ['Running'],
'top': ['Running'],
'get_archive': ['Running'],
'put_archive': ['Running'],
'get_archive': ['Running', 'Stopped', 'Paused'],
'put_archive': ['Running', 'Stopped', 'Paused'],
}

View File

@ -1389,6 +1389,16 @@ class TestContainerController(api_base.FunctionalTest):
container_get_archive.assert_called_once_with(
mock.ANY, test_container_obj, cmd['path'])
def test_get_archive_by_uuid_invalid_state(self):
uuid = uuidutils.generate_uuid()
test_object = utils.create_test_container(context=self.context,
uuid=uuid, status='Error')
with self.assertRaisesRegexp(
AppError,
"Cannot get_archive container %s in Error state" % uuid):
self.app.get('/v1/containers/%s/%s/' % (test_object.uuid,
'get_archive'))
@patch('zun.common.utils.validate_container_state')
@patch('zun.compute.api.API.container_put_archive')
@patch('zun.objects.Container.get_by_uuid')
@ -1431,6 +1441,16 @@ class TestContainerController(api_base.FunctionalTest):
container_put_archive.assert_called_once_with(
mock.ANY, test_container_obj, cmd['path'], cmd['data'])
def test_put_archive_by_uuid_invalid_state(self):
uuid = uuidutils.generate_uuid()
test_object = utils.create_test_container(context=self.context,
uuid=uuid, status='Error')
with self.assertRaisesRegexp(
AppError,
"Cannot put_archive container %s in Error state" % uuid):
self.app.post('/v1/containers/%s/%s/' % (test_object.uuid,
'put_archive'))
class TestContainerEnforcement(api_base.FunctionalTest):