Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sleeps to the tests that panic in the logger. #5439

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkg/reconciler/clusteringress/clusteringress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1130,6 +1130,8 @@ func TestGlobalResyncOnUpdateNetwork(t *testing.T) {
if err := grp.Wait(); err != nil {
t.Errorf("Wait() = %v", err)
}
// To let the informers shut down.
time.Sleep(3 * time.Second)
}()

sharedClient := fakesharedclient.Get(ctx)
Expand Down
4 changes: 3 additions & 1 deletion pkg/reconciler/configuration/queueing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ func getTestConfiguration() *v1alpha1.Configuration {
}

func TestNewConfigurationCallsSyncHandler(t *testing.T) {
defer logtesting.ClearAll()
ctx, cancel, informers := SetupFakeContextWithCancel(t)

configMapWatcher := configmap.NewStaticWatcher(&corev1.ConfigMap{
Expand All @@ -104,6 +103,9 @@ func TestNewConfigurationCallsSyncHandler(t *testing.T) {
if err := eg.Wait(); err != nil {
t.Fatalf("Error running controller: %v", err)
}
// To let the informers shut down.
time.Sleep(3 * time.Second)
logtesting.ClearAll()
}()

servingClient := fakeservingclient.Get(ctx)
Expand Down
26 changes: 21 additions & 5 deletions pkg/reconciler/nscert/nscert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"fmt"
"testing"
"time"

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
Expand Down Expand Up @@ -59,12 +60,13 @@ var (

func newTestSetup(t *testing.T, configs ...*corev1.ConfigMap) (
ctx context.Context,
cancel context.CancelFunc,
informers []controller.Informer,
controller *ctrl.Impl,
rclr *reconciler,
configMapWatcher *configmap.ManualWatcher) {

ctx, informers = SetupFakeContext(t)
ctx, cancel, informers = SetupFakeContextWithCancel(t)
configMapWatcher = &configmap.ManualWatcher{Namespace: system.Namespace()}

controller = NewController(ctx, configMapWatcher)
Expand Down Expand Up @@ -191,8 +193,12 @@ func TestReconcile(t *testing.T) {
}

func TestUpdateDomainTemplate(t *testing.T) {
defer ClearAll()
ctx, _, _, reconciler, watcher := newTestSetup(t)
ctx, cancel, _, _, reconciler, watcher := newTestSetup(t)
defer func() {
cancel()
time.Sleep(3 * time.Second)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should make SetupFakeContextWithCancel(t) return a cancel function with this built in for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I commented on this, since not all the tests suffer from this, making all of them delayed sounds a bit harsh.

ClearAll()
}()

sorter := cmpopts.SortSlices(func(a, b string) bool {
return a < b
Expand Down Expand Up @@ -303,7 +309,12 @@ func TestDomainConfigDefaultDomain(t *testing.T) {
"other.com": "selector:\n app: dev",
},
}
ctx, _, _, reconciler, _ := newTestSetup(t, domCfg)
ctx, cancel, _, _, reconciler, _ := newTestSetup(t, domCfg)
defer func() {
cancel()
time.Sleep(3 * time.Second)
ClearAll()
}()

ns := kubeNamespace("testns")
nsInformer := fakeinformerfactory.Get(ctx).Core().V1().Namespaces()
Expand Down Expand Up @@ -336,7 +347,12 @@ func TestDomainConfigExplicitDefaultDomain(t *testing.T) {
"default.com": "",
},
}
ctx, _, _, reconciler, _ := newTestSetup(t, domCfg)
ctx, cancel, _, _, reconciler, _ := newTestSetup(t, domCfg)
defer func() {
cancel()
time.Sleep(3 * time.Second)
ClearAll()
}()

namespace := kubeNamespace("testns")
nsInformer := fakeinformerfactory.Get(ctx).Core().V1().Namespaces()
Expand Down
9 changes: 8 additions & 1 deletion pkg/reconciler/revision/revision_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,10 @@ func (r *errorResolver) Resolve(_ string, _ k8schain.Options, _ sets.String) (st

func TestResolutionFailed(t *testing.T) {
ctx, cancel, _, controller, _ := newTestController(t)
defer cancel()
defer func() {
cancel()
time.Sleep(3 * time.Second)
}()

// Unconditionally return this error during resolution.
errorMessage := "I am the expected error message, hear me ROAR!"
Expand Down Expand Up @@ -568,6 +571,8 @@ func TestGlobalResyncOnConfigMapUpdateRevision(t *testing.T) {
if err := grp.Wait(); err != nil {
t.Errorf("Wait() = %v", err)
}
// To allow all the informers shut down.
time.Sleep(3 * time.Second)
}()

servingClient := fakeservingclient.Get(ctx)
Expand Down Expand Up @@ -722,6 +727,8 @@ func TestGlobalResyncOnConfigMapUpdateDeployment(t *testing.T) {
if err := grp.Wait(); err != nil {
t.Errorf("Wait() = %v", err)
}
// To allow all the informers shut down.
time.Sleep(3 * time.Second)
}()

kubeClient := fakekubeclient.Get(ctx)
Expand Down