3 . "$(dirname "$0")/testlib.sh"
5 begin_test "custom-transfer-wrong-path"
9 # this repo name is the indicator to the server to support custom transfer
10 reponame="test-custom-transfer-fail"
11 setup_remote_repo "$reponame"
13 clone_repo "$reponame" $reponame
15 # deliberately incorrect path
16 git config lfs.customtransfer.testcustom.path path-to-nothing
18 git lfs track "*.dat" 2>&1 | tee track.log
19 grep "Tracking \"\*.dat\"" track.log
21 contents="jksgdfljkgsdlkjafg lsjdgf alkjgsd lkfjag sldjkgf alkjsgdflkjagsd kljfg asdjgf kalsd"
22 contents_oid=$(calc_oid "$contents")
24 printf "$contents" > a.dat
26 git add .gitattributes
27 git commit -m "add a.dat" 2>&1 | tee commit.log
28 GIT_TRACE=1 GIT_TRANSFER_TRACE=1 git push origin master 2>&1 | tee pushcustom.log
29 # use PIPESTATUS otherwise we get exit code from tee
31 grep "xfer: adapter \"testcustom\" Begin()" pushcustom.log
32 grep "Failed to start custom transfer command" pushcustom.log
33 if [ "$res" = "0" ]; then
34 echo "Push should have failed because of an incorrect custom transfer path."
41 begin_test "custom-transfer-upload-download"
45 # this repo name is the indicator to the server to support custom transfer
46 reponame="test-custom-transfer-1"
47 setup_remote_repo "$reponame"
49 clone_repo "$reponame" $reponame
51 # set up custom transfer adapter
52 git config lfs.customtransfer.testcustom.path lfstest-customadapter
54 git lfs track "*.dat" 2>&1 | tee track.log
55 grep "Tracking \"\*.dat\"" track.log
56 git add .gitattributes
57 git commit -m "Tracking"
59 # set up a decent amount of data so that there's work for multiple concurrent adapters
62 \"CommitDate\":\"$(get_date -10d)\",
64 {\"Filename\":\"verify.dat\",\"Size\":18,\"Data\":\"send-verify-action\"},
65 {\"Filename\":\"file1.dat\",\"Size\":1024},
66 {\"Filename\":\"file2.dat\",\"Size\":750}]
69 \"CommitDate\":\"$(get_date -7d)\",
71 {\"Filename\":\"file1.dat\",\"Size\":1050},
72 {\"Filename\":\"file3.dat\",\"Size\":660},
73 {\"Filename\":\"file4.dat\",\"Size\":230}]
76 \"CommitDate\":\"$(get_date -5d)\",
78 {\"Filename\":\"file5.dat\",\"Size\":1200},
79 {\"Filename\":\"file6.dat\",\"Size\":300}]
82 \"CommitDate\":\"$(get_date -2d)\",
84 {\"Filename\":\"file3.dat\",\"Size\":120},
85 {\"Filename\":\"file5.dat\",\"Size\":450},
86 {\"Filename\":\"file7.dat\",\"Size\":520},
87 {\"Filename\":\"file8.dat\",\"Size\":2048}]
89 ]" | lfstest-testutils addcommits
91 GIT_TRACE=1 GIT_TRANSFER_TRACE=1 git push origin master 2>&1 | tee pushcustom.log
92 # use PIPESTATUS otherwise we get exit code from tee
93 [ ${PIPESTATUS[0]} = "0" ]
95 grep "xfer: started custom adapter process" pushcustom.log
96 grep "xfer\[lfstest-customadapter\]:" pushcustom.log
97 grep "Uploading LFS objects: 100% (12/12)" pushcustom.log
99 rm -rf .git/lfs/objects
100 GIT_TRACE=1 GIT_TRANSFER_TRACE=1 git lfs fetch --all 2>&1 | tee fetchcustom.log
101 [ ${PIPESTATUS[0]} = "0" ]
103 grep "xfer: started custom adapter process" fetchcustom.log
104 grep "xfer\[lfstest-customadapter\]:" fetchcustom.log
106 grep "Terminating test custom adapter gracefully" fetchcustom.log
108 objectlist=`find .git/lfs/objects -type f`
109 [ "$(echo "$objectlist" | wc -l)" -eq 12 ]
113 begin_test "custom-transfer-standalone"
117 # setup a git repo to be used as a local repo, not remote
118 reponame="test-custom-transfer-standalone"
119 setup_remote_repo "$reponame"
121 # clone directly, not through lfstest-gitserver
122 clone_repo_url "$REMOTEDIR/$reponame.git" $reponame
124 # set up custom transfer adapter to use a specific transfer agent
125 git config lfs.customtransfer.testcustom.path lfstest-standalonecustomadapter
126 git config lfs.customtransfer.testcustom.concurrent false
127 git config lfs.standalonetransferagent testcustom
128 export TEST_STANDALONE_BACKUP_PATH="$(pwd)/test-custom-transfer-standalone-backup"
129 mkdir -p $TEST_STANDALONE_BACKUP_PATH
130 rm -rf $TEST_STANDALONE_BACKUP_PATH/*
132 git lfs track "*.dat" 2>&1 | tee track.log
133 grep "Tracking \"\*.dat\"" track.log
134 git add .gitattributes
135 git commit -m "Tracking"
137 # set up a decent amount of data so that there's work for multiple concurrent adapters
140 \"CommitDate\":\"$(get_date -10d)\",
142 {\"Filename\":\"verify.dat\",\"Size\":18,\"Data\":\"send-verify-action\"},
143 {\"Filename\":\"file1.dat\",\"Size\":1024},
144 {\"Filename\":\"file2.dat\",\"Size\":750}]
147 \"CommitDate\":\"$(get_date -7d)\",
149 {\"Filename\":\"file1.dat\",\"Size\":1050},
150 {\"Filename\":\"file3.dat\",\"Size\":660},
151 {\"Filename\":\"file4.dat\",\"Size\":230}]
154 \"CommitDate\":\"$(get_date -5d)\",
156 {\"Filename\":\"file5.dat\",\"Size\":1200},
157 {\"Filename\":\"file6.dat\",\"Size\":300}]
160 \"CommitDate\":\"$(get_date -2d)\",
162 {\"Filename\":\"file3.dat\",\"Size\":120},
163 {\"Filename\":\"file5.dat\",\"Size\":450},
164 {\"Filename\":\"file7.dat\",\"Size\":520},
165 {\"Filename\":\"file8.dat\",\"Size\":2048}]
167 ]" | lfstest-testutils addcommits
169 GIT_TRACE=1 GIT_TRANSFER_TRACE=1 git push origin master 2>&1 | tee pushcustom.log
170 # use PIPESTATUS otherwise we get exit code from tee
171 [ ${PIPESTATUS[0]} = "0" ]
173 # Make sure the lock verification is not attempted.
174 grep "locks/verify$" pushcustom.log && false
176 grep "xfer: started custom adapter process" pushcustom.log
177 grep "xfer\[lfstest-standalonecustomadapter\]:" pushcustom.log
178 grep "Uploading LFS objects: 100% (12/12)" pushcustom.log
180 rm -rf .git/lfs/objects
181 GIT_TRACE=1 GIT_TRANSFER_TRACE=1 git lfs fetch --all 2>&1 | tee fetchcustom.log
182 [ ${PIPESTATUS[0]} = "0" ]
184 grep "xfer: started custom adapter process" fetchcustom.log
185 grep "xfer\[lfstest-standalonecustomadapter\]:" fetchcustom.log
186 grep "Downloading LFS objects: 100% (12/12)" fetchcustom.log
188 grep "Terminating test custom adapter gracefully" fetchcustom.log
190 objectlist=`find .git/lfs/objects -type f`
191 [ "$(echo "$objectlist" | wc -l)" -eq 12 ]
195 begin_test "custom-transfer-standalone-urlmatch"
199 # setup a git repo to be used as a local repo, not remote
200 reponame="test-custom-transfer-standalone-urlmatch"
201 setup_remote_repo "$reponame"
203 # clone directly, not through lfstest-gitserver
204 clone_repo_url "$REMOTEDIR/$reponame.git" $reponame
206 # set up custom transfer adapter to use a specific transfer agent, using a URL prefix match
207 git config lfs.customtransfer.testcustom.path lfstest-standalonecustomadapter
208 git config lfs.customtransfer.testcustom.concurrent false
209 git config remote.origin.lfsurl https://git.example.com/example/path/to/repo
210 git config lfs.https://git.example.com/example/path/.standalonetransferagent testcustom
211 git config lfs.standalonetransferagent invalid-agent
213 # git config lfs.standalonetransferagent testcustom
214 export TEST_STANDALONE_BACKUP_PATH="$(pwd)/test-custom-transfer-standalone-urlmatch-backup"
215 mkdir -p $TEST_STANDALONE_BACKUP_PATH
216 rm -rf $TEST_STANDALONE_BACKUP_PATH/*
218 git lfs track "*.dat" 2>&1 | tee track.log
219 grep "Tracking \"\*.dat\"" track.log
220 git add .gitattributes
221 git commit -m "Tracking"
223 # set up a decent amount of data so that there's work for multiple concurrent adapters
226 \"CommitDate\":\"$(get_date -10d)\",
228 {\"Filename\":\"verify.dat\",\"Size\":18,\"Data\":\"send-verify-action\"},
229 {\"Filename\":\"file1.dat\",\"Size\":1024},
230 {\"Filename\":\"file2.dat\",\"Size\":750}]
233 \"CommitDate\":\"$(get_date -7d)\",
235 {\"Filename\":\"file1.dat\",\"Size\":1050},
236 {\"Filename\":\"file3.dat\",\"Size\":660},
237 {\"Filename\":\"file4.dat\",\"Size\":230}]
240 \"CommitDate\":\"$(get_date -5d)\",
242 {\"Filename\":\"file5.dat\",\"Size\":1200},
243 {\"Filename\":\"file6.dat\",\"Size\":300}]
246 \"CommitDate\":\"$(get_date -2d)\",
248 {\"Filename\":\"file3.dat\",\"Size\":120},
249 {\"Filename\":\"file5.dat\",\"Size\":450},
250 {\"Filename\":\"file7.dat\",\"Size\":520},
251 {\"Filename\":\"file8.dat\",\"Size\":2048}]
253 ]" | lfstest-testutils addcommits
255 GIT_TRACE=1 GIT_TRANSFER_TRACE=1 git push origin master 2>&1 | tee pushcustom.log
256 # use PIPESTATUS otherwise we get exit code from tee
257 [ ${PIPESTATUS[0]} = "0" ]
259 # Make sure the lock verification is not attempted.
260 grep "locks/verify$" pushcustom.log && false
262 grep "xfer: started custom adapter process" pushcustom.log
263 grep "xfer\[lfstest-standalonecustomadapter\]:" pushcustom.log
264 grep "Uploading LFS objects: 100% (12/12)" pushcustom.log
266 rm -rf .git/lfs/objects
267 GIT_TRACE=1 GIT_TRANSFER_TRACE=1 git lfs fetch --all 2>&1 | tee fetchcustom.log
268 [ ${PIPESTATUS[0]} = "0" ]
270 grep "xfer: started custom adapter process" fetchcustom.log
271 grep "xfer\[lfstest-standalonecustomadapter\]:" fetchcustom.log
272 grep "Downloading LFS objects: 100% (12/12)" fetchcustom.log
274 grep "Terminating test custom adapter gracefully" fetchcustom.log
276 objectlist=`find .git/lfs/objects -type f`
277 [ "$(echo "$objectlist" | wc -l)" -eq 12 ]