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