From b856a1f9e1afc7940248bf09f3f0de1db3c7c861 Mon Sep 17 00:00:00 2001 From: fabianofranz Date: Tue, 17 Mar 2015 17:44:09 -0300 Subject: [PATCH] Make test-end-to-end use osc login|project --- hack/test-end-to-end.sh | 53 +++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/hack/test-end-to-end.sh b/hack/test-end-to-end.sh index cd3811f5f5f2..eb78707d52ba 100755 --- a/hack/test-end-to-end.sh +++ b/hack/test-end-to-end.sh @@ -200,37 +200,35 @@ if [[ "${API_SCHEME}" == "https" ]]; then # Read client cert data in to send to containerized components sudo chmod -R a+rX "${CERT_DIR}/openshift-client/" - # Make osc use ${CERT_DIR}/admin/.kubeconfig, and ignore anything in the running user's $HOME dir + # Ignore anything in the running user's $HOME dir + # Commands that need to run as admin will use ADMIN_CONFIG_FILE, everything else will login as a normal user sudo chmod -R a+rwX "${CERT_DIR}/admin/" export HOME="${CERT_DIR}/admin" - export KUBECONFIG="${CERT_DIR}/admin/.kubeconfig" - echo "[INFO] To debug: export KUBECONFIG=$KUBECONFIG" + export ADMIN_CONFIG_FILE="${CERT_DIR}/admin/.kubeconfig" fi wait_for_url "${KUBELET_SCHEME}://${API_HOST}:${KUBELET_PORT}/healthz" "[INFO] kubelet: " 0.5 60 wait_for_url "${API_SCHEME}://${API_HOST}:${API_PORT}/healthz" "apiserver: " 0.25 80 wait_for_url "${API_SCHEME}://${API_HOST}:${API_PORT}/api/v1beta1/minions/127.0.0.1" "apiserver(minions): " 0.25 80 -# Set KUBERNETES_MASTER for osc -export KUBERNETES_MASTER="${API_SCHEME}://${API_HOST}:${API_PORT}" - # add e2e-user as a viewer for the default namespace so we can see infrastructure pieces appear openshift ex policy add-user view anypassword:e2e-user --namespace=default -# create test project so that this shows up in the console -openshift ex new-project test --description="This is an example project to demonstrate OpenShift v3" --admin="anypassword:e2e-user" +# create projects so that this shows up in the console and can be used in osc +openshift ex new-project test --description="This is an example project to demonstrate OpenShift v3" --admin="anypassword:e2e-user" --config="${ADMIN_CONFIG_FILE}" +openshift ex new-project docker --description="This is an example project to demonstrate OpenShift v3" --admin="anypassword:e2e-user" --config="${ADMIN_CONFIG_FILE}" +openshift ex new-project custom --description="This is an example project to demonstrate OpenShift v3" --admin="anypassword:e2e-user" --config="${ADMIN_CONFIG_FILE}" echo "The console should be available at ${API_SCHEME}://${PUBLIC_MASTER_HOST}:$(($API_PORT + 1)). You may need to visit ${API_SCHEME}://${PUBLIC_MASTER_HOST}:${API_PORT} first to accept the certificate." -echo "Log in as 'e2e-user' to see the 'test' project." # install the router echo "[INFO] Installing the router" -openshift ex router --create --credentials="${KUBECONFIG}" --images="${USE_IMAGES}" +OPENSHIFTCONFIG="${ADMIN_CONFIG_FILE}" openshift ex router --create --credentials="${ADMIN_CONFIG_FILE}" --images="${USE_IMAGES}" # install the registry. The --mount-host option is provided to reuse local storage. echo "[INFO] Installing the registry" # TODO: add --images="${USE_IMAGES}" when the Docker registry is built alongside OpenShift -openshift ex registry --create --credentials="${KUBECONFIG}" --mount-host="/tmp/openshift.local.registry" --images='openshift/origin-${component}:latest' +OPENSHIFTCONFIG="${ADMIN_CONFIG_FILE}" openshift ex registry --create --credentials="${ADMIN_CONFIG_FILE}" --mount-host="/tmp/openshift.local.registry" --images='openshift/origin-${component}:latest' echo "[INFO] Pre-pulling and pushing centos7" docker pull centos:centos7 @@ -240,10 +238,10 @@ echo "[INFO] Pulled centos7" echo "[INFO] Waiting for Docker registry pod to start" # TODO: simplify when #4702 is fixed upstream -wait_for_command '[[ "$(osc get endpoints docker-registry -t "{{ if .endpoints }}{{ len .endpoints }}{{ else }}0{{ end }}" || echo "0")" != "0" ]]' $((5*TIME_MIN)) +wait_for_command '[[ "$(osc get endpoints docker-registry -t "{{ if .endpoints }}{{ len .endpoints }}{{ else }}0{{ end }}" --config="${CERT_DIR}/admin/.kubeconfig" || echo "0")" != "0" ]]' $((5*TIME_MIN)) # services can end up on any IP. Make sure we get the IP we need for the docker registry -DOCKER_REGISTRY=$(osc get --output-version=v1beta1 --template="{{ .portalIP }}:{{ .port }}" service docker-registry) +DOCKER_REGISTRY=$(osc get --output-version=v1beta1 --template="{{ .portalIP }}:{{ .port }}" service docker-registry --config="${ADMIN_CONFIG_FILE}") echo "[INFO] Verifying the docker-registry is up at ${DOCKER_REGISTRY}" wait_for_url_timed "http://${DOCKER_REGISTRY}" "[INFO] Docker registry says: " $((2*TIME_MIN)) @@ -254,18 +252,31 @@ docker tag -f centos:centos7 ${DOCKER_REGISTRY}/cached/centos:centos7 docker push ${DOCKER_REGISTRY}/cached/centos:centos7 echo "[INFO] Pushed centos7" +# Client setup +echo "[INFO] Logging in as a regular user (e2e-user:pass) with project 'test' which will be used from now on..." +osc login -u e2e-user -p pass -n test --loglevel=4 --server="${API_SCHEME}://${API_HOST}:${API_PORT}" --insecure-skip-tls-verify + # Process template and create -echo "[INFO] Submitting application template json for processing..." -osc process -n test -f examples/sample-app/application-template-stibuild.json > "${STI_CONFIG_FILE}" -osc process -n docker -f examples/sample-app/application-template-dockerbuild.json > "${DOCKER_CONFIG_FILE}" -osc process -n custom -f examples/sample-app/application-template-custombuild.json > "${CUSTOM_CONFIG_FILE}" +echo "[INFO] Submitting application template json for processing (project 'test')..." +osc project test +osc process -f examples/sample-app/application-template-stibuild.json > "${STI_CONFIG_FILE}" +echo "[INFO] Submitting application template json for processing (project 'docker')..." +osc project docker +osc process -f examples/sample-app/application-template-dockerbuild.json > "${DOCKER_CONFIG_FILE}" +echo "[INFO] Submitting application template json for processing (project 'custom')..." +osc project custom +osc process -f examples/sample-app/application-template-custombuild.json > "${CUSTOM_CONFIG_FILE}" + +# Switching to the 'test' project which will be used from now on +echo "[INFO] Switching back to project 'test'..." +osc project test echo "[INFO] Applying STI application config" -osc create -n test -f "${STI_CONFIG_FILE}" +osc create -f "${STI_CONFIG_FILE}" # Trigger build echo "[INFO] Starting build from ${STI_CONFIG_FILE} and streaming its logs..." -osc start-build -n test ruby-sample-build --follow +osc start-build ruby-sample-build --follow wait_for_build "test" wait_for_app "test" @@ -285,7 +296,7 @@ wait_for_app "test" # ensure the router is started # TODO: simplify when #4702 is fixed upstream -wait_for_command '[[ "$(osc get endpoints router -t "{{ if .endpoints }}{{ len .endpoints }}{{ else }}0{{ end }}" || echo "0")" != "0" ]]' $((5*TIME_MIN)) +wait_for_command '[[ "$(osc get endpoints router -t "{{ if .endpoints }}{{ len .endpoints }}{{ else }}0{{ end }}" --config="${ADMIN_CONFIG_FILE}" || echo "0")" != "0" ]]' $((5*TIME_MIN)) echo "[INFO] Validating routed app response..." validate_response "-s -k --resolve www.example.com:443:${CONTAINER_ACCESSIBLE_API_HOST} https://www.example.com" "Hello from OpenShift" 0.2 50 @@ -296,4 +307,4 @@ if [[ "$TEST_ASSETS" == "true" ]]; then pushd ${OS_ROOT}/assets > /dev/null grunt test-e2e popd > /dev/null -fi +fi \ No newline at end of file