@@ -117,7 +117,7 @@ os::cmd::expect_success 'oc status -n default'
117
117
118
118
# check to make sure a project admin can push an image to an image stream that doesn't exist
119
119
os::cmd::expect_success ' oc project cache'
120
- e2e_user_token=$( oc whoami -t)
120
+ e2e_user_token=" $( oc whoami -t) "
121
121
122
122
echo " [INFO] Docker login as e2e-user to ${DOCKER_REGISTRY} "
123
123
os::cmd::expect_success
" docker login -u e2e-user -p ${e2e_user_token} -e [email protected] ${DOCKER_REGISTRY} "
@@ -129,10 +129,10 @@ os::cmd::expect_success "docker push ${DOCKER_REGISTRY}/cache/ruby-22-centos7:la
129
129
echo " [INFO] Pushed ruby-22-centos7"
130
130
131
131
# get image's digest
132
- rubyimagedigest=$( oc get -o jsonpath=' {.status.tags[?(@.tag=="latest")].items[0].image}' is/ruby-22-centos7)
132
+ rubyimagedigest=" $( oc get -o jsonpath=' {.status.tags[?(@.tag=="latest")].items[0].image}' is/ruby-22-centos7) "
133
133
echo " [INFO] Ruby image digest: $rubyimagedigest "
134
134
# get a random, non-empty blob
135
- rubyimageblob=$( oc get isimage -o go-template=' {{range .image.dockerImageLayers}}{{if gt .size 1024.}}{{.name}},{{end}}{{end}}' ruby-22-centos7@${rubyimagedigest} | cut -d , -f 1)
135
+ rubyimageblob=" $( oc get isimage -o go-template=' {{range .image.dockerImageLayers}}{{if gt .size 1024.}}{{.name}},{{end}}{{end}}' ruby-22-centos7@${rubyimagedigest} | cut -d , -f 1) "
136
136
echo " [INFO] Ruby's testing blob digest: $rubyimageblob "
137
137
138
138
# verify remote images can be pulled directly from the local registry
@@ -170,7 +170,7 @@ echo "[INFO] Cross namespace pull successful"
170
170
171
171
# verify we can pull from tagged image (using image digest)
172
172
remove_docker_images " ${DOCKER_REGISTRY} /custom/cross" namespace-pull
173
- imagedigest=$( oc get istag hello-world:latest --template={{.image.metadata.name}})
173
+ imagedigest=" $( oc get istag hello-world:latest --template=' {{.image.metadata.name}}' ) "
174
174
echo " [INFO] Tagging hello-world@${imagedigest} to the same image stream and pulling it"
175
175
os::cmd::expect_success " oc tag hello-world@${imagedigest} hello-world:new-id-tag"
176
176
os::cmd::expect_success " docker pull ${DOCKER_REGISTRY} /cache/hello-world:new-id-tag"
@@ -197,26 +197,26 @@ echo "[INFO] Cross namespace pull successful"
197
197
os::cmd::expect_success ' oc login -u schema2-user -p pass'
198
198
os::cmd::expect_success " oc new-project schema2"
199
199
os::cmd::expect_success " oc project schema2"
200
- schema2_user_token=$( oc whoami -t)
200
+ schema2_user_token=" $( oc whoami -t) "
201
201
202
202
echo " [INFO] Fetch manifest V2 schema 2 image with old client using pullthrough"
203
203
os::cmd::expect_success " oc import-image --confirm --from=hello-world:latest hello-world:pullthrough"
204
204
os::cmd::expect_success_and_text " oc get -o jsonpath='{.image.dockerImageManifestMediaType}' istag hello-world:pullthrough" ' application/vnd\.docker\.distribution\.manifest\.v2\+json'
205
- hello_world_name=$( oc get -o ' jsonpath={.image.metadata.name}' istag hello-world:pullthrough)
206
- os::cmd::expect_success_and_text " echo ${hello_world_name:- } " ' .+'
205
+ hello_world_name=" $( oc get -o ' jsonpath={.image.metadata.name}' istag hello-world:pullthrough) "
206
+ os::cmd::expect_success_and_text " echo ' ${hello_world_name} ' " ' .+'
207
207
# dockerImageManifest is retrievable only with "images" resource
208
- hello_world_config_name=$( oc get -o ' jsonpath={.dockerImageManifest}' image " $hello_world_name " --context=" $CLUSTER_ADMIN_CONTEXT " | jq -r ' .config.digest' )
209
- hello_world_config_image=$( oc get -o ' jsonpath={.image.dockerImageConfig}' istag hello-world:pullthrough | jq -r ' .container_config.Image' )
210
- os::cmd::expect_success_and_text " echo ${hello_world_config_name:- } ,${hello_world_config_image:- } " ' .+,.+'
208
+ hello_world_config_name=" $( oc get -o ' jsonpath={.dockerImageManifest}' image " ${ hello_world_name} " --context=" ${ CLUSTER_ADMIN_CONTEXT} " | jq -r ' .config.digest' ) "
209
+ hello_world_config_image=" $( oc get -o ' jsonpath={.image.dockerImageConfig}' istag hello-world:pullthrough | jq -r ' .container_config.Image' ) "
210
+ os::cmd::expect_success_and_text " echo ' ${hello_world_config_name} ,${hello_world_config_image} ' " ' .+,.+'
211
211
# verify we can fetch the config
212
- os::cmd::expect_success_and_text " curl -u 'schema2-user:${schema2_user_token} ' -v -s -o ${ARTIFACT_DIR} /hello-world-config.json ${DOCKER_REGISTRY} /v2/schema2/hello-world/blobs/${hello_world_config_name} 2>&1" " Docker-Content-Digest:\s*${hello_world_config_name} "
213
- os::cmd::expect_success_and_text " jq -r '.container_config.Image' ${ARTIFACT_DIR} /hello-world-config.json" " ${hello_world_config_image} "
212
+ os::cmd::expect_success_and_text " curl -u 'schema2-user:${schema2_user_token} ' -v -s -o ' ${ARTIFACT_DIR} /hello-world-config.json' ' ${DOCKER_REGISTRY} /v2/schema2/hello-world/blobs/${hello_world_config_name} ' 2>&1" " Docker-Content-Digest:\s*${hello_world_config_name} "
213
+ os::cmd::expect_success_and_text " jq -r '.container_config.Image' ' ${ARTIFACT_DIR} /hello-world-config.json' " " ${hello_world_config_image} "
214
214
# no accept header provided, the registry will convert schema 2 to schema 1 on-the-fly
215
- hello_world_schema1_digest=$( curl -u schema2-user:${schema2_user_token} -s -v -o ${ARTIFACT_DIR} /hello-world-manifest.json ${DOCKER_REGISTRY} /v2/schema2/hello-world/manifests/pullthrough | & sed -n ' s/.*Docker-Content-Digest:\s*\(\S\+\).*/\1/p' )
215
+ hello_world_schema1_digest=" $( curl -u " schema2-user:${schema2_user_token} " -s -v -o " ${ARTIFACT_DIR} /hello-world-manifest.json" " ${DOCKER_REGISTRY} /v2/schema2/hello-world/manifests/pullthrough" | & sed -n ' s/.*Docker-Content-Digest:\s*\(\S\+\).*/\1/p' ) "
216
216
# ensure the manifest was converted to schema 1
217
217
os::cmd::expect_success_and_text " jq -r '.schemaVersion' ${ARTIFACT_DIR} /hello-world-manifest.json" ' ^1$'
218
- os::cmd::expect_success_and_not_text " echo '${hello_world_schema1_digest:- } '" " ${hello_world_name:- } "
219
- os::cmd::expect_success_and_text " echo '${hello_world_schema1_digest:- } '" " .+"
218
+ os::cmd::expect_success_and_not_text " echo '${hello_world_schema1_digest} '" " ${hello_world_name} "
219
+ os::cmd::expect_success_and_text " echo '${hello_world_schema1_digest} '" " .+"
220
220
os::cmd::expect_success_and_text " curl -I -u 'schema2-user:${schema2_user_token} ' '${DOCKER_REGISTRY} /v2/schema2/hello-world/manifests/${hello_world_schema1_digest} '" " 404 Not Found"
221
221
echo " [INFO] Manifest V2 schema 2 image fetched successfully with old client"
222
222
@@ -227,7 +227,7 @@ os::cmd::expect_success_and_text 'oc whoami' 'system:admin'
227
227
# check to make sure an image-pusher can push an image
228
228
os::cmd::expect_success ' oc policy add-role-to-user system:image-pusher -n cache pusher'
229
229
os::cmd::expect_success ' oc login -u pusher -p pass'
230
- pusher_token=$( oc whoami -t)
230
+ pusher_token=" $( oc whoami -t) "
231
231
232
232
echo " [INFO] Docker login as pusher to ${DOCKER_REGISTRY} "
233
233
os::cmd::expect_success
" docker login -u e2e-user -p ${pusher_token} -e [email protected] ${DOCKER_REGISTRY} "
@@ -249,9 +249,9 @@ os::cmd::try_until_text 'oc policy who-can get imagestreams/layers -n custom' 's
249
249
os::cmd::expect_success " docker pull ${DOCKER_REGISTRY} /custom/cross:namespace-pull"
250
250
os::cmd::expect_success " docker pull ${DOCKER_REGISTRY} /custom/cross:namespace-pull-id"
251
251
# unauthorized pushes return authorization errors, regardless of backing data
252
- os::cmd::expect_failure_and_text " docker push ${DOCKER_REGISTRY} /missing/image:tag" " authentication required|not authorized "
253
- os::cmd::expect_failure_and_text " docker push ${DOCKER_REGISTRY} /custom/cross:namespace-pull" " authentication required|not authorized "
254
- os::cmd::expect_failure_and_text " docker push ${DOCKER_REGISTRY} /custom/cross:namespace-pull-id" " authentication required|not authorized "
252
+ os::cmd::expect_failure_and_text " docker push ' ${DOCKER_REGISTRY} /missing/image:tag' " " authentication required"
253
+ os::cmd::expect_failure_and_text " docker push ' ${DOCKER_REGISTRY} /custom/cross:namespace-pull' " " authentication required"
254
+ os::cmd::expect_failure_and_text " docker push ' ${DOCKER_REGISTRY} /custom/cross:namespace-pull-id' " " authentication required"
255
255
# test anonymous pushes
256
256
os::cmd::expect_success ' oc policy add-role-to-user system:image-pusher system:anonymous -n custom'
257
257
os::cmd::try_until_text ' oc policy who-can update imagestreams/layers -n custom' ' system:anonymous'
@@ -510,8 +510,9 @@ os::cmd::expect_success "oc exec -p ${registry_pod} du /registry > '${LOG_DIR}/p
510
510
os::cmd::expect_code " diff ${LOG_DIR} /prune-images.before.txt ${LOG_DIR} /prune-images.after.txt" 1
511
511
echo " [INFO] Validated image pruning"
512
512
513
+ # with registry's re-deployment we loose all the blobs stored in its storage until now
513
514
echo " [INFO] Configure registry to accept manifest V2 schema 2"
514
- os::cmd::expect_success " oc project ${CLUSTER_ADMIN_CONTEXT} "
515
+ os::cmd::expect_success " oc project ' ${CLUSTER_ADMIN_CONTEXT} ' "
515
516
os::cmd::expect_success ' oc env -n default dc/docker-registry REGISTRY_MIDDLEWARE_REPOSITORY_OPENSHIFT_ACCEPTSCHEMA2=true'
516
517
wait_for_registry
517
518
echo " [INFO] Registry configured to accept manifest V2 schema 2"
@@ -521,7 +522,7 @@ os::cmd::expect_success "oc login -u schema2-user -p pass"
521
522
os::cmd::expect_success " oc project schema2"
522
523
# tagging remote docker.io/busybox image
523
524
os::cmd::expect_success " docker tag busybox '${DOCKER_REGISTRY} /schema2/busybox'"
524
- os::cmd::expect_success
" docker login -u e2e-user -p ${schema2_user_token} -e [email protected] ${DOCKER_REGISTRY} "
525
+ os::cmd::expect_success
" docker login -u e2e-user -p ' ${schema2_user_token} ' -e [email protected] ' ${DOCKER_REGISTRY} ' "
525
526
os::cmd::expect_success " docker push '${DOCKER_REGISTRY} /schema2/busybox'"
526
527
# image accepted as schema 2
527
528
os::cmd::expect_success_and_text " oc get -o jsonpath='{.image.dockerImageManifestMediaType}' istag busybox:latest" ' application/vnd\.docker\.distribution\.manifest\.v2\+json'
@@ -531,24 +532,24 @@ echo "[INFO] Convert manifest V2 schema 2 to schema 1 for older client"
531
532
os::cmd::expect_success ' oc login -u schema2-user -p pass'
532
533
os::cmd::expect_success " oc new-project schema2tagged"
533
534
os::cmd::expect_success " oc tag --source=istag schema2/busybox:latest busybox:latest"
534
- busybox_name=$( oc get -o ' jsonpath={.image.metadata.name}' istag busybox:latest)
535
- os::cmd::expect_success_and_text " echo ${busybox_name:- } " ' .+'
535
+ busybox_name=" $( oc get -o ' jsonpath={.image.metadata.name}' istag busybox:latest) "
536
+ os::cmd::expect_success_and_text " echo ' ${busybox_name} ' " ' .+'
536
537
# no accept header provided, registry converts on-the-fly to schema 1
537
- busybox_schema1_digest=$( curl -u " schema2-user:${schema2_user_token} " -s -v -o ${ARTIFACT_DIR} /busybox-manifest.json ${DOCKER_REGISTRY} /v2/schema2tagged/busybox/manifests/latest | & sed -n ' s/.*Docker-Content-Digest:\s*\(\S\+\).*/\1/p' )
538
+ busybox_schema1_digest=" $( curl -u " schema2-user:${schema2_user_token} " -s -v -o " ${ARTIFACT_DIR} /busybox-manifest.json" " ${DOCKER_REGISTRY} /v2/schema2tagged/busybox/manifests/latest" | & sed -n ' s/.*Docker-Content-Digest:\s*\(\S\+\).*/\1/p' ) "
538
539
# ensure the manifest was converted to schema 1
539
- os::cmd::expect_success_and_text " jq -r '.schemaVersion' ${ARTIFACT_DIR} /busybox-manifest.json" ' ^1$'
540
- os::cmd::expect_success_and_not_text " echo '${busybox_schema1_digest:- } '" " ${busybox_name:- } "
541
- os::cmd::expect_success_and_text " echo '${busybox_schema1_digest:- } '" " .+"
540
+ os::cmd::expect_success_and_text " jq -r '.schemaVersion' ' ${ARTIFACT_DIR} /busybox-manifest.json' " ' ^1$'
541
+ os::cmd::expect_success_and_not_text " echo '${busybox_schema1_digest} '" " ${busybox_name} "
542
+ os::cmd::expect_success_and_text " echo '${busybox_schema1_digest} '" " .+"
542
543
# schema 1 is generated on-the-fly, it's not stored in the registry, thus Not Found
543
544
os::cmd::expect_success_and_text " curl -I -u 'schema2-user:${schema2_user_token} ' '${DOCKER_REGISTRY} /v2/schema2tagged/busybox/manifests/${busybox_schema1_digest} '" " 404 Not Found"
544
545
# ensure we can fetch it back as schema 2
545
- os::cmd::expect_success_and_text " curl -I -u 'schema2-user:${schema2_user_token} ' -H 'Accept: application/vnd.docker.distribution.manifest.v2+json' ${DOCKER_REGISTRY} /v2/schema2tagged/busybox/manifests/latest" " Docker-Content-Digest:\s*${busybox_name} "
546
+ os::cmd::expect_success_and_text " curl -I -u 'schema2-user:${schema2_user_token} ' -H 'Accept: application/vnd.docker.distribution.manifest.v2+json' ' ${DOCKER_REGISTRY} /v2/schema2tagged/busybox/manifests/latest' " " Docker-Content-Digest:\s*${busybox_name} "
546
547
echo " [INFO] Manifest V2 schema 2 successfully converted to schema 1"
547
548
548
549
echo " [INFO] Verify image size calculation"
549
- busybox_expected_size=$( oc get -o jsonpath=' {.dockerImageManifest}' image ${busybox_name} --context=" ${CLUSTER_ADMIN_CONTEXT} " | jq -r ' [.. | .size?] | add' )
550
- busybox_calculated_size=$( oc get -o go-template=' {{.dockerImageMetadata.Size}}' image ${busybox_name} --context=" ${CLUSTER_ADMIN_CONTEXT} " )
551
- os::cmd::expect_success_and_text " echo ${busybox_expected_size:- } :${busybox_calculated_size:- } " ' ^[1-9][0-9]*:[1-9][0-9]*$'
550
+ busybox_expected_size=" $( oc get -o ' jsonpath={.dockerImageManifest}' image " ${busybox_name} " --context=" ${CLUSTER_ADMIN_CONTEXT} " | jq -r ' [.. | .size?] | add' ) "
551
+ busybox_calculated_size=" $( oc get -o go-template=' {{.dockerImageMetadata.Size}}' image " ${busybox_name} " --context=" ${CLUSTER_ADMIN_CONTEXT} " ) "
552
+ os::cmd::expect_success_and_text " echo ' ${busybox_expected_size} :${busybox_calculated_size} ' " ' ^[1-9][0-9]*:[1-9][0-9]*$'
552
553
os::cmd::expect_success_and_text " echo '${busybox_expected_size} '" " ${busybox_calculated_size} "
553
554
echo " [INFO] Image size matches"
554
555
0 commit comments