OpenStack Compute (Nova)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
3.3KB

  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. from nova import test
  13. from nova.tests import fixtures as nova_fixtures
  14. from nova.tests.functional import integrated_helpers
  15. from nova.tests.unit.image import fake as fake_image
  16. from nova import utils
  17. class ListDeletedServersWithMarker(test.TestCase,
  18. integrated_helpers.InstanceHelperMixin):
  19. """Regression test for bug 1849409 introduced in Queens where listing
  20. deleted servers with a marker returns the wrong results because the marker
  21. is nulled out if BuildRequestList.get_by_filters does not raise
  22. MarkerNotFound, but that does not mean the marker was found in the build
  23. request list.
  24. """
  25. def setUp(self):
  26. super(ListDeletedServersWithMarker, self).setUp()
  27. # Start standard fixtures.
  28. self.useFixture(nova_fixtures.PlacementFixture())
  29. self.useFixture(nova_fixtures.NeutronFixture(self))
  30. fake_image.stub_out_image_service(self)
  31. self.addCleanup(fake_image.FakeImageService_reset)
  32. # Start nova services.
  33. self.api = self.useFixture(nova_fixtures.OSAPIFixture(
  34. api_version='v2.1')).admin_api
  35. self.start_service('conductor')
  36. self.start_service('scheduler')
  37. self.start_service('compute')
  38. def test_list_deleted_servers_with_marker(self):
  39. # Create a server.
  40. server = self._build_minimal_create_server_request(
  41. self.api, 'test_list_deleted_servers_with_marker',
  42. image_uuid=fake_image.get_valid_image_id(),
  43. networks='none')
  44. # networks='none' requires microversion >= 2.37
  45. with utils.temporary_mutation(self.api, microversion='2.37'):
  46. server = self.api.post_server({'server': server})
  47. server = self._wait_for_state_change(self.api, server, 'ACTIVE')
  48. # Now delete the server and wait for it to be gone.
  49. self.api.delete_server(server['id'])
  50. self._wait_until_deleted(server)
  51. # List deleted servers, we should get the one back.
  52. servers = self.api.get_servers(detail=False,
  53. search_opts={'deleted': True,
  54. 'name': server['name']})
  55. self.assertEqual(1, len(servers), servers)
  56. self.assertEqual(server['id'], servers[0]['id'])
  57. # Now list deleted servers with a marker which should not return the
  58. # marker instance.
  59. servers = self.api.get_servers(detail=False,
  60. search_opts={'deleted': True,
  61. 'marker': server['id']})
  62. # FIXME(mriedem): This is bug 1849409 where the marker param is not
  63. # honored correctly when using deleted=True.
  64. server_names = [serv['name'] for serv in servers]
  65. self.assertIn(server['name'], server_names)