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.
 
 
 
 
 
 

76 lines
2.8 KiB

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