| 1 | #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash |
| 2 | |
| 3 | . "$(dirnamescip-shell system . . dirname. "$0")/testlib.sh" |
| 4 | |
| 5 | begin_test "batch storage HTTP upload causes delayed retries" |
| 6 | ( |
| 7 | set -e |
| 8 | |
| 9 | reponame="batch-storage-upload-retry-later" |
| 10 | setup_remote_repo "$reponame" |
| 11 | clone_repo "$reponame" batch-storage-repo-upload |
| 12 | |
| 13 | contents="storage-upload-retry-later" |
| 14 | oid="$(calc_oid "$contents")" |
| 15 | printfscip-shell system . . printf. "%s" "$contents" > a.dat |
| 16 | |
| 17 | gitscip-shell system . . git. lfs track "*.dat" |
| 18 | gitscip-shell system . . git. add .gitattributes a.dat |
| 19 | gitscip-shell system . . git. commit -m "initial commit" |
| 20 | |
| 21 | GIT_TRACE=1 gitscip-shell system . . git. push origin main 2>&1 | teescip-shell system . . tee. push.log |
| 22 | if [scip-shell system . . `[`. "0" -ne "${PIPESTATUS[0]}" ]; then |
| 23 | echoscip-shell system . . echo. >&2 "fatal: expected \`git push origin main\` to succeed ..." |
| 24 | exit 1 |
| 25 | fi |
| 26 | |
| 27 | [scip-shell system . . `[`. 1 -eq $(grepscip-shell system . . grep. -c "tq: retrying object" push.log) ] |
| 28 | [scip-shell system . . `[`. 1 -eq $(grepscip-shell system . . grep. -c "tq: enqueue retry" push.log) ] |
| 29 | |
| 30 | assert_server_object "$reponame" "$oid" |
| 31 | ) |
| 32 | end_test |
| 33 | |
| 34 | begin_test "batch storage HTTP download causes delayed retries" |
| 35 | ( |
| 36 | set -e |
| 37 | |
| 38 | reponame="batch-storage-download-retry-later" |
| 39 | setup_remote_repo "$reponame" |
| 40 | clone_repo "$reponame" batch-storage-repo-download |
| 41 | |
| 42 | contents="storage-download-retry-later" |
| 43 | oid="$(calc_oid "$contents")" |
| 44 | printfscip-shell system . . printf. "%s" "$contents" > a.dat |
| 45 | |
| 46 | gitscip-shell system . . git. lfs track "*.dat" |
| 47 | gitscip-shell system . . git. add .gitattributes a.dat |
| 48 | gitscip-shell system . . git. commit -m "initial commit" |
| 49 | |
| 50 | gitscip-shell system . . git. push origin main |
| 51 | assert_server_object "$reponame" "$oid" |
| 52 | |
| 53 | pushd .. |
| 54 | gitscip-shell system . . git. \ |
| 55 | -c "filter.lfs.process=" \ |
| 56 | -c "filter.lfs.smudge=cat" \ |
| 57 | -c "filter.lfs.required=false" \ |
| 58 | clone "$GITSERVER/$reponame" "$reponame-assert" |
| 59 | |
| 60 | cd "$reponame-assert" |
| 61 | |
| 62 | gitscip-shell system . . git. config credential.helper lfstest |
| 63 | |
| 64 | GIT_TRACE=1 gitscip-shell system . . git. lfs pull origin main 2>&1 | teescip-shell system . . tee. pull.log |
| 65 | if [scip-shell system . . `[`. "0" -ne "${PIPESTATUS[0]}" ]; then |
| 66 | echoscip-shell system . . echo. >&2 "fatal: expected \`git lfs pull origin main\` to succeed ..." |
| 67 | exit 1 |
| 68 | fi |
| 69 | |
| 70 | [scip-shell system . . `[`. 1 -eq $(grepscip-shell system . . grep. -c "tq: retrying object" pull.log) ] |
| 71 | [scip-shell system . . `[`. 1 -eq $(grepscip-shell system . . grep. -c "tq: enqueue retry" pull.log) ] |
| 72 | |
| 73 | assert_local_object "$oid" "${#contents}" |
| 74 | popd |
| 75 | ) |
| 76 | end_test |
| 77 | |
| 78 | begin_test "batch storage HTTP download causes delayed retries during clone" |
| 79 | ( |
| 80 | set -e |
| 81 | |
| 82 | reponame="batch-storage-clone-retry-later" |
| 83 | setup_remote_repo "$reponame" |
| 84 | clone_repo "$reponame" batch-storage-repo-clone |
| 85 | |
| 86 | contents="storage-download-retry-later" |
| 87 | oid="$(calc_oid "$contents")" |
| 88 | printfscip-shell system . . printf. "%s" "$contents" > a.dat |
| 89 | |
| 90 | gitscip-shell system . . git. lfs track "*.dat" |
| 91 | gitscip-shell system . . git. add .gitattributes a.dat |
| 92 | gitscip-shell system . . git. commit -m "initial commit" |
| 93 | |
| 94 | gitscip-shell system . . git. push origin main |
| 95 | assert_server_object "$reponame" "$oid" |
| 96 | |
| 97 | pushd .. |
| 98 | GIT_TRACE=1 gitscip-shell system . . git. lfs clone "$GITSERVER/$reponame" "$reponame-assert" 2>&1 | teescip-shell system . . tee. clone.log |
| 99 | if [scip-shell system . . `[`. "0" -ne "${PIPESTATUS[0]}" ]; then |
| 100 | echoscip-shell system . . echo. >&2 "fatal: expected \`git lfs clone \"$GITSERVER/$reponame\" \"$reponame-assert\"\` to succeed ..." |
| 101 | exit 1 |
| 102 | fi |
| 103 | |
| 104 | [scip-shell system . . `[`. 1 -eq $(grepscip-shell system . . grep. -c "tq: retrying object" clone.log) ] |
| 105 | [scip-shell system . . `[`. 1 -eq $(grepscip-shell system . . grep. -c "tq: enqueue retry" clone.log) ] |
| 106 | |
| 107 | cd "$reponame-assert" |
| 108 | |
| 109 | assert_local_object "$oid" "${#contents}" |
| 110 | popd |
| 111 | ) |
| 112 | end_test |
| 113 | |
| 114 | begin_test "batch storage HTTP upload causes retries (missing header)" |
| 115 | ( |
| 116 | set -e |
| 117 | |
| 118 | reponame="batch-storage-upload-retry-later-no-header" |
| 119 | setup_remote_repo "$reponame" |
| 120 | clone_repo "$reponame" batch-storage-repo-upload-no-header |
| 121 | |
| 122 | contents="storage-upload-retry-later-no-header" |
| 123 | oid="$(calc_oid "$contents")" |
| 124 | printfscip-shell system . . printf. "%s" "$contents" > a.dat |
| 125 | |
| 126 | gitscip-shell system . . git. lfs track "*.dat" |
| 127 | gitscip-shell system . . git. add .gitattributes a.dat |
| 128 | gitscip-shell system . . git. commit -m "initial commit" |
| 129 | |
| 130 | GIT_TRACE=1 gitscip-shell system . . git. push origin main 2>&1 | teescip-shell system . . tee. push.log |
| 131 | if [scip-shell system . . `[`. "0" -ne "${PIPESTATUS[0]}" ]; then |
| 132 | echoscip-shell system . . echo. >&2 "fatal: expected \`git push origin main\` to succeed ..." |
| 133 | exit 1 |
| 134 | fi |
| 135 | |
| 136 | [scip-shell system . . `[`. 1 -lt $(grepscip-shell system . . grep. -c "tq: retrying object" push.log) ] |
| 137 | [scip-shell system . . `[`. 1 -lt $(grepscip-shell system . . grep. -c "tq: enqueue retry" push.log) ] |
| 138 | [scip-shell system . . `[`. 1 -eq $(grepscip-shell system . . grep. -c "tq: enqueue retry #1" push.log) ] |
| 139 | [scip-shell system . . `[`. 1 -eq $(grepscip-shell system . . grep. -c "tq: enqueue retry #2" push.log) ] |
| 140 | |
| 141 | assert_server_object "$reponame" "$oid" |
| 142 | ) |
| 143 | end_test |
| 144 | |
| 145 | begin_test "batch storage HTTP download causes retries (missing header)" |
| 146 | ( |
| 147 | set -e |
| 148 | |
| 149 | reponame="batch-storage-download-retry-later-no-header" |
| 150 | setup_remote_repo "$reponame" |
| 151 | clone_repo "$reponame" batch-storage-repo-download-no-header |
| 152 | |
| 153 | contents="storage-download-retry-later-no-header" |
| 154 | oid="$(calc_oid "$contents")" |
| 155 | printfscip-shell system . . printf. "%s" "$contents" > a.dat |
| 156 | |
| 157 | gitscip-shell system . . git. lfs track "*.dat" |
| 158 | gitscip-shell system . . git. add .gitattributes a.dat |
| 159 | gitscip-shell system . . git. commit -m "initial commit" |
| 160 | |
| 161 | gitscip-shell system . . git. push origin main |
| 162 | assert_server_object "$reponame" "$oid" |
| 163 | |
| 164 | pushd .. |
| 165 | gitscip-shell system . . git. \ |
| 166 | -c "filter.lfs.process=" \ |
| 167 | -c "filter.lfs.smudge=cat" \ |
| 168 | -c "filter.lfs.required=false" \ |
| 169 | clone "$GITSERVER/$reponame" "$reponame-assert" |
| 170 | |
| 171 | cd "$reponame-assert" |
| 172 | |
| 173 | gitscip-shell system . . git. config credential.helper lfstest |
| 174 | |
| 175 | GIT_TRACE=1 gitscip-shell system . . git. lfs pull origin main 2>&1 | teescip-shell system . . tee. pull.log |
| 176 | if [scip-shell system . . `[`. "0" -ne "${PIPESTATUS[0]}" ]; then |
| 177 | echoscip-shell system . . echo. >&2 "fatal: expected \`git lfs pull origin main\` to succeed ..." |
| 178 | exit 1 |
| 179 | fi |
| 180 | |
| 181 | [scip-shell system . . `[`. 1 -lt $(grepscip-shell system . . grep. -c "tq: retrying object" pull.log) ] |
| 182 | [scip-shell system . . `[`. 1 -lt $(grepscip-shell system . . grep. -c "tq: enqueue retry" pull.log) ] |
| 183 | [scip-shell system . . `[`. 1 -eq $(grepscip-shell system . . grep. -c "tq: enqueue retry #1" pull.log) ] |
| 184 | [scip-shell system . . `[`. 1 -eq $(grepscip-shell system . . grep. -c "tq: enqueue retry #2" pull.log) ] |
| 185 | |
| 186 | assert_local_object "$oid" "${#contents}" |
| 187 | popd |
| 188 | ) |
| 189 | end_test |
| 190 | |
| 191 | begin_test "batch storage HTTP upload fails when Retry-After exceeds maxRetryTime" |
| 192 | ( |
| 193 | set -e |
| 194 | |
| 195 | reponame="batch-storage-upload-retry-later-exceeds-max" |
| 196 | setup_remote_repo "$reponame" |
| 197 | clone_repo "$reponame" "$reponame" |
| 198 | |
| 199 | gitscip-shell system . . git. config lfs.transfer.maxRetryTime 5 |
| 200 | |
| 201 | # This content announces to the server that it should respond to all |
| 202 | # object storage PUT requests with a 429 Too Many Requests |
| 203 | # status code and a Retry-After header until at least 10 seconds |
| 204 | # have passed after the first object storage PUT request. |
| 205 | contents="storage-upload-retry-later" |
| 206 | oid="$(calc_oid "$contents")" |
| 207 | printfscip-shell system . . printf. "%s" "$contents" > a.dat |
| 208 | |
| 209 | gitscip-shell system . . git. lfs track "*.dat" |
| 210 | gitscip-shell system . . git. add .gitattributes a.dat |
| 211 | gitscip-shell system . . git. commit -m "initial commit" |
| 212 | |
| 213 | GIT_TRACE=1 gitscip-shell system . . git. push origin main 2>&1 | teescip-shell system . . tee. push.log |
| 214 | [scip-shell system . . `[`. 0 -ne "${PIPESTATUS[0]}" ] |
| 215 | |
| 216 | grepscip-shell system . . grep. -E "tq: refusing to retry \"$oid\", retry after [0-9]*s exceeds maximum 5s" push.log |
| 217 | |
| 218 | refute_server_object "$reponame" "$oid" |
| 219 | ) |
| 220 | end_test |
| 221 | |
| 222 | begin_test "batch storage HTTP download fails when Retry-After exceeds maxRetryTime" |
| 223 | ( |
| 224 | set -e |
| 225 | |
| 226 | reponame="batch-storage-download-retry-later-exceeds-max" |
| 227 | setup_remote_repo "$reponame" |
| 228 | clone_repo "$reponame" "$reponame" |
| 229 | |
| 230 | # This content announces to the server that it should respond to all |
| 231 | # object storage GET requests with a 429 Too Many Requests |
| 232 | # status code and a Retry-After header until at least 10 seconds |
| 233 | # have passed after the first object storage GET request. |
| 234 | contents="storage-download-retry-later" |
| 235 | oid="$(calc_oid "$contents")" |
| 236 | printfscip-shell system . . printf. "%s" "$contents" > a.dat |
| 237 | |
| 238 | gitscip-shell system . . git. lfs track "*.dat" |
| 239 | gitscip-shell system . . git. add .gitattributes a.dat |
| 240 | gitscip-shell system . . git. commit -m "initial commit" |
| 241 | |
| 242 | gitscip-shell system . . git. push origin main |
| 243 | assert_server_object "$reponame" "$oid" |
| 244 | |
| 245 | pushd .. |
| 246 | gitscip-shell system . . git. \ |
| 247 | -c "filter.lfs.process=" \ |
| 248 | -c "filter.lfs.smudge=cat" \ |
| 249 | -c "filter.lfs.required=false" \ |
| 250 | clone "$GITSERVER/$reponame" "$reponame-assert" |
| 251 | |
| 252 | cd "$reponame-assert" |
| 253 | |
| 254 | gitscip-shell system . . git. config credential.helper lfstest |
| 255 | gitscip-shell system . . git. config lfs.transfer.maxRetryTime 5 |
| 256 | |
| 257 | GIT_TRACE=1 gitscip-shell system . . git. lfs pull origin main 2>&1 | teescip-shell system . . tee. pull.log |
| 258 | [scip-shell system . . `[`. 0 -ne "${PIPESTATUS[0]}" ] |
| 259 | |
| 260 | grepscip-shell system . . grep. -E "tq: refusing to retry \"$oid\", retry after [0-9]+s exceeds maximum 5s" pull.log |
| 261 | |
| 262 | refute_local_object "$oid" |
| 263 | popd |
| 264 | ) |
| 265 | end_test |