From ea9735010f43e85a195b0d4e5b0ed69a58d928ab Mon Sep 17 00:00:00 2001 From: Catherine Fang Date: Wed, 28 Jun 2023 08:28:09 -0400 Subject: [PATCH] fix --- internal/discovery/types.go | 2 ++ pkg/customresourcestate/config.go | 1 + tests/e2e/discovery_test.go | 5 +++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/discovery/types.go b/internal/discovery/types.go index 9d31176ed9..9337e2c7ae 100644 --- a/internal/discovery/types.go +++ b/internal/discovery/types.go @@ -19,6 +19,7 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" ) +// GroupVersionKindPlural is GVK + Plural type GroupVersionKindPlural struct { schema.GroupVersionKind Plural string @@ -28,6 +29,7 @@ func (g GroupVersionKindPlural) String() string { return fmt.Sprintf("%s/%s, Kind=%s, Plural=%s", g.Group, g.Version, g.Kind, g.Plural) } +// KindPlural is Kind + Plural type KindPlural struct { Kind string Plural string diff --git a/pkg/customresourcestate/config.go b/pkg/customresourcestate/config.go index 174694c865..101c3ee8e0 100644 --- a/pkg/customresourcestate/config.go +++ b/pkg/customresourcestate/config.go @@ -165,6 +165,7 @@ type ConfigDecoder interface { Decode(v interface{}) (err error) } +// GVKToGVKP interface implements ResolveGVKToGVKPs type GVKToGVKP interface { ResolveGVKToGVKPs(gvk schema.GroupVersionKind) (resolvedGVKPs []discovery.GroupVersionKindPlural, err error) } diff --git a/tests/e2e/discovery_test.go b/tests/e2e/discovery_test.go index 144e2c05d7..225792bfdc 100644 --- a/tests/e2e/discovery_test.go +++ b/tests/e2e/discovery_test.go @@ -29,12 +29,12 @@ import ( "k8s.io/klog/v2" "k8s.io/kube-state-metrics/v2/internal" - "k8s.io/kube-state-metrics/v2/pkg/customresourcestate" "k8s.io/kube-state-metrics/v2/pkg/options" ) // PopulateTimeout is the timeout on populating the cache for the first time. const PopulateTimeout = 10 * time.Second +const Interval = 3 * time.Second func TestVariableVKsDiscoveryAndResolution(t *testing.T) { @@ -140,7 +140,8 @@ func TestVariableVKsDiscoveryAndResolution(t *testing.T) { // Wait for the metric to be available. ch := make(chan bool, 1) klog.InfoS("waiting for metrics to become available") - err = wait.PollUntilContextTimeout(context.TODO(), customresourcestate.Interval, PopulateTimeout, true, func(ctx context.Context) (bool, error) { + + err = wait.PollUntilContextTimeout(context.TODO(), Interval, PopulateTimeout, true, func(ctx context.Context) (bool, error) { out, err := exec.Command("curl", "localhost:8080/metrics").Output() if err != nil { return false, err