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
56 changes: 56 additions & 0 deletions web/cypress/e2e/coo/02.acm_alerting_ui.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// 02.acm_alerting_ui.cy.ts
// E2E test for validating ACM Alerting UI integration with Cluster Observability Operator (COO)
import { commonPages } from '../../views/common';
import { nav } from '../../views/nav';

const MCP = {
namespace: 'openshift-cluster-observability-operator',
packageName: 'cluster-observability-operator',
operatorName: 'Cluster Observability Operator',
config: {
kind: 'UIPlugin',
name: 'monitoring',
},
};

const MP = {
namespace: 'openshift-monitoring',
operatorName: 'Cluster Monitoring Operator',
};

describe('ACM Alerting UI', () => {
before(() => {
cy.beforeBlockCOO(MCP, MP);
cy.log('=== [Setup] Installing ACM operator and MultiCluster Observability ===');
// install acm through shell script
cy.exec('bash ./cypress/fixtures/coo/acm-install.sh', {
env: { KUBECONFIG: Cypress.env('KUBECONFIG_PATH'), },
failOnNonZeroExit: false,
timeout: 600000, // long time script
});
// update UIPlugin with the acm related content, (OCP enabled since installed from operatorHub)
cy.exec(`oc apply -f ./cypress/fixtures/coo/acm-uiplugin.yaml --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`);
// add thanos-ruler-custom-rules
cy.exec(`oc apply -f ./cypress/fixtures/coo/acm-alerrule-test.yaml --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`);
});

it('Admin perspective - Observe Menu', () => {
//cy.visit('/');
nav.sidenav.clickNavLink(['Observe', 'Alerting']);
commonPages.titleShouldHaveText('Alerting');

// TO DO:
// Fleet Management => local-cluster => Observe => Alerting

cy.log('✅ ACM Alerting UI test completed successfully');
});

after(() => {
cy.log('=== [Teardown] Uninstalling ACM operator and cleaning up ===');
cy.exec('bash ./cypress/fixtures/coo/acm-uninstall.sh', {
env: { KUBECONFIG: Cypress.env('KUBECONFIG_PATH') },
failOnNonZeroExit: false,
timeout: 600000,
});
});
});
42 changes: 42 additions & 0 deletions web/cypress/fixtures/coo/acm-alerrule-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: thanos-ruler-custom-rules
namespace: open-cluster-management-observability
data:
custom_rules.yaml: |
groups:
- name: alertrule-testing
rules:
- alert: Watchdog
annotations:
summary: An alert that should always be firing to certify that Alertmanager is working properly.
description: This is an alert meant to ensure that the entire alerting pipeline is functional.
expr: vector(1)
labels:
instance: "local"
cluster: "local"
clusterID: "111111111"
severity: info
- alert: Watchdog-spoke
annotations:
summary: An alert that should always be firing to certify that Alertmanager is working properly.
description: This is an alert meant to ensure that the entire alerting pipeline is functional.
expr: vector(1)
labels:
instance: "spoke"
cluster: "spoke"
clusterID: "22222222"
severity: warn
- name: cluster-health
rules:
- alert: ClusterCPUHealth-jb
annotations:
summary: Notify when CPU utilization on a cluster is greater than the defined utilization limit
description: "The cluster has a high CPU usage: core for"
expr: |
max(cluster:cpu_usage_cores:sum) by (clusterID, cluster, prometheus) > 0
labels:
cluster: "{{ $labels.cluster }}"
prometheus: "{{ $labels.prometheus }}"
severity: critical
168 changes: 168 additions & 0 deletions web/cypress/fixtures/coo/acm-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
#!/bin/bash
set -eux
oc patch Scheduler cluster --type='json' -p '[{ "op": "replace", "path": "/spec/mastersSchedulable", "value": true }]'

