diff --git a/pkg/reconciler/autoscaling/hpa/hpa_test.go b/pkg/reconciler/autoscaling/hpa/hpa_test.go index 55c7161ff064..ed5e9331cc60 100644 --- a/pkg/reconciler/autoscaling/hpa/hpa_test.go +++ b/pkg/reconciler/autoscaling/hpa/hpa_test.go @@ -113,7 +113,7 @@ func TestControllerCanReconcile(t *testing.T) { la.Promote(reconciler.UniversalBucket(), func(reconciler.Bucket, types.NamespacedName) {}) } - err = ctl.Reconciler.Reconcile(context.Background(), testNamespace+"/"+testRevision) + err = ctl.Reconciler.Reconcile(ctx, testNamespace+"/"+testRevision) if err != nil { t.Error("Reconcile() =", err) } diff --git a/pkg/reconciler/autoscaling/kpa/kpa_test.go b/pkg/reconciler/autoscaling/kpa/kpa_test.go index ba7ab71d6ce5..1bf8f26a3060 100644 --- a/pkg/reconciler/autoscaling/kpa/kpa_test.go +++ b/pkg/reconciler/autoscaling/kpa/kpa_test.go @@ -1402,7 +1402,7 @@ func TestUpdate(t *testing.T) { } // Wait for the Reconcile to complete. - if err := ctl.Reconciler.Reconcile(context.Background(), testNamespace+"/"+testRevision); err != nil { + if err := ctl.Reconciler.Reconcile(ctx, testNamespace+"/"+testRevision); err != nil { t.Error("Reconcile() =", err) } @@ -1429,7 +1429,7 @@ func TestUpdate(t *testing.T) { fakeservingclient.Get(ctx).AutoscalingV1alpha1().PodAutoscalers(testNamespace).Update(ctx, kpa, metav1.UpdateOptions{}) fakepainformer.Get(ctx).Informer().GetIndexer().Update(kpa) - if err := ctl.Reconciler.Reconcile(context.Background(), testNamespace+"/"+testRevision); err != nil { + if err := ctl.Reconciler.Reconcile(ctx, testNamespace+"/"+testRevision); err != nil { t.Error("Reconcile() =", err) } @@ -1475,7 +1475,7 @@ func TestControllerCreateError(t *testing.T) { la.Promote(reconciler.UniversalBucket(), func(reconciler.Bucket, types.NamespacedName) {}) } - got := ctl.Reconciler.Reconcile(context.Background(), key) + got := ctl.Reconciler.Reconcile(ctx, key) if !errors.Is(got, want) { t.Errorf("Reconcile() = %v, wanted %v wrapped", got, want) } @@ -1518,7 +1518,7 @@ func TestControllerUpdateError(t *testing.T) { la.Promote(reconciler.UniversalBucket(), func(reconciler.Bucket, types.NamespacedName) {}) } - got := ctl.Reconciler.Reconcile(context.Background(), key) + got := ctl.Reconciler.Reconcile(ctx, key) if !errors.Is(got, want) { t.Errorf("Reconcile() = %v, wanted %v wrapped", got, want) } @@ -1560,7 +1560,7 @@ func TestControllerGetError(t *testing.T) { la.Promote(reconciler.UniversalBucket(), func(reconciler.Bucket, types.NamespacedName) {}) } - got := ctl.Reconciler.Reconcile(context.Background(), key) + got := ctl.Reconciler.Reconcile(ctx, key) if !errors.Is(got, want) { t.Errorf("Reconcile() = %v, wanted %v wrapped", got, want) } @@ -1593,7 +1593,7 @@ func TestScaleFailure(t *testing.T) { la.Promote(reconciler.UniversalBucket(), func(reconciler.Bucket, types.NamespacedName) {}) } - if err := ctl.Reconciler.Reconcile(context.Background(), testNamespace+"/"+testRevision); err == nil { + if err := ctl.Reconciler.Reconcile(ctx, testNamespace+"/"+testRevision); err == nil { t.Error("Reconcile() = nil, wanted error") } } diff --git a/pkg/reconciler/domainmapping/reconciler_test.go b/pkg/reconciler/domainmapping/reconciler_test.go index 1bf42664057c..98634040db5d 100644 --- a/pkg/reconciler/domainmapping/reconciler_test.go +++ b/pkg/reconciler/domainmapping/reconciler_test.go @@ -17,11 +17,11 @@ limitations under the License. package domainmapping import ( - "context" "testing" network "knative.dev/networking/pkg" "knative.dev/networking/pkg/apis/networking" + logtesting "knative.dev/pkg/logging/testing" "knative.dev/serving/pkg/reconciler/domainmapping/config" ) @@ -71,7 +71,8 @@ func TestAutoTLSEnabled(t *testing.T) { wantAutoTLSEnabled: true, }} { t.Run(tc.name, func(t *testing.T) { - ctx := config.ToContext(context.Background(), &config.Config{ + ctx := logtesting.TestContextWithLogger(t) + ctx = config.ToContext(ctx, &config.Config{ Network: &network.Config{ AutoTLS: tc.configAutoTLSEnabled, }, diff --git a/pkg/reconciler/revision/revision_test.go b/pkg/reconciler/revision/revision_test.go index a7c3bbcdbb6b..ec1a08c7c372 100644 --- a/pkg/reconciler/revision/revision_test.go +++ b/pkg/reconciler/revision/revision_test.go @@ -170,7 +170,7 @@ func createRevision( // Since Reconcile looks in the lister, we need to add it to the informer fakerevisioninformer.Get(ctx).Informer().GetIndexer().Add(rev) - if err := controller.Reconciler.Reconcile(context.Background(), KeyOrDie(rev)); err == nil { + if err := controller.Reconciler.Reconcile(ctx, KeyOrDie(rev)); err == nil { rev, _, _ = addResourcesToInformers(t, ctx, rev) } return rev @@ -186,7 +186,7 @@ func updateRevision( fakeservingclient.Get(ctx).ServingV1().Revisions(rev.Namespace).Update(ctx, rev, metav1.UpdateOptions{}) fakerevisioninformer.Get(ctx).Informer().GetIndexer().Update(rev) - if err := controller.Reconciler.Reconcile(context.Background(), KeyOrDie(rev)); err == nil { + if err := controller.Reconciler.Reconcile(ctx, KeyOrDie(rev)); err == nil { addResourcesToInformers(t, ctx, rev) } } @@ -449,7 +449,7 @@ func TestStatusUnknownWhenDigestsNotResolvedYet(t *testing.T) { fakeservingclient.Get(ctx).ServingV1().Revisions(rev.Namespace).Create(ctx, rev, metav1.CreateOptions{}) fakerevisioninformer.Get(ctx).Informer().GetIndexer().Add(rev) - if err := controller.Reconciler.Reconcile(context.Background(), KeyOrDie(rev)); err != nil { + if err := controller.Reconciler.Reconcile(ctx, KeyOrDie(rev)); err != nil { t.Fatal("Reconcile failed:", err) } diff --git a/pkg/reconciler/route/route_test.go b/pkg/reconciler/route/route_test.go index 158f77dbe6b6..7e9245daa3ab 100644 --- a/pkg/reconciler/route/route_test.go +++ b/pkg/reconciler/route/route_test.go @@ -52,6 +52,7 @@ import ( "knative.dev/networking/pkg/apis/networking/v1alpha1" "knative.dev/pkg/configmap" "knative.dev/pkg/controller" + logtesting "knative.dev/pkg/logging/testing" pkgnet "knative.dev/pkg/network" "knative.dev/pkg/ptr" "knative.dev/pkg/reconciler" @@ -199,7 +200,7 @@ func TestCreateRouteForOneReserveRevision(t *testing.T) { // Since Reconcile looks in the lister, we need to add it to the informer fakerouteinformer.Get(ctx).Informer().GetIndexer().Add(route) - ctl.Reconciler.Reconcile(context.Background(), KeyOrDie(route)) + ctl.Reconciler.Reconcile(ctx, KeyOrDie(route)) ci := getRouteIngressFromClient(ctx, t, route) @@ -268,7 +269,7 @@ func TestCreateRouteForOneReserveRevision(t *testing.T) { } fakeingressinformer.Get(ctx).Informer().GetIndexer().Update(ci) - ctl.Reconciler.Reconcile(context.Background(), KeyOrDie(route)) + ctl.Reconciler.Reconcile(ctx, KeyOrDie(route)) // Look for the events. Events are delivered asynchronously so we need to use // hooks here. Each hook tests for a specific event. @@ -332,7 +333,7 @@ func TestCreateRouteWithMultipleTargets(t *testing.T) { // Since Reconcile looks in the lister, we need to add it to the informer. fakerouteinformer.Get(ctx).Informer().GetIndexer().Add(route) - ctl.Reconciler.Reconcile(context.Background(), KeyOrDie(route)) + ctl.Reconciler.Reconcile(ctx, KeyOrDie(route)) ci := getRouteIngressFromClient(ctx, t, route) domain := strings.Join([]string{route.Name, route.Namespace, defaultDomainSuffix}, ".") @@ -450,7 +451,7 @@ func TestCreateRouteWithOneTargetReserve(t *testing.T) { // Since Reconcile looks in the lister, we need to add it to the informer fakerouteinformer.Get(ctx).Informer().GetIndexer().Add(route) - ctl.Reconciler.Reconcile(context.Background(), KeyOrDie(route)) + ctl.Reconciler.Reconcile(ctx, KeyOrDie(route)) ci := getRouteIngressFromClient(ctx, t, route) domain := strings.Join([]string{route.Name, route.Namespace, defaultDomainSuffix}, ".") @@ -582,7 +583,7 @@ func TestCreateRouteWithDuplicateTargets(t *testing.T) { // Since Reconcile looks in the lister, we need to add it to the informer fakerouteinformer.Get(ctx).Informer().GetIndexer().Add(route) - ctl.Reconciler.Reconcile(context.Background(), KeyOrDie(route)) + ctl.Reconciler.Reconcile(ctx, KeyOrDie(route)) ci := getRouteIngressFromClient(ctx, t, route) domain := strings.Join([]string{route.Name, route.Namespace, defaultDomainSuffix}, ".") @@ -788,7 +789,7 @@ func TestCreateRouteWithNamedTargets(t *testing.T) { // Since Reconcile looks in the lister, we need to add it to the informer fakerouteinformer.Get(ctx).Informer().GetIndexer().Add(route) - ctl.Reconciler.Reconcile(context.Background(), KeyOrDie(route)) + ctl.Reconciler.Reconcile(ctx, KeyOrDie(route)) ci := getRouteIngressFromClient(ctx, t, route) domain := strings.Join([]string{route.Name, route.Namespace, defaultDomainSuffix}, ".") @@ -997,7 +998,7 @@ func TestCreateRouteWithNamedTargetsAndTagBasedRouting(t *testing.T) { fakeservingclient.Get(ctx).ServingV1().Routes(testNamespace).Create(ctx, route, metav1.CreateOptions{}) // Since Reconcile looks in the lister, we need to add it to the informer fakerouteinformer.Get(ctx).Informer().GetIndexer().Add(route) - ctl.Reconciler.Reconcile(context.Background(), KeyOrDie(route)) + ctl.Reconciler.Reconcile(ctx, KeyOrDie(route)) ci := getRouteIngressFromClient(ctx, t, route) domain := strings.Join([]string{route.Name, route.Namespace, defaultDomainSuffix}, ".") @@ -1325,7 +1326,7 @@ func TestUpdateDomainConfigMap(t *testing.T) { // Create a route. fakerouteinformer.Get(ctx).Informer().GetIndexer().Add(route) routeClient.Create(ctx, route, metav1.CreateOptions{}) - if err := ctl.Reconciler.Reconcile(context.Background(), KeyOrDie(route)); err != nil { + if err := ctl.Reconciler.Reconcile(ctx, KeyOrDie(route)); err != nil { t.Fatal("Reconcile() =", err) } addRouteToInformers(ctx, t, route) @@ -1375,7 +1376,7 @@ func TestUpdateDomainConfigMap(t *testing.T) { // Now that we know the exact version the reconciler is going to see in the // informers, let's reconcile. - if err := ctl.Reconciler.Reconcile(context.Background(), KeyOrDie(route)); err != nil { + if err := ctl.Reconciler.Reconcile(ctx, KeyOrDie(route)); err != nil { t.Fatal("Reconcile() =", err) } @@ -1625,7 +1626,8 @@ func TestAutoTLSEnabled(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - ctx := config.ToContext(context.Background(), &config.Config{ + ctx := logtesting.TestContextWithLogger(t) + ctx = config.ToContext(ctx, &config.Config{ Network: &network.Config{ AutoTLS: test.configAutoTLSEnabled, },