Skip to content

Commit

Permalink
Login using OCP token for e2e tests (#675)
Browse files Browse the repository at this point in the history
* Login using OCP token for e2e tests

Signed-off-by: Anatolii Bazko <abazko@redhat.com>

* Use different operator image name

Signed-off-by: Anatolii Bazko <abazko@redhat.com>

* Fix operator image name

Signed-off-by: Anatolii Bazko <abazko@redhat.com>
  • Loading branch information
tolusha committed Feb 12, 2021
1 parent c2f4c75 commit 5430780
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 23 deletions.
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
34 changes: 24 additions & 10 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 OPERATOR_IMAGE="test/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
2 changes: 1 addition & 1 deletion .github/workflows/minishift-operator-update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- uses: actions/checkout@v1
- name: Build Che operator image
run: |
export OPERATOR_IMAGE=quay.io/eclipse/che-operator:test
export OPERATOR_IMAGE=test/che-operator:test
# coreutils provides a readlink that supports `-f`
brew install coreutils docker docker-machine
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/minishift-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
# All docker operations should be done in this step
- name: Build Che operator image
run: |
export OPERATOR_IMAGE=quay.io/eclipse/che-operator:test
export OPERATOR_IMAGE=test/che-operator:test
# coreutils provides a readlink that supports `-f`
brew install coreutils docker docker-machine
Expand Down

0 comments on commit 5430780

Please sign in to comment.