test-apt-update-expected-size 2.7 KB

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