Skip to content
Open
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
1 change: 1 addition & 0 deletions web/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default defineConfig({
LOGIN_PASSWORD: process.env.CYPRESS_LOGIN_USERS.split(',')[0].split(':')[1],
TIMEZONE: process.env.CYPRESS_TIMEZONE || 'UTC',
MOCK_NEW_METRICS: process.env.CYPRESS_MOCK_NEW_METRICS || 'false',
COO_NAMESPACE: process.env.CYPRESS_COO_NAMESPACE || 'openshift-cluster-observability-operator',
typeDelay: 200,
},
fixturesFolder: 'cypress/fixtures',
Expand Down
5 changes: 5 additions & 0 deletions web/cypress/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ Set the following var to use custom Monitoring Plugin image (that goes on Cluste
export CYPRESS_MP_IMAGE=<Monitoring Plugin image>
```

Set the following var to specify the Cluster Observability Operator namespace. Defaults to `openshift-cluster-observability-operator` if not set. This is useful when testing with different namespace configurations (e.g., using `coo` instead of the default).
```bash
export CYPRESS_COO_NAMESPACE=openshift-cluster-observability-operator
```

Set the var to skip Cluster Observability and all the required operators installation.
```bash
export CYPRESS_SKIP_COO_INSTALL=true
Expand Down
9 changes: 9 additions & 0 deletions web/cypress/configure-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ print_current_config() {

# Optional vars
print_var "CYPRESS_MP_IMAGE" "${CYPRESS_MP_IMAGE-}"
print_var "CYPRESS_COO_NAMESPACE" "${CYPRESS_COO_NAMESPACE-}"
print_var "CYPRESS_SKIP_COO_INSTALL" "${CYPRESS_SKIP_COO_INSTALL-}"
print_var "CYPRESS_COO_UI_INSTALL" "${CYPRESS_COO_UI_INSTALL-}"
print_var "CYPRESS_KONFLUX_COO_BUNDLE_IMAGE" "${CYPRESS_KONFLUX_COO_BUNDLE_IMAGE-}"
Expand Down Expand Up @@ -217,6 +218,7 @@ main() {
local def_login_users=${CYPRESS_LOGIN_USERS-}
local def_kubeconfig=${CYPRESS_KUBECONFIG_PATH-${KUBECONFIG-}}
local def_mp_image=${CYPRESS_MP_IMAGE-}
local def_coo_namespace=${CYPRESS_COO_NAMESPACE-}
local def_skip_coo=${CYPRESS_SKIP_COO_INSTALL-}
local def_coo_ui_install=${CYPRESS_COO_UI_INSTALL-}
local def_konflux_bundle=${CYPRESS_KONFLUX_COO_BUNDLE_IMAGE-}
Expand Down Expand Up @@ -400,6 +402,9 @@ main() {
local mp_image
mp_image=$(ask "Custom Monitoring Plugin image (CYPRESS_MP_IMAGE)" "$def_mp_image")

local coo_namespace
coo_namespace=$(ask "Cluster Observability Operator namespace (CYPRESS_COO_NAMESPACE)" "${def_coo_namespace:-openshift-cluster-observability-operator}")

local skip_coo_install_ans
skip_coo_install_ans=$(ask_yes_no "Skip Cluster Observability installation? (sets CYPRESS_SKIP_COO_INSTALL)" "$(bool_to_default_yn "$def_skip_coo")")
local skip_coo_install="false"
Expand Down Expand Up @@ -471,6 +476,9 @@ main() {
if [[ -n "$mp_image" ]]; then
export_lines+=("export CYPRESS_MP_IMAGE='$(printf %s "$mp_image" | escape_for_single_quotes)'" )
fi
if [[ -n "$coo_namespace" ]]; then
export_lines+=("export CYPRESS_COO_NAMESPACE='$(printf %s "$coo_namespace" | escape_for_single_quotes)'" )
fi
export_lines+=("export CYPRESS_SKIP_COO_INSTALL='$(printf %s "$skip_coo_install" | escape_for_single_quotes)'" )
export_lines+=("export CYPRESS_COO_UI_INSTALL='$(printf %s "$coo_ui_install" | escape_for_single_quotes)'" )
if [[ -n "$konflux_bundle" ]]; then
Expand Down Expand Up @@ -529,6 +537,7 @@ main() {
echo " CYPRESS_LOGIN_USERS=${CYPRESS_LOGIN_USERS:-$login_users}"
echo " CYPRESS_KUBECONFIG_PATH=${CYPRESS_KUBECONFIG_PATH:-$kubeconfig}"
[[ -n "${CYPRESS_MP_IMAGE-}$mp_image" ]] && echo " CYPRESS_MP_IMAGE=${CYPRESS_MP_IMAGE:-$mp_image}"
[[ -n "${CYPRESS_COO_NAMESPACE-}$coo_namespace" ]] && echo " CYPRESS_COO_NAMESPACE=${CYPRESS_COO_NAMESPACE:-$coo_namespace}"
echo " CYPRESS_SKIP_COO_INSTALL=${CYPRESS_SKIP_COO_INSTALL:-$skip_coo_install}"
echo " CYPRESS_COO_UI_INSTALL=${CYPRESS_COO_UI_INSTALL:-$coo_ui_install}"
[[ -n "${CYPRESS_KONFLUX_COO_BUNDLE_IMAGE-}$konflux_bundle" ]] && echo " CYPRESS_KONFLUX_COO_BUNDLE_IMAGE=${CYPRESS_KONFLUX_COO_BUNDLE_IMAGE:-$konflux_bundle}"
Expand Down
2 changes: 1 addition & 1 deletion web/cypress/e2e/coo/01.coo_bvt.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { nav } from '../../views/nav';

// Set constants for the operators that need to be installed for tests.
const MCP = {
namespace: 'openshift-cluster-observability-operator',
namespace: Cypress.env('COO_NAMESPACE'),
packageName: 'cluster-observability-operator',
operatorName: 'Cluster Observability Operator',
config: {
Expand Down
4 changes: 2 additions & 2 deletions web/cypress/e2e/incidents/00.coo_incidents_e2e.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { incidentsPage } from '../../views/incidents-page';

// Set constants for the operators that need to be installed for tests.
const MCP = {
namespace: 'openshift-cluster-observability-operator',
namespace: Cypress.env('COO_NAMESPACE'),
packageName: 'cluster-observability-operator',
operatorName: 'Cluster Observability Operator',
config: {
Expand All @@ -17,7 +17,7 @@ const MCP = {
};

const MP = {
namespace: 'openshift-monitoring',
namespace: Cypress.env('COO_NAMESPACE'),
operatorName: 'Cluster Monitoring Operator',
};

Expand Down
4 changes: 2 additions & 2 deletions web/cypress/e2e/incidents/01.incidents.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { commonPages } from '../../views/common';
import { incidentsPage } from '../../views/incidents-page';

const MCP = {
namespace: 'openshift-cluster-observability-operator',
namespace: Cypress.env('COO_NAMESPACE'),
packageName: 'cluster-observability-operator',
operatorName: 'Cluster Observability Operator',
config: {
Expand All @@ -22,7 +22,7 @@ const MCP = {
};

const MP = {
namespace: 'openshift-monitoring',
namespace: Cypress.env('COO_NAMESPACE'),
operatorName: 'Cluster Monitoring Operator',
};

Expand Down
4 changes: 2 additions & 2 deletions web/cypress/e2e/incidents/02.incidents-mocking-example.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { incidentsPage } from '../../views/incidents-page';
import { IncidentDefinition } from '../../support/incidents_prometheus_query_mocks';

const MCP = {
namespace: 'openshift-cluster-observability-operator',
namespace: Cypress.env('COO_NAMESPACE'),
packageName: 'cluster-observability-operator',
operatorName: 'Cluster Observability Operator',
config: {
Expand All @@ -22,7 +22,7 @@ const MCP = {
};

const MP = {
namespace: 'openshift-monitoring',
namespace: Cypress.env('COO_NAMESPACE'),
operatorName: 'Cluster Monitoring Operator',
};

Expand Down
4 changes: 2 additions & 2 deletions web/cypress/e2e/incidents/regression/01.reg_filtering.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Verifies: OU-727
import { incidentsPage } from '../../../views/incidents-page';

const MCP = {
namespace: 'openshift-cluster-observability-operator',
namespace: Cypress.env('COO_NAMESPACE'),
packageName: 'cluster-observability-operator',
operatorName: 'Cluster Observability Operator',
config: {
Expand All @@ -21,7 +21,7 @@ const MCP = {
};

const MP = {
namespace: 'openshift-monitoring',
namespace: Cypress.env('COO_NAMESPACE'),
operatorName: 'Cluster Monitoring Operator',
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function verifyTooltipPositioning(
}

const MCP = {
namespace: 'openshift-cluster-observability-operator',
namespace: Cypress.env('COO_NAMESPACE'),
packageName: 'cluster-observability-operator',
operatorName: 'Cluster Observability Operator',
config: {
Expand All @@ -55,7 +55,7 @@ const MCP = {
};

const MP = {
namespace: 'openshift-monitoring',
namespace: Cypress.env('COO_NAMESPACE'),
operatorName: 'Cluster Monitoring Operator',
};

Expand Down
4 changes: 2 additions & 2 deletions web/cypress/e2e/incidents/regression/03.reg_api_calls.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Verifies: OU-1020, OU-706
import { incidentsPage } from '../../../views/incidents-page';

const MCP = {
namespace: 'openshift-cluster-observability-operator',
namespace: Cypress.env('COO_NAMESPACE'),
packageName: 'cluster-observability-operator',
operatorName: 'Cluster Observability Operator',
config: {
Expand All @@ -22,7 +22,7 @@ const MCP = {
};

const MP = {
namespace: 'openshift-monitoring',
namespace: Cypress.env('COO_NAMESPACE'),
operatorName: 'Cluster Monitoring Operator',
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Test cases:
import { incidentsPage } from '../../../views/incidents-page';

const MCP = {
namespace: 'openshift-cluster-observability-operator',
namespace: Cypress.env('COO_NAMESPACE'),
packageName: 'cluster-observability-operator',
operatorName: 'Cluster Observability Operator',
config: {
Expand All @@ -26,7 +26,7 @@ const MCP = {
};

const MP = {
namespace: 'openshift-monitoring',
namespace: Cypress.env('COO_NAMESPACE'),
operatorName: 'Cluster Monitoring Operator',
};

Expand Down
10 changes: 6 additions & 4 deletions web/cypress/fixtures/coo/coo_stage.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
#!/bin/bash
echo COO install through FBC

COO_NAMESPACE="${CYPRESS_COO_NAMESPACE:-openshift-cluster-observability-operator}"

oc apply -f - <<EOF
apiVersion: v1
kind: Namespace
metadata:
labels:
openshift.io/cluster-monitoring: "true"
name: openshift-cluster-observability-operator
name: ${COO_NAMESPACE}
EOF

oc apply -f - <<EOF
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
namespace: openshift-cluster-observability-operator
namespace: ${COO_NAMESPACE}
name: og-global
labels:
og_label: openshift-cluster-observability-operator
og_label: ${COO_NAMESPACE}
spec:
upgradeStrategy: Default
EOF
Expand Down Expand Up @@ -65,7 +67,7 @@ metadata:
labels:
operators.coreos.com/observability-operator.openshift-operators: ""
name: cluster-observability-operator
namespace: openshift-cluster-observability-operator
namespace: ${COO_NAMESPACE}
spec:
channel: stable
installPlanApproval: Automatic
Expand Down
3 changes: 3 additions & 0 deletions web/cypress/fixtures/export.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ export CYPRESS_KUBECONFIG_PATH=~/Downloads/kubeconfig
# Set the following var to use custom Monitoring Plugin image (that goes on Cluster Monitoring Operator). The image will be patched in CMO CSV.
export CYPRESS_MP_IMAGE=<Monitoring Plugin image>

# Set the following var to specify the Cluster Observability Operator namespace (defaults to openshift-cluster-observability-operator if not set)
export CYPRESS_COO_NAMESPACE=openshift-cluster-observability-operator

# Set the var to skip Cluster Observability and all the required operators installation.
export CYPRESS_SKIP_COO_INSTALL=false

Expand Down
23 changes: 11 additions & 12 deletions web/cypress/support/commands/operator-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ const operatorUtils = {
cy.exec(`oc new-project perses-dev --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`);

cy.log('Create openshift-cluster-sample-dashboard instance.');
cy.exec(`oc apply -f ./cypress/fixtures/coo/openshift-cluster-sample-dashboard.yaml --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`);
cy.exec(`sed 's/namespace: openshift-cluster-observability-operator/namespace: ${MCP.namespace}/g' ./cypress/fixtures/coo/openshift-cluster-sample-dashboard.yaml | oc apply -f - --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`);

cy.log('Create perses-dashboard-sample instance.');
cy.exec(`oc apply -f ./cypress/fixtures/coo/perses-dashboard-sample.yaml --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`);
Expand Down Expand Up @@ -342,7 +342,7 @@ const operatorUtils = {
});

cy.exec(
`sleep 15 && oc wait --for=jsonpath='{.metadata.name}'=health-analyzer --timeout=60s servicemonitor/health-analyzer --namespace=openshift-cluster-observability-operator -n ${MCP.namespace} --timeout=60s --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`,
`sleep 15 && oc wait --for=jsonpath='{.metadata.name}'=health-analyzer --timeout=60s servicemonitor/health-analyzer -n ${MCP.namespace} --timeout=60s --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`,
{
timeout: readyTimeoutMilliseconds,
failOnNonZeroExit: true
Expand Down Expand Up @@ -407,39 +407,38 @@ const operatorUtils = {

cy.log('Delete Monitoring UI Plugin instance.');
cy.executeAndDelete(
`oc delete ${config.kind} ${config.name} --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`,
`oc delete ${config.kind} ${config.name} --ignore-not-found --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`,
);

// Common cleanup steps
cy.log('Remove openshift-cluster-sample-dashboard instance.');
cy.executeAndDelete(`oc delete -f ./cypress/fixtures/coo/openshift-cluster-sample-dashboard.yaml --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`);
cy.executeAndDelete(`sed 's/namespace: openshift-cluster-observability-operator/namespace: ${MCP.namespace}/g' ./cypress/fixtures/coo/openshift-cluster-sample-dashboard.yaml | oc delete -f - --ignore-not-found --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`);

cy.log('Remove perses-dashboard-sample instance.');
cy.executeAndDelete(`oc delete -f ./cypress/fixtures/coo/perses-dashboard-sample.yaml --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`);
cy.executeAndDelete(`oc delete -f ./cypress/fixtures/coo/perses-dashboard-sample.yaml --ignore-not-found --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`);

cy.log('Remove prometheus-overview-variables instance.');
cy.executeAndDelete(`oc delete -f ./cypress/fixtures/coo/prometheus-overview-variables.yaml --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`);
cy.executeAndDelete(`oc delete -f ./cypress/fixtures/coo/prometheus-overview-variables.yaml --ignore-not-found --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`);

cy.log('Remove thanos-compact-overview-1var instance.');
cy.executeAndDelete(`oc delete -f ./cypress/fixtures/coo/thanos-compact-overview-1var.yaml --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`);
cy.executeAndDelete(`oc delete -f ./cypress/fixtures/coo/thanos-compact-overview-1var.yaml --ignore-not-found --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`);

cy.log('Remove Thanos Querier instance.');
cy.executeAndDelete(`oc delete -f ./cypress/fixtures/coo/thanos-querier-datasource.yaml --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`);
cy.executeAndDelete(`oc delete -f ./cypress/fixtures/coo/thanos-querier-datasource.yaml --ignore-not-found --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`);

cy.log('Remove perses-dev namespace');
cy.executeAndDelete(`oc delete namespace perses-dev --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`);
cy.executeAndDelete(`oc delete namespace perses-dev --ignore-not-found --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`);

// Additional cleanup only when COO is installed
if (!Cypress.env('SKIP_COO_INSTALL')) {
cy.log('Remove Cluster Observability Operator namespace');
cy.executeAndDelete(`oc delete namespace ${MCP.namespace} --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`);
cy.executeAndDelete(`oc delete namespace ${MCP.namespace} --ignore-not-found --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`);
}
},

RemoveClusterAdminRole(): void {
cy.log('Remove cluster-admin role from user.');
cy.executeAndDelete(
`oc adm policy remove-cluster-role-from-user cluster-admin ${Cypress.env('LOGIN_USERNAME')} --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`,
`oc adm policy remove-cluster-role-from-user cluster-admin ${Cypress.env('LOGIN_USERNAME')} --ignore-not-found --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`,
);
},

Expand Down
16 changes: 8 additions & 8 deletions web/cypress/support/commands/virtualization-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,30 +151,30 @@ const virtualizationUtils = {
//https://docs.redhat.com/en/documentation/openshift_container_platform/4.19/html/virtualization/installing#virt-deleting-virt-cli_uninstalling-virt

cy.log('Delete Hyperconverged instance.');
cy.executeAndDelete(`oc patch hyperconverged.hco.kubevirt.io/kubevirt-hyperconverged -n ${KBV.namespace} -p '{"metadata":{"finalizers":[]}}' --type=merge --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`);
cy.executeAndDelete(`oc patch hyperconverged.hco.kubevirt.io/kubevirt-hyperconverged -n ${KBV.namespace} -p '{"metadata":{"finalizers":[]}}' --type=merge --ignore-not-found --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`);

cy.executeAndDelete(`oc patch kubevirt.kubevirt.io/kubevirt -n ${KBV.namespace} --type=merge -p '{"metadata":{"finalizers":[]}}' --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`);
cy.executeAndDelete(`oc patch kubevirt.kubevirt.io/kubevirt -n ${KBV.namespace} --type=merge -p '{"metadata":{"finalizers":[]}}' --ignore-not-found --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`);

cy.executeAndDelete(`oc delete HyperConverged kubevirt-hyperconverged -n ${KBV.namespace} --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`);
cy.executeAndDelete(`oc delete HyperConverged kubevirt-hyperconverged -n ${KBV.namespace} --ignore-not-found --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`);

cy.log('Remove Openshift Virtualization subscription');
cy.executeAndDelete(`oc delete subscription ${config.name} -n ${KBV.namespace} --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`);
cy.executeAndDelete(`oc delete subscription ${config.name} -n ${KBV.namespace} --ignore-not-found --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`);

cy.log('Remove Openshift Virtualization CSV');
cy.executeAndDelete(`oc delete csv -n ${KBV.namespace} -l operators.coreos.com/kubevirt-hyperconverged.openshift-cnv --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`,
cy.executeAndDelete(`oc delete csv -n ${KBV.namespace} -l operators.coreos.com/kubevirt-hyperconverged.openshift-cnv --ignore-not-found --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`,
);

cy.log('Remove Openshift Virtualization namespace');
cy.executeAndDelete(`oc delete namespace ${KBV.namespace} --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`);
cy.executeAndDelete(`oc delete namespace ${KBV.namespace} --ignore-not-found --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`);

cy.log('Delete Hyperconverged CRD instance.');
cy.executeAndDelete(
`oc delete crd --dry-run=client -l operators.coreos.com/kubevirt-hyperconverged.openshift-cnv --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`,
`oc delete crd --dry-run=client -l operators.coreos.com/kubevirt-hyperconverged.openshift-cnv --ignore-not-found --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`,
);

cy.log('Delete Kubevirt instance.');
cy.executeAndDelete(
`oc delete crd -l operators.coreos.com/kubevirt-hyperconverged.openshift-cnv --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`,
`oc delete crd -l operators.coreos.com/kubevirt-hyperconverged.openshift-cnv --ignore-not-found --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`,
);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export function createIncidentMock(
endpoint: 'metrics',
instance: '10.128.0.134:8443',
job: 'health-analyzer',
namespace: 'openshift-cluster-observability-operator',
namespace: Cypress.env('COO_NAMESPACE'),
pod: 'health-analyzer-55fc4cbbb6-5gjcv',
prometheus: 'openshift-monitoring/k8s',
service: 'health-analyzer'
Expand Down