Skip to content

Commit b28744a

Browse files
committed
fix(test/blackbox): address Copilot review feedback in push/pull helpers
Use curl --fail for manifest deletes so HTTP errors fail the test. Remove the duplicate regctl --format flag in helper_push_manifest_with_regclient. Harden helper_authn_ml_artifacts with run and status checks, using a binary-safe shell redirect for the ONNX artifact round-trip. Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
1 parent 1919c9b commit b28744a

2 files changed

Lines changed: 27 additions & 13 deletions

File tree

test/blackbox/helpers_pushpull.bash

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ function helper_delete_manifest() {
224224
local zot_port
225225
zot_port=$(get_zot_port)
226226

227-
run curl -X DELETE "http://127.0.0.1:${zot_port}/v2/${image_name}/manifests/${tag}"
227+
run curl --fail -X DELETE "http://127.0.0.1:${zot_port}/v2/${image_name}/manifests/${tag}"
228228
[ "${status}" -eq 0 ]
229229
}
230230

@@ -438,8 +438,7 @@ function helper_push_manifest_with_regclient() {
438438

439439
run regctl manifest put "localhost:${zot_port}/test-regclient:1.0.0" \
440440
--format oci \
441-
--content-type application/vnd.oci.image.manifest.v1+json \
442-
--format oci <<JSON
441+
--content-type application/vnd.oci.image.manifest.v1+json <<JSON
443442
${manifest}
444443
JSON
445444
[ "${status}" -eq 0 ]

test/blackbox/helpers_pushpull_authn.bash

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -206,31 +206,46 @@ function helper_authn_list_oci_artifact_references_with_regclient() {
206206
function helper_authn_ml_artifacts() {
207207
local user=${1:-${AUTH_USER}}
208208
local pass=${2:-${AUTH_PASS}}
209+
local zot_port sha256_in sha256_out
209210

210211
helper_authn_regctl_login "${user}" "${pass}"
212+
zot_port=$(get_zot_port)
211213

212-
curl -v -L0 \
214+
run curl --fail -L -0 \
213215
https://github.com/tarilabs/demo20231212/raw/main/v1.nb20231206162408/mnist.onnx \
214216
-o "${BATS_FILE_TMPDIR}/mnist.onnx"
215-
sha256_in=$(sha256sum "${BATS_FILE_TMPDIR}/mnist.onnx" | awk '{print $1}')
217+
[ "${status}" -eq 0 ]
218+
219+
run sha256sum "${BATS_FILE_TMPDIR}/mnist.onnx"
220+
[ "${status}" -eq 0 ]
221+
sha256_in=$(echo "${output}" | awk '{print $1}')
222+
[ -n "${sha256_in}" ]
216223

217-
regctl artifact put \
224+
run regctl artifact put \
218225
--annotation description="used for demo purposes" \
219226
--annotation model_format_name="onnx" \
220227
--annotation model_format_version="1" \
221228
--artifact-type "application/vnd.model.type" \
222-
"localhost:$(get_zot_port)/models/my-model-from-gh:v1" \
229+
"localhost:${zot_port}/models/my-model-from-gh:v1" \
223230
-f "${BATS_FILE_TMPDIR}/mnist.onnx"
231+
[ "${status}" -eq 0 ]
224232

225-
regctl artifact list "localhost:$(get_zot_port)/models/my-model-from-gh:v1" \
233+
run regctl artifact list "localhost:${zot_port}/models/my-model-from-gh:v1" \
226234
--format '{{jsonPretty .}}'
227-
regctl artifact list --filter-artifact-type "application/vnd.model.type" \
228-
"localhost:$(get_zot_port)/models/my-model-from-gh:v1" \
235+
[ "${status}" -eq 0 ]
236+
237+
run regctl artifact list --filter-artifact-type "application/vnd.model.type" \
238+
"localhost:${zot_port}/models/my-model-from-gh:v1" \
229239
--format '{{jsonPretty .}}'
240+
[ "${status}" -eq 0 ]
230241

231-
regctl artifact get "localhost:$(get_zot_port)/models/my-model-from-gh:v1" \
232-
>"${BATS_FILE_TMPDIR}/mnist.onnx.check"
233-
sha256_out=$(sha256sum "${BATS_FILE_TMPDIR}/mnist.onnx.check" | awk '{print $1}')
242+
run bash -c "regctl artifact get 'localhost:${zot_port}/models/my-model-from-gh:v1' >'${BATS_FILE_TMPDIR}/mnist.onnx.check'"
243+
[ "${status}" -eq 0 ]
244+
245+
run sha256sum "${BATS_FILE_TMPDIR}/mnist.onnx.check"
246+
[ "${status}" -eq 0 ]
247+
sha256_out=$(echo "${output}" | awk '{print $1}')
248+
[ -n "${sha256_out}" ]
234249
[ "${sha256_in}" = "${sha256_out}" ]
235250
}
236251

0 commit comments

Comments
 (0)