Skip to content

Commit

Permalink
chore(e2e): automate E2E scenario with use of Operator for installati…
Browse files Browse the repository at this point in the history
…on refactored
  • Loading branch information
Omar-AlJaljuli committed Dec 12, 2024
1 parent 31b574e commit 23518a1
Show file tree
Hide file tree
Showing 12 changed files with 175 additions and 3 deletions.
16 changes: 15 additions & 1 deletion .ibm/images/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,19 @@ RUN echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.
apt-get install google-cloud-cli google-cloud-sdk-gke-gcloud-auth-plugin -y && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Set working directory
# Install skopeo
RUN apt-get update -y && \
apt-get install -y skopeo

# Install umoci
RUN curl -LO "https://github.com/opencontainers/umoci/releases/download/v0.4.7/umoci.amd64" && \
chmod +x umoci.amd64 && \
mv umoci.amd64 /usr/local/bin/umoci

# Install opm
RUN curl -LO "https://github.com/operator-framework/operator-registry/releases/download/v1.23.0/linux-amd64-opm" && \
chmod +x linux-amd64-opm && \
mv linux-amd64-opm /usr/local/bin/opm

# Set working directory
WORKDIR /tmp/
1 change: 1 addition & 0 deletions .ibm/pipelines/env_variables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ NAME_SPACE_RBAC="${NAME_SPACE_RBAC:-showcase-rbac}"
NAME_SPACE_RUNTIME="${NAME_SPACE_RUNTIME:-showcase-runtime}"
NAME_SPACE_POSTGRES_DB="${NAME_SPACE_POSTGRES_DB:-postgress-external-db}"
NAME_SPACE_RDS="showcase-rds-nightly"
OPERATOR_MANAGER='rhdh-operator'
CHART_VERSION="2.15.2"
GITHUB_APP_APP_ID=$(cat /tmp/secrets/GITHUB_APP_3_APP_ID)
GITHUB_APP_CLIENT_ID=$(cat /tmp/secrets/GITHUB_APP_3_CLIENT_ID)
Expand Down
59 changes: 58 additions & 1 deletion .ibm/pipelines/jobs/operator.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,65 @@
#!/bin/sh

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

configure_namespace $namespace

# Make sure script is up to date
rm -f /tmp/install-rhdh-catalog-source.sh
curl -L https://raw.githubusercontent.com/redhat-developer/rhdh-operator/refs/heads/main/.rhdh/scripts/install-rhdh-catalog-source.sh > /tmp/install-rhdh-catalog-source.sh
chmod +x /tmp/install-rhdh-catalog-source.sh
bash -x /tmp/install-rhdh-catalog-source.sh --next --install-operator rhdh
}

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

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

initiate_operator_deployments() {
configure_namespace "${OPERATOR_MANAGER}"
install_rhdh_operator "${DIR}" "${OPERATOR_MANAGER}"

configure_namespace "${NAME_SPACE}"
local rhdh_base_url="https://backstage-${RELEASE_NAME}-${NAME_SPACE}.${K8S_CLUSTER_ROUTER_BASE}"
apply_yaml_files "${DIR}" "${NAME_SPACE}" "${rhdh_base_url}"
create_dynamic_plugins_config "${DIR}/value_files/${HELM_CHART_VALUE_FILE_NAME}" "/tmp/configmap-dynamic-plugins.yaml"
oc apply -f /tmp/configmap-dynamic-plugins.yaml -n "${NAME_SPACE}"
oc apply -f "$DIR/resources/redis-cache/redis-deployment.yaml" --namespace="${NAME_SPACE}"
deploy_rhdh_operator "${DIR}" "${NAME_SPACE}"

configure_namespace "${NAME_SPACE_RBAC}"
local rbac_rhdh_base_url="https://backstage-${RELEASE_NAME_RBAC}-${NAME_SPACE_RBAC}.${K8S_CLUSTER_ROUTER_BASE}"
apply_yaml_files "${DIR}" "${NAME_SPACE_RBAC}" "${rbac_rhdh_base_url}"
create_dynamic_plugins_config "${DIR}/value_files/${HELM_CHART_RBAC_VALUE_FILE_NAME}" "/tmp/configmap-dynamic-plugins-rbac.yaml"
oc apply -f /tmp/configmap-dynamic-plugins-rbac.yaml -n "${NAME_SPACE_RBAC}"
deploy_rhdh_operator "${DIR}" "${NAME_SPACE_RBAC}"
}

