mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-22 18:25:56 +01:00
Refactor cnab push test case
Signed-off-by: Yang Jiao <jiaoya@vmware.com>
This commit is contained in:
parent
d260e632d8
commit
97ad26af6f
@ -19,8 +19,31 @@ Library Process
|
||||
|
||||
*** Keywords ***
|
||||
CNAB Push Bundle
|
||||
[Arguments] ${ip} ${user} ${pwd} ${target} ${bundle_file} ${docker_user} ${docker_pwd}
|
||||
${rc} ${output}= Run And Return Rc And Output ./tests/robot-cases/Group0-Util/cnab_push_bundle.sh ${ip} ${user} ${pwd} ${target} ${bundle_file} ${docker_user} ${docker_pwd}
|
||||
[Arguments] ${ip} ${user} ${pwd} ${target} ${bundle_file} ${registry} ${namespace} ${index1} ${index2}
|
||||
${rc} ${output}= Run And Return Rc And Output ./tests/robot-cases/Group0-Util/cnab_push_bundle.sh ${ip} ${user} ${pwd} ${target} ${bundle_file} ${registry} ${namespace} ${index1} ${index2}
|
||||
Log To Console ${output}
|
||||
Log ${output}
|
||||
Should Be Equal As Integers ${rc} 0
|
||||
|
||||
Prepare Cnab Push Test Data
|
||||
[Arguments] ${ip} ${user} ${pwd} ${project} ${index1_image1} ${index1_image2} ${index2_image1} ${index2_image2} ${image_tag}=latest
|
||||
${index1} = Set Variable index1
|
||||
${index2} = Set Variable index2
|
||||
${index1_tag} = Set Variable latest
|
||||
${index2_tag} = Set Variable latest
|
||||
Push image ${ip} ${user} ${pwd} ${project} ${index1_image1}
|
||||
Push image ${ip} ${user} ${pwd} ${project} ${index1_image2}
|
||||
Push image ${ip} ${user} ${pwd} ${project} ${index2_image1}
|
||||
Push image ${ip} ${user} ${pwd} ${project} ${index2_image2}
|
||||
Go Into Project ${project}
|
||||
Wait Until Page Contains ${project}/${index1_image1}
|
||||
Wait Until Page Contains ${project}/${index1_image2}
|
||||
Wait Until Page Contains ${project}/${index2_image1}
|
||||
Wait Until Page Contains ${project}/${index2_image2}
|
||||
|
||||
Docker Push Index ${ip} ${user} ${pwd} ${ip}/${project}/${index1}:${index1_tag} ${ip}/${project}/${index1_image1}:${image_tag} ${ip}/${project}/${index1_image2}:${image_tag}
|
||||
Docker Push Index ${ip} ${user} ${pwd} ${ip}/${project}/${index2}:${index2_tag} ${ip}/${project}/${index2_image1}:${image_tag} ${ip}/${project}/${index2_image2}:${image_tag}
|
||||
Go Into Project ${project}
|
||||
Wait Until Page Contains ${index1}
|
||||
Wait Until Page Contains ${index2}
|
||||
[Return] ${index1}:${index1_tag} ${index2}:${index2_tag}
|
||||
|
@ -1 +1 @@
|
||||
{"actions":{"io.cnab.status":{}},"definitions":{"port":{"default":"8080","type":"string"},"text":{"default":"Hello, World!","type":"string"}},"description":"Hello, World!","images":{"hello":{"contentDigest":"sha256:61d5cb94d7e546518a7bbd5bee06bfad0ecea8f56a75b084522a43dccbbcd845","description":"hello","image":"redis","imageType":"docker","mediaType":"application/vnd.docker.distribution.manifest.v2+json","size":528}},"invocationImages":[{"contentDigest":"sha256:61d5cb94d7e546518a7bbd5bee06bfad0ecea8f56a75b084522a43dccbbcd845","image":"busybox","imageType":"docker","mediaType":"application/vnd.docker.distribution.manifest.v2+json","size":941}],"maintainers":[{"email":"user@email.com","name":"user"}],"name":"hello-world","parameters":{"fields":{"definition":"","destination":null}},"schemaVersion":"v1.0.0","version":"0.1.0"}
|
||||
{"actions":{"io.cnab.status":{}},"definitions":{"port":{"default":"8080","type":"string"},"text":{"default":"Hello, World!","type":"string"}},"description":"Hello, World!","images":{"hello":{"description":"hello","image":"registry/namespace/image1","imageType":"docker","mediaType":"application/vnd.docker.distribution.manifest.v2+json","size":528}},"invocationImages":[{"image":"registry/namespace/image2","imageType":"docker","mediaType":"application/vnd.docker.distribution.manifest.v2+json","size":941}],"maintainers":[{"email":"user@email.com","name":"user"}],"name":"hello-world","parameters":{"fields":{"definition":"","destination":null}},"schemaVersion":"v1.0.0","version":"0.1.0"}
|
@ -6,20 +6,16 @@ USER=$2
|
||||
PWD=$3
|
||||
TARGET=$4
|
||||
BUNDLE_FILE=$5
|
||||
DOCKER_USER=$6
|
||||
DOCKER_PWD=$7
|
||||
echo $DOCKER_USER
|
||||
echo $IP
|
||||
REGISTRY=$6
|
||||
NAMESPACE=$7
|
||||
IMAGE1=$8
|
||||
IMAGE2=$9
|
||||
|
||||
TOKEN=$(curl --user "$DOCKER_USER:$DOCKER_PWD" "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token)
|
||||
curl -v -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest 2>&1 | grep RateLimit
|
||||
sed -i "s/registry/$REGISTRY/g" "$BUNDLE_FILE"
|
||||
sed -i "s/namespace/$NAMESPACE/g" "$BUNDLE_FILE"
|
||||
sed -i "s/image1/$IMAGE1/g" "$BUNDLE_FILE"
|
||||
sed -i "s/image2/$IMAGE2/g" "$BUNDLE_FILE"
|
||||
|
||||
docker login -u $DOCKER_USER -p $DOCKER_PWD
|
||||
docker login $IP -u $USER -p $PWD
|
||||
|
||||
cnab-to-oci fixup $BUNDLE_FILE --target $TARGET --bundle fixup_bundle.json --auto-update-bundle
|
||||
|
||||
TOKEN=$(curl --user "$DOCKER_USER:$DOCKER_PWD" "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token)
|
||||
curl -v -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest 2>&1 | grep RateLimit
|
||||
|
||||
cnab-to-oci push fixup_bundle.json --target $TARGET --auto-update-bundle
|
||||
docker login "$IP" -u "$USER" -p "$PWD"
|
||||
cnab-to-oci fixup "$BUNDLE_FILE" --target "$TARGET" --bundle fixup_bundle.json --auto-update-bundle
|
||||
cnab-to-oci push fixup_bundle.json --target "$TARGET" --auto-update-bundle
|
@ -77,12 +77,17 @@ Test Case - Push CNAB Bundle and Display
|
||||
[Tags] push_cnab
|
||||
Init Chrome Driver
|
||||
${d}= Get Current Date result_format=%m%s
|
||||
|
||||
Sign In Harbor ${HARBOR_URL} user010 Test1@34
|
||||
${index1_image1}= Set Variable busybox
|
||||
${index1_image2}= Set Variable alpine
|
||||
${index2_image1}= Set Variable hello-world
|
||||
${index2_image2}= Set Variable redis
|
||||
${user}= Set Variable user010
|
||||
${pwd}= Set Variable Test1@34
|
||||
Sign In Harbor ${HARBOR_URL} ${user} ${pwd}
|
||||
Create An New Project And Go Into Project test${d}
|
||||
|
||||
${index1} ${index2}= Prepare Cnab Push Test Data ${ip} ${user} ${pwd} test${d} ${index1_image1} ${index1_image2} ${index2_image1} ${index2_image2}
|
||||
${target}= Set Variable ${ip}/test${d}/cnab${d}:cnab_tag${d}
|
||||
Retry Keyword N Times When Error 5 CNAB Push Bundle ${ip} user010 Test1@34 ${target} ./tests/robot-cases/Group0-Util/bundle.json ${DOCKER_USER} ${DOCKER_PWD}
|
||||
Retry Keyword N Times When Error 5 CNAB Push Bundle ${ip} ${user} ${pwd} ${target} ./tests/robot-cases/Group0-Util/bundle.json ${ip} test${d} ${index1} ${index2}
|
||||
|
||||
Go Into Project test${d}
|
||||
Wait Until Page Contains test${d}/cnab${d}
|
||||
|
Loading…
Reference in New Issue
Block a user