2018-09-19 18:57:15 +02:00
# Copyright Project Harbor Authors
2017-08-07 08:02:38 +02:00
#
# 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 any keywords related to the Harbor private registry appliance
Library Selenium2Library
Library OperatingSystem
*** Variables ***
*** Keywords ***
Install Harbor to Test Server
2017-10-30 07:55:03 +01:00
Log To Console \nStart Docker Daemon
Start Docker Daemon Locally
Sleep 5s
2017-08-07 08:02:38 +02:00
${rc} ${output}= Run And Return Rc And Output docker ps
Should Be Equal As Integers ${rc} 0
Log To Console \n${output}
Log To Console \nconfig harbor cfg
Config Harbor cfg http_proxy=https
2017-10-30 07:55:03 +01:00
Prepare Cert
2017-08-07 08:02:38 +02:00
Log To Console \ncomplile and up harbor now
2017-10-30 07:55:03 +01:00
Compile and Up Harbor With Source Code
2017-08-07 08:02:38 +02:00
${rc} ${output}= Run And Return Rc And Output docker ps
Should Be Equal As Integers ${rc} 0
Log To Console \n${output}
2017-10-30 07:55:03 +01:00
Generate Certificate Authority For Chrome
2017-08-07 08:02:38 +02:00
Up Harbor
2018-07-19 17:50:25 +02:00
[Arguments] ${with_notary}=true ${with_clair}=true ${with_chartmuseum}=true
${rc} ${output}= Run And Return Rc And Output make start -e NOTARYFLAG=${with_notary} CLAIRFLAG=${with_clair} CHARTFLAG=${with_chartmuseum}
2017-10-30 07:55:03 +01:00
Log ${rc}
Log ${output}
Should Be Equal As Integers ${rc} 0
2017-08-07 08:02:38 +02:00
Down Harbor
2018-07-19 17:50:25 +02:00
[Arguments] ${with_notary}=true ${with_clair}=true ${with_chartmuseum}=true
${rc} ${output}= Run And Return Rc And Output echo "Y" | make down -e NOTARYFLAG=${with_notary} CLAIRFLAG=${with_clair} CHARTFLAG=${with_chartmuseum}
2017-10-30 07:55:03 +01:00
Log ${rc}
2018-05-02 17:42:42 +02:00
Log ${output}
2017-10-30 07:55:03 +01:00
Should Be Equal As Integers ${rc} 0
2017-08-07 08:02:38 +02:00
Package Harbor Offline
2019-11-20 07:59:29 +01:00
[Arguments] ${with_notary}=true ${with_clair}=true ${with_migrator}=true ${with_chartmuseum}=true
2017-10-30 07:55:03 +01:00
Log To Console \nStart Docker Daemon
Start Docker Daemon Locally
2019-11-22 07:03:03 +01:00
Log To Console \n\nmake package_offline BASEIMAGETAG=%{Harbor_Build_Base_Tag} NPM_REGISTRY=%{NPM_REGISTRY} VERSIONTAG=%{Harbor_Assets_Version} PKGVERSIONTAG=%{Harbor_Package_Version} NOTARYFLAG=${with_notary} CLAIRFLAG=${with_clair} MIGRATORFLAG=${with_migrator} CHARTFLAG=${with_chartmuseum} HTTPPROXY=
2020-03-23 05:21:08 +01:00
${rc} ${output}= Run And Return Rc And Output make package_offline BASEIMAGETAG=%{Harbor_Build_Base_Tag} NPM_REGISTRY=%{NPM_REGISTRY} VERSIONTAG=%{Harbor_Assets_Version} PKGVERSIONTAG=%{Harbor_Package_Version} NOTARYFLAG=${with_notary} CLAIRFLAG=${with_clair} MIGRATORFLAG=${with_migrator} CHARTFLAG=${with_chartmuseum} HTTPPROXY=
2019-10-18 04:46:44 +02:00
Log To Console ${rc}
Log To Console ${output}
2017-10-30 07:55:03 +01:00
Should Be Equal As Integers ${rc} 0
2017-08-07 08:02:38 +02:00
2017-12-18 09:07:08 +01:00
Package Harbor Online
2019-06-18 08:57:14 +02:00
[Arguments] ${with_notary}=true ${with_clair}=true ${with_migrator}=false ${with_chartmuseum}=true
2017-12-18 09:07:08 +01:00
Log To Console \nStart Docker Daemon
Start Docker Daemon Locally
2019-11-19 10:01:28 +01:00
Log To Console \nmake package_online VERSIONTAG=%{Harbor_Assets_Version} PKGVERSIONTAG=%{Harbor_Package_Version} NOTARYFLAG=${with_notary} CLAIRFLAG=${with_clair} MIGRATORFLAG=${with_migrator} CHARTFLAG=${with_chartmuseum} HTTPPROXY=
2019-10-29 09:09:54 +01:00
${rc} ${output}= Run And Return Rc And Output make package_online VERSIONTAG=%{Harbor_Assets_Version} PKGVERSIONTAG=%{Harbor_Package_Version} NOTARYFLAG=${with_notary} CLAIRFLAG=${with_clair} MIGRATORFLAG=${with_migrator} CHARTFLAG=${with_chartmuseum} HTTPPROXY=
2017-12-18 09:07:08 +01:00
Log ${rc}
Log ${output}
Should Be Equal As Integers ${rc} 0
2019-03-20 04:28:57 +01:00
2017-08-07 08:02:38 +02:00
Switch To LDAP
2017-10-30 07:55:03 +01:00
Down Harbor
${rc} ${output}= Run And Return Rc And Output rm -rf /data
Log ${rc}
Should Be Equal As Integers ${rc} 0
Prepare Cert
Config Harbor cfg auth=ldap_auth http_proxy=https
Prepare
Up Harbor
2020-01-06 04:04:34 +01:00
Docker Pull osixia/openldap:1.1.7
2017-11-01 11:19:58 +01:00
${rc} ${output}= Run And Return Rc And Output cd tests && ./ldapprepare.sh
2017-08-07 08:02:38 +02:00
Log ${rc}
2017-11-01 11:19:58 +01:00
Log ${output}
2017-08-07 08:02:38 +02:00
Should Be Equal As Integers ${rc} 0
${rc} ${output}= Run And Return Rc And Output docker ps
2017-10-30 07:55:03 +01:00
Log ${output}
2019-03-20 04:28:57 +01:00
Should Be Equal As Integers ${rc} 0
2017-10-30 07:55:03 +01:00
Generate Certificate Authority For Chrome
2019-03-20 04:28:57 +01:00
2018-01-23 06:04:19 +01:00
Enable Notary Client
2017-10-30 07:55:03 +01:00
${rc} ${output}= Run And Return Rc And Output rm -rf ~/.docker/
2017-08-07 08:02:38 +02:00
Log ${rc}
2020-01-06 04:04:34 +01:00
${rc} ${output}= Run And Return Rc and Output curl -o /notary_ca.crt -s -k -X GET --header 'Accept: application/json' -u 'admin:Harbor12345' 'https://${ip}/api/systeminfo/getcert'
2017-10-30 07:55:03 +01:00
Log ${output}
Should Be Equal As Integers ${rc} 0
2017-08-07 08:02:38 +02:00
2019-12-18 03:42:20 +01:00
Remove Notary Signature
[Arguments] ${ip} ${image}
2020-01-06 04:04:34 +01:00
${rc} ${output}= Run And Return Rc And Output ./tests/robot-cases/Group0-Util/notary-remove-image-signature.expect ${ip} library ${image} ${notaryServerEndpoint}
2019-12-18 03:42:20 +01:00
Log To Console ${output}
Log ${output}
Should Be Equal As Integers ${rc} 0
2017-08-07 08:02:38 +02:00
Prepare
2018-07-19 17:50:25 +02:00
[Arguments] ${with_notary}=true ${with_clair}=true ${with_chartmuseum}=true
${rc} ${output}= Run And Return Rc And Output make prepare -e NOTARYFLAG=${with_notary} CLAIRFLAG=${with_clair} CHARTFLAG=${with_chartmuseum}
2017-10-30 07:55:03 +01:00
Log ${rc}
Log ${output}
Should Be Equal As Integers ${rc} 0
2017-08-07 08:02:38 +02:00
Config Harbor cfg
# Will change the IP and Protocol in the harbor.cfg
[Arguments] ${http_proxy}=http ${auth}=db_auth
${rc} ${output}= Run And Return Rc And Output ip addr s eth0 |grep "inet "|awk '{print $2}' |awk -F "/" '{print $1}'
2017-10-30 07:55:03 +01:00
${rc}= Run And Return Rc sed "s/^hostname = .*/hostname = ${output}/g" -i ./make/harbor.cfg
2017-08-07 08:02:38 +02:00
Log ${rc}
Should Be Equal As Integers ${rc} 0
${rc}= Run And Return Rc sed "s/^ui_url_protocol = .*/ui_url_protocol = ${http_proxy}/g" -i ./make/harbor.cfg
Log ${rc}
Should Be Equal As Integers ${rc} 0
2017-10-30 07:55:03 +01:00
${rc}= Run And Return Rc sed "s/^auth_mode = .*/auth_mode = ${auth}/g" -i ./make/harbor.cfg
2017-08-07 08:02:38 +02:00
Log ${rc}
Should Be Equal As Integers ${rc} 0
2017-10-30 07:55:03 +01:00
${out}= Run cat ./make/harbor.cfg
2019-03-20 04:28:57 +01:00
Log ${out}
2017-08-07 08:02:38 +02:00
Prepare Cert
# Will change the IP and Protocol in the harbor.cfg
2017-10-30 07:55:03 +01:00
${rc} ${ip}= Run And Return Rc And Output ip addr s eth0 |grep "inet "|awk '{print $2}' |awk -F "/" '{print $1}'
Log ${ip}
${rc}= Run And Return Rc sed "s/^IP=.*/IP=${ip}/g" -i ./tests/generateCerts.sh
Log ${rc}
${out}= Run cat ./tests/generateCerts.sh
2019-03-20 04:28:57 +01:00
Log ${out}
2017-10-30 07:55:03 +01:00
${rc} ${output}= Run And Return Rc And Output ./tests/generateCerts.sh
Should Be Equal As Integers ${rc} 0
2017-08-07 08:02:38 +02:00
Compile and Up Harbor With Source Code
2019-06-21 08:19:28 +02:00
[Arguments] ${with_notary}=true ${with_clair}=true ${with_chartmuseum}=true
${rc} ${output}= Run And Return Rc And Output make install swagger_client NOTARYFLAG=${with_notary} CLAIRFLAG=${with_clair} CHARTFLAG=${with_chartmuseum} HTTPPROXY=
2017-10-30 07:55:03 +01:00
Log ${output}
Should Be Equal As Integers ${rc} 0
2017-08-07 08:02:38 +02:00
Sleep 20
2019-03-20 04:28:57 +01:00
2017-11-03 11:34:51 +01:00
Wait for Harbor Ready
[Arguments] ${protocol} ${HARBOR_IP}
Log To Console Waiting for Harbor to Come Up...
:FOR ${i} IN RANGE 20
\ ${out}= Run curl -k ${protocol}://${HARBOR_IP}
\ Log ${out}
\ ${status}= Run Keyword And Return Status Should Not Contain ${out} 502 Bad Gateway
\ ${status}= Run Keyword If ${status} Run Keyword And Return Status Should Not Contain ${out} Connection refused
\ ${status}= Run Keyword If ${status} Run Keyword And Return Status Should Contain ${out} <title>Harbor</title>
\ Return From Keyword If ${status} ${HARBOR_IP}
\ Sleep 30s
Fail Harbor failed to come up properly!
2018-06-01 08:38:10 +02:00
Get Harbor Version
${rc} ${output}= Run And Return Rc And Output curl -k -X GET --header 'Accept: application/json' 'https://${ip}/api/systeminfo'|grep -i harbor_version
Log To Console ${output}