summaryrefslogtreecommitdiff
path: root/test/integration/test-apt-update-expected-size
diff options
context:
space:
mode:
authorMichael Vogt <mvo@ubuntu.com>2014-10-08 08:37:01 +0200
committerMichael Vogt <mvo@ubuntu.com>2014-10-08 08:37:01 +0200
commit0c158e03ceb509a08d3d4ded79c3151237f669dd (patch)
treedc7a5cf8f15a7907d00beb75b5fa4d246ec3d36a /test/integration/test-apt-update-expected-size
parenta943fbf21ca0b9b58b8f1492fc518679b1d7c749 (diff)
parentf2b47ba290f3a178c584da83f007cf0f720baabb (diff)
Merge remote-tracking branch 'mvo/feature/expected-size' into debian/experimental
Diffstat (limited to 'test/integration/test-apt-update-expected-size')
-rwxr-xr-xtest/integration/test-apt-update-expected-size44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/integration/test-apt-update-expected-size b/test/integration/test-apt-update-expected-size
new file mode 100755
index 000000000..58920f544
--- /dev/null
+++ b/test/integration/test-apt-update-expected-size
@@ -0,0 +1,44 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+configarchitecture "i386"
+
+insertpackage 'unstable' 'apt' 'all' '1.0'
+
+setupaptarchive --no-update
+changetowebserver
+
+# normal update works fine
+testsuccess aptget update
+
+# make InRelease really big
+mv aptarchive/dists/unstable/InRelease aptarchive/dists/unstable/InRelease.good
+dd if=/dev/zero of=aptarchive/dists/unstable/InRelease bs=1M count=2 2>/dev/null
+touch -d '+1hour' aptarchive/dists/unstable/InRelease
+aptget update -o Apt::Get::List-Cleanup=0 -o acquire::MaxReleaseFileSize=$((1*1000*1000)) -o Debug::pkgAcquire::worker=0 > output.log
+msgtest 'Check that the max write warning is triggered'
+if grep -q "Writing more data than expected" output.log; then
+ msgpass
+else
+ cat output.log
+ msgfail
+fi
+# ensure the failed InRelease file got renamed
+testsuccess ls rootdir/var/lib/apt/lists/partial/*InRelease.FAILED
+mv aptarchive/dists/unstable/InRelease.good aptarchive/dists/unstable/InRelease
+
+
+# append junk at the end of the Packages.gz/Packages
+SIZE="$(stat --printf=%s aptarchive/dists/unstable/main/binary-i386/Packages)"
+echo "1234567890" >> aptarchive/dists/unstable/main/binary-i386/Packages.gz
+echo "1234567890" >> aptarchive/dists/unstable/main/binary-i386/Packages
+NEW_SIZE="$(stat --printf=%s aptarchive/dists/unstable/main/binary-i386/Packages)"
+rm -f rootdir/var/lib/apt/lists/localhost*
+testequal "W: Failed to fetch http://localhost:8080/dists/unstable/main/binary-i386/Packages Writing more data than expected ($NEW_SIZE > $SIZE) [IP: ::1 8080]
+
+E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update -qq
+