Skip to content

Commit

Permalink
Merge pull request #4757 from sedefsavas/crs-timeout
Browse files Browse the repository at this point in the history
🐛 CRS test fix: get ClusterResourceSetBinding with live client
  • Loading branch information
k8s-ci-robot authored Jun 8, 2021
2 parents 29cc056 + 67b6251 commit 786375f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
)

const (
timeout = time.Second * 5
timeout = time.Second * 15
defaultNamespaceName = "default"
)

Expand Down
5 changes: 4 additions & 1 deletion exp/addons/controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ import (
"os"
"testing"

corev1 "k8s.io/api/core/v1"
"sigs.k8s.io/cluster-api/controllers/remote"
"sigs.k8s.io/cluster-api/exp/addons/api/v1alpha4"
"sigs.k8s.io/cluster-api/internal/envtest"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller"
// +kubebuilder:scaffold:imports
)
Expand All @@ -35,7 +38,7 @@ var (

func TestMain(m *testing.M) {
fmt.Println("Creating new test environment")
env = envtest.New()
env = envtest.New([]client.Object{&corev1.ConfigMap{}, &corev1.Secret{}, &v1alpha4.ClusterResourceSetBinding{}}...)

trckr, err := remote.NewClusterCacheTracker(env.Manager, remote.ClusterCacheTrackerOptions{})
if err != nil {
Expand Down
16 changes: 11 additions & 5 deletions internal/envtest/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ type Environment struct {
//
// This function should be called only once for each package you're running tests within,
// usually the environment is initialized in a suite_test.go file within a `BeforeSuite` ginkgo block.
func New() *Environment {
func New(uncachedObjs ...client.Object) *Environment {
// Get the root of the current file to use in CRD paths.
_, filename, _, _ := goruntime.Caller(0) //nolint
root := path.Join(path.Dir(filename), "..", "..")
Expand Down Expand Up @@ -134,11 +134,17 @@ func New() *Environment {
panic(err)
}

objs := []client.Object{}
if len(uncachedObjs) > 0 {
objs = append(objs, uncachedObjs...)
}

options := manager.Options{
Scheme: scheme.Scheme,
MetricsBindAddress: "0",
CertDir: env.WebhookInstallOptions.LocalServingCertDir,
Port: env.WebhookInstallOptions.LocalServingPort,
Scheme: scheme.Scheme,
MetricsBindAddress: "0",
CertDir: env.WebhookInstallOptions.LocalServingCertDir,
Port: env.WebhookInstallOptions.LocalServingPort,
ClientDisableCacheFor: objs,
}

mgr, err := ctrl.NewManager(env.Config, options)
Expand Down

0 comments on commit 786375f

Please sign in to comment.