oc apply -f - <<EOF
apiVersion: v1
kind: Namespace
metadata:
name: open-cluster-management
---
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
namespace: open-cluster-management
name: og-global
labels:
og_label: open-cluster-management
spec:
targetNamespaces:
- open-cluster-management
upgradeStrategy: Default
EOF
oc apply -f - <<EOF
---
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
labels:
operators.coreos.com/advanced-cluster-management.open-cluster-management: ""
name: advanced-cluster-management
namespace: open-cluster-management
spec:
installPlanApproval: Automatic
name: advanced-cluster-management
source: redhat-operators
sourceNamespace: openshift-marketplace
---
EOF
tries=30
while [[ $tries -gt 0 ]] &&
! oc -n open-cluster-management rollout status deploy/multiclusterhub-operator; do
sleep 10
((tries--))
done
oc wait -n open-cluster-management --for=condition=Available deploy/multiclusterhub-operator --timeout=300s
oc apply -f - <<EOF
apiVersion: operator.open-cluster-management.io/v1
kind: MultiClusterHub
metadata:
name: multiclusterhub
namespace: open-cluster-management
spec: {}
EOF
sleep 5m
oc wait -n open-cluster-management --for=condition=Available deploy/search-api --timeout=300s
oc wait -n open-cluster-management --for=condition=Available deploy/search-collector --timeout=300s
oc wait -n open-cluster-management --for=condition=Available deploy/search-indexer --timeout=300s
oc -n open-cluster-management get pod
#create multi-cluster
oc create ns open-cluster-management-observability || true
oc apply -f -<<EOF
apiVersion: apps/v1
kind: Deployment
metadata:
name: minio
namespace: open-cluster-management-observability
labels:
app.kubernetes.io/name: minio
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: minio
strategy:
type: Recreate
template:
metadata:
labels:
app.kubernetes.io/name: minio
spec:
containers:
- command:
- /bin/sh
- -c
- mkdir -p /storage/thanos && /usr/bin/minio server /storage
env:
- name: MINIO_ACCESS_KEY
value: minio
- name: MINIO_SECRET_KEY
value: minio123
image: quay.io/minio/minio:RELEASE.2021-08-25T00-41-18Z
name: minio
ports:
- containerPort: 9000
protocol: TCP
volumeMounts:
- mountPath: /storage
name: storage
volumes:
- name: storage
persistentVolumeClaim:
claimName: minio
EOF
oc apply -f - <<EOF
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
labels:
app.kubernetes.io/name: minio
name: minio
namespace: open-cluster-management-observability
spec:
storageClassName: gp3-csi
accessModes:
- ReadWriteOnce
resources:
requests:
storage: "1Gi"
EOF
oc apply -f - <<EOF
apiVersion: v1
stringData:
thanos.yaml: |
type: s3
config:
bucket: "thanos"
endpoint: "minio:9000"
insecure: true
access_key: "minio"
secret_key: "minio123"
kind: Secret
metadata:
name: thanos-object-storage
namespace: open-cluster-management-observability
type: Opaque
EOF
oc apply -f -<<EOF
apiVersion: v1
kind: Service
metadata:
name: minio
namespace: open-cluster-management-observability
spec:
ports:
- port: 9000
protocol: TCP
targetPort: 9000
selector:
app.kubernetes.io/name: minio
type: ClusterIP
EOF
oc wait -n open-cluster-management-observability --for=condition=Available deploy/minio --timeout=300s
oc apply -f - <<EOF
apiVersion: observability.open-cluster-management.io/v1beta2
kind: MultiClusterObservability
metadata:
name: observability
spec:
observabilityAddonSpec: {}
storageConfig:
metricObjectStorage:
name: thanos-object-storage
key: thanos.yaml
EOF
sleep 1m
oc wait --for=condition=Ready pod -l alertmanager=observability,app=multicluster-observability-alertmanager -n open-cluster-management-observability --timeout=300s
oc -n open-cluster-management-observability get pod
oc -n open-cluster-management-observability get svc | grep -E 'alertmanager|rbac-query'
13 changes: 13 additions & 0 deletions web/cypress/fixtures/coo/acm-uiplugin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: observability.openshift.io/v1alpha1
kind: UIPlugin
metadata:
name: monitoring
spec:
monitoring:
acm:
enabled: true
alertmanager:
url: 'https://alertmanager.open-cluster-management-observability.svc:9095'
thanosQuerier:
url: 'https://rbac-query-proxy.open-cluster-management-observability.svc:8443'
type: Monitoring
44 changes: 44 additions & 0 deletions web/cypress/fixtures/coo/acm-uninstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash
set -eux
echo "[ACM Uninstall] Using KUBECONFIG=${KUBECONFIG:-~/.kube/config}"

# --- Step 1: delete MultiClusterObservability ---
echo "[ACM Uninstall] Deleting MultiClusterObservability (MCO)..."
oc delete MultiClusterObservability observability -n open-cluster-management-observability --ignore-not-found=true

# --- Step 2: delete MinIO、PVC、Secret、Service ---
echo "[ACM Uninstall] Cleaning up MinIO and related resources..."
oc delete deploy minio -n open-cluster-management-observability --ignore-not-found=true
oc delete pvc minio -n open-cluster-management-observability --ignore-not-found=true
oc delete secret thanos-object-storage -n open-cluster-management-observability --ignore-not-found=true
oc delete svc minio -n open-cluster-management-observability --ignore-not-found=true

# --- Step 3: delete MultiClusterHub ---
echo "[ACM Uninstall] Deleting MultiClusterHub..."
oc delete MultiClusterHub multiclusterhub -n open-cluster-management --ignore-not-found=true

# wait for MultiClusterHub deleted
echo "[ACM Uninstall] Waiting for MultiClusterHub cleanup..."
oc wait MultiClusterHub multiclusterhub -n open-cluster-management --for=delete --timeout=180s || true

# --- Step 4: delete Subscription and OperatorGroup ---
echo "[ACM Uninstall] Deleting ACM Operator Subscription & OperatorGroup..."
oc delete sub advanced-cluster-management -n open-cluster-management --ignore-not-found=true
oc delete og og-global -n open-cluster-management --ignore-not-found=true

# --- Step 5: delete namespace ---
echo "[ACM Uninstall] Deleting ACM-related namespaces..."
oc delete ns open-cluster-management-observability --ignore-not-found=true
oc delete ns open-cluster-management --ignore-not-found=true

# # --- Step 6: clean up CRDs(optional)---
# echo "[ACM Uninstall] Cleaning up CRDs (optional cleanup)..."
# oc delete crd multiclusterhubs.operator.open-cluster-management.io --ignore-not-found=true
# oc delete crd multiclusterobservabilities.observability.open-cluster-management.io --ignore-not-found=true

# --- Step 7: Pod / Finalizer ---
# echo "[ACM Uninstall] Removing potential finalizers..."
# oc get ns open-cluster-management-observability -o json | jq '.spec.finalizers=[]' | oc replace --raw "/api/v1/namespaces/open-cluster-management-observability/finalize" -f - || true
# oc get ns open-cluster-management -o json | jq '.spec.finalizers=[]' | oc replace --raw "/api/v1/namespaces/open-cluster-management/finalize" -f - || true

echo "[ACM Uninstall] ✅ Completed cleanup."