Exemple #1
0
    def test_remote_package_delete(self):
        """Verify remote package delete works."""
        def list_packages_mock(*args, **kwargs):
            return ['Quilt/Test']

        def _tophashes_with_packages_mock(*args, **kwargs):
            return {'101': {'Quilt/Test'}}

        def list_objects_mock(*args):
            return [{
                'Key': '.quilt/named_packages/Quilt/Test/0'
            }, {
                'Key': '.quilt/named_packages/Quilt/Test/latest'
            }]

        def get_bytes_mock(*args):
            return b'101', None

        with patch('quilt3.api.list_packages', new=list_packages_mock), \
                patch('quilt3.api._tophashes_with_packages', new=_tophashes_with_packages_mock), \
                patch('quilt3.api.list_objects', new=list_objects_mock), \
                patch('quilt3.api.get_bytes', new=get_bytes_mock), \
                patch('quilt3.api.delete_object') as delete_mock:
            quilt3.delete_package('Quilt/Test', registry='s3://test-bucket')

            delete_mock.assert_any_call('test-bucket', '.quilt/packages/101')
            delete_mock.assert_any_call('test-bucket',
                                        '.quilt/named_packages/Quilt/Test/0')
            delete_mock.assert_any_call(
                'test-bucket', '.quilt/named_packages/Quilt/Test/latest')
Exemple #2
0
    def test_local_package_delete_overlapping(self):
        """
        Verify local package delete works when multiple packages reference the
        same tophash.
        """
        top_hash = Package().build("Quilt/Test1").top_hash
        top_hash = Package().build("Quilt/Test2").top_hash

        assert 'Quilt/Test1' in quilt3.list_packages()
        assert top_hash in [
            p.name for p in (LOCAL_REGISTRY / '.quilt/packages').iterdir()
        ]

        quilt3.delete_package('Quilt/Test1')

        assert 'Quilt/Test1' not in quilt3.list_packages()
        assert top_hash in [
            p.name for p in (LOCAL_REGISTRY / '.quilt/packages').iterdir()
        ]

        quilt3.delete_package('Quilt/Test2')
        assert 'Quilt/Test2' not in quilt3.list_packages()
        assert top_hash not in [
            p.name for p in (LOCAL_REGISTRY / '.quilt/packages').iterdir()
        ]
Exemple #3
0
    def test_local_package_delete(self):
        """Verify local package delete works."""
        top_hash = Package().build("Quilt/Test").top_hash
        assert 'Quilt/Test' in quilt3.list_packages()

        quilt3.delete_package('Quilt/Test')
        assert 'Quilt/Test' not in quilt3.list_packages()
Exemple #4
0
    def test_remote_package_delete(self):
        """Verify remote package delete works."""
        self.s3_stubber.add_response(
            method='list_objects_v2',
            service_response={
                'Contents': [{
                    'Key': '.quilt/named_packages/Quilt/Test/0',
                    'Size': 64,
                }, {
                    'Key': '.quilt/named_packages/Quilt/Test/latest',
                    'Size': 64,
                }]
            },
            expected_params={
                'Bucket': 'test-bucket',
                'Prefix': '.quilt/named_packages/Quilt/Test/',
            })

        for path in [
                'Quilt/Test/0', 'Quilt/Test/latest', 'Quilt/Test/', 'Quilt/'
        ]:
            self.s3_stubber.add_response(method='delete_object',
                                         service_response={},
                                         expected_params={
                                             'Bucket':
                                             'test-bucket',
                                             'Key':
                                             f'.quilt/named_packages/{path}',
                                         })

        quilt3.delete_package('Quilt/Test', registry='s3://test-bucket')
def repro(package_name, registry_name, push_dest):

    print("Attempting to reproduce 'unable to delete package' issue")

    generate_new_package_version(package_name, registry_name, push_dest)

    fn_info = FunctionReporter(
        f"Deleting package {package_name} from registry {registry_name}")
    try:
        quilt3.delete_package(package_name, registry_name)
        fn_info.succeeded(None, additional_detail="COULD NOT REPRO")
    except Exception as ex:
        fn_info.failed(ex)
Exemple #6
0
    def delete_package(self, del_from_bucket=True):
        """ Delete package

        Args:
            del_from_bucket (:obj:`bool`, optional): if :obj:`True`, delete the
                files for the package from the AWS bucket
        """
        quilt3.delete_package(self.get_full_package_id(),
                              registry=self.get_aws_bucket_uri())

        if del_from_bucket:
            bucket = quilt3.Bucket(self.get_aws_bucket_uri())
            bucket.delete_dir('.quilt/named_packages/' +
                              self.get_full_package_id() + '/')
            bucket.delete_dir(self.get_full_package_id() + '/')
Exemple #7
0
    def test_remote_package_delete_overlapping(self):
        """
        Verify remote package delete works when multiple packages reference the
        same tophash.
        """
        def list_packages_mock(*args, **kwargs):
            return ['Quilt/Test1', 'Quilt/Test2']

        def _tophashes_with_packages_mock(*args, **kwargs):
            return {'101': {'Quilt/Test1', 'Quilt/Test2'}}

        def list_objects_mock(*args):
            return [{
                'Key': '.quilt/named_packages/Quilt/Test1/0'
            }, {
                'Key': '.quilt/named_packages/Quilt/Test1/latest'
            }, {
                'Key': '.quilt/named_packages/Quilt/Test2/0'
            }, {
                'Key': '.quilt/named_packages/Quilt/Test2/latest'
            }]

        def get_bytes_mock(*args):
            return b'101', None

        with patch('quilt3.api.list_packages', new=list_packages_mock), \
                patch('quilt3.api._tophashes_with_packages', new=_tophashes_with_packages_mock), \
                patch('quilt3.api.list_objects', new=list_objects_mock), \
                patch('quilt3.api.get_bytes', new=get_bytes_mock), \
                patch('quilt3.api.delete_object') as delete_mock:
            quilt3.delete_package('Quilt/Test1', registry='s3://test-bucket')

            # the reference count for the tophash 101 is still one, so it should still exist
            assert call(
                'test-bucket',
                '.quilt/packages/101') not in delete_mock.call_args_list
            delete_mock.assert_any_call('test-bucket',
                                        '.quilt/named_packages/Quilt/Test1/0')
            delete_mock.assert_any_call(
                'test-bucket', '.quilt/named_packages/Quilt/Test1/latest')