Repository: borgbackup/borg

Issue:
ArchiverTestCase: flaky test "test_delete_force"?
It seems as if `test_delete_force` in `ArchiverTestCase` is a bit flaky. In Fedora's build infrastructure the test suite passes most of the time but sometimes it does not (this is with borgbackup 1.1.11). I've seen this in EPEL 7 as well as Fedora 31/32/33.

Koschei is Fedora's "background build service" and you can see the failures in 2020-05-08 and 2020-05-16. Without any changes to the borgbackup package the test suite passed next time (check `build.log` for details):
https://koschei.fedoraproject.org/package/borgbackup?collection=f33

I hit the same problem yesterday in F31:

- scratch build passes: https://koji.fedoraproject.org/koji/taskinfo?taskID=44835124
- actual build a few minutes later fails: https://koji.fedoraproject.org/koji/taskinfo?taskID=44835853

Any idea how to debug this? I suspect it happens more often when there is quite a bit of load on the builders.


Discussion:
```
______________________ ArchiverTestCase.test_delete_force ______________________
self = <borg.testsuite.archiver.ArchiverTestCase testMethod=test_delete_force>
    def test_delete_force(self):
        self.cmd('init', '--encryption=none', self.repository_location)
        self.create_src_archive('test')
        with Repository(self.repository_path, exclusive=True) as repository:
            manifest, key = Manifest.load(repository, Manifest.NO_OPERATION_CHECK)
            archive = Archive(repository, key, manifest, 'test')
            for item in archive.iter_items():
                if 'chunks' in item:
>                   first_chunk_id = item.chunks[0].id
E                   IndexError: list index out of range
build/lib.linux-x86_64-3.7/borg/testsuite/archiver.py:1499: IndexError
```
Well, looks like we have items with an empty chunks list.

Hmm, is there maybe an empty file in `src/borg` that leads to that?

But I guess we should not depend on not having empty files below there, so the test preparation should just check that the item has a **non-empty** chunks list.
i.e.:
```
if 'chunks' in item and len(item.chunks) > 0:
```

Resolving patch:
diff --git a/src/borg/testsuite/archiver.py b/src/borg/testsuite/archiver.py
--- a/src/borg/testsuite/archiver.py
+++ b/src/borg/testsuite/archiver.py
@@ -1496,11 +1496,12 @@ def test_delete_force(self):
             manifest, key = Manifest.load(repository, Manifest.NO_OPERATION_CHECK)
             archive = Archive(repository, key, manifest, 'test')
             for item in archive.iter_items():
-                if 'chunks' in item:
-                    first_chunk_id = item.chunks[0].id
-                    repository.delete(first_chunk_id)
-                    repository.commit()
+                if item.path.endswith('testsuite/archiver.py'):
+                    repository.delete(item.chunks[-1].id)
                     break
+            else:
+                assert False  # missed the file
+            repository.commit()
         output = self.cmd('delete', '--force', self.repository_location + '::test')
         self.assert_in('deleted archive was corrupted', output)
         self.cmd('check', '--repair', self.repository_location)


Test patch: