]> source.dussan.org Git - jgit.git/commit
Add tests for handling pack files removal during fetch 23/1176123/1
authorDariusz Luksza <dariusz.luksza@gmail.com>
Fri, 17 Nov 2023 19:28:53 +0000 (19:28 +0000)
committerDariusz Luksza <dariusz.luksza@gmail.com>
Mon, 29 Jan 2024 09:24:26 +0000 (09:24 +0000)
commit60af389b49fe1d05753a4a2b9146d1b925c71e23
tree804b48cdb70d58dfea7511f01a4cf5a232fff822
parentb4c66104fb7502f133989291a4a5595f965771d3
Add tests for handling pack files removal during fetch

Although this could sound like a corner case, it really can occur out
there in the real world. Especially in the Gerrit world where the
repositories could be GC'ed on a separate process or system.

The `FileNotFoundException` seems to be handled correctly in
`PackFile#doOpen` (line 671) and it will mark the pack as invalid. But
triggering that code path was not an easy task.

First of all, we need to add a new commit to the `master` branch of the
test repository after `UploadPack` object is created.

Secondly, in the refspec for fetch, commit id instead of "regular"
refspec must be used.

With both in place, we can see a warning log statement about deleted
pack file. And the fetch succeeds!

Also, tests for the removal of *.idx and *.bitmap files were added.

This unveiled a corner for the *.idx file deletion while fetching, as
the test will fail with "Unreachable pack index" IOException only
when the HEAD commit is empty.

Change-Id: If26c83f9b12993d1ab7d6bad6bd863c29520b062
Signed-off-by: Dariusz Luksza <dariusz.luksza@gmail.com>
(cherry picked from commit ba5adc4ce6f234cb300b0f73a1efdba9bba1b5d8)
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackHandleDeletedPackFileTest.java [new file with mode: 0644]