Merge pull request #525 from sclorg/use_internal_openshift_registry
Use internal openshift registry
This commit is contained in:
parent
aa1ec203ed
commit
3e1d82ec39
12 changed files with 471 additions and 242 deletions
|
|
@ -5,9 +5,8 @@ source "$(dirname "${BASH_SOURCE[0]}")"/test-lib.sh
|
|||
|
||||
# Set of functions for testing docker images in OpenShift using 'oc' command
|
||||
|
||||
# A variable containing the overall test result; must be changed to 0 in the end
|
||||
# of the testing script:
|
||||
# OS_TESTSUITE_RESULT=0
|
||||
# A variable containing the overall test result
|
||||
# TESTSUITE_RESULT=0
|
||||
# And the following trap must be set, in the beginning of the test script:
|
||||
# trap ct_os_cleanup EXIT SIGINT
|
||||
|
||||
|
|
@ -32,13 +31,6 @@ function ct_os_set_path_oc_4() {
|
|||
return 1
|
||||
fi
|
||||
export PATH="${oc_path}:${PATH}"
|
||||
oc version
|
||||
if ! oc version | grep -q "Client Version: ${oc_version}." ; then
|
||||
echo "ERROR: something went wrong, oc located at ${oc_path}, but oc of version ${oc_version} not found in PATH ($PATH)" >&1
|
||||
return 1
|
||||
else
|
||||
echo "PATH set correctly, binary oc found in version ${oc_version}: $(command -v oc)"
|
||||
fi
|
||||
}
|
||||
|
||||
# ct_os_prepare_ocp4
|
||||
|
|
@ -55,10 +47,15 @@ function ct_os_set_ocp4() {
|
|||
OS_OC_CLIENT_VERSION=${OS_OC_CLIENT_VERSION:-4.4}
|
||||
ct_os_set_path_oc_4 "${OS_OC_CLIENT_VERSION}"
|
||||
|
||||
oc version
|
||||
|
||||
login=$(cat "$KUBEPASSWORD")
|
||||
oc login -u kubeadmin -p "$login"
|
||||
oc version
|
||||
if ! oc version | grep -q "Client Version: ${OS_OC_CLIENT_VERSION}." ; then
|
||||
echo "ERROR: something went wrong, oc located at ${oc_path}, but oc of version ${OS_OC_CLIENT_VERSION} not found in PATH ($PATH)" >&1
|
||||
return 1
|
||||
else
|
||||
echo "PATH set correctly, binary oc found in version ${OS_OC_CLIENT_VERSION}: $(command -v oc)"
|
||||
fi
|
||||
echo "Login to OpenShift ${OS_OC_CLIENT_VERSION} is DONE"
|
||||
# let openshift cluster to sync to avoid some race condition errors
|
||||
sleep 3
|
||||
|
|
@ -80,37 +77,28 @@ function ct_os_upload_image_external_registry() {
|
|||
}
|
||||
|
||||
|
||||
function ct_os_login_external_registry() {
|
||||
local docker_token
|
||||
# docker login fails with "404 page not found" error sometimes, just try it more times
|
||||
# shellcheck disable=SC2034
|
||||
echo "loging"
|
||||
[ -z "${INTERNAL_DOCKER_REGISTRY:-}" ] && "INTERNAL_DOCKER_REGISTRY has to be set for working with Internal registry" && return 1
|
||||
# shellcheck disable=SC2034
|
||||
for i in $(seq 12) ; do
|
||||
# shellcheck disable=SC2015
|
||||
docker_token=$(cat "$DOCKER_UPSHIFT_TOKEN")
|
||||
# shellcheck disable=SC2015
|
||||
docker login -u rhscl-ci-testing -p "$docker_token" "${INTERNAL_DOCKER_REGISTRY}" && return 0 || :
|
||||
sleep 5
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
function ct_os_import_image_ocp4() {
|
||||
local image_name="${1}"; shift
|
||||
local imagestream=${1:-$image_name:latest}
|
||||
local namespace
|
||||
|
||||
namespace=${CT_NAMESPACE:-"$(oc project -q)"}
|
||||
deploy_image_name="${INTERNAL_DOCKER_REGISTRY}/rhscl-ci-testing/${imagestream}"
|
||||
echo "Uploading image ${image_name} as ${deploy_image_name} , ${imagestream} into external registry."
|
||||
ct_os_upload_image_external_registry "${image_name}" "${imagestream}"
|
||||
if [ "${CT_TAG_IMAGE:-false}" == 'true' ]; then
|
||||
echo "Tag ${deploy_image_name} to ${namespace}/${imagestream}"
|
||||
oc tag --source=docker "${deploy_image_name}" "${namespace}/${imagestream}" --insecure=true --reference-policy=local
|
||||
else
|
||||
echo "Import image into OpenShift 4 environment ${namespace}/${imagestream} from ${deploy_image_name}"
|
||||
oc import-image "${namespace}/${imagestream}" --from="${deploy_image_name}" --confirm --reference-policy=local
|
||||
fi
|
||||
echo "Uploading image ${image_name} as ${imagestream} into OpenShift internal registry."
|
||||
ct_os_upload_image_v4 "${image_name}" "${imagestream}"
|
||||
|
||||
}
|
||||
|
||||
# ct_os_check_login
|
||||
# ---------------
|
||||
# function checks if the login to openshift was successful
|
||||
# if successful returns 0
|
||||
# if not, write error message, sets test result to 1
|
||||
# and exits with non-zero
|
||||
# Uses: $TESTSUITE_RESULT - overall result of all tests
|
||||
function ct_os_check_login() {
|
||||
oc status || {
|
||||
echo "-------------------------------------------"
|
||||
echo "It looks like oc is not properly logged in."
|
||||
# shellcheck disable=SC2034
|
||||
TESTSUITE_RESULT=1
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue