Skip to content
This repository has been archived by the owner on May 19, 2024. It is now read-only.

Commit

Permalink
Merge pull request #22 from akesser/feature/count-objects
Browse files Browse the repository at this point in the history
feat: add metrics for counting objects indiviual by gvr and in total
  • Loading branch information
akesser committed Jan 22, 2024
2 parents fe430a8 + 6d53531 commit 81ba827
Show file tree
Hide file tree
Showing 13 changed files with 476 additions and 99 deletions.
4 changes: 2 additions & 2 deletions cluster/charts/x-metrics/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ apiVersion: v2
name: x-metrics
description: A Helm chart for x-metrics
type: application
version: 0.1.3
appVersion: "v0.1.0"
version: 0.1.4
appVersion: "v0.2.0"

maintainers:
- name: crossplanecontrib
2 changes: 1 addition & 1 deletion cluster/charts/x-metrics/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ replicaCount: 1
image:
repository: xpkg.upbound.io/crossplane-contrib/x-metrics
pullPolicy: IfNotPresent
tag: "v0.1.0"
tag: "v0.2.0"

imagePullSecrets: []
nameOverride: ""
Expand Down
9 changes: 8 additions & 1 deletion examples/clustermetric.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,11 @@ kind: ClusterMetric
metadata:
name: clustermetric-sample
spec:
matchName: ".crossplane.io"
matchName: "objects.kubernetes.crossplane.io"
---
apiVersion: metrics.crossplane.io/v1
kind: ClusterMetric
metadata:
name: clustermetric-sample2
spec:
matchName: "iam.aws.crossplane.io"
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ require (
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/crossplane/crossplane-runtime v0.19.0
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/zapr v1.2.3 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
Expand All @@ -33,7 +33,7 @@ require (
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/go-cmp v0.5.9
github.com/google/gofuzz v1.1.0 // indirect
github.com/google/uuid v1.1.2 // indirect
github.com/google/uuid v1.1.2
github.com/imdario/mergo v0.3.12 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
Expand All @@ -51,11 +51,11 @@ require (
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/net v0.20.0 // indirect
golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/term v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/term v0.16.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.3.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
Expand Down
21 changes: 10 additions & 11 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ github.com/evanphx/json-patch v0.5.2/go.mod h1:ZWS5hhDbVDyob71nXKNL0+PWn6ToqBHMi
github.com/evanphx/json-patch v4.12.0+incompatible h1:4onqiflcdA9EOZ4RxV643DvftH5pOlLGNtQ5lPWQu84=
github.com/evanphx/json-patch/v5 v5.6.0 h1:b91NhWfaz02IuVxO9faSllyAtNXHMPkC5J8sJCLunww=
github.com/evanphx/json-patch/v5 v5.6.0/go.mod h1:G79N1coSVB93tBe7j6PhzjmR3/2VvlbKOFpnXhI9Bw4=
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
Expand Down Expand Up @@ -353,8 +353,8 @@ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwY
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g=
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo=
golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
Expand Down Expand Up @@ -413,22 +413,21 @@ golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0 h1:n2a8QNdAb0sZNpU9R1ALUXBbY+w51fCQDN+7EdxNBsY=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.16.0 h1:m+B6fahuftsE9qjo0VWp2FW0mB3MTJvR0BaMQrq0pmE=
golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
Expand Down
16 changes: 9 additions & 7 deletions pkg/controller/metric/metric_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,15 @@ func (r *MetricReconciler) getGVRForMetric(ctx context.Context, metric *metricsv
// if we need a gvr for a metrics resource, we only watch namespaced resources
if (match || inNameList) && !inExcludeList && (namespaced == inNamespace || !namespaced) {
for _, version := range crd.Spec.Versions {
metricName := xmetrics.GetValidLabel(crd.Spec.Group + "_" + crd.Spec.Names.Kind + "_" + version.Name)
list[metricName] = Resource{
Group: crd.Spec.Group,
Version: version.Name,
Resource: crd.Spec.Names.Plural,
Kind: crd.Spec.Names.Kind,
MetricName: metricName,
if version.Storage {
metricName := xmetrics.GetValidLabel(crd.Spec.Group + "_" + crd.Spec.Names.Kind + "_" + version.Name)
list[metricName] = Resource{
Group: crd.Spec.Group,
Version: version.Name,
Resource: crd.Spec.Names.Plural,
Kind: crd.Spec.Names.Kind,
MetricName: metricName,
}
}
}
}
Expand Down
133 changes: 73 additions & 60 deletions pkg/controller/metric/metric_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ var _ = Describe("Managed Metrics", func() {
Expect(k8sClient.Delete(ctx, metric)).Should(Succeed())
}, SpecTimeout(time.Second*20))

It("Should select correct crds for multiple versions", func(ctx SpecContext) {
It("Should select correct crd for multiple versions", func(ctx SpecContext) {
mm.ResetRegister()
metricsMemory = map[string]*MetricsMemory{}

Expand Down Expand Up @@ -359,7 +359,9 @@ var _ = Describe("Managed Metrics", func() {
Eventually(func() int {
mmMap = mm.GetRegister()
return len(mmMap)
}).WithTimeout(time.Second * 20).Should(Equal(4))
}).WithTimeout(time.Second * 20).Should(Equal(2))
// We expect only two entries as only crd versions with
// Storage: true will be watched

gvr1, ok := mmMap["testb_cloud_NameC_v1"]
Expect(ok).Should(BeTrue(), "Should have metrics for NameC v1")
Expand All @@ -368,26 +370,12 @@ var _ = Describe("Managed Metrics", func() {
Expect(gvr1.Version).Should(Equal("v1"))
Expect(gvr1.Resource).Should(Equal("namecs"))

gvr2, ok := mmMap["testb_cloud_NameC_v1beta1"]
Expect(ok).Should(BeTrue(), "Should have metrics for NameC v1beta1")

Expect(gvr2.Group).Should(Equal("testb.cloud"))
Expect(gvr2.Version).Should(Equal("v1beta1"))
Expect(gvr2.Resource).Should(Equal("namecs"))

gvr3, ok := mmMap["testb_cloud_NameD_v2"]
gvr2, ok := mmMap["testb_cloud_NameD_v2"]
Expect(ok).Should(BeTrue(), "Should have metrics for NameD v2")

Expect(gvr3.Group).Should(Equal("testb.cloud"))
Expect(gvr3.Version).Should(Equal("v2"))
Expect(gvr3.Resource).Should(Equal("nameds"))

gvr4, ok := mmMap["testb_cloud_NameD_v1alpha1"]
Expect(ok).Should(BeTrue(), "Should have metrics for NameD v1alpha1")

Expect(gvr4.Group).Should(Equal("testb.cloud"))
Expect(gvr4.Version).Should(Equal("v1alpha1"))
Expect(gvr4.Resource).Should(Equal("nameds"))
Expect(gvr2.Group).Should(Equal("testb.cloud"))
Expect(gvr2.Version).Should(Equal("v2"))
Expect(gvr2.Resource).Should(Equal("nameds"))

Expect(k8sClient.Delete(ctx, metric)).Should(Succeed())
}, SpecTimeout(time.Second*20))
Expand Down Expand Up @@ -477,7 +465,7 @@ var _ = Describe("Managed Metrics", func() {
Eventually(func() int {
mmMap = mm.GetRegister()
return len(mmMap)
}).Should(Equal(4))
}).Should(Equal(3))

gvr1, ok := mmMap["testa_cloud_NameA_v1"]
Expect(ok).Should(BeTrue(), "Should have metrics for NameA v1")
Expand All @@ -500,13 +488,6 @@ var _ = Describe("Managed Metrics", func() {
Expect(gvr3.Version).Should(Equal("v1"))
Expect(gvr3.Resource).Should(Equal("namecs"))

gvr4, ok := mmMap["testb_cloud_NameC_v1beta1"]
Expect(ok).Should(BeTrue(), "Should have metrics for NameC v1beta1")

Expect(gvr4.Group).Should(Equal("testb.cloud"))
Expect(gvr4.Version).Should(Equal("v1beta1"))
Expect(gvr4.Resource).Should(Equal("namecs"))
Expect(k8sClient.Delete(ctx, metric)).Should(Succeed())
}, SpecTimeout(time.Second*20))

It("Should match categories", func(ctx SpecContext) {
Expand Down Expand Up @@ -609,6 +590,7 @@ var _ = Describe("Managed Metrics", func() {

Expect(k8sClient.Delete(ctx, metric)).Should(Succeed())
}, SpecTimeout(time.Second*20))

It("Should match categories OR", func(ctx SpecContext) {
mm.ResetRegister()
metricsMemory = map[string]*MetricsMemory{}
Expand Down Expand Up @@ -649,7 +631,7 @@ var _ = Describe("Managed Metrics", func() {
Eventually(func() int {
mmMap = mm.GetRegister()
return len(mmMap)
}).Should(Equal(3))
}).Should(Equal(2))

gvr1, ok := mmMap["testa_cloud_NameA_v1"]
Expect(ok).Should(BeTrue(), "Should have metrics for NameA v1")
Expand All @@ -665,13 +647,6 @@ var _ = Describe("Managed Metrics", func() {
Expect(gvr2.Version).Should(Equal("v1"))
Expect(gvr2.Resource).Should(Equal("namecs"))

gvr3, ok := mmMap["testb_cloud_NameC_v1beta1"]
Expect(ok).Should(BeTrue(), "Should have metrics for NameC v1beta1")

Expect(gvr3.Group).Should(Equal("testb.cloud"))
Expect(gvr3.Version).Should(Equal("v1beta1"))
Expect(gvr3.Resource).Should(Equal("namecs"))

Expect(k8sClient.Delete(ctx, metric)).Should(Succeed())
}, SpecTimeout(time.Second*20))

Expand Down Expand Up @@ -827,7 +802,7 @@ var _ = Describe("Managed Metrics", func() {
Eventually(func() int {
mmMap = mm.GetRegister()
return len(mmMap)
}).Should(Equal(3))
}).Should(Equal(2))

gvr1, ok := mmMap["testa_cloud_NameA_v1"]
Expect(ok).Should(BeTrue(), "Should have metrics for NameA v1")
Expand All @@ -843,13 +818,6 @@ var _ = Describe("Managed Metrics", func() {
Expect(gvr2.Version).Should(Equal("v1"))
Expect(gvr2.Resource).Should(Equal("namecs"))

gvr3, ok := mmMap["testb_cloud_NameC_v1beta1"]
Expect(ok).Should(BeTrue(), "Should have metrics for NameC v1beta1")

Expect(gvr3.Group).Should(Equal("testb.cloud"))
Expect(gvr3.Version).Should(Equal("v1beta1"))
Expect(gvr3.Resource).Should(Equal("namecs"))

var met metricsv1.Metric
metRequest := types.NamespacedName{
Name: metricName,
Expand Down Expand Up @@ -914,7 +882,7 @@ var _ = Describe("Managed Metrics", func() {
Eventually(func() int {
mmMap = mm.GetRegister()
return len(mmMap)
}).Should(Equal(3))
}).Should(Equal(2))

gvr1, ok := mmMap["testa_cloud_NameA_v1"]
Expect(ok).Should(BeTrue(), "Should have metrics for NameA v1")
Expand All @@ -930,13 +898,6 @@ var _ = Describe("Managed Metrics", func() {
Expect(gvr2.Version).Should(Equal("v1"))
Expect(gvr2.Resource).Should(Equal("namecs"))

gvr3, ok := mmMap["testb_cloud_NameC_v1beta1"]
Expect(ok).Should(BeTrue(), "Should have metrics for NameC v1beta1")

Expect(gvr3.Group).Should(Equal("testb.cloud"))
Expect(gvr3.Version).Should(Equal("v1beta1"))
Expect(gvr3.Resource).Should(Equal("namecs"))

var met metricsv1.Metric
metRequest := types.NamespacedName{
Name: metricName,
Expand Down Expand Up @@ -1083,7 +1044,7 @@ var _ = Describe("Managed Metrics", func() {
Eventually(func() int {
mmMap = mm.GetRegister()
return len(mmMap)
}).Should(Equal(3))
}).Should(Equal(2))

gvr2, ok := mmMap["testa_cloud_NameA_v1"]
Expect(ok).Should(BeTrue(), "Should have metrics for NameA v1")
Expand All @@ -1099,13 +1060,6 @@ var _ = Describe("Managed Metrics", func() {
Expect(gvr3.Version).Should(Equal("v1"))
Expect(gvr3.Resource).Should(Equal("namecs"))

gvr4, ok := mmMap["testb_cloud_NameC_v1beta1"]
Expect(ok).Should(BeTrue(), "Should have metrics for NameC v1beta1")

Expect(gvr4.Group).Should(Equal("testb.cloud"))
Expect(gvr4.Version).Should(Equal("v1beta1"))
Expect(gvr4.Resource).Should(Equal("namecs"))

numCalls := mm.GetNumOfCalls()

for _, v := range numCalls {
Expand All @@ -1116,6 +1070,65 @@ var _ = Describe("Managed Metrics", func() {
Expect(k8sClient.Delete(ctx, metric2)).Should(Succeed())
}, SpecTimeout(time.Second*20))

It("Should add count for objects", func() {
mm.ResetRegister()
metricsMemory = map[string]*MetricsMemory{}

metricName := "cmetrica"
metricNamespace := generateNamespaceName()

mNamespace := corev1.Namespace{
ObjectMeta: metav1.ObjectMeta{
Name: metricNamespace,
},
}
err2 := k8sClient.Create(ctx, &mNamespace)
Expect(err2).NotTo(HaveOccurred(), "failed to create x-metrics namespace")
matchName := "testa.cloud"
metric := &metricsv1.Metric{
TypeMeta: metav1.TypeMeta{
APIVersion: "metrics.crossplane.io/v1",
Kind: "ClusterMetric",
},
ObjectMeta: metav1.ObjectMeta{
Name: metricName,
Namespace: metricNamespace,
},
Spec: metricsv1.MetricSpec{
MatchName: &matchName,
IncludeNames: &[]string{"namecs.testb.cloud"},
},
}

Expect(k8sClient.Create(ctx, metric)).Should(Succeed())
var mmMap map[string]schema.GroupVersionResource
Eventually(func() int {
mmMap = mm.GetRegister()
return len(mmMap)
}).Should(Equal(3))

gvr1, ok := mmMap["testa_cloud_NameA_v1"]
Expect(ok).Should(BeTrue(), "Should have metrics for NameA v1")

Expect(gvr1.Group).Should(Equal("testa.cloud"))
Expect(gvr1.Version).Should(Equal("v1"))
Expect(gvr1.Resource).Should(Equal("nameas"))

gvr2, ok := mmMap["testa_cloud_NameB_v1beta1"]
Expect(ok).Should(BeTrue(), "Should have metrics for NameB v1beta1")

Expect(gvr2.Group).Should(Equal("testa.cloud"))
Expect(gvr2.Version).Should(Equal("v1beta1"))
Expect(gvr2.Resource).Should(Equal("namebs"))

gvr3, ok := mmMap["testb_cloud_NameC_v1"]
Expect(ok).Should(BeTrue(), "Should have metrics for NameC v1")

Expect(gvr3.Group).Should(Equal("testb.cloud"))
Expect(gvr3.Version).Should(Equal("v1"))
Expect(gvr3.Resource).Should(Equal("namecs"))
})

It("Should delete crds correctly", func() {
ctx := context.Background()

Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/metric/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ var _ = BeforeSuite(func() {

By("bootstrapping test environment")
testEnv = &envtest.Environment{
CRDDirectoryPaths: []string{filepath.Join("..", "config", "crd", "bases")},
CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "package", "crds")},
ErrorIfCRDPathMissing: true,
}

Expand Down
Loading

0 comments on commit 81ba827

Please sign in to comment.