Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,14 @@ tests:
test:
- ref: monitoring-plugin-tests-monitoring-dev-ui
workflow: ipi-aws
- always_run: false
as: e2e-perses
optional: true
steps:
cluster_profile: openshift-org-aws
test:
- ref: monitoring-plugin-tests-perses-ui
workflow: ipi-aws
zz_generated_metadata:
branch: main
org: openshift
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -975,6 +975,87 @@ presubmits:
secret:
secretName: result-aggregator
trigger: (?m)^/test( | .* )e2e-monitoring-reg,?($|\s.*)
- agent: kubernetes
always_run: false
branches:
- ^main$
- ^main-
cluster: build01
context: ci/prow/e2e-perses
decorate: true
labels:
ci-operator.openshift.io/cloud: aws
ci-operator.openshift.io/cloud-cluster-profile: openshift-org-aws
ci.openshift.io/generator: prowgen
pj-rehearse.openshift.io/can-be-rehearsed: "true"
name: pull-ci-openshift-monitoring-plugin-main-e2e-perses
optional: true
rerun_command: /test e2e-perses
spec:
containers:
- args:
- --gcs-upload-secret=/secrets/gcs/service-account.json
- --image-import-pull-secret=/etc/pull-secret/.dockerconfigjson
- --lease-server-credentials-file=/etc/boskos/credentials
- --report-credentials-file=/etc/report/credentials
- --secret-dir=/secrets/ci-pull-credentials
- --target=e2e-perses
command:
- ci-operator
env:
- name: HTTP_SERVER_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
image: quay-proxy.ci.openshift.org/openshift/ci:ci_ci-operator_latest
imagePullPolicy: Always
name: ""
ports:
- containerPort: 8080
name: http
resources:
requests:
cpu: 10m
volumeMounts:
- mountPath: /etc/boskos
name: boskos
readOnly: true
- mountPath: /secrets/ci-pull-credentials
name: ci-pull-credentials
readOnly: true
- mountPath: /secrets/gcs
name: gcs-credentials
readOnly: true
- mountPath: /secrets/manifest-tool
name: manifest-tool-local-pusher
readOnly: true
- mountPath: /etc/pull-secret
name: pull-secret
readOnly: true
- mountPath: /etc/report
name: result-aggregator
readOnly: true
serviceAccountName: ci-operator
volumes:
- name: boskos
secret:
items:
- key: credentials
path: credentials
secretName: boskos-credentials
- name: ci-pull-credentials
secret:
secretName: ci-pull-credentials
- name: manifest-tool-local-pusher
secret:
secretName: manifest-tool-local-pusher
- name: pull-secret
secret:
secretName: registry-pull-credentials
- name: result-aggregator
secret:
secretName: result-aggregator
trigger: (?m)^/test( | .* )e2e-perses,?($|\s.*)
- agent: kubernetes
always_run: false
branches:
Expand Down
14 changes: 14 additions & 0 deletions ci-operator/step-registry/monitoring-plugin/tests/perses-ui/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
approvers:
- etmurasaki
- jan--f
- jgbernalp
- kyoto
- peteryurkovich
- zhuje
options: {}
reviewers:
- etmurasaki
- jgbernalp
- kyoto
- peteryurkovich
- zhuje
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
#!/bin/bash

set -o nounset
set -o errexit
set -o pipefail

# List of variables to check.
vars=(
CYPRESS_SKIP_COO_INSTALL
CYPRESS_COO_UI_INSTALL
CYPRESS_KONFLUX_COO_BUNDLE_IMAGE
CYPRESS_CUSTOM_COO_BUNDLE_IMAGE
CYPRESS_MCP_CONSOLE_IMAGE
CYPRESS_MP_IMAGE
CYPRESS_FBC_STAGE_COO_IMAGE
CYPRESS_TIMEZONE
CYPRESS_SESSION
CYPRESS_DEBUG
CYPRESS_SKIP_KBV_INSTALL
CYPRESS_KBV_UI_INSTALL
CYPRESS_KONFLUX_KBV_BUNDLE_IMAGE
CYPRESS_CUSTOM_KBV_BUNDLE_IMAGE
CYPRESS_FBC_STAGE_KBV_IMAGE
)

