Skip to content

Commit

Permalink
Added necessary files and configuration to the ci script to test the …
Browse files Browse the repository at this point in the history
…e2e tests on operator if the nightly job is called
  • Loading branch information
Omar-AlJaljuli committed Sep 18, 2024
1 parent 7e29bd4 commit 0313768
Show file tree
Hide file tree
Showing 8 changed files with 316 additions and 4 deletions.
1 change: 1 addition & 0 deletions .ibm/pipelines/env_variables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ RELEASE_NAME_RBAC=rhdh-rbac
NAME_SPACE="${NAME_SPACE:-showcase}"
NAME_SPACE_RBAC="${NAME_SPACE_RBAC:-showcase-rbac}"
NAME_SPACE_POSTGRES_DB="${NAME_SPACE_POSTGRES_DB:-postgress-external-db}"
OPERATOR_MANAGER='rhdh-operator'
CHART_VERSION="2.15.2"
GITHUB_APP_APP_ID=Mzc2ODY2
GITHUB_APP_CLIENT_ID=SXYxLjdiZDNlZDFmZjY3MmY3ZDg=
Expand Down
79 changes: 75 additions & 4 deletions .ibm/pipelines/openshift-ci-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,16 @@ configure_namespace() {
oc config set-context --current --namespace="${project}"
}

configure_namespace_if_nonexistent() {
local project=$1
if oc get namespace "${project}" >/dev/null 2>&1; then
echo "Namespace ${project} already exists!"
else
oc create namespace "${project}"
oc config set-context --current --namespace="${project}"
fi
}

