test-apt-update-expected-size 2.9 KB

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