-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Thibault Mange <[email protected]>
- Loading branch information
1 parent
f15ca59
commit b84bfbc
Showing
11 changed files
with
205 additions
and
11 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
operators/multiclusterobservability/manifests/base/grafana/alerts/kustomization.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
resources: | ||
- dash-acm-alert-analysis.yaml | ||
- dash-acm-alerts-by-clusters.yaml | ||
- dash-acm-cluster-by-alerts.yaml | ||
- scrape-config.yaml |
4 changes: 4 additions & 0 deletions
4
operators/multiclusterobservability/manifests/base/grafana/hcp-nexus/kustomization.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
resources: | ||
- dash-acm-hcp-overview.yaml | ||
- dash-acm-resources-hcp.yaml | ||
- scrape-config.yaml |
3 changes: 3 additions & 0 deletions
3
operators/multiclusterobservability/manifests/base/grafana/hcp/kustomization.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
resources: | ||
- dash-acm-hcp-overview.yaml | ||
- dash-acm-resources-hcp.yaml |
9 changes: 9 additions & 0 deletions
9
operators/multiclusterobservability/manifests/base/grafana/ocp311/kustomization.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
resources: | ||
- dash-acm-clusters-overview-ocp311.yaml | ||
- dash-acm-optimization-overview-ocp311.yaml | ||
- dash-k8s-capacity-planning-ocp311.yaml | ||
- dash-k8s-compute-resources-namespace-pods-ocp311.yaml | ||
- dash-k8s-compute-resources-pod-ocp311.yaml | ||
- dash-k8s-namespaces-in-cluster-ocp311.yaml | ||
- dash-k8s-pods-in-namespace-ocp311.yaml | ||
- dash-k8s-summary-by-node-ocp311.yaml |
19 changes: 19 additions & 0 deletions
19
operators/multiclusterobservability/manifests/base/grafana/platform-nexus/kustomization.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
resources: | ||
- dash-acm-clusters-overview.yaml | ||
- dash-acm-optimization-overview.yaml | ||
- dash-cluster-rsrc-use.yaml | ||
- dash-k8s-apiserver.yaml | ||
- dash-k8s-compute-resources-cluster.yaml | ||
- dash-k8s-compute-resources-namespace-pods.yaml | ||
- dash-k8s-compute-resources-namespace-workloads.yaml | ||
- dash-k8s-compute-resources-node-pods.yaml | ||
- dash-k8s-compute-resources-pod.yaml | ||
- dash-k8s-compute-resources-workload.yaml | ||
- dash-k8s-etcd.yaml | ||
- dash-k8s-networking-cluster.yaml | ||
- dash-k8s-service-level-overview-api-server-cluster.yaml | ||
- dash-k8s-service-level-overview-api-server.yaml | ||
- dash-node-rsrc-use.yaml | ||
- prometheus-rule.yaml | ||
- scrape-config.yaml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
operators/multiclusterobservability/manifests/base/grafana/platform/kustomization.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
resources: | ||
- dash-acm-clusters-overview-optimized.yaml | ||
- dash-acm-clusters-overview.yaml | ||
- dash-acm-optimization-overview.yaml | ||
- dash-cluster-rsrc-use.yaml | ||
- dash-k8s-apiserver.yaml | ||
- dash-k8s-compute-resources-cluster.yaml | ||
- dash-k8s-compute-resources-namespace-pods.yaml | ||
- dash-k8s-compute-resources-namespace-workloads.yaml | ||
- dash-k8s-compute-resources-node-pods.yaml | ||
- dash-k8s-compute-resources-pod.yaml | ||
- dash-k8s-compute-resources-workload.yaml | ||
- dash-k8s-etcd.yaml | ||
- dash-k8s-networking-cluster.yaml | ||
- dash-k8s-service-level-overview-api-server-cluster.yaml | ||
- dash-k8s-service-level-overview-api-server.yaml | ||
- dash-node-rsrc-use.yaml |
8 changes: 8 additions & 0 deletions
8
operators/multiclusterobservability/manifests/base/grafana/virtualization/kustomization.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
resources: | ||
- dash-acm-openshift-virtualization-overview.yaml | ||
- dash-acm-openshift-virtualization-single-cluster-view.yaml | ||
- dash-acm-openshift-virtualization-single-vm-view.yaml | ||
- dash-acm-virtual-machines-by-time-in-status.yaml | ||
- dash-acm-virtual-machines-inventory.yaml | ||
- scrape-config.yaml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
operators/multiclusterobservability/pkg/rendering/renderer_grafana_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package rendering | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
|
||
obv1beta2 "github.com/stolostron/multicluster-observability-operator/operators/multiclusterobservability/api/v1beta2" | ||
"github.com/stolostron/multicluster-observability-operator/operators/multiclusterobservability/pkg/rendering/templates" | ||
rendererutil "github.com/stolostron/multicluster-observability-operator/operators/pkg/rendering" | ||
templatesutil "github.com/stolostron/multicluster-observability-operator/operators/pkg/rendering/templates" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" | ||
) | ||
|
||
func TestRenderGrafana(t *testing.T) { | ||
wd, err := os.Getwd() | ||
assert.NoError(t, err) | ||
templatesPath := filepath.Join(wd, "..", "..", "manifests") | ||
tmplRenderer := templatesutil.NewTemplateRenderer(templatesPath) | ||
grafanaTemplates, err := templates.GetOrLoadGrafanaTemplates(tmplRenderer) | ||
require.NoError(t, err) | ||
|
||
testCases := map[string]struct { | ||
mco obv1beta2.MultiClusterObservability | ||
expect func(*testing.T, []*unstructured.Unstructured) | ||
}{ | ||
"MCOA for metrics is enabled": { | ||
mco: obv1beta2.MultiClusterObservability{ | ||
Spec: obv1beta2.MultiClusterObservabilitySpec{ | ||
Capabilities: &obv1beta2.CapabilitiesSpec{ | ||
Platform: &obv1beta2.PlatformCapabilitiesSpec{ | ||
Metrics: obv1beta2.PlatformMetricsSpec{ | ||
Collection: obv1beta2.PlatformMetricsCollectionSpec{ | ||
Enabled: true, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
expect: func(t *testing.T, res []*unstructured.Unstructured) { | ||
assert.Len(t, res, 44) | ||
}, | ||
}, | ||
"MCOA for metrics is disabled": { | ||
mco: obv1beta2.MultiClusterObservability{}, | ||
expect: func(t *testing.T, res []*unstructured.Unstructured) { | ||
assert.Len(t, res, 40) | ||
for _, r := range res { | ||
assert.NotContains(t, r.GetName(), "nexus") | ||
} | ||
}, | ||
}, | ||
} | ||
|
||
for tcName, tc := range testCases { | ||
|
||
t.Run(tcName, func(t *testing.T) { | ||
mcoRenderer := &MCORenderer{ | ||
renderer: rendererutil.NewRenderer(), | ||
cr: &tc.mco, | ||
} | ||
|
||
mcoRenderer.newGranfanaRenderer() | ||
namespace := "myns" | ||
grafanaResources, err := mcoRenderer.renderGrafanaTemplates(grafanaTemplates, namespace, nil) | ||
require.NoError(t, err) | ||
for _, r := range grafanaResources { | ||
if r.GetKind() == "ClusterRole" { | ||
continue | ||
} | ||
assert.Equal(t, namespace, r.GetNamespace(), fmt.Sprintf(" resource %s/%s", r.GetKind(), r.GetName())) | ||
} | ||
|
||
tc.expect(t, grafanaResources) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters