git_mirror_size_limit config option to set max git mirror size

GitHub and GitLab have some kinds of limits on how big a git repo can be,
this makes that option configurable.  This also is very useful for tests.
This commit is contained in:
Hans-Christoph Steiner 2020-01-13 11:48:23 +01:00
parent 4fa11ef4fc
commit e76a0c9d6a
No known key found for this signature in database
GPG key ID: 3E177817BA1B9BFA
5 changed files with 100 additions and 4 deletions

View file

@ -45,6 +45,15 @@ class CommonTest(unittest.TestCase):
os.makedirs(self.tmpdir)
os.chdir(self.basedir)
def test_parse_human_readable_size(self):
for k, v in ((9827, 9827), (123.456, 123), ('123b', 123), ('1.2', 1),
('10.43 KiB', 10680), ('11GB', 11000000000), ('59kb', 59000),
('343.1 mb', 343100000), ('99.9GiB', 107266808217)):
self.assertEqual(fdroidserver.common.parse_human_readable_size(k), v)
for v in ((12, 123), '0xfff', [], None, '12,123', '123GG', '982374bb', self):
with self.assertRaises(ValueError):
fdroidserver.common.parse_human_readable_size(v)
def test_assert_config_keystore(self):
with tempfile.TemporaryDirectory() as tmpdir, TmpCwd(tmpdir):
with self.assertRaises(FDroidException):

View file

@ -1096,6 +1096,59 @@ $fdroid update --create-key
test -e $KEYSTORE
#------------------------------------------------------------------------------#
echo_header "setup a new repo from scratch using ANDROID_HOME with git mirror"
# fake git remote server for repo mirror
SERVER_GIT_MIRROR=`create_test_dir`
cd $SERVER_GIT_MIRROR
git init
git config receive.denyCurrentBranch updateInstead
REPOROOT=`create_test_dir`
GIT_MIRROR=$REPOROOT/git-mirror
cd $REPOROOT
fdroid_init_with_prebuilt_keystore
echo "servergitmirrors = '$SERVER_GIT_MIRROR'" >> config.py
cp $WORKSPACE/tests/repo/com.politedroid_[345].apk repo/
$fdroid update --create-metadata
$fdroid deploy
test -e $GIT_MIRROR/fdroid/repo/com.politedroid_3.apk
test -e $GIT_MIRROR/fdroid/repo/com.politedroid_4.apk
test -e $GIT_MIRROR/fdroid/repo/com.politedroid_5.apk
test -e $SERVER_GIT_MIRROR/fdroid/repo/com.politedroid_3.apk
test -e $SERVER_GIT_MIRROR/fdroid/repo/com.politedroid_4.apk
test -e $SERVER_GIT_MIRROR/fdroid/repo/com.politedroid_5.apk
date > $GIT_MIRROR/.git/test-stamp
# add one more APK to trigger archiving
cp $WORKSPACE/tests/repo/com.politedroid_6.apk repo/
$fdroid update
$fdroid deploy
test -e $REPOROOT/archive/com.politedroid_3.apk
! test -e $GIT_MIRROR/fdroid/archive/com.politedroid_3.apk
! test -e $SERVER_GIT_MIRROR/fdroid/archive/com.politedroid_3.apk
test -e $GIT_MIRROR/fdroid/repo/com.politedroid_4.apk
test -e $GIT_MIRROR/fdroid/repo/com.politedroid_5.apk
test -e $GIT_MIRROR/fdroid/repo/com.politedroid_6.apk
test -e $SERVER_GIT_MIRROR/fdroid/repo/com.politedroid_4.apk
test -e $SERVER_GIT_MIRROR/fdroid/repo/com.politedroid_5.apk
test -e $SERVER_GIT_MIRROR/fdroid/repo/com.politedroid_6.apk
before=`du -s --bytes $GIT_MIRROR/.git/ | awk '{print $1}'`
echo "git_mirror_size_limit = '60kb'" >> config.py
$fdroid update
$fdroid deploy
test -e $REPOROOT/archive/com.politedroid_3.apk
! test -e $SERVER_GIT_MIRROR/fdroid/archive/com.politedroid_3.apk
after=`du -s --bytes $GIT_MIRROR/.git/ | awk '{print $1}'`
! test -e $GIT_MIRROR/.git/test-stamp
git -C $GIT_MIRROR gc
git -C $SERVER_GIT_MIRROR gc
test $before -gt $after
#------------------------------------------------------------------------------#
echo_header "sign binary repo in offline box, then publishing from online box"