test-apt-update-expected-size 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 'Writing more data than expected' 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. }
  24. test_packagestoobig() {
  25. insertpackage 'unstable' 'foo' 'i386' '1.0'
  26. buildaptarchivefromfiles '+1 hour'
  27. signreleasefiles
  28. # append junk at the end of the Packages.gz/Packages
  29. SIZE="$(stat --printf=%s aptarchive/dists/unstable/main/binary-i386/Packages.gz)"
  30. find aptarchive/dists -name 'Packages*' | while read pkg; do
  31. echo "1234567890" >> "$pkg"
  32. touch -d '+1hour' "$pkg"
  33. done
  34. NEW_SIZE="$(stat --printf=%s aptarchive/dists/unstable/main/binary-i386/Packages.gz)"
  35. testfailuremsg "E: Failed to fetch ${1}/dists/unstable/main/binary-i386/Packages.gz Writing more data than expected ($NEW_SIZE > $SIZE)
  36. 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
  37. }
  38. methodtest() {
  39. # less complicated test setup this way
  40. webserverconfig 'aptwebserver::support::modified-since' 'false' "$1"
  41. webserverconfig 'aptwebserver::support::last-modified' 'false' "$1" # curl is clever and sees hits here also
  42. msgmsg 'Test with' "$1" 'and clean start'
  43. rm -rf rootdir/var/lib/apt/lists rootdir/var/lib/apt/lists.good
  44. # normal update works fine
  45. testsuccess aptget update
  46. mv rootdir/var/lib/apt/lists rootdir/var/lib/apt/lists.good
  47. # starting fresh works
  48. test_inreleasetoobig "$1"
  49. rm -rf aptarchive/dists rootdir/var/lib/apt/lists
  50. cp -a aptarchive/dists.good aptarchive/dists
  51. test_packagestoobig "$1"
  52. rm -rf aptarchive/dists rootdir/var/lib/apt/lists
  53. cp -a aptarchive/dists.good aptarchive/dists
  54. msgmsg 'Test with' "$1" 'and existing old data'
  55. cp -a rootdir/var/lib/apt/lists.good rootdir/var/lib/apt/lists
  56. test_inreleasetoobig "$1"
  57. rm -rf aptarchive/dists rootdir/var/lib/apt/lists
  58. cp -a rootdir/var/lib/apt/lists.good rootdir/var/lib/apt/lists
  59. cp -a aptarchive/dists.good aptarchive/dists
  60. test_packagestoobig "$1"
  61. rm -rf aptarchive/dists
  62. cp -a aptarchive/dists.good aptarchive/dists
  63. }
  64. changetowebserver
  65. methodtest "http://localhost:${APTHTTPPORT}"
  66. changetohttpswebserver
  67. methodtest "https://localhost:${APTHTTPSPORT}"