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
@@ -1,5 +1,5 @@
import { runAllRegressionMetricsTests } from '../../../support/monitoring/02.reg_metrics.cy';
import { runAllRegressionMetricsTestsNamespace } from '../../../support/monitoring/05.reg_metrics_namespace.cy';
import { runAllRegressionMetricsTests1 } from '../../../support/monitoring/02.reg_metrics_1.cy';
import { runAllRegressionMetricsTestsNamespace1 } from '../../../support/monitoring/05.reg_metrics_namespace_1.cy';
import { commonPages } from '../../../views/common';
import { nav } from '../../../views/nav';
import { guidedTour } from '../../../views/tour';
Expand All @@ -26,7 +26,7 @@ describe('Regression: Monitoring - Metrics (Administrator)', { tags: ['@monitori
});

// Run tests in Administrator perspective
runAllRegressionMetricsTests({
runAllRegressionMetricsTests1({
name: 'Administrator',
});

Expand All @@ -49,7 +49,7 @@ describe('Regression: Monitoring - Metrics Namespaced (Administrator)', { tags:
});

// Run tests in Administrator perspective
runAllRegressionMetricsTestsNamespace({
runAllRegressionMetricsTestsNamespace1({
name: 'Administrator',
});

Expand Down
57 changes: 57 additions & 0 deletions web/cypress/e2e/monitoring/regression/02.reg_metrics_admin_2.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { runAllRegressionMetricsTests2 } from '../../../support/monitoring/02.reg_metrics_2.cy';
import { runAllRegressionMetricsTestsNamespace2 } from '../../../support/monitoring/05.reg_metrics_namespace_2.cy';
import { commonPages } from '../../../views/common';
import { nav } from '../../../views/nav';
import { guidedTour } from '../../../views/tour';

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

// Test suite for Administrator perspective
describe('Regression: Monitoring - Metrics (Administrator)', { tags: ['@monitoring', '@metrics'] }, () => {

before(() => {
cy.beforeBlock(MP);
});

beforeEach(() => {
cy.visit('/');
guidedTour.close();
cy.validateLogin();
nav.sidenav.clickNavLink(['Observe', 'Metrics']);
commonPages.titleShouldHaveText('Metrics');
cy.changeNamespace("All Projects");
});

// Run tests in Administrator perspective
runAllRegressionMetricsTests2({
name: 'Administrator',
});

});

// Test suite for Administrator perspective
describe('Regression: Monitoring - Metrics Namespaced (Administrator)', { tags: ['@monitoring', '@metrics'] }, () => {

before(() => {
cy.beforeBlock(MP);
});

beforeEach(() => {
cy.visit('/');
guidedTour.close();
cy.validateLogin();
nav.sidenav.clickNavLink(['Observe', 'Metrics']);
commonPages.titleShouldHaveText('Metrics');
cy.changeNamespace(MP.namespace);
});

// Run tests in Administrator perspective
runAllRegressionMetricsTestsNamespace2({
name: 'Administrator',
});

});

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { alerts } from '../../fixtures/monitoring/alert';
import { runAllRegressionMetricsTests } from '../../support/monitoring/02.reg_metrics.cy';
import { runAllRegressionMetricsTestsNamespace } from '../../support/monitoring/05.reg_metrics_namespace.cy';
import { runAllRegressionMetricsTests1 } from '../../support/monitoring/02.reg_metrics_1.cy';
import { runAllRegressionMetricsTestsNamespace1 } from '../../support/monitoring/05.reg_metrics_namespace_1.cy';
import { commonPages } from '../../views/common';
import { nav } from '../../views/nav';
import { guidedTour } from '../../views/tour';
Expand Down Expand Up @@ -71,7 +71,7 @@ describe('Regression: Monitoring - Metrics (Virtualization)', { tags: ['@virtual
alerts.getWatchdogAlert();
});

runAllRegressionMetricsTests({
runAllRegressionMetricsTests1({
name: 'Virtualization',
});

Expand All @@ -91,7 +91,7 @@ describe('Regression: Monitoring - Metrics Namespaced (Virtualization)', { tags:
alerts.getWatchdogAlert();
});

runAllRegressionMetricsTestsNamespace({
runAllRegressionMetricsTestsNamespace1({
name: 'Virtualization',
});

Expand Down
98 changes: 98 additions & 0 deletions web/cypress/e2e/virtualization/02.coo_ivt_metrics_2.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import { alerts } from '../../fixtures/monitoring/alert';
import { runAllRegressionMetricsTests2 } from '../../support/monitoring/02.reg_metrics_2.cy';
import { runAllRegressionMetricsTestsNamespace2 } from '../../support/monitoring/05.reg_metrics_namespace_2.cy';
import { commonPages } from '../../views/common';
import { nav } from '../../views/nav';
import { guidedTour } from '../../views/tour';

// Set constants for the operators that need to be installed for tests.
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',
};

const KBV = {
namespace: 'openshift-cnv',
packageName: 'kubevirt-hyperconverged',
config: {
kind: 'HyperConverged',
name: 'kubevirt-hyperconverged',
},
crd: {
kubevirt: 'kubevirts.kubevirt.io',
hyperconverged: 'hyperconvergeds.hco.kubevirt.io',
}
};

describe('Installation: COO and setting up Monitoring Plugin', { tags: ['@virtualization', '@slow'] }, () => {

before(() => {
cy.beforeBlockCOO(MCP, MP);
});

it('1. Installation: COO and setting up Monitoring Plugin', () => {
cy.log('Installation: COO and setting up Monitoring Plugin');
});
});

describe('IVT: Monitoring UIPlugin + Virtualization', { tags: ['@virtualization', '@slow'] }, () => {

before(() => {
cy.beforeBlockVirtualization(KBV);
});

it('1. Virtualization perspective - Observe Menu', () => {
cy.log('Virtualization perspective - Observe Menu and verify all submenus');
cy.switchPerspective('Virtualization');
guidedTour.closeKubevirtTour();
});
});

describe('Regression: Monitoring - Metrics (Virtualization)', { tags: ['@virtualization', '@metrics'] }, () => {

beforeEach(() => {
cy.visit('/');
cy.validateLogin();
cy.switchPerspective('Virtualization');
guidedTour.closeKubevirtTour();
alerts.getWatchdogAlert();
nav.sidenav.clickNavLink(['Observe', 'Metrics']);
commonPages.titleShouldHaveText('Metrics');
cy.changeNamespace("All Projects");
alerts.getWatchdogAlert();
});

runAllRegressionMetricsTests2({
name: 'Virtualization',
});

});

describe('Regression: Monitoring - Metrics Namespaced (Virtualization)', { tags: ['@virtualization', '@metrics'] }, () => {

beforeEach(() => {
cy.visit('/');
cy.validateLogin();
cy.switchPerspective('Virtualization');
guidedTour.closeKubevirtTour();
alerts.getWatchdogAlert();
nav.sidenav.clickNavLink(['Observe', 'Metrics']);
commonPages.titleShouldHaveText('Metrics');
cy.changeNamespace(MP.namespace);
alerts.getWatchdogAlert();
});

runAllRegressionMetricsTestsNamespace2({
name: 'Virtualization',
});

});
82 changes: 82 additions & 0 deletions web/cypress/fixtures/coo/force_delete_ns.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/bin/bash

# Script to force-delete a Kubernetes Namespace stuck in a 'Terminating' state
# by automatically clearing its finalizers using sed and tr (instead of jq).

NAMESPACE=$1
KUBECONFIG_PATH=$2

echo "NAMESPACE: $NAMESPACE"
echo "KUBECONFIG_PATH: $KUBECONFIG_PATH"

# --- Input Validation ---
if [ -z "$NAMESPACE" ]; then
echo "Error: Please provide the namespace name as the first argument."
echo "Usage: ./force-delete-ns.sh <namespace-name> [kubeconfig-path]"
exit 1
fi

# Build kubeconfig flag if provided
KUBECONFIG_FLAG=""
if [ -n "$KUBECONFIG_PATH" ]; then
KUBECONFIG_FLAG="--kubeconfig $KUBECONFIG_PATH"
fi

# Check if the namespace exists
if ! oc get namespace "$NAMESPACE" $KUBECONFIG_FLAG &> /dev/null; then
echo "Namespace '$NAMESPACE' not found or already deleted."
exit 0
fi

echo "Attempting to force-delete namespace '$NAMESPACE' by removing finalizers..."

# Step 1: Remove finalizers from common problematic resources
echo "Checking for resources with finalizers in namespace '$NAMESPACE'..."
# Focus on common resources that have finalizers (much faster than checking everything)
RESOURCE_TYPES="perses,persesdashboard,persistentvolumeclaims,pods,services,deployments,statefulsets,daemonsets"

for resource_type in $(echo $RESOURCE_TYPES | tr ',' ' '); do
oc get "$resource_type" -n "$NAMESPACE" $KUBECONFIG_FLAG -o name 2>/dev/null | \
while read -r item; do
if [ -n "$item" ]; then
# Check if the resource has finalizers
HAS_FINALIZERS=$(oc get "$item" -n "$NAMESPACE" $KUBECONFIG_FLAG -o jsonpath='{.metadata.finalizers}' 2>/dev/null || echo "")
if [ -n "$HAS_FINALIZERS" ] && [ "$HAS_FINALIZERS" != "[]" ]; then
echo " Removing finalizers from $item..."
oc patch "$item" -n "$NAMESPACE" $KUBECONFIG_FLAG --type json -p '[{"op": "remove", "path": "/metadata/finalizers"}]' 2>/dev/null || true
fi
fi
done
done

# Step 2: Remove finalizers from the namespace itself (if it still exists)
# Check if namespace still exists before trying to remove its finalizers
if oc get namespace "$NAMESPACE" $KUBECONFIG_FLAG &> /dev/null; then
# 1. Retrieve the namespace JSON.
# 2. Use 'tr' to remove all newlines, creating a single-line JSON string.
# 3. Use 'sed' to perform a substitution:
# - It finds the pattern "finalizers": [ <anything that is not a closing bracket> ]
# - It replaces the entire pattern with "finalizers": [] (an empty array).
# 4. Pipe the modified JSON directly to the Kubernetes /finalize endpoint.
echo "Removing finalizers from namespace '$NAMESPACE' itself..."
oc get namespace "$NAMESPACE" $KUBECONFIG_FLAG -o json | \
tr -d '\n' | \
sed 's/"finalizers": \[[^]]*\]/"finalizers": []/' | \
oc replace $KUBECONFIG_FLAG --raw "/api/v1/namespaces/$NAMESPACE/finalize" -f -

EXIT_CODE=$?

if [ $EXIT_CODE -eq 0 ]; then
echo ""
echo "✅ Success: Finalizers for namespace '$NAMESPACE' have been cleared."
echo "The Namespace should now be fully deleted. Confirm with: oc get ns"
else
echo ""
echo "❌ Error: The command failed with exit code $EXIT_CODE."
echo "Please check your oc connection and the namespace name."
fi
else
echo ""
echo "✅ Success: Namespace '$NAMESPACE' was already deleted after removing resource finalizers."
EXIT_CODE=0
fi
Loading