handle_operator() {
set_github_app_3_credentials
oc_login

apply_yaml_files "${DIR}" "${NAME_SPACE}"
API_SERVER_URL=$(oc whoami --show-server)
ENCODED_API_SERVER_URL=$(echo "${API_SERVER_URL}" | base64)
ENCODED_CLUSTER_NAME=$(echo "my-cluster" | base64)

export K8S_CLUSTER_ROUTER_BASE=$(oc get route console -n openshift-console -o=jsonpath='{.spec.host}' | sed 's/^[^.]*\.//')
local url="https://backstage-${RELEASE_NAME}-${NAME_SPACE}.${K8S_CLUSTER_ROUTER_BASE}"
local rbac_url="https://backstage-${RELEASE_NAME_RBAC}-${NAME_SPACE_RBAC}.${K8S_CLUSTER_ROUTER_BASE}"

configure_namespace "${NAME_SPACE}"
deploy_test_backstage_provider "${NAME_SPACE}"
cluster_setup
initiate_operator_deployments
check_and_test "${RELEASE_NAME}" "${NAME_SPACE}" "${url}"
check_and_test "${RELEASE_NAME_RBAC}" "${NAME_SPACE_RBAC}" "${rbac_url}"
}
8 changes: 8 additions & 0 deletions .ibm/pipelines/openshift-ci-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ for SCRIPT in "${SCRIPTS[@]}"; do
echo "Loaded ${SCRIPT}"
done

############# REMOVE ONCE PR IS READY ############################
NAME_SPACE="showcase-operator-nightly"
NAME_SPACE_RBAC="showcase-op-rbac-nightly"
JOB_NAME=e2e-tests-operator-nightly
export K8S_CLUSTER_URL=$(cat /tmp/secrets/RHDH_PR_OS_CLUSTER_URL)
export K8S_CLUSTER_TOKEN=$(cat /tmp/secrets/RHDH_PR_OS_CLUSTER_TOKEN)
##################################################################