# Loop through each variable.
for var in "${vars[@]}"; do
if [[ -z "${!var}" ]]; then
unset "$var"
echo "Unset variable: $var"
else
echo "$var is set to '${!var}'"
fi
done

# Read kubeadmin password from file
if [[ -z "${KUBEADMIN_PASSWORD_FILE:-}" ]]; then
echo "Error: KUBEADMIN_PASSWORD_FILE variable is not set"
exit 0
fi

if [[ ! -f "${KUBEADMIN_PASSWORD_FILE}" ]]; then
echo "Error: Kubeadmin password file ${KUBEADMIN_PASSWORD_FILE} does not exist"
exit 0
fi

kubeadmin_password=$(cat "${KUBEADMIN_PASSWORD_FILE}")
echo "Successfully read kubeadmin password from ${KUBEADMIN_PASSWORD_FILE}"

# Set proxy vars.
if [ -f "${SHARED_DIR}/proxy-conf.sh" ] ; then
source "${SHARED_DIR}/proxy-conf.sh"
fi

## skip all tests when console is not installed.
if ! (oc get clusteroperator console --kubeconfig=${KUBECONFIG}) ; then
echo "console is not installed, skipping all console tests."
exit 0
fi

# Function to copy artifacts to the artifact directory after test run.
function copyArtifacts {
if [ -d "/tmp/monitoring-plugin/web/cypress/screenshots/" ]; then
cp -r /tmp/monitoring-plugin/web/cypress/screenshots/ "${ARTIFACT_DIR}/screenshots"
echo "Screenshots copied successfully."
else
echo "Directory screenshots does not exist. Nothing to copy."
fi
if [ -d "/tmp/monitoring-plugin/web/cypress/videos/" ]; then
cp -r /tmp/monitoring-plugin/web/cypress/videos/ "${ARTIFACT_DIR}/videos"
echo "Videos copied successfully."
else
echo "Directory videos does not exist. Nothing to copy."
fi
}

## Add IDP for testing
# prepare users
users=""
htpass_file=/tmp/users.htpasswd

for i in $(seq 1 5); do
username="uiauto-test-${i}"
password=$(tr </dev/urandom -dc 'a-z0-9' | fold -w 12 | head -n 1 || true)
users+="${username}:${password},"
if [ -f "${htpass_file}" ]; then
htpasswd -B -b ${htpass_file} "${username}" "${password}"
else
htpasswd -c -B -b ${htpass_file} "${username}" "${password}"
fi
done

# remove trailing ',' for case parsing
users=${users%?}

# current generation
gen=$(oc get deployment oauth-openshift -n openshift-authentication -o jsonpath='{.metadata.generation}')

# add users to cluster
oc create secret generic uiauto-htpass-secret --from-file=htpasswd=${htpass_file} -n openshift-config
oc patch oauth cluster --type='json' -p='[{"op": "add", "path": "/spec/identityProviders", "value": [{"type": "HTPasswd", "name": "uiauto-htpasswd-idp", "mappingMethod": "claim", "htpasswd":{"fileData":{"name": "uiauto-htpass-secret"}}}]}]'

## wait for oauth-openshift to rollout
wait_auth=true
expected_replicas=$(oc get deployment oauth-openshift -n openshift-authentication -o jsonpath='{.spec.replicas}')
while $wait_auth; do
available_replicas=$(oc get deployment oauth-openshift -n openshift-authentication -o jsonpath='{.status.availableReplicas}')
new_gen=$(oc get deployment oauth-openshift -n openshift-authentication -o jsonpath='{.metadata.generation}')
if [[ $expected_replicas == "$available_replicas" && $((new_gen)) -gt $((gen)) ]]; then
wait_auth=false
else
sleep 10
fi
done
echo "authentication operator finished updating"

# Copy the artifacts to the aritfact directory at the end of the test run.
trap copyArtifacts EXIT

# Set Kubeconfig var for Cypress.
cp -L $KUBECONFIG /tmp/kubeconfig && export CYPRESS_KUBECONFIG_PATH=/tmp/kubeconfig

# Set Cypress base URL var.
console_route=$(oc get route console -n openshift-console -o jsonpath='{.spec.host}')
export CYPRESS_BASE_URL=https://$console_route

