test-acquire-same-repository-multiple-times 2.8 KB

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