| 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 | backupIFS="$IFS" |
| 27 | IFS="$(printf "\n\b")" |
| 28 | for METH in $(find "$OLDMETHODS" ! -type d); do |
| 29 | ln -s "$OLDMETHODS/$(basename "$METH")" "$NEWMETHODS" |
| 30 | done |
| 31 | IFS="$backupIFS" |
| 32 | rm "${NEWMETHODS}/file" "${NEWMETHODS}/http" |
| 33 | cat >"${NEWMETHODS}/file" <<EOF |
| 34 | #!/bin/sh |
| 35 | while read line; do |
| 36 | echo "\$line" |
| 37 | if [ -z "\$line" ]; then |
| 38 | sleep 0.5 |
| 39 | fi |
| 40 | done | '$OLDMETHODS/'"\${0##*/}" |
| 41 | EOF |
| 42 | chmod +x "${NEWMETHODS}/file" |
| 43 | ln -s "${NEWMETHODS}/file" "${NEWMETHODS}/http" |
| 44 | |
| 45 | tworepos() { |
| 46 | msgtest "Downloading the same repository twice over $1" "$3" |
| 47 | testsuccess --nomsg aptget update -o Debug::pkgAcquire::Worker=1 |
| 48 | cp rootdir/tmp/testsuccess.output download.log |
| 49 | #cat download.log |
| 50 | aptget indextargets --format '$(FILENAME)' --no-release-info | sort > file.lst |
| 51 | testequal "$(find "$(readlink -f ./rootdir/var/lib/apt/lists)" -name '*_dists_*' \( ! -name '*InRelease' \) -type f | sort)" cat file.lst |
| 52 | testsuccess aptcache policy |
| 53 | testequal "foo: |
| 54 | Installed: (none) |
| 55 | Candidate: 1.0 |
| 56 | Version table: |
| 57 | 1.0 500 |
| 58 | 500 $1:$2 jessie/main all Packages |
| 59 | 500 $1:$2 stable/main all Packages" aptcache policy foo |
| 60 | testfailure aptcache show foo/unstable |
| 61 | testsuccess aptcache show foo/stable |
| 62 | testsuccess aptcache show foo/jessie |
| 63 | } |
| 64 | |
| 65 | tworepos 'file' "$APTARCHIVE" 'no partial' |
| 66 | testequal '14' grep -c '200%20URI%20Start' ./download.log |
| 67 | testequal '14' grep -c '201%20URI%20Done' ./download.log |
| 68 | testequal '8' grep -c '^ @ Queue: Action combined' ./download.log |
| 69 | tworepos 'file' "$APTARCHIVE" 'hit' |
| 70 | testequal '6' grep -c '200%20URI%20Start' ./download.log |
| 71 | testequal '6' grep -c '201%20URI%20Done' ./download.log |
| 72 | testequal '0' grep -c '^ @ Queue: Action combined' ./download.log |
| 73 | rm -rf rootdir/var/lib/apt/lists |
| 74 | |
| 75 | changetowebserver |
| 76 | |
| 77 | tworepos 'http' "//localhost:${APTHTTPPORT}" 'no partial' |
| 78 | testequal '12' grep -c '200%20URI%20Start' ./download.log |
| 79 | testequal '12' grep -c '201%20URI%20Done' ./download.log |
| 80 | testequal '8' grep -c '^ @ Queue: Action combined' ./download.log |
| 81 | tworepos 'http' "//localhost:${APTHTTPPORT}" 'hit' |
| 82 | testequal '2' grep -c '200%20URI%20Start' ./download.log |
| 83 | testequal '4' grep -c '201%20URI%20Done' ./download.log |
| 84 | testequal '0' grep -c '^ @ Queue: Action combined' ./download.log |
| 85 | rm -rf rootdir/var/lib/apt/lists |