From 52b5ef6d34de5ea048ee6e56d7ab62cb2b89119b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20He=C3=9Felmann?= Date: Tue, 7 Nov 2023 14:58:31 +0100 Subject: [PATCH 1/4] disable OpenShift monitoring for internal Centrals --- .../pkg/central/reconciler/reconciler.go | 17 +++++ .../pkg/central/reconciler/reconciler_test.go | 76 ++++++++++++++++++- 2 files changed, 92 insertions(+), 1 deletion(-) diff --git a/fleetshard/pkg/central/reconciler/reconciler.go b/fleetshard/pkg/central/reconciler/reconciler.go index da59818eb1..f2f637b317 100644 --- a/fleetshard/pkg/central/reconciler/reconciler.go +++ b/fleetshard/pkg/central/reconciler/reconciler.go @@ -286,6 +286,7 @@ func (r *CentralReconciler) applyCentralConfig(remoteCentral *private.ManagedCen r.applyProxyConfig(central) r.applyDeclarativeConfig(central) r.applyAnnotations(central) + r.applyMonitoring(remoteCentral, central) return nil } @@ -359,6 +360,22 @@ func (r *CentralReconciler) applyTelemetry(remoteCentral *private.ManagedCentral central.Spec.Central.Telemetry = telemetry } +func (r *CentralReconciler) applyMonitoring(remoteCentral *private.ManagedCentral, central *v1alpha1.Central) { + if central.Spec.Central == nil { + central.Spec.Central = &v1alpha1.CentralComponentSpec{} + } + // Disable OpenShift monitoring for internal Centrals to avoid overloading Telemeter with probe service metrics. + if remoteCentral.Metadata.Internal { + if central.Spec.Monitoring == nil { + central.Spec.Monitoring = &v1alpha1.GlobalMonitoring{} + } + if central.Spec.Monitoring.OpenShiftMonitoring == nil { + central.Spec.Monitoring.OpenShiftMonitoring = &v1alpha1.OpenShiftMonitoring{} + } + central.Spec.Monitoring.OpenShiftMonitoring.Enabled = false + } +} + func (r *CentralReconciler) restoreCentralSecrets(ctx context.Context, remoteCentral private.ManagedCentral) error { restoreSecrets := []string{} for _, secretName := range remoteCentral.Metadata.SecretsStored { // pragma: allowlist secret diff --git a/fleetshard/pkg/central/reconciler/reconciler_test.go b/fleetshard/pkg/central/reconciler/reconciler_test.go index 50cedb8134..8716edc9c5 100644 --- a/fleetshard/pkg/central/reconciler/reconciler_test.go +++ b/fleetshard/pkg/central/reconciler/reconciler_test.go @@ -2010,8 +2010,82 @@ func Test_getCentralConfig_telemetry(t *testing.T) { } } -func TestReconciler_applyRoutes(t *testing.T) { +func Test_getCentralConfig_monitoring(t *testing.T) { + type args struct { + isInternal bool + central *v1alpha1.Central + } + + tcs := []struct { + name string + args args + assert func(t *testing.T, c *v1alpha1.Central) + }{ + { + name: "should disable OpenShift monitoring when Central is internal", + args: args{ + isInternal: true, + central: &v1alpha1.Central{ + Spec: v1alpha1.CentralSpec{ + Monitoring: &v1alpha1.GlobalMonitoring{ + OpenShiftMonitoring: &v1alpha1.OpenShiftMonitoring{ + Enabled: true, + }, + }, + }, + }, + }, + assert: func(t *testing.T, c *v1alpha1.Central) { + assert.False(t, c.Spec.Monitoring.OpenShiftMonitoring.Enabled) + }, + }, + { + name: "should disable OpenShift monitoring when not defined and Central is internal", + args: args{ + isInternal: true, + central: &v1alpha1.Central{ + Spec: v1alpha1.CentralSpec{}, + }, + }, + assert: func(t *testing.T, c *v1alpha1.Central) { + assert.False(t, c.Spec.Monitoring.OpenShiftMonitoring.Enabled) + }, + }, + { + name: "should leave OpenShift monitoring enabled when Central is not internal", + args: args{ + isInternal: false, + central: &v1alpha1.Central{ + Spec: v1alpha1.CentralSpec{ + Monitoring: &v1alpha1.GlobalMonitoring{ + OpenShiftMonitoring: &v1alpha1.OpenShiftMonitoring{ + Enabled: true, + }, + }, + }, + }, + }, + assert: func(t *testing.T, c *v1alpha1.Central) { + assert.True(t, c.Spec.Monitoring.OpenShiftMonitoring.Enabled) + }, + }, + } + for _, tc := range tcs { + t.Run(tc.name, func(t *testing.T) { + r := &CentralReconciler{} + mc := &private.ManagedCentral{ + Metadata: private.ManagedCentralAllOfMetadata{ + Internal: tc.args.isInternal, + }, + } + r.applyMonitoring(mc, tc.args.central) + tc.assert(t, tc.args.central) + }) + } +} + +func TestReconciler_applyRoutes(t *testing.T) { type args struct { useRoutes bool } From b936999996998ac356a7330fc73e84ffbec25cf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20He=C3=9Felmann?= Date: Tue, 7 Nov 2023 21:19:29 +0100 Subject: [PATCH 2/4] use gitops template renderer --- .../pkg/central/reconciler/reconciler.go | 17 --- .../pkg/central/reconciler/reconciler_test.go | 75 ----------- internal/dinosaur/pkg/gitops/config.go | 6 +- .../dinosaur/pkg/gitops/default_central.yaml | 3 + .../pkg/gitops/default_central_test.go | 116 +++++++++++++++++- 5 files changed, 120 insertions(+), 97 deletions(-) diff --git a/fleetshard/pkg/central/reconciler/reconciler.go b/fleetshard/pkg/central/reconciler/reconciler.go index f2f637b317..da59818eb1 100644 --- a/fleetshard/pkg/central/reconciler/reconciler.go +++ b/fleetshard/pkg/central/reconciler/reconciler.go @@ -286,7 +286,6 @@ func (r *CentralReconciler) applyCentralConfig(remoteCentral *private.ManagedCen r.applyProxyConfig(central) r.applyDeclarativeConfig(central) r.applyAnnotations(central) - r.applyMonitoring(remoteCentral, central) return nil } @@ -360,22 +359,6 @@ func (r *CentralReconciler) applyTelemetry(remoteCentral *private.ManagedCentral central.Spec.Central.Telemetry = telemetry } -func (r *CentralReconciler) applyMonitoring(remoteCentral *private.ManagedCentral, central *v1alpha1.Central) { - if central.Spec.Central == nil { - central.Spec.Central = &v1alpha1.CentralComponentSpec{} - } - // Disable OpenShift monitoring for internal Centrals to avoid overloading Telemeter with probe service metrics. - if remoteCentral.Metadata.Internal { - if central.Spec.Monitoring == nil { - central.Spec.Monitoring = &v1alpha1.GlobalMonitoring{} - } - if central.Spec.Monitoring.OpenShiftMonitoring == nil { - central.Spec.Monitoring.OpenShiftMonitoring = &v1alpha1.OpenShiftMonitoring{} - } - central.Spec.Monitoring.OpenShiftMonitoring.Enabled = false - } -} - func (r *CentralReconciler) restoreCentralSecrets(ctx context.Context, remoteCentral private.ManagedCentral) error { restoreSecrets := []string{} for _, secretName := range remoteCentral.Metadata.SecretsStored { // pragma: allowlist secret diff --git a/fleetshard/pkg/central/reconciler/reconciler_test.go b/fleetshard/pkg/central/reconciler/reconciler_test.go index 8716edc9c5..c03d65a364 100644 --- a/fleetshard/pkg/central/reconciler/reconciler_test.go +++ b/fleetshard/pkg/central/reconciler/reconciler_test.go @@ -2010,81 +2010,6 @@ func Test_getCentralConfig_telemetry(t *testing.T) { } } -func Test_getCentralConfig_monitoring(t *testing.T) { - type args struct { - isInternal bool - central *v1alpha1.Central - } - - tcs := []struct { - name string - args args - assert func(t *testing.T, c *v1alpha1.Central) - }{ - { - name: "should disable OpenShift monitoring when Central is internal", - args: args{ - isInternal: true, - central: &v1alpha1.Central{ - Spec: v1alpha1.CentralSpec{ - Monitoring: &v1alpha1.GlobalMonitoring{ - OpenShiftMonitoring: &v1alpha1.OpenShiftMonitoring{ - Enabled: true, - }, - }, - }, - }, - }, - assert: func(t *testing.T, c *v1alpha1.Central) { - assert.False(t, c.Spec.Monitoring.OpenShiftMonitoring.Enabled) - }, - }, - { - name: "should disable OpenShift monitoring when not defined and Central is internal", - args: args{ - isInternal: true, - central: &v1alpha1.Central{ - Spec: v1alpha1.CentralSpec{}, - }, - }, - assert: func(t *testing.T, c *v1alpha1.Central) { - assert.False(t, c.Spec.Monitoring.OpenShiftMonitoring.Enabled) - }, - }, - { - name: "should leave OpenShift monitoring enabled when Central is not internal", - args: args{ - isInternal: false, - central: &v1alpha1.Central{ - Spec: v1alpha1.CentralSpec{ - Monitoring: &v1alpha1.GlobalMonitoring{ - OpenShiftMonitoring: &v1alpha1.OpenShiftMonitoring{ - Enabled: true, - }, - }, - }, - }, - }, - assert: func(t *testing.T, c *v1alpha1.Central) { - assert.True(t, c.Spec.Monitoring.OpenShiftMonitoring.Enabled) - }, - }, - } - - for _, tc := range tcs { - t.Run(tc.name, func(t *testing.T) { - r := &CentralReconciler{} - mc := &private.ManagedCentral{ - Metadata: private.ManagedCentralAllOfMetadata{ - Internal: tc.args.isInternal, - }, - } - r.applyMonitoring(mc, tc.args.central) - tc.assert(t, tc.args.central) - }) - } -} - func TestReconciler_applyRoutes(t *testing.T) { type args struct { useRoutes bool diff --git a/internal/dinosaur/pkg/gitops/config.go b/internal/dinosaur/pkg/gitops/config.go index 87950ef0d4..3d8b541ba9 100644 --- a/internal/dinosaur/pkg/gitops/config.go +++ b/internal/dinosaur/pkg/gitops/config.go @@ -72,7 +72,7 @@ func validatePatch(path *field.Path, patch string) field.ErrorList { // tryRenderDummyCentralWithPatch renders a dummy Central instance with the given patch. // useful to test that a patch is valid. func tryRenderDummyCentralWithPatch(patch string) error { - var dummyParams = getDummyCentralParams() + var dummyParams = getDummyCentralParams(false) dummyConfig := Config{ Centrals: CentralsConfig{ Overrides: []CentralOverride{ @@ -89,7 +89,7 @@ func tryRenderDummyCentralWithPatch(patch string) error { return nil } -func getDummyCentralParams() CentralParams { +func getDummyCentralParams(isInternal bool) CentralParams { return CentralParams{ ID: "id", Name: "name", @@ -106,7 +106,7 @@ func getDummyCentralParams() CentralParams { OrganizationID: "organizationId", OrganizationName: "organizationName", InstanceType: "instanceType", - IsInternal: false, + IsInternal: isInternal, } } diff --git a/internal/dinosaur/pkg/gitops/default_central.yaml b/internal/dinosaur/pkg/gitops/default_central.yaml index 4264d0db57..027a043ffd 100644 --- a/internal/dinosaur/pkg/gitops/default_central.yaml +++ b/internal/dinosaur/pkg/gitops/default_central.yaml @@ -55,3 +55,6 @@ spec: memory: 2Gi monitoring: exposeEndpoint: Enabled + monitoring: + openshift: + enabled: {{ not .IsInternal }} diff --git a/internal/dinosaur/pkg/gitops/default_central_test.go b/internal/dinosaur/pkg/gitops/default_central_test.go index 8b01a55413..6c277ebf39 100644 --- a/internal/dinosaur/pkg/gitops/default_central_test.go +++ b/internal/dinosaur/pkg/gitops/default_central_test.go @@ -13,7 +13,7 @@ import ( ) func TestDefaultCentral(t *testing.T) { - p := getDummyCentralParams() + p := getDummyCentralParams(false) central, err := renderDefaultCentral(p) assert.NoError(t, err) @@ -102,7 +102,119 @@ func TestDefaultCentral(t *testing.T) { ExposeEndpoint: &exposeEndpointEnabled, }, }, - Monitoring: nil, + Monitoring: &v1alpha1.GlobalMonitoring{ + OpenShiftMonitoring: &v1alpha1.OpenShiftMonitoring{ + Enabled: true, + }, + }, + }, + } + + // compare yaml + wantBytes, err := yaml.Marshal(wantCentral) + assert.NoError(t, err) + + gotBytes, err := yaml.Marshal(central) + assert.NoError(t, err) + + assert.YAMLEq(t, string(wantBytes), string(gotBytes)) +} + +func TestInternalCentral(t *testing.T) { + p := getDummyCentralParams(true) + central, err := renderDefaultCentral(p) + assert.NoError(t, err) + + exposeEndpointEnabled := v1alpha1.ExposeEndpointEnabled + autoScalingEnabled := v1alpha1.ScannerAutoScalingEnabled + scannerComponentEnabled := v1alpha1.ScannerComponentEnabled + + wantCentral := v1alpha1.Central{ + ObjectMeta: metav1.ObjectMeta{ + Name: p.Name, + Namespace: p.Namespace, + Labels: map[string]string{ + "rhacs.redhat.com/instance-type": p.InstanceType, + "rhacs.redhat.com/org-id": p.OrganizationID, + "rhacs.redhat.com/tenant": p.ID, + }, + Annotations: map[string]string{ + "rhacs.redhat.com/org-name": p.OrganizationName, + "platform.stackrox.io/managed-services": "true", + }, + }, + Spec: v1alpha1.CentralSpec{ + Central: &v1alpha1.CentralComponentSpec{ + AdminPasswordGenerationDisabled: pointers.Bool(true), + Monitoring: &v1alpha1.Monitoring{ + ExposeEndpoint: &exposeEndpointEnabled, + }, + DeploymentSpec: v1alpha1.DeploymentSpec{ + Resources: &v1.ResourceRequirements{ + Limits: v1.ResourceList{ + v1.ResourceCPU: resource.MustParse("4"), + v1.ResourceMemory: resource.MustParse("8Gi"), + }, + Requests: v1.ResourceList{ + v1.ResourceCPU: resource.MustParse("2"), + v1.ResourceMemory: resource.MustParse("4Gi"), + }, + }, + }, + }, + Customize: &v1alpha1.CustomizeSpec{ + Annotations: map[string]string{ + "rhacs.redhat.com/org-name": p.OrganizationName, + }, + Labels: map[string]string{ + "rhacs.redhat.com/instance-type": p.InstanceType, + "rhacs.redhat.com/org-id": p.OrganizationID, + "rhacs.redhat.com/tenant": p.ID, + }, + }, + Scanner: &v1alpha1.ScannerComponentSpec{ + Analyzer: &v1alpha1.ScannerAnalyzerComponent{ + Scaling: &v1alpha1.ScannerAnalyzerScaling{ + AutoScaling: &autoScalingEnabled, + MaxReplicas: pointers.Int32(3), + MinReplicas: pointers.Int32(1), + Replicas: pointers.Int32(1), + }, + DeploymentSpec: v1alpha1.DeploymentSpec{ + Resources: &v1.ResourceRequirements{ + Limits: v1.ResourceList{ + v1.ResourceCPU: resource.MustParse("3"), + v1.ResourceMemory: resource.MustParse("8Gi"), + }, + Requests: v1.ResourceList{ + v1.ResourceCPU: resource.MustParse("1.5"), + v1.ResourceMemory: resource.MustParse("4Gi"), + }, + }, + }, + }, + ScannerComponent: &scannerComponentEnabled, + DB: &v1alpha1.DeploymentSpec{ + Resources: &v1.ResourceRequirements{ + Limits: v1.ResourceList{ + v1.ResourceCPU: resource.MustParse("2.5"), + v1.ResourceMemory: resource.MustParse("4Gi"), + }, + Requests: v1.ResourceList{ + v1.ResourceCPU: resource.MustParse("1.25"), + v1.ResourceMemory: resource.MustParse("2Gi"), + }, + }, + }, + Monitoring: &v1alpha1.Monitoring{ + ExposeEndpoint: &exposeEndpointEnabled, + }, + }, + Monitoring: &v1alpha1.GlobalMonitoring{ + OpenShiftMonitoring: &v1alpha1.OpenShiftMonitoring{ + Enabled: false, + }, + }, }, } From 3e3c82a951309e1c816fb8825b39a32136d46baa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20He=C3=9Felmann?= Date: Tue, 7 Nov 2023 21:23:40 +0100 Subject: [PATCH 3/4] set isInternal manually --- internal/dinosaur/pkg/gitops/config.go | 6 +++--- internal/dinosaur/pkg/gitops/default_central_test.go | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/internal/dinosaur/pkg/gitops/config.go b/internal/dinosaur/pkg/gitops/config.go index 3d8b541ba9..87950ef0d4 100644 --- a/internal/dinosaur/pkg/gitops/config.go +++ b/internal/dinosaur/pkg/gitops/config.go @@ -72,7 +72,7 @@ func validatePatch(path *field.Path, patch string) field.ErrorList { // tryRenderDummyCentralWithPatch renders a dummy Central instance with the given patch. // useful to test that a patch is valid. func tryRenderDummyCentralWithPatch(patch string) error { - var dummyParams = getDummyCentralParams(false) + var dummyParams = getDummyCentralParams() dummyConfig := Config{ Centrals: CentralsConfig{ Overrides: []CentralOverride{ @@ -89,7 +89,7 @@ func tryRenderDummyCentralWithPatch(patch string) error { return nil } -func getDummyCentralParams(isInternal bool) CentralParams { +func getDummyCentralParams() CentralParams { return CentralParams{ ID: "id", Name: "name", @@ -106,7 +106,7 @@ func getDummyCentralParams(isInternal bool) CentralParams { OrganizationID: "organizationId", OrganizationName: "organizationName", InstanceType: "instanceType", - IsInternal: isInternal, + IsInternal: false, } } diff --git a/internal/dinosaur/pkg/gitops/default_central_test.go b/internal/dinosaur/pkg/gitops/default_central_test.go index 6c277ebf39..2feddbf169 100644 --- a/internal/dinosaur/pkg/gitops/default_central_test.go +++ b/internal/dinosaur/pkg/gitops/default_central_test.go @@ -13,7 +13,7 @@ import ( ) func TestDefaultCentral(t *testing.T) { - p := getDummyCentralParams(false) + p := getDummyCentralParams() central, err := renderDefaultCentral(p) assert.NoError(t, err) @@ -121,7 +121,8 @@ func TestDefaultCentral(t *testing.T) { } func TestInternalCentral(t *testing.T) { - p := getDummyCentralParams(true) + p := getDummyCentralParams() + p.IsInternal = true central, err := renderDefaultCentral(p) assert.NoError(t, err) From 67c60ee199db40ddc2085ebd35f0d8f1ab9d9c30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20He=C3=9Felmann?= Date: Tue, 7 Nov 2023 21:36:53 +0100 Subject: [PATCH 4/4] extract test functions --- .../pkg/gitops/default_central_test.go | 125 +++--------------- 1 file changed, 19 insertions(+), 106 deletions(-) diff --git a/internal/dinosaur/pkg/gitops/default_central_test.go b/internal/dinosaur/pkg/gitops/default_central_test.go index 2feddbf169..96aba3e27a 100644 --- a/internal/dinosaur/pkg/gitops/default_central_test.go +++ b/internal/dinosaur/pkg/gitops/default_central_test.go @@ -12,16 +12,12 @@ import ( "sigs.k8s.io/yaml" ) -func TestDefaultCentral(t *testing.T) { - p := getDummyCentralParams() - central, err := renderDefaultCentral(p) - assert.NoError(t, err) - +func wantCentralForDummyParams(p *CentralParams) *v1alpha1.Central { exposeEndpointEnabled := v1alpha1.ExposeEndpointEnabled autoScalingEnabled := v1alpha1.ScannerAutoScalingEnabled scannerComponentEnabled := v1alpha1.ScannerComponentEnabled - wantCentral := v1alpha1.Central{ + return &v1alpha1.Central{ ObjectMeta: metav1.ObjectMeta{ Name: p.Name, Namespace: p.Namespace, @@ -109,122 +105,39 @@ func TestDefaultCentral(t *testing.T) { }, }, } +} + +func assertCentralEquality(t *testing.T, wantCentral *v1alpha1.Central, gotCentral *v1alpha1.Central) { + assert.Equal(t, wantCentral, gotCentral) // compare yaml wantBytes, err := yaml.Marshal(wantCentral) assert.NoError(t, err) - gotBytes, err := yaml.Marshal(central) + gotBytes, err := yaml.Marshal(gotCentral) assert.NoError(t, err) assert.YAMLEq(t, string(wantBytes), string(gotBytes)) } -func TestInternalCentral(t *testing.T) { +func TestDefaultCentral(t *testing.T) { p := getDummyCentralParams() - p.IsInternal = true - central, err := renderDefaultCentral(p) + gotCentral, err := renderDefaultCentral(p) assert.NoError(t, err) - exposeEndpointEnabled := v1alpha1.ExposeEndpointEnabled - autoScalingEnabled := v1alpha1.ScannerAutoScalingEnabled - scannerComponentEnabled := v1alpha1.ScannerComponentEnabled + wantCentral := wantCentralForDummyParams(&p) - wantCentral := v1alpha1.Central{ - ObjectMeta: metav1.ObjectMeta{ - Name: p.Name, - Namespace: p.Namespace, - Labels: map[string]string{ - "rhacs.redhat.com/instance-type": p.InstanceType, - "rhacs.redhat.com/org-id": p.OrganizationID, - "rhacs.redhat.com/tenant": p.ID, - }, - Annotations: map[string]string{ - "rhacs.redhat.com/org-name": p.OrganizationName, - "platform.stackrox.io/managed-services": "true", - }, - }, - Spec: v1alpha1.CentralSpec{ - Central: &v1alpha1.CentralComponentSpec{ - AdminPasswordGenerationDisabled: pointers.Bool(true), - Monitoring: &v1alpha1.Monitoring{ - ExposeEndpoint: &exposeEndpointEnabled, - }, - DeploymentSpec: v1alpha1.DeploymentSpec{ - Resources: &v1.ResourceRequirements{ - Limits: v1.ResourceList{ - v1.ResourceCPU: resource.MustParse("4"), - v1.ResourceMemory: resource.MustParse("8Gi"), - }, - Requests: v1.ResourceList{ - v1.ResourceCPU: resource.MustParse("2"), - v1.ResourceMemory: resource.MustParse("4Gi"), - }, - }, - }, - }, - Customize: &v1alpha1.CustomizeSpec{ - Annotations: map[string]string{ - "rhacs.redhat.com/org-name": p.OrganizationName, - }, - Labels: map[string]string{ - "rhacs.redhat.com/instance-type": p.InstanceType, - "rhacs.redhat.com/org-id": p.OrganizationID, - "rhacs.redhat.com/tenant": p.ID, - }, - }, - Scanner: &v1alpha1.ScannerComponentSpec{ - Analyzer: &v1alpha1.ScannerAnalyzerComponent{ - Scaling: &v1alpha1.ScannerAnalyzerScaling{ - AutoScaling: &autoScalingEnabled, - MaxReplicas: pointers.Int32(3), - MinReplicas: pointers.Int32(1), - Replicas: pointers.Int32(1), - }, - DeploymentSpec: v1alpha1.DeploymentSpec{ - Resources: &v1.ResourceRequirements{ - Limits: v1.ResourceList{ - v1.ResourceCPU: resource.MustParse("3"), - v1.ResourceMemory: resource.MustParse("8Gi"), - }, - Requests: v1.ResourceList{ - v1.ResourceCPU: resource.MustParse("1.5"), - v1.ResourceMemory: resource.MustParse("4Gi"), - }, - }, - }, - }, - ScannerComponent: &scannerComponentEnabled, - DB: &v1alpha1.DeploymentSpec{ - Resources: &v1.ResourceRequirements{ - Limits: v1.ResourceList{ - v1.ResourceCPU: resource.MustParse("2.5"), - v1.ResourceMemory: resource.MustParse("4Gi"), - }, - Requests: v1.ResourceList{ - v1.ResourceCPU: resource.MustParse("1.25"), - v1.ResourceMemory: resource.MustParse("2Gi"), - }, - }, - }, - Monitoring: &v1alpha1.Monitoring{ - ExposeEndpoint: &exposeEndpointEnabled, - }, - }, - Monitoring: &v1alpha1.GlobalMonitoring{ - OpenShiftMonitoring: &v1alpha1.OpenShiftMonitoring{ - Enabled: false, - }, - }, - }, - } + assertCentralEquality(t, wantCentral, &gotCentral) +} - // compare yaml - wantBytes, err := yaml.Marshal(wantCentral) +func TestInternalCentral(t *testing.T) { + p := getDummyCentralParams() + p.IsInternal = true + gotCentral, err := renderDefaultCentral(p) assert.NoError(t, err) - gotBytes, err := yaml.Marshal(central) - assert.NoError(t, err) + wantCentral := wantCentralForDummyParams(&p) + wantCentral.Spec.Monitoring.OpenShiftMonitoring.Enabled = false - assert.YAMLEq(t, string(wantBytes), string(gotBytes)) + assertCentralEquality(t, wantCentral, &gotCentral) }