Add nightly test case of push docker manifest list

1. Add notary tool in E2E Dockerfile;
2. Add push docker manifest list test in nightly;
3. Modify document for e2e user guide;
4. Add CNAB tool  in E2E Dockerfile;

Signed-off-by: danfengliu <danfengl@vmware.com>
This commit is contained in:
danfengliu 2020-03-30 17:44:56 +08:00
parent ceded08507
commit 8f9822d168
11 changed files with 822 additions and 688 deletions

View File

@ -20,12 +20,12 @@ Before scripting, please make sure swagger client has been made by "make swagger
We use $HARBORCLIENT_PATH represent the path of "harborclient" you've made by "make swagger_client". We use $HARBORCLIENT_PATH represent the path of "harborclient" you've made by "make swagger_client".
Deploy Harbor instance for testing, and we will use $HARBOR_URL to represent the deployed Harbor in this document. Deploy Harbor instance for testing, and we will use $HARBOR_IP_ADDR to represent the deployed Harbor in this document.
Harbor E2E API test scripts will import python library under archive "harborclient", please set OS environment variant for Harbor E2E API test scripts: Harbor E2E API test scripts will import python library under archive "harborclient", please set OS environment variant for Harbor E2E API test scripts:
1. `export HARBOR_HOST=$HARBOR_URL` 1. `export HARBOR_HOST=$HARBOR_IP_ADDR`
2. `export SWAGGER_CLIENT_PATH=$HARBORCLIENT_PATH` 2. `export SWAGGER_CLIENT_PATH=$HARBORCLIENT_PATH`
Until now, we have all preparation work done. Until now, we have all preparation work done.

View File

@ -85,6 +85,10 @@ RUN wget https://get.helm.sh/helm-v3.0.0-linux-386.tar.gz && tar zxvf helm-v3.0.
mv linux-386/helm /usr/local/bin/helm3 && \ mv linux-386/helm /usr/local/bin/helm3 && \
helm3 plugin install https://github.com/chartmuseum/helm-push helm3 plugin install https://github.com/chartmuseum/helm-push
RUN wget https://github.com/theupdateframework/notary/releases/download/v0.6.1/notary-Linux-amd64 && \
chmod +x notary-Linux-amd64 && \
mv notary-Linux-amd64 /usr/local/bin/notary
RUN wget http://nchc.dl.sourceforge.net/sourceforge/tcl/tcl8.4.11-src.tar.gz && \ RUN wget http://nchc.dl.sourceforge.net/sourceforge/tcl/tcl8.4.11-src.tar.gz && \
tar xfvz tcl8.4.11-src.tar.gz && \ tar xfvz tcl8.4.11-src.tar.gz && \
cd tcl8.4.11/unix && \ cd tcl8.4.11/unix && \
@ -105,6 +109,12 @@ RUN wget http://nchc.dl.sourceforge.net/sourceforge/tcl/tcl8.4.11-src.tar.gz &&
cd /ixdba.net/bin && \ cd /ixdba.net/bin && \
mv expect /usr/local/bin/expect mv expect /usr/local/bin/expect
RUN CNAB_PATH=$(go env GOPATH)/src/github.com/docker && mkdir -p $CNAB_PATH && cd $CNAB_PATH && git clone https://github.com/cnabio/cnab-to-oci.git && \
cd cnab-to-oci && git checkout v0.3.0-beta4 && \
go list && \
make build && \
mv bin/cnab-to-oci /usr/local/bin
# Add docker in docker support # Add docker in docker support
# version: docker:1.13-dind # version: docker:1.13-dind
# reference: https://github.com/docker-library/docker/blob/b202ec7e529f5426e2ad7e8c0a8b82cacd406573/1.13/dind/Dockerfile # reference: https://github.com/docker-library/docker/blob/b202ec7e529f5426e2ad7e8c0a8b82cacd406573/1.13/dind/Dockerfile

View File

