Files
odo/scripts/configure-installer-tests-cluster.sh
Mohammed Ahmed c941d6932d Splitting configure-installer-test-cluster into a library. (#4194)
* Spliting configure-installer-test-cluster into a library.

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Fixing password for developer and libdir

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Some fixes

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Fixing periodic tests developer pass

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Changing way script gets it current dir

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Renameing function and doing a set -e

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Fixup for usage where caller script is called with `.`

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Updating remaining scripts to use same auth lib

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Moving htpass up one level

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Adding some echos

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Setting +e for login

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Removing exit on error for parts of the script, where it should not matter

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>
2020-11-24 20:33:23 +01:00

80 lines
2.7 KiB
Bash
Executable File

#!/bin/bash
set -x
# Setup to find nessasary data from cluster setup
## Constants
LIBDIR="./scripts/configure-cluster"
LIBCOMMON="$LIBDIR/common"
SETUP_OPERATORS="$LIBCOMMON/setup-operators.sh"
AUTH_SCRIPT="$LIBCOMMON/auth.sh"
# Overrideable information
DEFAULT_INSTALLER_ASSETS_DIR=${DEFAULT_INSTALLER_ASSETS_DIR:-$(pwd)}
KUBEADMIN_USER=${KUBEADMIN_USER:-"kubeadmin"}
KUBEADMIN_PASSWORD_FILE=${KUBEADMIN_PASSWORD_FILE:-"${DEFAULT_INSTALLER_ASSETS_DIR}/auth/kubeadmin-password"}
CI_OPERATOR_HUB_PROJECT="ci-operator-hub-project"
# Exported to current env
ORIGINAL_KUBECONFIG=${KUBECONFIG:-"${DEFAULT_INSTALLER_ASSETS_DIR}/auth/kubeconfig"}
export KUBECONFIG=$ORIGINAL_KUBECONFIG
# list of namespace to create
IMAGE_TEST_NAMESPACES="openjdk-11-rhel8 nodejs-12-rhel7 nodejs-12"
# Attempt resolution of kubeadmin, only if a CI is not set
if [ -z $CI ]; then
# Check if nessasary files exist
if [ ! -f $KUBEADMIN_PASSWORD_FILE ]; then
echo "Could not find kubeadmin password file"
exit 1
fi
if [ ! -f $KUBECONFIG ]; then
echo "Could not find kubeconfig file"
exit 1
fi
# Get kubeadmin password from file
KUBEADMIN_PASSWORD=`cat $KUBEADMIN_PASSWORD_FILE`
# Login as admin user
oc login -u $KUBEADMIN_USER -p $KUBEADMIN_PASSWORD
else
# Copy kubeconfig to temporary kubeconfig file
# Read and Write permission to temporary kubeconfig file
TMP_DIR=$(mktemp -d)
cp $KUBECONFIG $TMP_DIR/kubeconfig
chmod 640 $TMP_DIR/kubeconfig
export KUBECONFIG=$TMP_DIR/kubeconfig
fi
# Setup the cluster for Operator tests
# Create a new namesapce which will be used for OperatorHub checks
oc new-project $CI_OPERATOR_HUB_PROJECT
# Let developer user have access to the project
oc adm policy add-role-to-user edit developer
sh $SETUP_OPERATORS
# OperatorHub setup complete
# Create the namespace for e2e image test apply pull secret to the namespace
for i in `echo $IMAGE_TEST_NAMESPACES`; do
# create the namespace
oc new-project $i
# Applying pull secret to the namespace which will be used for pulling images from authenticated registry
oc get secret pull-secret -n openshift-config -o yaml | sed "s/openshift-config/$i/g" | oc apply -f -
# Let developer user have access to the project
oc adm policy add-role-to-user edit developer
done
# Workarounds - Note we should find better soulutions asap
# Missing wildfly in OpenShift Adding it manually to cluster Please remove once wildfly is again visible
oc apply -n openshift -f https://raw.githubusercontent.com/openshift/library/master/arch/x86_64/community/wildfly/imagestreams/wildfly-centos7.json
sh $AUTH_SCRIPT
# KUBECONFIG cleanup only if CI is set
if [ ! -f $CI ]; then
rm -rf $KUBECONFIG
export KUBECONFIG=$ORIGINAL_KUBECONFIG
fi