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