]> git.saurik.com Git - apt.git/blob - test/integration/test-handle-redirect-as-used-mirror-change
The entire concept of PendingError() is flawed :/.
[apt.git] / test / integration / test-handle-redirect-as-used-mirror-change
1 #!/bin/sh
2 set -e
3
4 TESTDIR="$(readlink -f "$(dirname "$0")")"
5 . "$TESTDIR/framework"
6 setupenvironment
7 configarchitecture 'amd64'
8 configcompression '.' 'gz'
9
10 buildsimplenativepackage 'unrelated' 'all' '0.5~squeeze1' 'unstable'
11
12 export APT_DONT_SIGN=''
13 setupaptarchive --no-update
14 changetowebserver
15 webserverconfig 'aptwebserver::redirect::replace::/redirectme/' "http://0.0.0.0:${APTHTTPPORT}/"
16 rewritesourceslist "http://localhost:${APTHTTPPORT}/redirectme"
17
18 testsuccessequal "Get:1 http://0.0.0.0:${APTHTTPPORT} unstable InRelease [$(stat -c %s aptarchive/dists/unstable/InRelease) B]
19 Get:2 http://0.0.0.0:${APTHTTPPORT} unstable/main Sources [$(stat -c %s aptarchive/dists/unstable/main/source/Sources.gz) B]
20 Get:3 http://0.0.0.0:${APTHTTPPORT} unstable/main all Packages [$(stat -c %s aptarchive/dists/unstable/main/binary-all/Packages.gz) B]
21 Get:4 http://0.0.0.0:${APTHTTPPORT} unstable/main Translation-en [$(stat -c %s aptarchive/dists/unstable/main/i18n/Translation-en.gz) B]
22 Reading package lists..." aptget update
23
24 grepwebserverlogs() {
25 testsuccess grep -h "$1" aptarchive/webserver.log.client*.log
26 shift
27 sort rootdir/tmp/testsuccess.output > aptwebserver.log
28 testfileequal 'aptwebserver.log' "$@"
29 }
30
31 # ensure we asked the redirector only once
32 grepwebserverlogs '^Location:' "Location: http://0.0.0.0:${APTHTTPPORT}/dists/unstable/InRelease"
33
34 testsuccessequal "Hit:1 http://0.0.0.0:${APTHTTPPORT} unstable InRelease
35 Reading package lists..." aptget update
36
37 grepwebserverlogs '^Location:' "Location: http://0.0.0.0:${APTHTTPPORT}/dists/unstable/InRelease
38 Location: http://0.0.0.0:${APTHTTPPORT}/dists/unstable/InRelease"
39
40 rm -rf rootdir/var/lib/apt/lists
41 testsuccess apt update -o Debug::Acquire::http=1 -o Acquire::SameMirrorForAllIndexes=0
42 grepwebserverlogs '^Location:' "Location: http://0.0.0.0:${APTHTTPPORT}/dists/unstable/InRelease
43 Location: http://0.0.0.0:${APTHTTPPORT}/dists/unstable/InRelease
44 Location: http://0.0.0.0:${APTHTTPPORT}/dists/unstable/InRelease
45 Location: http://0.0.0.0:${APTHTTPPORT}/dists/unstable/main/binary-all/Packages.gz
46 Location: http://0.0.0.0:${APTHTTPPORT}/dists/unstable/main/i18n/Translation-en.gz
47 Location: http://0.0.0.0:${APTHTTPPORT}/dists/unstable/main/source/Sources.gz"
48
49 cd downloaded
50 testsuccess apthelper download-file "http://localhost:${APTHTTPPORT}/redirectme/dists/unstable/InRelease" inrelease
51 testsuccess test -s inrelease
52 cd - >/dev/null
53
54 webserverconfig "aptwebserver::redirect::replace::http://0.0.0.0:${APTHTTPPORT}/dists/unstable/InRelease" "http://0.0.0.0:${APTHTTPPORT}/storage/dists/unstable/InRelease"
55 mkdir -p aptarchive/storage/dists/unstable
56 mv aptarchive/dists/unstable/InRelease aptarchive/storage/dists/unstable
57 rm -rf rootdir/var/lib/apt/lists
58 testsuccessequal "Get:1 http://0.0.0.0:${APTHTTPPORT}/storage unstable InRelease [$(stat -c %s aptarchive/storage/dists/unstable/InRelease) B]
59 Ign:2 http://0.0.0.0:${APTHTTPPORT}/storage unstable/main Sources
60 404 Not Found
61 Ign:3 http://0.0.0.0:${APTHTTPPORT}/storage unstable/main all Packages
62 404 Not Found
63 Ign:4 http://0.0.0.0:${APTHTTPPORT}/storage unstable/main Translation-en
64 404 Not Found
65 Get:2 http://0.0.0.0:${APTHTTPPORT} unstable/main Sources [$(stat -c %s aptarchive/dists/unstable/main/source/Sources.gz) B]
66 Get:3 http://0.0.0.0:${APTHTTPPORT} unstable/main all Packages [$(stat -c %s aptarchive/dists/unstable/main/binary-all/Packages.gz) B]
67 Get:4 http://0.0.0.0:${APTHTTPPORT} unstable/main Translation-en [$(stat -c %s aptarchive/dists/unstable/main/i18n/Translation-en.gz) B]
68 Reading package lists...
69 Building dependency tree...
70 All packages are up to date." apt update
71
72 find aptarchive -name 'InRelease' -delete
73 rm -rf rootdir/var/lib/apt/lists
74
75 testsuccessequal "Ign:1 http://0.0.0.0:${APTHTTPPORT}/storage unstable InRelease
76 404 Not Found
77 Get:2 http://0.0.0.0:${APTHTTPPORT} unstable Release [$(stat -c %s aptarchive/dists/unstable/Release) B]
78 Get:3 http://0.0.0.0:${APTHTTPPORT} unstable Release.gpg [$(stat -c %s aptarchive/dists/unstable/Release.gpg) B]
79 Get:4 http://0.0.0.0:${APTHTTPPORT} unstable/main Sources [$(stat -c %s aptarchive/dists/unstable/main/source/Sources.gz) B]
80 Get:5 http://0.0.0.0:${APTHTTPPORT} unstable/main all Packages [$(stat -c %s aptarchive/dists/unstable/main/binary-all/Packages.gz) B]
81 Get:6 http://0.0.0.0:${APTHTTPPORT} unstable/main Translation-en [$(stat -c %s aptarchive/dists/unstable/main/i18n/Translation-en.gz) B]
82 Reading package lists..." aptget update
83
84 testsuccessequal "Ign:1 http://0.0.0.0:${APTHTTPPORT}/storage unstable InRelease
85 404 Not Found
86 Hit:2 http://0.0.0.0:${APTHTTPPORT} unstable Release
87 Reading package lists..." aptget update
88
89 rm -rf rootdir/var/lib/apt/lists
90 find aptarchive -name 'Release.gpg' -delete
91 find aptarchive -name 'Release' -delete
92 testwarning aptget update
93 testsuccess grep 'does not have a Release file' rootdir/tmp/testwarning.output