@@ -407,8 +407,9 @@ func TestReconcile_InstallsWhenNil(t *testing.T) {
407407 },
408408 }
409409 infra := createTestInfrastructure (configv1 .HighlyAvailableTopologyMode )
410+ operatorNs := createTestNamespace (OperatorNamespace )
410411
411- client := fake .NewClientBuilder ().WithScheme (scheme ).WithObjects (network , infra ).Build ()
412+ client := fake .NewClientBuilder ().WithScheme (scheme ).WithObjects (network , infra , operatorNs ).Build ()
412413
413414 r := & ReconcileObservability {
414415 client : client ,
@@ -422,12 +423,6 @@ func TestReconcile_InstallsWhenNil(t *testing.T) {
422423 // This will fail because the manifest doesn't exist, which proves it tried to install
423424 g .Expect (err ).To (HaveOccurred ())
424425 g .Expect (err .Error ()).To (ContainSubstring ("failed to read" ))
425-
426- // Verify that the operator namespace was created despite the error
427- ns := & corev1.Namespace {}
428- nsErr := client .Get (context .TODO (), types.NamespacedName {Name : OperatorNamespace }, ns )
429- g .Expect (nsErr ).NotTo (HaveOccurred ())
430- g .Expect (ns .Name ).To (Equal (OperatorNamespace ))
431426}
432427
433428func TestReconcile_SkipsInstallWhenNilOnSNO (t * testing.T ) {
@@ -1115,12 +1110,6 @@ func TestReconcile_PartialFailure_OperatorInstallFails(t *testing.T) {
11151110
11161111 // Should fail at operator installation
11171112 g .Expect (err ).To (HaveOccurred ())
1118-
1119- // Verify that namespace was created despite operator install failure
1120- ns := & corev1.Namespace {}
1121- nsErr := client .Get (context .TODO (), types.NamespacedName {Name : OperatorNamespace }, ns )
1122- g .Expect (nsErr ).NotTo (HaveOccurred ())
1123- g .Expect (ns .Name ).To (Equal (OperatorNamespace ))
11241113}
11251114
11261115// TestReconcile_RecoveryAfterOperatorBecomesReady tests that reconciliation
@@ -1173,71 +1162,6 @@ func TestReconcile_RecoveryAfterOperatorBecomesReady(t *testing.T) {
11731162 g .Expect (err2 .Error ()).To (ContainSubstring ("failed to read" ))
11741163}
11751164
1176- // TestReconcile_NamespaceCreation tests namespace creation logic
1177- func TestReconcile_NamespaceCreation (t * testing.T ) {
1178- g := NewGomegaWithT (t )
1179-
1180- scheme := runtime .NewScheme ()
1181- _ = configv1 .AddToScheme (scheme )
1182- _ = corev1 .AddToScheme (scheme )
1183-
1184- network := createTestNetwork ("cluster" , "InstallAndEnable" )
1185-
1186- client := fake .NewClientBuilder ().WithScheme (scheme ).
1187- WithObjects (network ).
1188- Build ()
1189-
1190- r := & ReconcileObservability {
1191- client : client ,
1192- status : newMockStatusManager (),
1193- }
1194-
1195- req := ctrl.Request {NamespacedName : types.NamespacedName {Name : "cluster" }}
1196-
1197- // Reconciliation will fail, but should create the operator namespace first
1198- _ , _ = r .Reconcile (context .TODO (), req )
1199-
1200- // Verify operator namespace was created
1201- ns := & corev1.Namespace {}
1202- err := client .Get (context .TODO (), types.NamespacedName {Name : OperatorNamespace }, ns )
1203- g .Expect (err ).NotTo (HaveOccurred ())
1204- g .Expect (ns .Name ).To (Equal (OperatorNamespace ))
1205- }
1206-
1207- // TestReconcile_NamespaceAlreadyExists tests that reconciliation
1208- // handles pre-existing namespaces gracefully
1209- func TestReconcile_NamespaceAlreadyExists (t * testing.T ) {
1210- g := NewGomegaWithT (t )
1211-
1212- scheme := runtime .NewScheme ()
1213- _ = configv1 .AddToScheme (scheme )
1214- _ = corev1 .AddToScheme (scheme )
1215-
1216- network := createTestNetwork ("cluster" , "InstallAndEnable" )
1217- // Namespace already exists
1218- operatorNs := createTestNamespace (OperatorNamespace )
1219-
1220- client := fake .NewClientBuilder ().WithScheme (scheme ).
1221- WithObjects (network , operatorNs ).
1222- Build ()
1223-
1224- r := & ReconcileObservability {
1225- client : client ,
1226- status : newMockStatusManager (),
1227- }
1228-
1229- req := ctrl.Request {NamespacedName : types.NamespacedName {Name : "cluster" }}
1230-
1231- // Reconciliation should handle existing namespace gracefully
1232- _ , _ = r .Reconcile (context .TODO (), req )
1233-
1234- // Verify namespace still exists
1235- ns := & corev1.Namespace {}
1236- err := client .Get (context .TODO (), types.NamespacedName {Name : OperatorNamespace }, ns )
1237- g .Expect (err ).NotTo (HaveOccurred ())
1238- g .Expect (ns .Name ).To (Equal (OperatorNamespace ))
1239- }
1240-
12411165// Performance/Stress Tests
12421166
12431167// TestReconcile_ConcurrentReconciliations tests that multiple concurrent
0 commit comments