main() {
echo "Log file: ${LOGFILE}"
echo "JOB_NAME : $JOB_NAME"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ subjects:
- kind: ServiceAccount
name: rhdh-k8s-plugin
namespace: showcase-ci-nightly
- kind: ServiceAccount
name: rhdh-k8s-plugin
namespace: showcase-operator-nightly
- kind: ServiceAccount
name: rhdh-k8s-plugin
namespace: showcase-op-rbac-nightly
4 changes: 4 additions & 0 deletions .ibm/pipelines/resources/config_map/app-config-rhdh-rbac.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
app:
baseUrl: ${RHDH_BASE_URL}
title: Red Hat Developer Hub
backend:
baseUrl: ${RHDH_BASE_URL}
cors:
origin: ${RHDH_BASE_URL}
auth:
keys:
- secret: temp
Expand Down
4 changes: 4 additions & 0 deletions .ibm/pipelines/resources/config_map/app-config-rhdh.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
app:
baseUrl: ${RHDH_BASE_URL}
title: Red Hat Developer Hub
branding:
fullLogo: "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/Pgo8IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDIwMDEwOTA0Ly9FTiIgImh0dHA6Ly93d3cudzMub3JnL1RSLzIwMDEvUkVDLVNWRy0yMDAxMDkwNC9EVEQvc3ZnMTAuZHRkIj4KPCEtLSBDcmVhdGVkIHVzaW5nIEtyaXRhOiBodHRwczovL2tyaXRhLm9yZyAtLT4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIAogICAgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiCiAgICB4bWxuczprcml0YT0iaHR0cDovL2tyaXRhLm9yZy9uYW1lc3BhY2VzL3N2Zy9rcml0YSIKICAgIHhtbG5zOnNvZGlwb2RpPSJodHRwOi8vc29kaXBvZGkuc291cmNlZm9yZ2UubmV0L0RURC9zb2RpcG9kaS0wLmR0ZCIKICAgIHdpZHRoPSIxNjBwdCIKICAgIGhlaWdodD0iODBwdCIKICAgIHZpZXdCb3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3Q6IGF1dG87Zm9udC1mYW1pbHk6IFJlZCBIYXQgVGV4dDtmb250LXNpemU6IDE0O2ZvbnQtd2VpZ2h0OiA3MDA7Ij48dHNwYW4geD0iMCI+UmVkIEhhdDwvdHNwYW4+PHRzcGFuIHg9IjAiIGR5PSIxOC41MTU2MjUiPkRldmVsb3BlciBIdWI8L3RzcGFuPjwvdGV4dD4KPC9zdmc+Cg=="
Expand All @@ -15,6 +16,9 @@ app:
headerColor2: 'rgb(45, 190, 50)'
navigationIndicatorColor: 'rgb(45, 113, 190)'
backend:
baseUrl: ${RHDH_BASE_URL}
cors:
origin: ${RHDH_BASE_URL}
reading:
allow:
- host: 'github.com'
Expand Down
19 changes: 19 additions & 0 deletions .ibm/pipelines/resources/rhdh-operator/rhdh-start-rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
kind: Backstage
apiVersion: rhdh.redhat.com/v1alpha2
metadata:
name: rhdh-rbac
spec:
application:
image: 'quay.io/rhdh/rhdh-hub-rhel9:next'
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
16 changes: 16 additions & 0 deletions .ibm/pipelines/resources/rhdh-operator/rhdh-start.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
kind: Backstage
apiVersion: rhdh.redhat.com/v1alpha2
metadata:
name: rhdh
spec:
application:
image: 'quay.io/rhdh/rhdh-hub-rhel9:next'
appConfig:
configMaps:
- name: app-config-rhdh
mountPath: /opt/app-root/src
dynamicPluginsConfigMapName: dynamic-plugins
extraEnvs:
secrets:
- name: rhdh-secrets
- name: redis-secret
13 changes: 12 additions & 1 deletion .ibm/pipelines/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,18 @@ select_config_map_file() {
fi
}

create_dynamic_plugins_config() {
local base_file=$1
local final_file=$2
echo "kind: ConfigMap
apiVersion: v1
metadata:
name: dynamic-plugins
data:
dynamic-plugins.yaml: |" >> ${final_file}
yq '.global.dynamic' ${base_file} | sed -e 's/^/ /' >> ${final_file}
}

create_app_config_map_k8s() {
local config_file=$1
local project=$2
Expand Down Expand Up @@ -721,4 +733,3 @@ oc_login() {
echo "OCP version: $(oc version)"
export K8S_CLUSTER_ROUTER_BASE=$(oc get route console -n openshift-console -o=jsonpath='{.spec.host}' | sed 's/^[^.]*\.//')
}

2 changes: 2 additions & 0 deletions e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
"showcase-rbac-nightly": "playwright test --project=showcase-rbac",
"showcase-k8s-ci-nightly": "playwright test --project=showcase-k8s",
"showcase-rbac-k8s-ci-nightly": "playwright test --project=showcase-rbac-k8s",
"showcase-operator-nightly": "playwright test --project=showcase-operator",
"showcase-op-rbac-nightly": "playwright test --project=showcase-operator-rbac",
"showcase-rds-nightly": "playwright test --project=postgres-health-check",
"showcase-runtime": "playwright test --project=showcase-runtime",
"lint:check": "eslint . --ext .js,.ts",
Expand Down
30 changes: 30 additions & 0 deletions e2e-tests/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,36 @@ export default defineConfig({
"**/playwright/e2e/plugins/bulk-import.spec.ts",
],
},
{
name: "showcase-operator",
use: {
...devices["Desktop Chrome"],
viewport: { width: 1920, height: 1080 },
},
testIgnore: [
"**/playwright/e2e/plugins/rbac/**/*.spec.ts",
"**/playwright/e2e/plugins/analytics/analytics-disabled-rbac.spec.ts",
"**/playwright/e2e/verify-tls-config-with-external-postgres-db.spec.ts",
"**/playwright/e2e/authProviders/**/*.spec.ts",
"**/playwright/e2e/plugins/bulk-import.spec.ts",
"**/playwright/e2e/plugins/tekton/tekton.spec.ts",
"**/playwright/e2e/catalog-scaffoldedfromLink.spec.ts",
"**/playwright/e2e/audit-log/**/*.spec.ts",
"**/playwright/e2e/plugins/topology/topology.spec.ts",
"**/playwright/e2e/verify-tls-config-health-check.spec.ts",
"**/playwright/e2e/configuration-test/config-map.spec.ts",
],
},
{
name: "showcase-operator-rbac",
...useCommonDeviceAndViewportConfig,
testMatch: [
"**/playwright/e2e/plugins/rbac/**/*.spec.ts",
"**/playwright/e2e/plugins/analytics/analytics-disabled-rbac.spec.ts",
"**/playwright/e2e/verify-tls-config-with-external-postgres-db.spec.ts",
"**/playwright/e2e/plugins/bulk-import.spec.ts",
],
},
{
name: "postgres-health-check",
...useCommonDeviceAndViewportConfig,
Expand Down

0 comments on commit 23518a1

Please sign in to comment.