@ -0,0 +1,25 @@
# Copyright Project Harbor Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License
*** Settings ***
Documentation This resource provides helper functions for docker operations
Library OperatingSystem
Library Process
*** Keywords ***
CNAB Push Bundle
[Arguments] ${ip} ${user} ${pwd} ${target} ${bundle_file}
${rc} ${output}= Run And Return Rc And Output ./tests/robot-cases/Group0-Util/cnab_push_bundle.sh ${ip} ${user} ${pwd} ${target} ${bundle_file}
Log ${output}
Should Be Equal As Integers ${rc} 0

View File

@ -107,6 +107,9 @@ Get Container IP
# If you are running this keyword in a container, make sure it is run with --privileged turned on # If you are running this keyword in a container, make sure it is run with --privileged turned on
Start Docker Daemon Locally Start Docker Daemon Locally
${pid}= Run pidof dockerd ${pid}= Run pidof dockerd
#${rc} ${output}= Run And Return Rc And Output ./tests/robot-cases/Group0-Util/docker_config.sh
#Log ${output}
#Should Be Equal As Integers ${rc} 0
Return From Keyword If '${pid}' != '${EMPTY}' Return From Keyword If '${pid}' != '${EMPTY}'
OperatingSystem.File Should Exist /usr/local/bin/dockerd-entrypoint.sh OperatingSystem.File Should Exist /usr/local/bin/dockerd-entrypoint.sh
${handle}= Start Process /usr/local/bin/dockerd-entrypoint.sh dockerd>./daemon-local.log 2>&1 shell=True ${handle}= Start Process /usr/local/bin/dockerd-entrypoint.sh dockerd>./daemon-local.log 2>&1 shell=True
@ -122,6 +125,8 @@ Prepare Docker Cert
[Arguments] ${ip} [Arguments] ${ip}
Wait Unitl Command Success mkdir -p /etc/docker/certs.d/${ip} Wait Unitl Command Success mkdir -p /etc/docker/certs.d/${ip}
Wait Unitl Command Success cp harbor_ca.crt /etc/docker/certs.d/${ip} Wait Unitl Command Success cp harbor_ca.crt /etc/docker/certs.d/${ip}
Wait Unitl Command Success cp harbor_ca.crt /usr/local/share/ca-certificates/
Wait Unitl Command Success update-ca-certificates
Kill Local Docker Daemon Kill Local Docker Daemon
[Arguments] ${handle} ${dockerd-pid} [Arguments] ${handle} ${dockerd-pid}
@ -154,3 +159,9 @@ Docker Tag
Docker Push Docker Push
[Arguments] ${image} [Arguments] ${image}
Wait Unitl Command Success docker push ${image} Wait Unitl Command Success docker push ${image}
Docker Push Index
[Arguments] ${ip} ${user} ${pwd} ${index} ${image1} ${image2}
${rc} ${output}= Run And Return Rc And Output ./tests/robot-cases/Group0-Util/docker_push_manifest_list.sh ${ip} ${user} ${pwd} ${index} ${image1} ${image2}
Log ${output}
Should Be Equal As Integers ${rc} 0

View File

@ -19,4 +19,6 @@ Documentation This resource provides any keywords related to the Harbor private
${artifact_action_xpath} //clr-dg-action-bar/clr-dropdown/span[contains(@class,'dropdown-toggle')] ${artifact_action_xpath} //clr-dg-action-bar/clr-dropdown/span[contains(@class,'dropdown-toggle')]
${artifact_action_delete_xpath} //clr-dropdown-menu//div[contains(.,'Delete')] ${artifact_action_delete_xpath} //clr-dropdown-menu//div[contains(.,'Delete')]
${artifact_action_copy_xpath} //clr-dropdown-menu//div[contains(.,'Copy') and @aria-label='retag'] ${artifact_action_copy_xpath} //clr-dropdown-menu//div[contains(.,'Copy') and @aria-label='retag']
${artifact_achieve_icon} //artifact-list-tab//clr-datagrid//clr-dg-row[contains(.,'sha256')]//clr-dg-cell[1]//clr-tooltip//clr-icon
${artifact_rows} //artifact-list-tab//clr-datagrid//clr-dg-row[contains(.,'sha256')]

