CI support for IBM Z (#3529)

This commit is contained in:
Zheng Xiao Mei
2020-07-24 16:19:53 +08:00
committed by GitHub
parent 000b051597
commit 4b6498c386
4 changed files with 226 additions and 9 deletions

View File

@@ -138,6 +138,11 @@ prepare-release: cross
configure-installer-tests-cluster:
. ./scripts/configure-installer-tests-cluster.sh
# configure cluster to run tests on s390x arch
.PHONY: configure-installer-tests-cluster-s390x
configure-installer-tests-cluster-s390x:
. ./scripts/configure-installer-tests-cluster-s390x.sh
.PHONY: test
test:

View File

@@ -0,0 +1,18 @@
= test-architecture-s390x
For all tests on s390x arch, the openshift cluster version is 4.3 or newer.
The prerequisites, please refer to default https://github.com/openshift/odo/blob/master/docs/dev/test-architecture.adoc[test-architecture]!
== Running integration and e2e tests locally
Odo CI for s390x is running locally now.The scripts/configure-installer-tests-cluster-s390x.sh is available in the https://github.com/openshift/odo/tree/master/scripts[odo] repository to help configure the test environment and the scripts/openshiftci-presubmit-all-tests.sh is available in the https://github.com/openshift/odo/tree/master/scripts[odo] repository to run integration and e2e tests covered on s390x arch.
For running all covered integration and e2e tests on 4.x cluster, you can run:
----
./scripts/openshiftci-presubmit-all-tests.sh
----
Similarly for running specific test on 4.x cluster, you can run:
----
./scripts/configure-installer-tests-cluster-s390x.sh
make test-xxx-xxx
----

View File

@@ -0,0 +1,168 @@
#!/bin/bash
set -x
# Setup to find nessasary data from cluster setup
## Constants
HTPASSWD_FILE="./htpass"
USERPASS="developer"
HTPASSWD_SECRET="htpasswd-secret"
#SETUP_OPERATORS="./scripts/setup-operators.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"}
# Default values
OC_STABLE_LOGIN="false"
#CI_OPERATOR_HUB_PROJECT="ci-operator-hub-project"
# Exported to current env
export KUBECONFIG=${KUBECONFIG:-"${DEFAULT_INSTALLER_ASSETS_DIR}/auth/kubeconfig"}
# List of users to create
USERS="developer odonoprojectattemptscreate odosingleprojectattemptscreate odologinnoproject odologinsingleproject1"
# 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
# Remove existing htpasswd file, if any
if [ -f $HTPASSWD_FILE ]; then
rm -rf $HTPASSWD_FILE
fi
# Set so first time -c parameter gets applied to htpasswd
HTPASSWD_CREATED=" -c "
# Create htpasswd entries for all listed users
for i in `echo $USERS`; do
htpasswd -b $HTPASSWD_CREATED $HTPASSWD_FILE $i $USERPASS
HTPASSWD_CREATED=""
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
oc import-image nodejs --from=registry.redhat.io/rhscl/nodejs-12-rhel7 --confirm -n openshift
sleep 5
oc annotate istag/nodejs:latest tags=builder -n openshift --overwrite
oc import-image java:8 --namespace=openshift --from=registry.redhat.io/redhat-openjdk-18/openjdk18-openshift --confirm
sleep 5
oc annotate istag/java:8 --namespace=openshift tags=builder --overwrite
oc apply -n openshift -f https://raw.githubusercontent.com/openshift/library/master/arch/s390x/official/ruby/imagestreams/ruby-rhel7.json
sleep 5
oc annotate istag/ruby:latest --namespace=openshift tags=builder --overwrite
oc import-image wildfly --confirm \--from docker.io/clefos/wildfly-120-centos7:latest --insecure -n openshift
sleep 5
oc annotate istag/wildfly:latest --namespace=openshift tags=builder --overwrite
oc apply -n openshift -f https://raw.githubusercontent.com/openshift/library/master/arch/s390x/official/nginx/imagestreams/nginx-rhel7.json
sleep 5
oc annotate istag/nginx:latest --namespace=openshift tags=builder --overwrite
oc apply -n openshift -f https://raw.githubusercontent.com/openshift/library/master/community/dotnet/imagestreams/dotnet-centos7.json
sleep 5
oc annotate istag/dotnet:latest --namespace=openshift tags=builder --overwrite
oc apply -n openshift -f https://raw.githubusercontent.com/openshift/library/master/arch/s390x/official/php/imagestreams/php-rhel7.json
sleep 5
oc annotate istag/php:latest --namespace=openshift tags=builder --overwrite
oc apply -n openshift -f https://raw.githubusercontent.com/openshift/library/master/arch/s390x/official/python/imagestreams/python-rhel7.json
sleep 5
oc annotate istag/python:latest --namespace=openshift tags=builder --overwrite
# Create secret in cluster, removing if it already exists
oc get secret $HTPASSWD_SECRET -n openshift-config &> /dev/null
if [ $? -eq 0 ]; then
oc delete secret $HTPASSWD_SECRET -n openshift-config &> /dev/null
fi
oc create secret generic ${HTPASSWD_SECRET} --from-file=htpasswd=${HTPASSWD_FILE} -n openshift-config
# Upload htpasswd as new login config
oc apply -f - <<EOF
apiVersion: config.openshift.io/v1
kind: OAuth
metadata:
name: cluster
spec:
identityProviders:
- name: htpassidp1
challenge: true
login: true
mappingMethod: claim
type: HTPasswd
htpasswd:
fileData:
name: ${HTPASSWD_SECRET}
EOF
# Login as developer and check for stable server
for i in {1..40}; do
# Try logging in as developer
#oc login -u developer -p $USERPASS &> /dev/null
KUBEADMIN_PASSWORD=`cat $KUBEADMIN_PASSWORD_FILE`
oc login -u $KUBEADMIN_USER -p $KUBEADMIN_PASSWORD &> /dev/null
if [ $? -eq 0 ]; then
# If login succeeds, assume success
OC_STABLE_LOGIN="true"
# Attempt failure of `oc whoami`
for j in {1..25}; do
oc whoami &> /dev/null
if [ $? -ne 0 ]; then
# If `oc whoami` fails, assume fail and break out of trying `oc whoami`
OC_STABLE_LOGIN="false"
break
fi
sleep 2
done
# If `oc whoami` never failed, break out trying to login again
if [ $OC_STABLE_LOGIN == "true" ]; then
break
fi
fi
sleep 3
done
if [ $OC_STABLE_LOGIN == "false" ]; then
echo "Failed to login as developer"
exit 1
fi
# Setup project
oc new-project myproject
sleep 4
oc version
oc get secret pull-secret -n openshift-config -o yaml --export | oc create -f -
# KUBECONFIG cleanup only if CI is set
if [ ! -f $CI ]; then
rm -rf $KUBECONFIG
export KUBECONFIG=$ORIGINAL_KUBECONFIG
fi

View File

@@ -5,8 +5,13 @@ set -e
# show commands
set -x
ARCH=$(uname -m)
export CI="openshift"
make configure-installer-tests-cluster
if [ "${ARCH}" == "s390x" ]; then
make configure-installer-tests-cluster-s390x
else
make configure-installer-tests-cluster
fi
make bin
mkdir -p $GOPATH/bin
go get -u github.com/onsi/ginkgo/ginkgo
@@ -27,14 +32,35 @@ odo login -u developer -p developer
# Check login user name for debugging purpose
oc whoami
# Integration tests
make test-integration
make test-integration-devfile
make test-cmd-login-logout
make test-cmd-project
make test-operator-hub
# import the odo-init-image for s390x arch
if [ "${ARCH}" == "s390x" ]; then
export ODO_BOOTSTRAPPER_IMAGE=registry.redhat.io/ocp-tools-4/odo-init-container-rhel8:1.1.4
fi
# E2e tests
make test-e2e-all
if [ "${ARCH}" == "s390x" ]; then
# Integration tests
make test-generic
make test-cmd-link-unlink
make test-cmd-pref-config
make test-cmd-watch
make test-cmd-debug
make test-cmd-login-logout
make test-cmd-project
make test-cmd-app
make test-cmd-storage
make test-cmd-push
make test-cmd-watch
# E2e tests
make test-e2e-beta
else
# Integration tests
make test-integration
make test-integration-devfile
make test-cmd-login-logout
make test-cmd-project
make test-operator-hub
# E2e tests
make test-e2e-all
fi
odo logout