]> git.saurik.com Git - apt.git/blame - test/integration/test-apt-update-expected-size
test-apt-download-progress: Allow smaller progress change
[apt.git] / test / integration / test-apt-update-expected-size
CommitLineData
a2d40703
MV
1#!/bin/sh
2set -e
3
4TESTDIR=$(readlink -f $(dirname $0))
5. $TESTDIR/framework
6
7setupenvironment
8configarchitecture "i386"
9
1dd20368 10insertpackage 'unstable' 'apt' 'i386' '1.0'
a2d40703
MV
11
12setupaptarchive --no-update
27925d82
DK
13cp -a aptarchive/dists aptarchive/dists.good
14
15test_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
28test_packagestoobig() {
1dd20368 29 insertpackage 'unstable' 'foo' 'i386' '1.0'
8d041b4f
DK
30 buildaptarchivefromfiles '+1 hour'
31 signreleasefiles
27925d82
DK
32 # append junk at the end of the Packages.gz/Packages
33 SIZE="$(stat --printf=%s aptarchive/dists/unstable/main/binary-i386/Packages)"
34 find aptarchive/dists -name 'Packages*' | while read pkg; do
35 echo "1234567890" >> "$pkg"
36 touch -d '+1hour' "$pkg"
37 done
38 NEW_SIZE="$(stat --printf=%s aptarchive/dists/unstable/main/binary-i386/Packages)"
39 testfailuremsg "W: Failed to fetch ${1}/dists/unstable/main/binary-i386/Packages Writing more data than expected ($NEW_SIZE > $SIZE)
448c38bd 40E: 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
41}
42
43methodtest() {
ba6b79bd
DK
44 # less complicated test setup this way
45 webserverconfig 'aptwebserver::support::modified-since' 'false' "$1"
46 webserverconfig 'aptwebserver::support::last-modified' 'false' "$1" # curl is clever and sees hits here also
47
27925d82
DK
48 msgmsg 'Test with' "$1" 'and clean start'
49 rm -rf rootdir/var/lib/apt/lists rootdir/var/lib/apt/lists.good
50 # normal update works fine
51 testsuccess aptget update
52 mv rootdir/var/lib/apt/lists rootdir/var/lib/apt/lists.good
53
54 # starting fresh works
55 test_inreleasetoobig "$1"
56 rm -rf aptarchive/dists rootdir/var/lib/apt/lists
57 cp -a aptarchive/dists.good aptarchive/dists
58 test_packagestoobig "$1"
59 rm -rf aptarchive/dists rootdir/var/lib/apt/lists
60 cp -a aptarchive/dists.good aptarchive/dists
61
62 msgmsg 'Test with' "$1" 'and existing old data'
63 cp -a rootdir/var/lib/apt/lists.good rootdir/var/lib/apt/lists
64 test_inreleasetoobig "$1"
65 rm -rf aptarchive/dists rootdir/var/lib/apt/lists
66 cp -a rootdir/var/lib/apt/lists.good rootdir/var/lib/apt/lists
67 cp -a aptarchive/dists.good aptarchive/dists
68 test_packagestoobig "$1"
69 rm -rf aptarchive/dists
70 cp -a aptarchive/dists.good aptarchive/dists
71}
72
a2d40703 73changetowebserver
6c0765c0 74methodtest "http://localhost:${APTHTTPPORT}"
a2d40703 75
27925d82 76changetohttpswebserver
6c0765c0 77methodtest "https://localhost:${APTHTTPSPORT}"