configure_external_postgres_db() {
local project=$1
oc apply -f "${DIR}/resources/postgres-db/postgres.yaml" --namespace="${NAME_SPACE_POSTGRES_DB}"
Expand Down Expand Up @@ -162,7 +172,7 @@ apply_yaml_files() {
token=$(oc get secret "${secret_name}" -n "${project}" -o=jsonpath='{.data.token}')
sed -i "s/OCM_CLUSTER_TOKEN: .*/OCM_CLUSTER_TOKEN: ${token}/" "$dir/auth/secrets-rhdh-secrets.yaml"

if [[ "${project}" == "showcase-rbac" || "${project}" == "showcase-rbac-nightly" || "${project}" == "showcase-rbac-1-2-x" ]]; then
if [[ "${project}" == "showcase-rbac" || "${project}" == "showcase-rbac-nightly" || "${project}" == "showcase-rbac-1-2-x" || "${project}" == "showcase-operator-rbac-nightly" ]]; then
oc apply -f "$dir/resources/config_map/configmap-app-config-rhdh-rbac.yaml" --namespace="${project}"
else
oc apply -f "$dir/resources/config_map/configmap-app-config-rhdh.yaml" --namespace="${project}"
Expand All @@ -173,6 +183,14 @@ apply_yaml_files() {
sleep 20 # wait for Pipeline Operator to be ready
oc apply -f "$dir/resources/pipeline-run/hello-world-pipeline.yaml"
oc apply -f "$dir/resources/pipeline-run/hello-world-pipeline-run.yaml"

if [[ "${project}" == "showcase-operator-nightly" ]]; then
oc apply -f "$dir/resources/rhdh-operator/dynamic_plugins/configmap-dynamic-plugins.yaml" --namespace="${project}"
fi

if [[ "${project}" == "showcase-operator-rbac-nightly" ]]; then
oc apply -f "$dir/resources/rhdh-operator/dynamic_plugins/configmap-dynamic-plugins-rbac.yaml" --namespace="${project}"
fi
}

run_tests() {
Expand Down Expand Up @@ -219,7 +237,11 @@ run_tests() {
check_backstage_running() {
local release_name=$1
local namespace=$2
local url="https://${release_name}-backstage-${namespace}.${K8S_CLUSTER_ROUTER_BASE}"
if [[ "${namespace}" == "showcase-operator-rbac-nightly" || "${namespace}" == "showcase-operator-nightly" ]]; then
local url="https://backstage-${release_name}-${namespace}.${K8S_CLUSTER_ROUTER_BASE}"
else
local url="https://${release_name}-backstage-${namespace}.${K8S_CLUSTER_ROUTER_BASE}"
fi

local max_attempts=30
local wait_seconds=30
Expand Down Expand Up @@ -259,6 +281,39 @@ install_pipelines_operator() {
fi
}

apply_operator_group_if_nonexistent() {
if [[ $(oc get OperatorGroup -n rhdh-operator 2>/dev/null | wc -l) -ge 1 ]]; then
echo "Red Hat Developer Hub operator group is already installed."
else
echo "Red Hat Developer Hub operator group does not exist. adding..."
oc apply -f "${dir}/resources/rhdh-operator/installation/rhdh-operator-group.yaml" -n "${namespace}"
fi
}

install_rhdh_operator() {
local dir=$1
local namespace=$2
CSV_NAME="Red Hat Developer Hub Operator"

if oc get csv -n "${namespace}" | grep -q "${CSV_NAME}"; then
echo "Red Hat Developer Hub operator is already installed."
elsedeploy_rhexistent "${namespace}"
apply_operator_group_if_nonexistent
oc apply -f "${dir}/resources/rhdh-operator/installation/rhdh-subscription.yaml" -n "${namespace}"
fi
}

deploy_rhdh_operator() {
local dir=$1
local namespace=$2

if [[ "${namespace}" == "showcase-operator-rbac-nightly" ]]; then
oc apply -f "${dir}/resources/rhdh-operator/deployment/rhdh-start-rbac.yaml" -n "${namespace}"
else
oc apply -f "${dir}/resources/rhdh-operator/deployment/rhdh-start.yaml" -n "${namespace}"
fi
}

initiate_deployments() {
add_helm_repos
configure_namespace "${NAME_SPACE}"
Expand Down Expand Up @@ -286,6 +341,17 @@ initiate_deployments() {
helm upgrade -i "${RELEASE_NAME_RBAC}" -n "${NAME_SPACE_RBAC}" "${HELM_REPO_NAME}/${HELM_IMAGE_NAME}" --version "${CHART_VERSION}" -f "${DIR}/value_files/${HELM_CHART_RBAC_VALUE_FILE_NAME}" --set global.clusterRouterBase="${K8S_CLUSTER_ROUTER_BASE}" --set upstream.backstage.image.repository="${QUAY_REPO}" --set upstream.backstage.image.tag="${TAG_NAME}"
}

initiate_deployments_operator() {
install_rhdh_operator "${DIR}" "${OPERATOR_MANAGER}"
configure_namespace "${NAME_SPACE}"
apply_yaml_files "${DIR}" "${NAME_SPACE}"
deploy_rhdh_operator "${DIR}" "${NAME_SPACE}"

configure_namespace "${NAME_SPACE_RBAC}"
apply_yaml_files "${DIR}" "${NAME_SPACE_RBAC}"
deploy_rhdh_operator "${DIR}" "${NAME_SPACE_RBAC}"
}

check_and_test() {
local release_name=$1
local namespace=$2
Expand Down Expand Up @@ -321,8 +387,13 @@ main() {

ENCODED_API_SERVER_URL=$(echo "${API_SERVER_URL}" | base64)
ENCODED_CLUSTER_NAME=$(echo "my-cluster" | base64)

initiate_deployments

if [[ "$JOB_NAME" == *operator* ]]; then
initiate_deployments_operator
else
initiate_deployments
fi

check_and_test "${RELEASE_NAME}" "${NAME_SPACE}"
check_and_test "${RELEASE_NAME_RBAC}" "${NAME_SPACE_RBAC}"
exit "${OVERALL_RESULT}"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
kind: Backstage
apiVersion: rhdh.redhat.com/v1alpha1
metadata:
name: rhdh-rbac
spec:
application:
appConfig:
configMaps:
- name: app-config-rhdh
mountPath: /opt/app-root/src
dynamicPluginsConfigMapName: dynamic-plugins
extraEnvs:
secrets:
- name: rhdh-secrets
extraFiles:
configMaps:
- name: rbac-policy
mountPath: /opt/app-root/src/rbac

18 changes: 18 additions & 0 deletions .ibm/pipelines/resources/rhdh-operator/deployment/rhdh-start.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
kind: Backstage
apiVersion: rhdh.redhat.com/v1alpha1
metadata:
name: rhdh
spec:
application:
appConfig:
configMaps:
- name: app-config-rhdh
mountPath: /opt/app-root/src
dynamicPluginsConfigMapName: dynamic-plugins
extraEnvs:
secrets:
- name: rhdh-secrets
extraFiles:
configMaps:
- name: rbac-policy
mountPath: /opt/app-root/src/rbac
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
kind: ConfigMap
apiVersion: v1
metadata:
name: dynamic-plugins
data:
dynamic-plugins.yaml: |
includes:
- 'dynamic-plugins.default.yaml'
plugins:
- package: ./dynamic-plugins/dist/backstage-plugin-catalog-backend-module-github-dynamic
disabled: false
pluginConfig:
catalog:
providers:
github:
my-test-org:
organization: janus-qe
catalogPath: '/catalog-info.yaml'
schedule:
frequency:
minutes: 1
timeout:
minutes: 1
initialDelay:
seconds: 15
- package: ./dynamic-plugins/dist/backstage-plugin-catalog-backend-module-github-org-dynamic
disabled: false
- package: ./dynamic-plugins/dist/backstage-plugin-github-issues
disabled: false
- package: ./dynamic-plugins/dist/roadiehq-backstage-plugin-github-pull-requests
disabled: false
- package: ./dynamic-plugins/dist/backstage-plugin-github-actions
disabled: false
- package: ./dynamic-plugins/dist/janus-idp-backstage-plugin-quay
disabled: false
- package: ./dynamic-plugins/dist/janus-idp-backstage-plugin-keycloak-backend-dynamic
disabled: false
- package: ./dynamic-plugins/dist/janus-idp-backstage-plugin-tekton
disabled: false
- package: ./dynamic-plugins/dist/backstage-plugin-kubernetes
disabled: false
- package: ./dynamic-plugins/dist/backstage-plugin-kubernetes-backend-dynamic
disabled: false
pluginConfig:
kubernetes:
clusterLocatorMethods:
- clusters:
- authProvider: serviceAccount
name: 'my-cluster'
serviceAccountToken: ${K8S_SERVICE_ACCOUNT_TOKEN}
url: ${K8S_CLUSTER_API_SERVER_URL}
type: config
customResources:
- apiVersion: 'v1beta1'
group: 'tekton.dev'
plural: 'pipelines'
- apiVersion: v1beta1
group: tekton.dev
plural: pipelineruns
- apiVersion: v1beta1
group: tekton.dev
plural: taskruns
- apiVersion: 'v1'
group: 'route.openshift.io'
plural: 'routes'
- group: 'org.eclipse.che'
apiVersion: 'v2'
plural: 'checlusters'
serviceLocatorMethod:
type: multiTenant
- package: ./dynamic-plugins/dist/janus-idp-backstage-plugin-ocm-backend-dynamic
disabled: false
pluginConfig:
catalog:
providers:
ocm:
default:
name: testCluster
url: ${OCM_CLUSTER_URL}
serviceAccountToken: ${OCM_CLUSTER_TOKEN}
skipTLSVerify: true
owner: janus-authors
- package: ./dynamic-plugins/dist/janus-idp-backstage-plugin-ocm
disabled: false
- package: ./dynamic-plugins/dist/backstage-plugin-tech-radar
disabled: false
- package: ./dynamic-plugins/dist/janus-idp-backstage-plugin-acr
disabled: false
- package: ./dynamic-plugins/dist/janus-idp-backstage-plugin-rbac
disabled: false
- package: './dynamic-plugins/dist/janus-idp-backstage-plugin-analytics-provider-segment'
disabled: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
kind: ConfigMap
apiVersion: v1
metadata:
name: dynamic-plugins
data:
dynamic-plugins.yaml: |
includes:
- 'dynamic-plugins.default.yaml'
plugins:
- package: ./dynamic-plugins/dist/backstage-plugin-catalog-backend-module-github-dynamic
disabled: false
pluginConfig:
catalog:
providers:
github:
my-test-org:
organization: janus-qe
catalogPath: '/catalog-info.yaml'
schedule:
frequency:
minutes: 1
timeout:
minutes: 1
initialDelay:
seconds: 15
- package: ./dynamic-plugins/dist/backstage-plugin-catalog-backend-module-github-org-dynamic
disabled: false
- package: ./dynamic-plugins/dist/backstage-plugin-github-issues
disabled: false
- package: ./dynamic-plugins/dist/roadiehq-backstage-plugin-github-pull-requests
disabled: false
- package: ./dynamic-plugins/dist/backstage-plugin-github-actions
disabled: false
- package: ./dynamic-plugins/dist/janus-idp-backstage-plugin-quay
disabled: false
- package: ./dynamic-plugins/dist/janus-idp-backstage-plugin-keycloak-backend-dynamic
disabled: false
- package: ./dynamic-plugins/dist/janus-idp-backstage-plugin-tekton
disabled: false
- package: ./dynamic-plugins/dist/backstage-plugin-kubernetes
disabled: false
- package: ./dynamic-plugins/dist/backstage-plugin-kubernetes-backend-dynamic
disabled: false
pluginConfig:
kubernetes:
clusterLocatorMethods:
- clusters:
- authProvider: serviceAccount
name: 'my-cluster'
serviceAccountToken: ${K8S_CLUSTER_TOKEN_ENCODED}
url: ${K8S_CLUSTER_API_SERVER_URL}
type: config
customResources:
- apiVersion: 'v1beta1'
group: 'tekton.dev'
plural: 'pipelines'
- apiVersion: v1beta1
group: tekton.dev
plural: pipelineruns
- apiVersion: v1beta1
group: tekton.dev
plural: taskruns
- apiVersion: 'v1'
group: 'route.openshift.io'
plural: 'routes'
serviceLocatorMethod:
type: multiTenant
- package: ./dynamic-plugins/dist/janus-idp-backstage-plugin-ocm-backend-dynamic
disabled: false
pluginConfig:
catalog:
providers:
ocm:
default:
name: testCluster # Can be any arbitrary name supported by kubernetes
url: ${OCM_CLUSTER_URL}
serviceAccountToken: ${OCM_CLUSTER_TOKEN}
skipTLSVerify: true
owner: janus-authors
- package: ./dynamic-plugins/dist/janus-idp-backstage-plugin-ocm
disabled: false
- package: ./dynamic-plugins/dist/backstage-plugin-tech-radar
disabled: false
- package: ./dynamic-plugins/dist/janus-idp-backstage-plugin-acr
disabled: false
- package: ./dynamic-plugins/dist/janus-idp-backstage-plugin-rbac
disabled: true
- package: ./dynamic-plugins/dist/roadiehq-scaffolder-backend-module-http-request-dynamic
disabled: false
- package: ./dynamic-plugins/dist/immobiliarelabs-backstage-plugin-gitlab-backend-dynamic
disabled: false
- package: ./dynamic-plugins/dist/backstage-plugin-catalog-backend-module-gitlab-dynamic
disabled: false
- package: ./dynamic-plugins/dist/janus-idp-backstage-plugin-topology
disabled: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
name: rhdh-operator-group
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: rhdh-operator
spec:
channel: fast
installPlanApproval: Automatic
name: rhdh
source: redhat-operators
sourceNamespace: openshift-marketplace

0 comments on commit 0313768

Please sign in to comment.