Esempio n. 1
0
    def test_immediate_delete(self):
        """
        test that images get deleted immediately by default
        """

        self.cleanup()
        self.start_servers()

        client = self._get_client()
        registry = self._get_registry_client()
        meta = client.add_image(TEST_IMAGE_META, TEST_IMAGE_DATA)
        id = meta['id']

        filters = {'deleted': True, 'is_public': 'none',
                   'status': 'pending_delete'}
        recs = registry.get_images_detailed(filters=filters)
        self.assertFalse(recs)

        client.delete_image(id)
        recs = registry.get_images_detailed(filters=filters)
        self.assertFalse(recs)

        filters = {'deleted': True, 'is_public': 'none', 'status': 'deleted'}
        recs = registry.get_images_detailed(filters=filters)
        self.assertTrue(recs)
        for rec in recs:
            self.assertEqual(rec['status'], 'deleted')

        self.stop_servers()
Esempio n. 2
0
    def test_immediate_delete(self):
        """
        test that images get deleted immediately by default
        """

        self.cleanup()
        self.start_servers()

        client = self._get_client()
        registry = self._get_registry_client()
        meta = client.add_image(TEST_IMAGE_META, TEST_IMAGE_DATA)
        id = meta['id']

        filters = {
            'deleted': True,
            'is_public': 'none',
            'status': 'pending_delete'
        }
        recs = registry.get_images_detailed(filters=filters)
        self.assertFalse(recs)

        client.delete_image(id)
        recs = registry.get_images_detailed(filters=filters)
        self.assertFalse(recs)

        filters = {'deleted': True, 'is_public': 'none', 'status': 'deleted'}
        recs = registry.get_images_detailed(filters=filters)
        self.assertTrue(recs)
        for rec in recs:
            self.assertEqual(rec['status'], 'deleted')

        self.stop_servers()
Esempio n. 3
0
    def test_delayed_delete(self):
        """
        test that images don't get deleted immediatly and that the scrubber
        scrubs them
        """

        self.cleanup()
        self.start_servers(delayed_delete=True, daemon=True)

        client = self._get_client()
        registry = self._get_registry_client()
        meta = client.add_image(TEST_IMAGE_META, TEST_IMAGE_DATA)
        id = meta['id']

        filters = {
            'deleted': True,
            'is_public': 'none',
            'status': 'pending_delete'
        }
        recs = registry.get_images_detailed(filters=filters)
        self.assertFalse(recs)

        client.delete_image(id)
        recs = registry.get_images_detailed(filters=filters)
        self.assertTrue(recs)

        filters = {'deleted': True, 'is_public': 'none'}
        recs = registry.get_images_detailed(filters=filters)
        self.assertTrue(recs)
        for rec in recs:
            self.assertEqual(rec['status'], 'pending_delete')

        # NOTE(jkoelker) The build servers sometimes take longer than
        #                15 seconds to scrub. Give it up to 5 min, checking
        #                checking every 15 seconds. When/if it flips to
        #                deleted, bail immediatly.
        deleted = set()
        recs = []
        for _ in xrange(3):
            time.sleep(5)

            recs = registry.get_images_detailed(filters=filters)
            self.assertTrue(recs)

            # NOTE(jkoelker) Reset the deleted set for this loop
            deleted = set()
            for rec in recs:
                deleted.add(rec['status'] == 'deleted')

            if False not in deleted:
                break

        self.assertTrue(recs)
        for rec in recs:
            self.assertEqual(rec['status'], 'deleted')

        self.stop_servers()
Esempio n. 4
0
    def test_delayed_delete(self):
        """
        test that images don't get deleted immediatly and that the scrubber
        scrubs them
        """

        self.cleanup()
        self.start_servers(delayed_delete=True, daemon=True)

        client = self._get_client()
        registry = self._get_registry_client()
        meta = client.add_image(TEST_IMAGE_META, TEST_IMAGE_DATA)
        id = meta['id']

        filters = {'deleted': True, 'is_public': 'none',
                   'status': 'pending_delete'}
        recs = registry.get_images_detailed(filters=filters)
        self.assertFalse(recs)

        client.delete_image(id)
        recs = registry.get_images_detailed(filters=filters)
        self.assertTrue(recs)

        filters = {'deleted': True, 'is_public': 'none'}
        recs = registry.get_images_detailed(filters=filters)
        self.assertTrue(recs)
        for rec in recs:
            self.assertEqual(rec['status'], 'pending_delete')

        # NOTE(jkoelker) The build servers sometimes take longer than
        #                15 seconds to scrub. Give it up to 5 min, checking
        #                checking every 15 seconds. When/if it flips to
        #                deleted, bail immediatly.
        deleted = set()
        recs = []
        for _ in xrange(3):
            time.sleep(5)

            recs = registry.get_images_detailed(filters=filters)
            self.assertTrue(recs)

            # NOTE(jkoelker) Reset the deleted set for this loop
            deleted = set()
            for rec in recs:
                deleted.add(rec['status'] == 'deleted')

            if False not in deleted:
                break

        self.assertTrue(recs)
        for rec in recs:
            self.assertEqual(rec['status'], 'deleted')

        self.stop_servers()