Imported Upstream version 2.4.2
[scm/test.git] / test / test-resume-tus.sh
1 #!/usr/bin/env bash
2
3 . "test/testlib.sh"
4
5 begin_test "tus-upload-uninterrupted"
6 (
7   set -e
8
9   # this repo name is the indicator to the server to use tus
10   reponame="test-tus-upload"
11   setup_remote_repo "$reponame"
12
13   clone_repo "$reponame" $reponame
14   git config lfs.tustransfers true
15
16   git lfs track "*.dat" 2>&1 | tee track.log
17   grep "Tracking \"\*.dat\"" track.log
18
19   contents="send-verify-action"
20   contents_oid=$(calc_oid "$contents")
21
22   printf "$contents" > a.dat
23   git add a.dat
24   git add .gitattributes
25   git commit -m "add a.dat" 2>&1 | tee commit.log
26   GIT_TRACE=1 GIT_TRANSFER_TRACE=1 git push origin master 2>&1 | tee pushtus.log
27   grep "xfer: tus.io uploading" pushtus.log
28
29   assert_server_object "$reponame" "$contents_oid"
30
31 )
32 end_test
33
34 begin_test "tus-upload-interrupted-resume"
35 (
36   set -e
37
38   # this repo name is the indicator to the server to use tus, AND to
39   # interrupt the upload part way
40   reponame="test-tus-upload-interrupt"
41   setup_remote_repo "$reponame"
42
43   clone_repo "$reponame" $reponame
44   git config lfs.tustransfers true
45
46   git lfs track "*.dat" 2>&1 | tee track.log
47   grep "Tracking \"\*.dat\"" track.log
48
49   contents_verify="send-verify-action"
50   contents_verify_oid="$(calc_oid "$contents_verify")"
51
52   # this string announces to server that we want it to abort the download part
53   # way, but reject the Range: header and fall back on re-downloading instead
54   contents="234587134187634598o634857619384765b747qcvtuedvoaicwtvseudtvcoqi7280r7qvow4i7r8c46pr9q6v9pri6ioq2r8"
55   contents_oid=$(calc_oid "$contents")
56
57   printf "$contents" > a.dat
58   printf "$contents_verify" > verify.dat
59   git add a.dat verify.dat
60   git add .gitattributes
61   git commit -m "add a.dat, verify.dat" 2>&1 | tee commit.log
62   GIT_TRACE=1 GIT_TRANSFER_TRACE=1 git push origin master 2>&1 | tee pushtus_resume.log
63   # first attempt will start from the beginning
64   grep "xfer: tus.io uploading" pushtus_resume.log
65   grep "HTTP: 500" pushtus_resume.log
66   # that will have failed but retry on 500 will resume it
67   grep "xfer: tus.io resuming" pushtus_resume.log
68   grep "HTTP: 204" pushtus_resume.log
69
70   # should have completed in the end
71   assert_server_object "$reponame" "$contents_oid"
72   assert_server_object "$reponame" "$contents_verify_oid"
73
74 )
75 end_test