EnterpriseDB / barman

Barman - Backup and Recovery Manager for PostgreSQL
https://www.pgbarman.org/
GNU General Public License v3.0
2.06k stars 191 forks source link

TestAnnotationManagerFile.test_delete_one_of_many_annotations fails on illumos #869

Open mtelka opened 10 months ago

mtelka commented 10 months ago

I see the following failure while testing barman 3.9.0 on OpenIndiana (an illumos distro):

________ TestAnnotationManagerFile.test_delete_one_of_many_annotations _________

self = <test_annotations.TestAnnotationManagerFile object at 0x7fffabe485b0>
tmpdir = local('/tmp/pytest-of-marcel/pytest-34/test_delete_one_of_many_annota0')

    def test_delete_one_of_many_annotations(self, tmpdir):
        """Tests we delete the correct annotation successfully"""
        base_backup_dir = tmpdir.mkdir("base")
        os.makedirs("%s/%s/annotations" % (base_backup_dir, test_backup_id))
        self._create_annotation_on_filesystem(
            base_backup_dir, test_backup_id, "test_annotation", "annotation_value"
        )
        self._create_annotation_on_filesystem(
            base_backup_dir, test_backup_id, "test_annotation_2", "annotation_value_2"
        )
        annotation_manager = AnnotationManagerFile(base_backup_dir)
>       annotation_manager.delete_annotation(test_backup_id, "test_annotation")

tests/test_annotations.py:225: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <barman.annotations.AnnotationManagerFile object at 0x7fffab92cd00>
backup_id = '20210723T095432', key = 'test_annotation'

    def delete_annotation(self, backup_id, key):
        """
        Deletes an annotation from the filesystem for the specified backup_id and
        annotation key.
        """
        annotation_path = self._get_annotation_path(backup_id, key)
        try:
            os.remove(annotation_path)
        except EnvironmentError as e:
            # For Python 2 compatibility we must check the error code directly
            # If the annotation doesn't exist then the failure to delete it is not an
            # error condition and we should not proceed to remove the annotations
            # directory
            if e.errno == errno.ENOENT:
                return
            else:
                raise
        try:
>           os.rmdir(os.path.dirname(annotation_path))
E           FileExistsError: [Errno 17] File exists: '/tmp/pytest-of-marcel/pytest-34/test_delete_one_of_many_annota0/base/20210723T095432/annotations'

barman/annotations.py:80: FileExistsError

The cause seems to be that the test barman is trying to remove non-empty directory. This is not allowed on illumos.