]> git.saurik.com Git - apt.git/blob - test/integration/test-acquire-same-repository-multiple-times
abdfef8f01e9dd10db9da155eb19162e7593097a
[apt.git] / test / integration / test-acquire-same-repository-multiple-times
1 #!/bin/sh
2 set -e
3
4 TESTDIR=$(readlink -f $(dirname $0))
5 . $TESTDIR/framework
6 setupenvironment
7 configarchitecture 'amd64'
8
9 TESTFILE="$TESTDIR/framework"
10 cp $TESTFILE aptarchive/foo
11 APTARCHIVE="$(readlink -f ./aptarchive)"
12
13 getcodenamefromsuite() { echo "jessie"; }
14 buildsimplenativepackage 'foo' 'all' '1.0' 'stable'
15 setupaptarchive --no-update
16 ln -s "${APTARCHIVE}/dists/stable" "${APTARCHIVE}/dists/jessie"
17 for FILE in rootdir/etc/apt/sources.list.d/*-stable-* ; do
18 sed 's#stable#jessie#g' $FILE > $(echo "$FILE" | sed 's#stable#jessie#g')
19 done
20
21 # install a slowed down file: otherwise its to fast to reproduce combining
22 NEWMETHODS="$(readlink -f rootdir)/usr/lib/apt/methods"
23 OLDMETHODS="$(readlink -f rootdir/usr/lib/apt/methods)"
24 rm $NEWMETHODS
25 mkdir $NEWMETHODS
26 for METH in $(find $OLDMETHODS ! -type d); do
27 ln -s $OLDMETHODS/$(basename $METH) $NEWMETHODS
28 done
29 rm "${NEWMETHODS}/file" "${NEWMETHODS}/http"
30 cat >"${NEWMETHODS}/file" <<EOF
31 #!/bin/sh
32 while read line; do
33 echo "\$line"
34 if [ -z "\$line" ]; then
35 sleep 0.5
36 fi
37 done | "$OLDMETHODS/\${0##*/}"
38 EOF
39 chmod +x "${NEWMETHODS}/file"
40 ln -s "${NEWMETHODS}/file" "${NEWMETHODS}/http"
41
42 tworepos() {
43 msgtest "Downloading the same repository twice over $1" "$3"
44 testsuccess --nomsg aptget update -o Debug::pkgAcquire::Worker=1
45 cp rootdir/tmp/testsuccess.output download.log
46 #cat download.log
47 aptget indextargets --format '$(FILENAME)' --no-release-info | sort > file.lst
48 testequal "$(find $(readlink -f ./rootdir/var/lib/apt/lists) -name '*_dists_*' \( ! -name '*InRelease' \) -type f | sort)" cat file.lst
49 testsuccess aptcache policy
50 testequal "foo:
51 Installed: (none)
52 Candidate: 1.0
53 Version table:
54 1.0 500
55 500 $1:$2 jessie/main amd64 Packages
56 500 $1:$2 stable/main amd64 Packages" aptcache policy foo
57 testfailure aptcache show foo/unstable
58 testsuccess aptcache show foo/stable
59 testsuccess aptcache show foo/jessie
60 }
61
62 tworepos 'file' "$APTARCHIVE" 'no partial'
63 testequal '12' grep -c '200%20URI%20Start' ./download.log
64 testequal '12' grep -c '201%20URI%20Done' ./download.log
65 testequal '6' grep -c '^ @ Queue: Action combined' ./download.log
66 tworepos 'file' "$APTARCHIVE" 'hit'
67 testequal '6' grep -c '200%20URI%20Start' ./download.log
68 testequal '6' grep -c '201%20URI%20Done' ./download.log
69 testequal '0' grep -c '^ @ Queue: Action combined' ./download.log
70 rm -rf rootdir/var/lib/apt/lists
71
72 changetowebserver
73
74 tworepos 'http' '//localhost:8080' 'no partial'
75 testequal '10' grep -c '200%20URI%20Start' ./download.log
76 testequal '10' grep -c '201%20URI%20Done' ./download.log
77 testequal '6' grep -c '^ @ Queue: Action combined' ./download.log
78 tworepos 'http' '//localhost:8080' 'hit'
79 testequal '2' grep -c '200%20URI%20Start' ./download.log
80 testequal '4' grep -c '201%20URI%20Done' ./download.log
81 testequal '0' grep -c '^ @ Queue: Action combined' ./download.log
82 rm -rf rootdir/var/lib/apt/lists