Skip to content

Commit

Permalink
[issue 21] - Enabling WildFly Helm Charts based provisioning test, fi…
Browse files Browse the repository at this point in the history
…xing the CI script to create users (master user is cluster-admin as well, because of failures in InfinispanOperatorProvisionerTest

Removing project creation that is handled by the ProjectCreator XTF extension
  • Loading branch information
fabiobrz committed May 18, 2023
1 parent 9d97b7d commit bd8d16e
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 38 deletions.
78 changes: 57 additions & 21 deletions .ci/openshift-ci/build-root/e2e-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#!/usr/bin/env bash
# exit immediately when a command fails
set -e
# only exit with zero if all commands of the pipeline exit successfully
set -o pipefail
# avoid exiting with non-zero if any of the pipeline commands fail because we need retries for oc login
#set -o pipefail
# error on unset variables
set -u
# print each command before executing it
Expand All @@ -16,33 +16,69 @@ printenv KUBEADMIN_PASSWORD_FILE
oc get node
oc config view

# For some reason the creation of a cluster admin and a user authentication mechanism does not allow for immediate
# login, even though the oc commands don't report any error.
# This doesn't let us get a token, and XTF won't take the xtf.openshift.admin.kubeconfig and
# xtf.openshift.master.kubeconfig properties into account when the token is not present.
# Eventually this turns out to be the condition that prevents the oc binary commands to succeed, because they would
# use a tmp oc.config file which is not found on the build cluster filesystem.
# This is why we login with kubeadmin, get a token and use its full set of credentials (username, password and token)
# both for xtf.openshift.admin.* and xtf.openshift.master.* properties
export TEST_CLUSTER_URL=$(oc whoami --show-server)

export SYSADMIN_USERNAME=kubeadmin
export SYSADMIN_PASSWORD=$(cat "${KUBEADMIN_PASSWORD_FILE}")
export TEST_CLUSTER_URL=$(oc whoami --show-server)
oc login "${TEST_CLUSTER_URL}" -u "${SYSADMIN_USERNAME}" -p "${SYSADMIN_PASSWORD}" --insecure-skip-tls-verify=true
export SYSADMIN_TOKEN=$(oc whoami -t)

# note that for some reason it takes a few minutes for this to be loaded by OCP and authentication start working
export TEST_ADMIN_USERNAME=tadmin
export TEST_ADMIN_PASSWORD=adminpwd
export TEST_USER_USERNAME=tuser
export TEST_USER_PASSWORD=userpwd
export HTPASSWD_FILE=users.htpasswd

htpasswd -c -B -b $HTPASSWD_FILE $TEST_ADMIN_USERNAME $TEST_ADMIN_PASSWORD
htpasswd -b $HTPASSWD_FILE $TEST_USER_USERNAME $TEST_USER_PASSWORD

cat $HTPASSWD_FILE

oc create secret generic htpass-secret --from-file=htpasswd=$HTPASSWD_FILE -n openshift-config
oc patch OAuth cluster -p '{"spec": {"identityProviders": [{"htpasswd": {"fileData": {"name": "htpass-secret"}},"mappingMethod": "claim","name": "my_htpasswd_provider","type": "HTPasswd"}]}}' --type=merge

# wait until authentication operator updates auth
sleep 45 # wait until operator notices changes
counter=0
while [ "$(oc get clusteroperator authentication -o custom-columns=STATUS:.status.conditions[1].status | tail -1)" == "True" ]; do
sleep 5
echo Waiting for authentication operator to finish processing
((counter=counter+1))
if [ "$counter" == "200" ]; then
echo "Timeout waiting for authentication operator."
exit 1
fi
done

counter=0
until [[ "$(oc login --insecure-skip-tls-verify ${TEST_CLUSTER_URL} -u ${TEST_ADMIN_USERNAME} -p ${TEST_ADMIN_PASSWORD})" =~ "Login successful" ]] || [[ counter++ -ge 80 ]]
do
sleep 5
done
export ADMIN_TOKEN=$(oc whoami -t)

counter=0
until [[ "$(oc login --insecure-skip-tls-verify ${TEST_CLUSTER_URL} -u ${TEST_USER_USERNAME} -p ${TEST_USER_PASSWORD})" =~ "Login successful" ]] || [[ counter++ -ge 80 ]]
do
sleep 5
done
export USER_TOKEN=$(oc whoami -t)

oc login --insecure-skip-tls-verify "${TEST_CLUSTER_URL}" -u ${SYSADMIN_USERNAME} -p "${SYSADMIN_PASSWORD}"
oc adm policy add-cluster-role-to-user cluster-admin ${TEST_ADMIN_USERNAME}
oc adm policy add-cluster-role-to-user cluster-admin ${TEST_USER_USERNAME}

export TEST_NAMESPACE=intersmash-test
oc new-project $TEST_NAMESPACE

cat >> test.properties <<EOL
xtf.openshift.url=${TEST_CLUSTER_URL}
xtf.openshift.namespace=${TEST_NAMESPACE}
xtf.bm.namespace=${TEST_NAMESPACE}-builds
xtf.openshift.admin.username=${SYSADMIN_USERNAME}
xtf.openshift.admin.password=${SYSADMIN_PASSWORD}
xtf.openshift.admin.token=${SYSADMIN_TOKEN}
xtf.openshift.master.username=${SYSADMIN_USERNAME}
xtf.openshift.master.password=${SYSADMIN_PASSWORD}
xtf.openshift.master.token=${SYSADMIN_TOKEN}
xtf.openshift.admin.username=${TEST_ADMIN_USERNAME}
xtf.openshift.admin.password=${TEST_ADMIN_PASSWORD}
xtf.openshift.admin.token=${ADMIN_TOKEN}
xtf.openshift.master.username=${TEST_USER_USERNAME}
xtf.openshift.master.password=${TEST_USER_PASSWORD}
xtf.openshift.master.token=${USER_TOKEN}
xtf.openshift.admin.kubeconfig=${KUBECONFIG}
xtf.openshift.master.kubeconfig=${KUBECONFIG}
Expand All @@ -52,4 +88,4 @@ cat test.properties

mkdir local-repo
mvn clean install -Dmaven.repo.local=./local-repo -DskipTests
mvn test -Dmaven.repo.local=./local-repo -pl testsuite/ -am
mvn test -Dmaven.repo.local=./local-repo -pl testsuite/
33 changes: 16 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,15 +245,15 @@ public class PostgresqlProvisionTest {

Mapping of implemented provisioners:

| Product | Application | Provisioner |
|:-----------|:-------------------------------------|:-------------------------------------|
| ActiveMQ | ActiveMQOperatorApplication* | ActiveMQOperatorProvisioner |
| Kafka | KafkaOperatorApplication | KafkaOperatorProvisioner |
| Wildfly | WildflyImageOpenShiftApplication | WildflyImageOpenShiftProvisioner |
| Wildfly | WildflyHelmChartOpenShiftApplication | WildflyHelmChartOpenShiftProvisioner |
| Infinispan | InfinispanOperatorApplication | InfinispanOperatorProvisioner |
| Keycloak | KeycloakOpenShiftApplication | KeycloakTemplateOpenShiftProvisioner |
| Keycloak | KeycloakOperatorApplication | KeycloakOperatorProvisioner |
| Product | Application | Provisioner | Notes |
|:-----------|:-------------------------------------|:-------------------------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ActiveMQ | ActiveMQOperatorApplication* | ActiveMQOperatorProvisioner | |
| Kafka | KafkaOperatorApplication | KafkaOperatorProvisioner | |
| Wildfly | WildflyImageOpenShiftApplication | WildflyImageOpenShiftProvisioner | |
| Wildfly | WildflyHelmChartOpenShiftApplication | WildflyHelmChartOpenShiftProvisioner | The `main` branch of https://github.com/wildfly/wildfly-charts is used and the model is generated based on the https://raw.githubusercontent.com/wildfly/wildfly-charts/main/charts/wildfly/values.schema.json value schema file |
| Infinispan | InfinispanOperatorApplication | InfinispanOperatorProvisioner | |
| Keycloak | KeycloakOpenShiftApplication | KeycloakTemplateOpenShiftProvisioner | |
| Keycloak | KeycloakOperatorApplication | KeycloakOperatorProvisioner | |

Additional services provisioners:

Expand All @@ -277,14 +277,13 @@ a given service on cloud environments via APIs that leverage the
Intersmash makes this feature available for currently supported products (see the table below), but that can be
extended easily, since Intersmash _provisioners_ are pluggable components.

| Product | Supported Operator version | Channel name | Supported product version | Repository | Notes |
|:--------------------------|:---------------------------|:---------------|:--------------------------|:----------------------------------------------------------|:------------------------------------------------------------------------------------|
| Hyperfoil | 0.21.0 | alpha | 0.23 | https://github.com/Hyperfoil/hyperfoil-operator | |
| Infinispan | 2.3.1 | 2.3.x | 14.0.6.Final | https://github.com/infinispan/infinispan-operator | |
| WildFly | 0.5.6 | alpha | 27.0.1.Final | https://github.com/wildfly/wildfly-operator | As available on https://operatorhub.io/operator/wildfly |
| Kafka provided by Strimzi | 0.29.0 | strimzi-0.29.x | 3.2.0 | https://github.com/strimzi/strimzi-kafka-operator | Latest Kafka provided by Strimzi Operator version seems to require some adjustments |
| ActiveMQ | 1.0.11 | upstream | 1.0.15 | https://github.com/artemiscloud/activemq-artemis-operator | We are using a custom index image <b>quay.io/jbossqe-eap/intersmash-activemq-operator-catalog:v1.0.11</b> built as described in https://github.com/Intersmash/intersmash/issues/32

| Product | Supported Operator version | Channel name | Supported product version | Repository | Notes |
|:--------------------------|:---------------------------|:---------------|:--------------------------|:----------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Hyperfoil | 0.21.0 | alpha | 0.23 | https://github.com/Hyperfoil/hyperfoil-operator | |
| Infinispan | 2.3.1 | 2.3.x | 14.0.6.Final | https://github.com/infinispan/infinispan-operator | |
| WildFly | 0.5.6 | alpha | 27.0.1.Final | https://github.com/wildfly/wildfly-operator | As available on https://operatorhub.io/operator/wildfly |
| Kafka provided by Strimzi | 0.29.0 | strimzi-0.29.x | 3.2.0 | https://github.com/strimzi/strimzi-kafka-operator | Latest Kafka provided by Strimzi Operator version seems to require some adjustments |
| ActiveMQ | 1.0.11 | upstream | 1.0.15 | https://github.com/artemiscloud/activemq-artemis-operator | We are using a custom index image <b>quay.io/jbossqe-eap/intersmash-activemq-operator-catalog:v1.0.11</b> built as described in https://github.com/Intersmash/intersmash/issues/32 |

Intersmash operator-based provisioners implement a common contract and high level behavior which is defined by the
[OperatorProvisioner](./intersmash-tools/intersmash-tools-core/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/OperatorProvisioner.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.slf4j.event.Level;

Expand Down

0 comments on commit bd8d16e

Please sign in to comment.