# Set Cypress authentication username and password.
# Use the IDP once issue https://issues.redhat.com/browse/OCPBUGS-59366 is fixed.
export CYPRESS_LOGIN_IDP_DEV_USER=uiauto-htpasswd-idp
export CYPRESS_LOGIN_IDP=kube:admin
export CYPRESS_LOGIN_USERS=kubeadmin:${kubeadmin_password},${users}

# Run the Cypress tests.
export NO_COLOR=1
export CYPRESS_CACHE_FOLDER=/tmp/Cypress

# Install npm modules
ls -ltr
npm install

# Run the Cypress tests
npm run test-cypress-perses
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"path": "monitoring-plugin/tests/perses-ui/monitoring-plugin-tests-perses-ui-ref.yaml",
"owners": {
"approvers": [
"etmurasaki",
"jan--f",
"jgbernalp",
"kyoto",
"peteryurkovich",
"zhuje"
],
"reviewers": [
"etmurasaki",
"jgbernalp",
"kyoto",
"peteryurkovich",
"zhuje"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
ref:
as: monitoring-plugin-tests-perses-ui
from: monitoring-ui-tests-runner
commands: monitoring-plugin-tests-perses-ui-commands.sh
timeout: 2h0m0s
grace_period: 60s
resources:
requests:
cpu: "1"
memory: 3Gi
limits:
memory: 4Gi
env:
- name: CYPRESS_SKIP_COO_INSTALL
default: ""
documentation: "Set the var to skip Cluster Observability and all the required operators installation from the Cypress test run."
- name: CYPRESS_COO_UI_INSTALL
default: "true"
documentation: "Set the var to install Cluster Observability from redhat-operators catalog source."
- name: CYPRESS_KONFLUX_COO_BUNDLE_IMAGE
default: ""
documentation: "Set the var to install Cluster Observability Operator using Konflux bundle."
- name: CYPRESS_CUSTOM_COO_BUNDLE_IMAGE
default: ""
documentation: "Set the var to use custom Cluster Observability Operator bundle image."
- name: CYPRESS_FBC_STAGE_COO_IMAGE
default: ""
documentation: "Set the var to use Cluster Observability Operator FBC image"
- name: CYPRESS_MCP_CONSOLE_IMAGE
default: ""
documentation: "Set the var to use custom Monitoring UI plugin image. The image will be patched in Cluster Observability Operator CSV."
- name: CYPRESS_MP_IMAGE
default: ""
documentation: "Set the following var to use custom Monitoring Plugin image (that goes on Cluster Monitoring Operator). The image will be patched in CMO CSV."
- name: CYPRESS_TIMEZONE
default: "UTC"
documentation: "Set the following var to specify the cluster timezone for incident timeline calculations. Defaults to UTC if not specified."
- name: CYPRESS_SESSION
default: "true"
documentation: "Set the following var to enable Cypress session management for faster test execution."
- name: CYPRESS_DEBUG
default: "true"
documentation: "Set the following var to enable Cypress debug mode to log in headless mode."
- name: CYPRESS_SKIP_KBV_INSTALL
default: "true"
documentation: "Set the var to skip Openshift Virtualization and all the required operators installation from the Cypress test run."
- name: CYPRESS_KBV_UI_INSTALL
default: "false"
documentation: "Set the var to install Openshift Virtualization from redhat-operators catalog source."
- name: CYPRESS_KONFLUX_KBV_BUNDLE_IMAGE
default: ""
documentation: "Set the var to install Openshift Virtualization Operator using Konflux bundle."
- name: CYPRESS_CUSTOM_KBV_BUNDLE_IMAGE
default: ""
documentation: "Set the var to use custom Openshift Virtualization Operator bundle image."
- name: CYPRESS_FBC_STAGE_KBV_IMAGE
default: ""
documentation: "Set the var to use Openshift Virtualization Operator FBC image."
dependencies:
- name: "monitoring-console-plugin"
env: CYPRESS_MCP_CONSOLE_IMAGE
- name: "monitoring-plugin"
env: CYPRESS_MP_IMAGE
documentation: |-
The monitoring-plugin-tests-monitoring-ui step executes the Monitoring Console Plugin Cypress tests.