test-handle-redirect-as-used-mirror-change 4.7 KB

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