Skip to content

Commit

Permalink
Resolve test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
jigisha620 committed Jul 4, 2024
1 parent c0dc41b commit 9fe3828
Show file tree
Hide file tree
Showing 23 changed files with 69 additions and 23 deletions.
4 changes: 3 additions & 1 deletion pkg/apis/v1/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"math/rand"
"testing"

"sigs.k8s.io/karpenter/pkg/test/v1alpha1"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/samber/lo"
Expand All @@ -43,7 +45,7 @@ func TestAPIs(t *testing.T) {
}

var _ = BeforeSuite(func() {
env = test.NewEnvironment(test.WithCRDs(apis.CRDs...))
env = test.NewEnvironment(test.WithCRDs(apis.CRDs...), test.WithCRDs(v1alpha1.CRDs...))
})

var _ = AfterEach(func() {
Expand Down
4 changes: 3 additions & 1 deletion pkg/apis/v1beta1/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"math/rand"
"testing"

"sigs.k8s.io/karpenter/pkg/test/v1alpha1"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/samber/lo"
Expand All @@ -43,7 +45,7 @@ func TestAPIs(t *testing.T) {
}

var _ = BeforeSuite(func() {
env = test.NewEnvironment(test.WithCRDs(apis.CRDs...))
env = test.NewEnvironment(test.WithCRDs(apis.CRDs...), test.WithCRDs(v1alpha1.CRDs...))
})

var _ = AfterEach(func() {
Expand Down
4 changes: 3 additions & 1 deletion pkg/controllers/disruption/orchestration/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"testing"
"time"

"sigs.k8s.io/karpenter/pkg/test/v1alpha1"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"k8s.io/apimachinery/pkg/api/resource"
Expand Down Expand Up @@ -70,7 +72,7 @@ func TestAPIs(t *testing.T) {
}

var _ = BeforeSuite(func() {
env = test.NewEnvironment(test.WithCRDs(apis.CRDs...))
env = test.NewEnvironment(test.WithCRDs(apis.CRDs...), test.WithCRDs(v1alpha1.CRDs...))
ctx = options.ToContext(ctx, test.Options())
fakeClock = clock.NewFakeClock(time.Now())
cloudProvider = fake.NewCloudProvider()
Expand Down
4 changes: 3 additions & 1 deletion pkg/controllers/disruption/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (
"testing"
"time"

"sigs.k8s.io/karpenter/pkg/test/v1alpha1"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/samber/lo"
Expand Down Expand Up @@ -80,7 +82,7 @@ func TestAPIs(t *testing.T) {
}

var _ = BeforeSuite(func() {
env = test.NewEnvironment(test.WithCRDs(coreapis.CRDs...))
env = test.NewEnvironment(test.WithCRDs(coreapis.CRDs...), test.WithCRDs(v1alpha1.CRDs...))
ctx = options.ToContext(ctx, test.Options())
cloudProvider = fake.NewCloudProvider()
fakeClock = clock.NewFakeClock(time.Now())
Expand Down
4 changes: 3 additions & 1 deletion pkg/controllers/leasegarbagecollection/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"testing"
"time"

"sigs.k8s.io/karpenter/pkg/test/v1alpha1"

"github.com/samber/lo"
coordinationsv1 "k8s.io/api/coordination/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -49,7 +51,7 @@ func TestAPIs(t *testing.T) {
}

var _ = BeforeSuite(func() {
env = test.NewEnvironment(test.WithCRDs(apis.CRDs...))
env = test.NewEnvironment(test.WithCRDs(apis.CRDs...), test.WithCRDs(v1alpha1.CRDs...))
ctx = options.ToContext(ctx, test.Options())

garbageCollectionController = leasegarbagecollection.NewController(env.Client)
Expand Down
4 changes: 3 additions & 1 deletion pkg/controllers/metrics/node/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"testing"
"time"

"sigs.k8s.io/karpenter/pkg/test/v1alpha1"

clock "k8s.io/utils/clock/testing"

v1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -59,7 +61,7 @@ func TestAPIs(t *testing.T) {
}

var _ = BeforeSuite(func() {
env = test.NewEnvironment(test.WithCRDs(apis.CRDs...))
env = test.NewEnvironment(test.WithCRDs(apis.CRDs...), test.WithCRDs(v1alpha1.CRDs...))

ctx = options.ToContext(ctx, test.Options())
cloudProvider = fake.NewCloudProvider()
Expand Down
4 changes: 3 additions & 1 deletion pkg/controllers/metrics/nodepool/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"strings"
"testing"

"sigs.k8s.io/karpenter/pkg/test/v1alpha1"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
v1 "k8s.io/api/core/v1"
Expand All @@ -47,7 +49,7 @@ func TestAPIs(t *testing.T) {
}

var _ = BeforeSuite(func() {
env = test.NewEnvironment(test.WithCRDs(apis.CRDs...))
env = test.NewEnvironment(test.WithCRDs(apis.CRDs...), test.WithCRDs(v1alpha1.CRDs...))
nodePoolController = nodepool.NewController(env.Client)
})

Expand Down
4 changes: 3 additions & 1 deletion pkg/controllers/node/termination/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
"testing"
"time"

"sigs.k8s.io/karpenter/pkg/test/v1alpha1"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/samber/lo"
Expand Down Expand Up @@ -62,7 +64,7 @@ func TestAPIs(t *testing.T) {

var _ = BeforeSuite(func() {
fakeClock = clock.NewFakeClock(time.Now())
env = test.NewEnvironment(test.WithCRDs(apis.CRDs...), test.WithFieldIndexers(test.NodeClaimFieldIndexer(ctx)))
env = test.NewEnvironment(test.WithCRDs(apis.CRDs...), test.WithCRDs(v1alpha1.CRDs...), test.WithFieldIndexers(test.NodeClaimFieldIndexer(ctx)))

cloudProvider = fake.NewCloudProvider()
recorder = test.NewEventRecorder()
Expand Down
4 changes: 3 additions & 1 deletion pkg/controllers/node/termination/terminator/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"sync"
"testing"

"sigs.k8s.io/karpenter/pkg/test/v1alpha1"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
v1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -54,7 +56,7 @@ func TestAPIs(t *testing.T) {
}

var _ = BeforeSuite(func() {
env = test.NewEnvironment(test.WithCRDs(apis.CRDs...))
env = test.NewEnvironment(test.WithCRDs(apis.CRDs...), test.WithCRDs(v1alpha1.CRDs...))
ctx = options.ToContext(ctx, test.Options())
recorder = test.NewEventRecorder()
queue = terminator.NewQueue(env.Client, recorder)
Expand Down
4 changes: 3 additions & 1 deletion pkg/controllers/nodeclaim/consistency/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
"testing"
"time"

"sigs.k8s.io/karpenter/pkg/test/v1alpha1"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
v1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -59,7 +61,7 @@ func TestAPIs(t *testing.T) {

var _ = BeforeSuite(func() {
fakeClock = clock.NewFakeClock(time.Now())
env = test.NewEnvironment(test.WithCRDs(apis.CRDs...), test.WithFieldIndexers(func(c cache.Cache) error {
env = test.NewEnvironment(test.WithCRDs(apis.CRDs...), test.WithCRDs(v1alpha1.CRDs...), test.WithFieldIndexers(func(c cache.Cache) error {
return c.IndexField(ctx, &v1.Node{}, "spec.providerID", func(obj client.Object) []string {
return []string{obj.(*v1.Node).Spec.ProviderID}
})
Expand Down
4 changes: 3 additions & 1 deletion pkg/controllers/nodeclaim/disruption/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"testing"
"time"

"sigs.k8s.io/karpenter/pkg/test/v1alpha1"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/samber/lo"
Expand Down Expand Up @@ -58,7 +60,7 @@ func TestAPIs(t *testing.T) {

var _ = BeforeSuite(func() {
fakeClock = clock.NewFakeClock(time.Now())
env = test.NewEnvironment(test.WithCRDs(apis.CRDs...), test.WithFieldIndexers(func(c cache.Cache) error {
env = test.NewEnvironment(test.WithCRDs(apis.CRDs...), test.WithCRDs(v1alpha1.CRDs...), test.WithFieldIndexers(func(c cache.Cache) error {
return c.IndexField(ctx, &v1.Node{}, "spec.providerID", func(obj client.Object) []string {
return []string{obj.(*v1.Node).Spec.ProviderID}
})
Expand Down
4 changes: 3 additions & 1 deletion pkg/controllers/nodeclaim/garbagecollection/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"testing"
"time"

"sigs.k8s.io/karpenter/pkg/test/v1alpha1"

v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/tools/record"
Expand Down Expand Up @@ -62,7 +64,7 @@ func TestAPIs(t *testing.T) {

var _ = BeforeSuite(func() {
fakeClock = clock.NewFakeClock(time.Now())
env = test.NewEnvironment(test.WithCRDs(apis.CRDs...), test.WithFieldIndexers(func(c cache.Cache) error {
env = test.NewEnvironment(test.WithCRDs(apis.CRDs...), test.WithCRDs(v1alpha1.CRDs...), test.WithFieldIndexers(func(c cache.Cache) error {
return c.IndexField(ctx, &v1.Node{}, "spec.providerID", func(obj client.Object) []string {
return []string{obj.(*v1.Node).Spec.ProviderID}
})
Expand Down
4 changes: 3 additions & 1 deletion pkg/controllers/nodeclaim/lifecycle/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"testing"
"time"

"sigs.k8s.io/karpenter/pkg/test/v1alpha1"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/samber/lo"
Expand Down Expand Up @@ -58,7 +60,7 @@ func TestAPIs(t *testing.T) {

var _ = BeforeSuite(func() {
fakeClock = clock.NewFakeClock(time.Now())
env = test.NewEnvironment(test.WithCRDs(apis.CRDs...), test.WithFieldIndexers(func(c cache.Cache) error {
env = test.NewEnvironment(test.WithCRDs(apis.CRDs...), test.WithCRDs(v1alpha1.CRDs...), test.WithFieldIndexers(func(c cache.Cache) error {
return c.IndexField(ctx, &v1.Node{}, "spec.providerID", func(obj client.Object) []string {
return []string{obj.(*v1.Node).Spec.ProviderID}
})
Expand Down
4 changes: 3 additions & 1 deletion pkg/controllers/nodeclaim/termination/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
"testing"
"time"

"sigs.k8s.io/karpenter/pkg/test/v1alpha1"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/samber/lo"
Expand Down Expand Up @@ -64,7 +66,7 @@ func TestAPIs(t *testing.T) {

var _ = BeforeSuite(func() {
fakeClock = clock.NewFakeClock(time.Now())
env = test.NewEnvironment(test.WithCRDs(apis.CRDs...), test.WithFieldIndexers(func(c cache.Cache) error {
env = test.NewEnvironment(test.WithCRDs(apis.CRDs...), test.WithCRDs(v1alpha1.CRDs...), test.WithFieldIndexers(func(c cache.Cache) error {
return c.IndexField(ctx, &v1.Node{}, "spec.providerID", func(obj client.Object) []string {
return []string{obj.(*v1.Node).Spec.ProviderID}
})
Expand Down
4 changes: 3 additions & 1 deletion pkg/controllers/nodepool/counter/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"testing"
"time"

"sigs.k8s.io/karpenter/pkg/test/v1alpha1"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
v1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -62,7 +64,7 @@ func TestAPIs(t *testing.T) {

var _ = BeforeSuite(func() {
cloudProvider = fake.NewCloudProvider()
env = test.NewEnvironment(test.WithCRDs(apis.CRDs...))
env = test.NewEnvironment(test.WithCRDs(apis.CRDs...), test.WithCRDs(v1alpha1.CRDs...))
fakeClock = clock.NewFakeClock(time.Now())
cluster = state.NewCluster(fakeClock, env.Client)
nodeClaimController = informer.NewNodeClaimController(env.Client, cluster)
Expand Down
4 changes: 3 additions & 1 deletion pkg/controllers/nodepool/hash/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"testing"
"time"

"sigs.k8s.io/karpenter/pkg/test/v1alpha1"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/samber/lo"
Expand Down Expand Up @@ -50,7 +52,7 @@ func TestAPIs(t *testing.T) {
}

var _ = BeforeSuite(func() {
env = test.NewEnvironment(test.WithCRDs(apis.CRDs...))
env = test.NewEnvironment(test.WithCRDs(apis.CRDs...), test.WithCRDs(v1alpha1.CRDs...))
nodePoolController = hash.NewController(env.Client)
})

Expand Down
4 changes: 3 additions & 1 deletion pkg/controllers/nodepool/validation/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
"strings"
"testing"

"sigs.k8s.io/karpenter/pkg/test/v1alpha1"

"github.com/Pallinder/go-randomdata"
v1 "k8s.io/api/core/v1"

Expand Down Expand Up @@ -50,7 +52,7 @@ func TestAPIs(t *testing.T) {
}

var _ = BeforeSuite(func() {
env = test.NewEnvironment(test.WithCRDs(apis.CRDs...))
env = test.NewEnvironment(test.WithCRDs(apis.CRDs...), test.WithCRDs(v1alpha1.CRDs...))
nodePoolValidationController = NewController(env.Client)
})
var _ = AfterEach(func() {
Expand Down
4 changes: 3 additions & 1 deletion pkg/controllers/provisioning/scheduling/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import (
"testing"
"time"

"sigs.k8s.io/karpenter/pkg/test/v1alpha1"

"github.com/awslabs/operatorpkg/status"

io_prometheus_client "github.com/prometheus/client_model/go"
Expand Down Expand Up @@ -85,7 +87,7 @@ func TestScheduling(t *testing.T) {
}

var _ = BeforeSuite(func() {
env = test.NewEnvironment(test.WithCRDs(apis.CRDs...))
env = test.NewEnvironment(test.WithCRDs(apis.CRDs...), test.WithCRDs(v1alpha1.CRDs...))
ctx = options.ToContext(ctx, test.Options())
cloudProvider = fake.NewCloudProvider()
instanceTypes, _ := cloudProvider.GetInstanceTypes(ctx, nil)
Expand Down
4 changes: 3 additions & 1 deletion pkg/controllers/provisioning/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
"testing"
"time"

"sigs.k8s.io/karpenter/pkg/test/v1alpha1"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/samber/lo"
Expand Down Expand Up @@ -69,7 +71,7 @@ func TestAPIs(t *testing.T) {
}

var _ = BeforeSuite(func() {
env = test.NewEnvironment(test.WithCRDs(apis.CRDs...))
env = test.NewEnvironment(test.WithCRDs(apis.CRDs...), test.WithCRDs(v1alpha1.CRDs...))
ctx = options.ToContext(ctx, test.Options())
cloudProvider = fake.NewCloudProvider()
fakeClock = clock.NewFakeClock(time.Now())
Expand Down
4 changes: 3 additions & 1 deletion pkg/controllers/state/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (
"testing"
"time"

"sigs.k8s.io/karpenter/pkg/test/v1alpha1"

storagev1 "k8s.io/api/storage/v1"
"k8s.io/apimachinery/pkg/util/sets"
cloudproviderapi "k8s.io/cloud-provider/api"
Expand Down Expand Up @@ -74,7 +76,7 @@ func TestAPIs(t *testing.T) {
}

var _ = BeforeSuite(func() {
env = test.NewEnvironment(test.WithCRDs(apis.CRDs...))
env = test.NewEnvironment(test.WithCRDs(apis.CRDs...), test.WithCRDs(v1alpha1.CRDs...))
ctx = options.ToContext(ctx, test.Options())
cloudProvider = fake.NewCloudProvider()
fakeClock = clock.NewFakeClock(time.Now())
Expand Down
4 changes: 3 additions & 1 deletion pkg/utils/node/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"context"
"testing"

"sigs.k8s.io/karpenter/pkg/test/v1alpha1"

"sigs.k8s.io/karpenter/pkg/utils/node"

. "github.com/onsi/ginkgo/v2"
Expand Down Expand Up @@ -47,7 +49,7 @@ func TestAPIs(t *testing.T) {
}

var _ = BeforeSuite(func() {
env = test.NewEnvironment(test.WithCRDs(apis.CRDs...), test.WithFieldIndexers(test.NodeClaimFieldIndexer(ctx)))
env = test.NewEnvironment(test.WithCRDs(apis.CRDs...), test.WithCRDs(v1alpha1.CRDs...), test.WithFieldIndexers(test.NodeClaimFieldIndexer(ctx)))
})

var _ = AfterSuite(func() {
Expand Down
4 changes: 3 additions & 1 deletion pkg/utils/nodeclaim/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"context"
"testing"

"sigs.k8s.io/karpenter/pkg/test/v1alpha1"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/samber/lo"
Expand Down Expand Up @@ -50,7 +52,7 @@ func TestAPIs(t *testing.T) {
}

var _ = BeforeSuite(func() {
env = test.NewEnvironment(test.WithCRDs(apis.CRDs...))
env = test.NewEnvironment(test.WithCRDs(apis.CRDs...), test.WithCRDs(v1alpha1.CRDs...))
})

var _ = AfterSuite(func() {
Expand Down
Loading

0 comments on commit 9fe3828

Please sign in to comment.