summaryrefslogtreecommitdiffstats
path: root/test/integration/test-acquire-same-file-multiple-times
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:00:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:00:48 +0000
commit851b6a097165af4d51c0db01b5e05256e5006896 (patch)
tree5f7c388ec894a7806c49a99f3bdb605d0b299a7c /test/integration/test-acquire-same-file-multiple-times
parentInitial commit. (diff)
downloadapt-upstream.tar.xz
apt-upstream.zip
Adding upstream version 2.6.1.upstream/2.6.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/integration/test-acquire-same-file-multiple-times')
-rwxr-xr-xtest/integration/test-acquire-same-file-multiple-times90
1 files changed, 90 insertions, 0 deletions
diff --git a/test/integration/test-acquire-same-file-multiple-times b/test/integration/test-acquire-same-file-multiple-times
new file mode 100755
index 0000000..fc82412
--- /dev/null
+++ b/test/integration/test-acquire-same-file-multiple-times
@@ -0,0 +1,90 @@
+#!/bin/sh
+set -e
+
+TESTDIR="$(readlink -f "$(dirname "$0")")"
+. "$TESTDIR/framework"
+setupenvironment
+configarchitecture 'amd64'
+
+TESTFILE="$TESTDIR/framework"
+cp "$TESTFILE" aptarchive/foo
+APTARCHIVE="$(readlink -f ./aptarchive)"
+
+filedown() {
+ msgtest 'Downloading the same URI twice over file' "$1"
+ testsuccess --nomsg apthelper download-file "file://$APTARCHIVE/foo" './downloaded/foo1' '' \
+ "file://$APTARCHIVE/foo" './downloaded/foo2' '' -o Debug::pkgAcquire::Worker=1
+ cp rootdir/tmp/testsuccess.output download.log
+ testsuccess cmp "$TESTFILE" ./downloaded/foo1
+ testsuccess cmp ./downloaded/foo1 ./downloaded/foo2
+ testequal '1' grep -c '200%20URI%20Start' ./download.log
+ testequal '1' grep -c '201%20URI%20Done' ./download.log
+ rm -f ./downloaded/foo1 ./downloaded/foo2
+}
+
+testrun() {
+ $1 'no partial'
+ cp "$TESTFILE" ./downloaded/foo1
+ $1 'complete partial 1'
+ cp "$TESTFILE" ./downloaded/foo2
+ $1 'complete partial 2'
+ cp "$TESTFILE" ./downloaded/foo1
+ cp "$TESTFILE" ./downloaded/foo2
+ $1 'complete partial 1+2'
+ dd if="$TESTFILE" of=./downloaded/foo1 bs=500 count=1 2>/dev/null
+ $1 'partial partial 1'
+ dd if="$TESTFILE" of=./downloaded/foo2 bs=500 count=1 2>/dev/null
+ $1 'partial partial 2'
+ dd if="$TESTFILE" of=./downloaded/foo1 bs=500 count=1 2>/dev/null
+ dd if="$TESTFILE" of=./downloaded/foo2 bs=500 count=1 2>/dev/null
+ $1 'partial partial 1+2'
+}
+testrun 'filedown'
+
+changetowebserver -o aptwebserver::redirect::replace::/foo2=/foo
+
+httpdown() {
+ msgtest 'Downloading the same URI to different files' 'twice over http'
+ testsuccess --nomsg apthelper download-file "http://localhost:${APTHTTPPORT}/foo" "./downloaded/foo1" '' \
+ "http://localhost:${APTHTTPPORT}/foo" './downloaded/foo2' '' -o Debug::pkgAcquire::Worker=1 -o Debug::Acquire::http=1
+ cp rootdir/tmp/testsuccess.output download.log
+ testsuccess cmp "$TESTDIR/framework" ./downloaded/foo1
+ testsuccess cmp ./downloaded/foo1 ./downloaded/foo2
+ testequal '1' grep -c '200%20URI%20Start' ./download.log
+ testequal '1' grep -c '201%20URI%20Done' ./download.log
+ rm -f ./downloaded/foo1 ./downloaded/foo2
+}
+testrun 'httpdown'
+
+httpredirectdown() {
+ msgtest 'Redirect leads' 'first URI to the second URI'
+ for i in 1 2 3 4 5 6 7 8 9 10; do
+ rm -f ./downloaded/foo1 ./downloaded/foo2
+ testsuccess --nomsg apthelper download-file "http://localhost:${APTHTTPPORT}/foo2" "./downloaded/foo1" '' \
+ "http://localhost:${APTHTTPPORT}/foo" './downloaded/foo2' '' -o Debug::pkgAcquire::Worker=1 -o Debug::Acquire::http=1
+ cp rootdir/tmp/testsuccess.output download.log
+ testsuccess cmp "$TESTDIR/framework" ./downloaded/foo1
+ testsuccess cmp ./downloaded/foo1 ./downloaded/foo2
+
+ if grep -q '103%20Redirect' ./download.log; then
+ break
+ fi
+ done
+ testequal '1' grep -c '200%20URI%20Start' ./download.log
+ testequal '1' grep -c '103%20Redirect' ./download.log
+ testequal '1' grep -c '201%20URI%20Done' ./download.log
+ rm -f ./downloaded/foo1 ./downloaded/foo2
+}
+testrun 'httpredirectdown'
+
+httpsamedown() {
+ msgtest 'Downloading two files via the same URI to' 'the same file'
+ testsuccess --nomsg apthelper download-file "http://localhost:${APTHTTPPORT}/foo" "./downloaded/foo1" '' \
+ "http://localhost:${APTHTTPPORT}/foo" './downloaded/foo1' '' -o Debug::pkgAcquire::Worker=1
+ cp rootdir/tmp/testsuccess.output download.log
+ testsuccess cmp "$TESTDIR/framework" ./downloaded/foo1
+ testequal '1' grep -c '200%20URI%20Start' ./download.log
+ testequal '1' grep -c '201%20URI%20Done' ./download.log
+ rm -f ./downloaded/foo1
+}
+testrun 'httpsamedown'