You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

100 lines
4.1 KiB

  1. #!/bin/sh
  2. set -e
  3. TESTDIR="$(readlink -f "$(dirname "$0")")"
  4. . "$TESTDIR/framework"
  5. setupenvironment
  6. configarchitecture 'i386'
  7. configcompression '.' 'gz'
  8. insertpackage 'unstable' 'apt' 'i386' '1.0'
  9. export APT_DONT_SIGN=''
  10. setupaptarchive --no-update
  11. cp -a aptarchive/dists aptarchive/dists.good
  12. test_inreleasetoobig() {
  13. # make InRelease really big to trigger fallback
  14. dd if=/dev/zero of=aptarchive/dists/unstable/InRelease bs=1M count=2 2>/dev/null
  15. touch -d '+1hour' aptarchive/dists/unstable/InRelease
  16. testsuccess aptget update -o Apt::Get::List-Cleanup=0 -o acquire::MaxReleaseFileSize=$((1*1000*1000)) -o Debug::pkgAcquire::worker=0
  17. msgtest 'Check that the max write warning is triggered'
  18. cp rootdir/tmp/testsuccess.output update.output
  19. testsuccess --nomsg grep -q 'File has unexpected size' update.output
  20. rm -f update.output
  21. # ensure the failed InRelease file got renamed
  22. testsuccess ls rootdir/var/lib/apt/lists/partial/*InRelease.FAILED
  23. testfailure test -e rootdir/var/lib/apt/lists/partial/Old.FAILED
  24. }
  25. test_packagestoobig() {
  26. insertpackage 'unstable' 'foo' 'i386' '1.0'
  27. buildaptarchivefromfiles '+1 hour'
  28. signreleasefiles
  29. # append junk at the end of the Packages.gz/Packages
  30. SIZE="$(stat --printf=%s aptarchive/dists/unstable/main/binary-i386/Packages.gz)"
  31. find aptarchive/dists -name 'Packages*' | while read pkg; do
  32. echo "1234567890" >> "$pkg"
  33. touch -d '+1hour' "$pkg"
  34. done
  35. NEW_SIZE="$(stat --printf=%s aptarchive/dists/unstable/main/binary-i386/Packages.gz)"
  36. testfailuremsg "E: Failed to fetch ${1}/dists/unstable/main/binary-i386/Packages.gz File has unexpected size ($NEW_SIZE != $SIZE). Mirror sync in progress?
  37. E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update -o Debug::pkgAcquire::Worker=1 -o Debug::Acquire::Transaction=0
  38. testsuccess ls rootdir/var/lib/apt/lists/partial/*Packages*.FAILED
  39. testfailure test -e rootdir/var/lib/apt/lists/partial/Old.FAILED
  40. }
  41. test_packagestoosmall() {
  42. insertpackage 'unstable' 'foo' 'i386' '1.0'
  43. buildaptarchivefromfiles '+1 hour'
  44. signreleasefiles
  45. # replace Packages.gz/Packages with short junk
  46. SIZE="$(stat --printf=%s aptarchive/dists/unstable/main/binary-i386/Packages.gz)"
  47. find aptarchive/dists -name 'Packages*' | while read pkg; do
  48. echo "1234567890" > "$pkg"
  49. touch -d '+1hour' "$pkg"
  50. done
  51. NEW_SIZE="$(stat --printf=%s aptarchive/dists/unstable/main/binary-i386/Packages.gz)"
  52. testfailuremsg "E: Failed to fetch ${1}/dists/unstable/main/binary-i386/Packages.gz File is smaller than expected ($NEW_SIZE < $SIZE). Mirror sync in progress?
  53. E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update -o Debug::pkgAcquire::Worker=1 -o Debug::Acquire::Transaction=0
  54. testsuccess ls rootdir/var/lib/apt/lists/partial/*Packages*.FAILED
  55. testfailure test -e rootdir/var/lib/apt/lists/partial/Old.FAILED
  56. }
  57. methodtest() {
  58. # less complicated test setup this way
  59. webserverconfig 'aptwebserver::support::modified-since' 'false' "$1"
  60. webserverconfig 'aptwebserver::support::last-modified' 'false' "$1" # curl is clever and sees hits here also
  61. msgmsg 'Test with' "$1" 'and clean start'
  62. rm -rf rootdir/var/lib/apt/lists rootdir/var/lib/apt/lists.good aptarchive/dists
  63. cp -a aptarchive/dists.good aptarchive/dists
  64. # normal update works fine
  65. testsuccess aptget update
  66. touch rootdir/var/lib/apt/lists/partial/Old.FAILED
  67. mv rootdir/var/lib/apt/lists rootdir/var/lib/apt/lists.good
  68. # starting fresh works
  69. test_inreleasetoobig "$1"
  70. rm -rf aptarchive/dists rootdir/var/lib/apt/lists
  71. cp -a aptarchive/dists.good aptarchive/dists
  72. test_packagestoobig "$1"
  73. msgmsg 'Test with' "$1" 'and existing old data'
  74. rm -rf aptarchive/dists rootdir/var/lib/apt/lists
  75. cp -a rootdir/var/lib/apt/lists.good rootdir/var/lib/apt/lists
  76. cp -a aptarchive/dists.good aptarchive/dists
  77. test_inreleasetoobig "$1"
  78. rm -rf aptarchive/dists rootdir/var/lib/apt/lists
  79. cp -a rootdir/var/lib/apt/lists.good rootdir/var/lib/apt/lists
  80. cp -a aptarchive/dists.good aptarchive/dists
  81. test_packagestoobig "$1"
  82. }
  83. changetowebserver
  84. methodtest "http://localhost:${APTHTTPPORT}"
  85. changetohttpswebserver
  86. methodtest "https://localhost:${APTHTTPSPORT}"