Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Login using OCP token for e2e tests #675

Merged
merged 3 commits into from
Feb 12, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .ci/cico_updates_openshift.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ runTests() {
waitWorkspaceStart
}

init
initDefaults
initOpenShiftDefaults
provisionOpenShiftOAuthUser
initStableTemplates "openshift" "stable"
runTests
3 changes: 2 additions & 1 deletion .ci/oci-nightly-olm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ runTests() {
waitWorkspaceStart
}

init
initDefaults
initOpenShiftDefaults
overrideDefaults
provisionOpenShiftOAuthUser
patchEclipseCheOperatorSubscription
Expand Down
3 changes: 2 additions & 1 deletion .ci/oci-single-host.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ runTests() {
waitWorkspaceStart
}

init
initDefaults
initOpenShiftDefaults
overrideDefaults
provisionOpenShiftOAuthUser
patchEclipseCheOperatorSubscription
Expand Down
32 changes: 23 additions & 9 deletions .github/bin/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,35 @@ catchFinish() {
exit $result
}

init() {
initDefaults() {
export RAM_MEMORY=8192
export NAMESPACE="eclipse-che"
export ARTIFACTS_DIR="/tmp/artifacts-che"
export TEMPLATES=${OPERATOR_REPO}/tmp
export OPERATOR_IMAGE="quay.io/eclipse/che-operator:test"
export DEFAULT_DEVFILE="https://raw.githubusercontent.com/eclipse/che-devfile-registry/master/devfiles/quarkus/devfile.yaml"
export CHE_EXPOSURE_STRATEGY="multi-host"
export OAUTH="true"

export XDG_DATA_HOME=/tmp/xdg_data
export XDG_CACHE_HOME=/tmp/xdg_cache
export XDG_CONFIG_HOME=/tmp/xdg_config

export OAUTH="false"

# turn off telemetry
mkdir -p ${XDG_CONFIG_HOME}/chectl
echo "{\"segment.telemetry\":\"off\"}" > ${XDG_CONFIG_HOME}/chectl/config.json

export OPENSHIFT_NIGHTLY_CSV_FILE="${OPERATOR_REPO}/deploy/olm-catalog/eclipse-che-preview-openshift/manifests/che-operator.clusterserviceversion.yaml"

# prepare templates directory
rm -rf ${TEMPLATES}
mkdir -p "${TEMPLATES}/che-operator" && chmod 777 "${TEMPLATES}"
}

initOpenShiftDefaults() {
export OAUTH="true"
export OPENSHIFT_NIGHTLY_CSV_FILE="${OPERATOR_REPO}/deploy/olm-catalog/eclipse-che-preview-openshift/manifests/che-operator.clusterserviceversion.yaml"
}

initLatestTemplates() {
cp -rf ${OPERATOR_REPO}/deploy/* "${TEMPLATES}/che-operator"
}
Expand Down Expand Up @@ -90,11 +94,12 @@ initStableTemplates() {

# Utility to wait for a workspace to be started after workspace:create.
waitWorkspaceStart() {
login

set +e
export x=0
while [ $x -le 180 ]
do
chectl auth:login -u admin -p admin --chenamespace=${NAMESPACE}
chectl workspace:list --chenamespace=${NAMESPACE}
workspaceList=$(chectl workspace:list --chenamespace=${NAMESPACE})
workspaceStatus=$(echo "$workspaceList" | grep RUNNING | awk '{ print $4} ')
Expand Down Expand Up @@ -201,19 +206,19 @@ updateEclipseChe() {
startNewWorkspace() {
# Create and start a workspace
sleep 5s
chectl auth:login -u admin -p admin --chenamespace=${NAMESPACE}
login
chectl workspace:create --start --chenamespace=${NAMESPACE} --devfile="${DEFAULT_DEVFILE}"
}

createWorkspace() {
sleep 5s
chectl auth:login -u admin -p admin --chenamespace=${NAMESPACE}
login
chectl workspace:create --chenamespace=${NAMESPACE} --devfile="${DEFAULT_DEVFILE}"
}

startExistedWorkspace() {
sleep 5s
chectl auth:login -u admin -p admin --chenamespace=${NAMESPACE}
login
chectl workspace:list --chenamespace=${NAMESPACE}
workspaceList=$(chectl workspace:list --chenamespace=${NAMESPACE})

Expand Down Expand Up @@ -310,7 +315,7 @@ applyOlmCR() {

# Create admin user inside of openshift cluster and login
function provisionOpenShiftOAuthUser() {
oc create secret generic htpass-secret --from-file=htpasswd="${OPERATOR_REPO}"/.github/bin/resources/users.htpasswd -n openshift-config
oc create secret generic htpass-secret --from-file=htpasswd="${OPERATOR_REPO}"/.github/bin/resources/users.htpasswd -n openshift-config
oc apply -f "${OPERATOR_REPO}"/.github/bin/resources/htpasswdProvider.yaml
oc adm policy add-cluster-role-to-user cluster-admin user

Expand All @@ -324,3 +329,12 @@ function provisionOpenShiftOAuthUser() {
sleep 10
done
}

login() {
if [[ ${OAUTH} == "false" ]]; then
chectl auth:login -u admin -p admin --chenamespace=${NAMESPACE}
else
# log in using OpenShift token
chectl auth:login --chenamespace=${NAMESPACE}
fi
}
2 changes: 1 addition & 1 deletion .github/bin/minikube/test-olm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ runTest() {
waitWorkspaceStart
}

init
initDefaults
insecurePrivateDockerRegistry
runTest
2 changes: 1 addition & 1 deletion .github/bin/minikube/test-operator-singlehost-gateway.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ runTest() {
waitWorkspaceStart
}

init
initDefaults
initLatestTemplates
prepareTemplates
buildCheOperatorImage
Expand Down
2 changes: 1 addition & 1 deletion .github/bin/minikube/test-operator-singlehost-native.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ runTest() {
waitWorkspaceStart
}

init
initDefaults
initLatestTemplates
prepareTemplates
buildCheOperatorImage
Expand Down
2 changes: 1 addition & 1 deletion .github/bin/minikube/test-operator-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ runTest() {
waitWorkspaceStart
}

init
initDefaults
initLatestTemplates
initStableTemplates "kubernetes" "stable"
prepareTemplates
Expand Down
2 changes: 1 addition & 1 deletion .github/bin/minikube/test-stable-olm-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ runTest() {
waitWorkspaceStart
}

init
initDefaults
initStableTemplates "kubernetes" "stable"
runTest
2 changes: 1 addition & 1 deletion .github/bin/minishift/test-operator-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ runTest() {
waitWorkspaceStart
}

init
initDefaults
installYq
initLatestTemplates
initStableTemplates "openshift" "stable"
Expand Down
2 changes: 1 addition & 1 deletion .github/bin/minishift/test-operator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ runTest() {
waitWorkspaceStart
}

init
initDefaults
installYq
initLatestTemplates
prepareTemplates
Expand Down
2 changes: 1 addition & 1 deletion .github/bin/minishift/test-stable-operator-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ runTest() {
waitWorkspaceStart
}

init
initDefaults
installYq
initStableTemplates "openshift" "stable"
prepareTemplates
Expand Down