]>
Commit | Line | Data |
---|---|---|
a2d40703 MV |
1 | #!/bin/sh |
2 | set -e | |
3 | ||
3abb6a6a DK |
4 | TESTDIR="$(readlink -f "$(dirname "$0")")" |
5 | . "$TESTDIR/framework" | |
a2d40703 MV |
6 | |
7 | setupenvironment | |
30979dd7 DK |
8 | configarchitecture 'i386' |
9 | configcompression '.' 'gz' | |
a2d40703 | 10 | |
1dd20368 | 11 | insertpackage 'unstable' 'apt' 'i386' '1.0' |
a2d40703 MV |
12 | |
13 | setupaptarchive --no-update | |
27925d82 DK |
14 | cp -a aptarchive/dists aptarchive/dists.good |
15 | ||
16 | test_inreleasetoobig() { | |
17 | # make InRelease really big to trigger fallback | |
18 | dd if=/dev/zero of=aptarchive/dists/unstable/InRelease bs=1M count=2 2>/dev/null | |
19 | touch -d '+1hour' aptarchive/dists/unstable/InRelease | |
20 | testsuccess aptget update -o Apt::Get::List-Cleanup=0 -o acquire::MaxReleaseFileSize=$((1*1000*1000)) -o Debug::pkgAcquire::worker=0 | |
21 | msgtest 'Check that the max write warning is triggered' | |
22 | cp rootdir/tmp/testsuccess.output update.output | |
23 | testsuccess --nomsg grep -q 'Writing more data than expected' update.output | |
24 | rm -f update.output | |
25 | # ensure the failed InRelease file got renamed | |
26 | testsuccess ls rootdir/var/lib/apt/lists/partial/*InRelease.FAILED | |
27 | } | |
28 | ||
29 | test_packagestoobig() { | |
1dd20368 | 30 | insertpackage 'unstable' 'foo' 'i386' '1.0' |
8d041b4f DK |
31 | buildaptarchivefromfiles '+1 hour' |
32 | signreleasefiles | |
27925d82 | 33 | # append junk at the end of the Packages.gz/Packages |
30979dd7 | 34 | SIZE="$(stat --printf=%s aptarchive/dists/unstable/main/binary-i386/Packages.gz)" |
27925d82 DK |
35 | find aptarchive/dists -name 'Packages*' | while read pkg; do |
36 | echo "1234567890" >> "$pkg" | |
37 | touch -d '+1hour' "$pkg" | |
38 | done | |
30979dd7 DK |
39 | NEW_SIZE="$(stat --printf=%s aptarchive/dists/unstable/main/binary-i386/Packages.gz)" |
40 | testfailuremsg "E: Failed to fetch ${1}/dists/unstable/main/binary-i386/Packages.gz Writing more data than expected ($NEW_SIZE > $SIZE) | |
448c38bd | 41 | E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update -o Debug::pkgAcquire::Worker=1 -o Debug::Acquire::Transaction=0 |
27925d82 DK |
42 | } |
43 | ||
44 | methodtest() { | |
ba6b79bd DK |
45 | # less complicated test setup this way |
46 | webserverconfig 'aptwebserver::support::modified-since' 'false' "$1" | |
47 | webserverconfig 'aptwebserver::support::last-modified' 'false' "$1" # curl is clever and sees hits here also | |
48 | ||
27925d82 DK |
49 | msgmsg 'Test with' "$1" 'and clean start' |
50 | rm -rf rootdir/var/lib/apt/lists rootdir/var/lib/apt/lists.good | |
51 | # normal update works fine | |
52 | testsuccess aptget update | |
53 | mv rootdir/var/lib/apt/lists rootdir/var/lib/apt/lists.good | |
54 | ||
55 | # starting fresh works | |
56 | test_inreleasetoobig "$1" | |
57 | rm -rf aptarchive/dists rootdir/var/lib/apt/lists | |
58 | cp -a aptarchive/dists.good aptarchive/dists | |
59 | test_packagestoobig "$1" | |
60 | rm -rf aptarchive/dists rootdir/var/lib/apt/lists | |
61 | cp -a aptarchive/dists.good aptarchive/dists | |
62 | ||
63 | msgmsg 'Test with' "$1" 'and existing old data' | |
64 | cp -a rootdir/var/lib/apt/lists.good rootdir/var/lib/apt/lists | |
65 | test_inreleasetoobig "$1" | |
66 | rm -rf aptarchive/dists rootdir/var/lib/apt/lists | |
67 | cp -a rootdir/var/lib/apt/lists.good rootdir/var/lib/apt/lists | |
68 | cp -a aptarchive/dists.good aptarchive/dists | |
69 | test_packagestoobig "$1" | |
70 | rm -rf aptarchive/dists | |
71 | cp -a aptarchive/dists.good aptarchive/dists | |
72 | } | |
73 | ||
a2d40703 | 74 | changetowebserver |
6c0765c0 | 75 | methodtest "http://localhost:${APTHTTPPORT}" |
a2d40703 | 76 | |
27925d82 | 77 | changetohttpswebserver |
6c0765c0 | 78 | methodtest "https://localhost:${APTHTTPSPORT}" |