View File

@ -210,6 +210,9 @@ Go Into Repo
Retry Wait Element ${tag_table_column_size} Retry Wait Element ${tag_table_column_size}
Capture Page Screenshot gointo_${repoName}.png Capture Page Screenshot gointo_${repoName}.png
Go Into Index
Retry Wait Element ${artifact_achieve_icon}
Switch To CardView Switch To CardView
Retry Element Click xpath=//hbr-repository-gridview//span[@class='card-btn']/clr-icon Retry Element Click xpath=//hbr-repository-gridview//span[@class='card-btn']/clr-icon
Sleep 5 Sleep 5

View File

@ -69,6 +69,7 @@ Resource Harbor-Pages/OIDC_Auth.robot
Resource Harbor-Pages/OIDC_Auth_Elements.robot Resource Harbor-Pages/OIDC_Auth_Elements.robot
Resource Harbor-Pages/Verify.robot Resource Harbor-Pages/Verify.robot
Resource Docker-Util.robot Resource Docker-Util.robot
Resource CNAB_Util.robot
Resource Helm-Util.robot Resource Helm-Util.robot
Resource OVA-Util.robot Resource OVA-Util.robot
Resource Cert-Util.robot Resource Cert-Util.robot

View File

@ -0,0 +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"}

View File

@ -0,0 +1,12 @@
#!/bin/bash
IP=$1
USER=$2
PWD=$3
TARGET=$4
BUNDLE_FILE=$5
echo $IP
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

View File

@ -0,0 +1,22 @@
#!/bin/bash
IP=$1
USER=$2
PWD=$3
INDEX=$4
IMAGE1=$5
IMAGE2=$6
echo $IP
docker login $IP -u $USER -p $PWD
cat /$HOME/.docker/config.json
sed -i '$d' /$HOME/.docker/config.json
sed -i '$d' /$HOME/.docker/config.json
echo -e "\n },\n \"experimental\": \"enabled\"\n}" >> /$HOME/.docker/config.json
cat /$HOME/.docker/config.json
docker manifest create $INDEX $IMAGE1 $IMAGE2
docker manifest push $INDEX

View File

@ -683,4 +683,51 @@ Test Case - Can Not Copy Image In ReadOnly Mode
Disable Read Only Disable Read Only
Close Browser Close Browser
Test Case - Push Docker Manifest Index and Display
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
${image_a}= Set Variable hello-world
${image_b}= Set Variable busybox
${image_a_ver}= Set Variable latest
${image_b_ver}= Set Variable latest
Sign In Harbor ${HARBOR_URL} user010 Test1@34
Create An New Project test${d}
Push image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} test${d} ${image_a}:${image_a_ver}
Go Into Project test${d}
Wait Until Page Contains test${d}/${image_a}
Push image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} test${d} ${image_b}:${image_b_ver}
Go Into Project test${d}
Wait Until Page Contains test${d}/${image_b}
Docker Push Index ${ip} user010 Test1@34 ${ip}/test${d}/index${d}:index_tag${d} ${ip}/test${d}/${image_a}:${image_a_ver} ${ip}/test${d}/${image_b}:${image_b_ver}
Go Into Project test${d}
Wait Until Page Contains test${d}/index${d}
Go Into Repo test${d}/index${d}
Wait Until Page Contains index_tag${d}
Go Into Project test${d}
Wait Until Page Contains test${d}/index${d}
Go Into Repo test${d}/index${d}
Go Into Index
Page Should Contain Element ${artifact_rows} limit=2
Test Case - Push CNAB Bundle and Display
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
Sign In Harbor ${HARBOR_URL} user010 Test1@34
Create An New Project test${d}
${target}= Set Variable ${ip}/test${d}/cnab${d}:cnab_tag${d}
CNAB Push Bundle ${ip} user010 Test1@34 ${target} ./tests/robot-cases/Group0-Util/bundle.json
Go Into Project test${d}
Wait Until Page Contains test${d}/cnab${d}
Go Into Repo test${d}/cnab${d}
Wait Until Page Contains cnab_tag${d}