summaryrefslogtreecommitdiff
path: root/test/integration/test-apt-update-expected-size
blob: 9711c293a023a1b4b8254c3bebd338acfb227dac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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 to trigger fallback
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
testsuccess aptget update -o Apt::Get::List-Cleanup=0  -o acquire::MaxReleaseFileSize=$((1*1000*1000)) -o Debug::pkgAcquire::worker=0
msgtest 'Check that the max write warning is triggered'
if grep -q "Writing more data than expected" rootdir/tmp/testsuccess.output; then
    msgpass
else
    cat rootdir/tmp/testsuccess.output
    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)"
find aptarchive -name 'Packages*' | while read pkg; do
	echo "1234567890" >> "$pkg"
done
NEW_SIZE="$(stat --printf=%s aptarchive/dists/unstable/main/binary-i386/Packages)"
rm -f rootdir/var/lib/apt/lists/localhost*
testfailureequal "W: Failed to fetch http://localhost:8080/dists/unstable/main/binary-i386/Packages  Writing more data than expected ($NEW_SIZE > $SIZE)

E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update -qq