From 218ea15de5120660e4a31c25a7c8471132f83354 Mon Sep 17 00:00:00 2001 From: Adam Harwayne Date: Tue, 5 May 2020 17:07:44 -0700 Subject: [PATCH] Prefix PullSubscription and Topic testing functions with PubSub (#989) * Prefix PullSubscription and Topic functions with PubSub. This is being done because the intevents version will soon need the same functions and will be given the non-prefixed names (as they will continue to exist past the next release). * Listers too. --- .../events/auditlogs/auditlogs_test.go | 228 +++++----- pkg/reconciler/events/build/build_test.go | 28 +- pkg/reconciler/events/pubsub/pubsub_test.go | 30 +- .../events/scheduler/scheduler_test.go | 204 ++++----- pkg/reconciler/events/storage/storage_test.go | 180 ++++---- .../messaging/channel/channel_test.go | 4 +- .../keda/pullsubscription_test.go | 418 +++++++++--------- .../keda/resources/scaled_object_test.go | 8 +- .../static/pullsubscription_test.go | 396 ++++++++--------- pkg/reconciler/pubsub/reconciler_test.go | 348 +++++++-------- pkg/reconciler/pubsub/topic/topic_test.go | 256 +++++------ pkg/reconciler/testing/listers.go | 4 +- ...cription.go => pubsub_pullsubscription.go} | 101 ++--- .../testing/{topic.go => pubsub_topic.go} | 66 +-- test/e2e/test_pullsubscription.go | 12 +- 15 files changed, 1115 insertions(+), 1168 deletions(-) rename pkg/reconciler/testing/{pullsubscription.go => pubsub_pullsubscription.go} (54%) rename pkg/reconciler/testing/{topic.go => pubsub_topic.go} (59%) diff --git a/pkg/reconciler/events/auditlogs/auditlogs_test.go b/pkg/reconciler/events/auditlogs/auditlogs_test.go index 2a5f0e0898..dc086c9d60 100644 --- a/pkg/reconciler/events/auditlogs/auditlogs_test.go +++ b/pkg/reconciler/events/auditlogs/auditlogs_test.go @@ -155,16 +155,16 @@ func TestAllCases(t *testing.T) { WithCloudAuditLogsSourceTopicUnknown("TopicNotConfigured", failedToReconcileTopicMsg)), }}, WantCreates: []runtime.Object{ - NewTopic(sourceName, testNS, - WithTopicSpec(pubsubv1alpha1.TopicSpec{ + NewPubSubTopic(sourceName, testNS, + WithPubSubTopicSpec(pubsubv1alpha1.TopicSpec{ Topic: "cloudauditlogssource-" + sourceUID, PropagationPolicy: "CreateDelete", }), - WithTopicLabels(map[string]string{ + WithPubSubTopicLabels(map[string]string{ "receive-adapter": receiveAdapterName, "events.cloud.google.com/source-name": sourceName, }), - WithTopicOwnerReferences([]metav1.OwnerReference{sourceOwnerRef(sourceName, sourceUID)}), + WithPubSubTopicOwnerReferences([]metav1.OwnerReference{sourceOwnerRef(sourceName, sourceUID)}), ), }, WantPatches: []clientgotesting.PatchActionImpl{ @@ -182,8 +182,8 @@ func TestAllCases(t *testing.T) { WithCloudAuditLogsSourceMethodName(testMethodName), WithCloudAuditLogsSourceServiceName(testServiceName), ), - NewTopic(sourceName, testNS, - WithTopicTopicID(testTopicID), + NewPubSubTopic(sourceName, testNS, + WithPubSubTopicTopicID(testTopicID), ), }, Key: testNS + "/" + sourceName, @@ -209,9 +209,9 @@ func TestAllCases(t *testing.T) { WithCloudAuditLogsSourceMethodName(testMethodName), WithCloudAuditLogsSourceServiceName(testServiceName), ), - NewTopic(sourceName, testNS, - WithTopicReady(testTopicID), - WithTopicAddress(testTopicURI), + NewPubSubTopic(sourceName, testNS, + WithPubSubTopicReady(testTopicID), + WithPubSubTopicAddress(testTopicURI), ), }, Key: testNS + "/" + sourceName, @@ -239,10 +239,10 @@ func TestAllCases(t *testing.T) { WithCloudAuditLogsSourceMethodName(testMethodName), WithCloudAuditLogsSourceServiceName(testServiceName), ), - NewTopic(sourceName, testNS, - WithTopicReady(""), - WithTopicProjectID(testProject), - WithTopicAddress(testTopicURI), + NewPubSubTopic(sourceName, testNS, + WithPubSubTopicReady(""), + WithPubSubTopicProjectID(testProject), + WithPubSubTopicAddress(testTopicURI), ), }, Key: testNS + "/" + sourceName, @@ -270,10 +270,10 @@ func TestAllCases(t *testing.T) { WithCloudAuditLogsSourceMethodName(testMethodName), WithCloudAuditLogsSourceServiceName(testServiceName), ), - NewTopic(sourceName, testNS, - WithTopicReady("garbaaaaage"), - WithTopicProjectID(testProject), - WithTopicAddress(testTopicURI), + NewPubSubTopic(sourceName, testNS, + WithPubSubTopicReady("garbaaaaage"), + WithPubSubTopicProjectID(testProject), + WithPubSubTopicAddress(testTopicURI), ), }, Key: testNS + "/" + sourceName, @@ -301,9 +301,9 @@ func TestAllCases(t *testing.T) { WithCloudAuditLogsSourceMethodName(testMethodName), WithCloudAuditLogsSourceServiceName(testServiceName), ), - NewTopic(sourceName, testNS, - WithTopicFailed(), - WithTopicTopicID(testTopicID), + NewPubSubTopic(sourceName, testNS, + WithPubSubTopicFailed(), + WithPubSubTopicTopicID(testTopicID), ), }, Key: testNS + "/" + sourceName, @@ -330,9 +330,9 @@ func TestAllCases(t *testing.T) { WithCloudAuditLogsSourceMethodName(testMethodName), WithCloudAuditLogsSourceServiceName(testServiceName), ), - NewTopic(sourceName, testNS, - WithTopicUnknown(), - WithTopicTopicID(testTopicID), + NewPubSubTopic(sourceName, testNS, + WithPubSubTopicUnknown(), + WithPubSubTopicTopicID(testTopicID), ), }, Key: testNS + "/" + sourceName, @@ -359,10 +359,10 @@ func TestAllCases(t *testing.T) { WithCloudAuditLogsSourceServiceName(testServiceName), WithCloudAuditLogsSourceSink(sinkGVK, sinkName), ), - NewTopic(sourceName, testNS, - WithTopicReady(testTopicID), - WithTopicAddress(testTopicURI), - WithTopicProjectID(testProject), + NewPubSubTopic(sourceName, testNS, + WithPubSubTopicReady(testTopicID), + WithPubSubTopicAddress(testTopicURI), + WithPubSubTopicProjectID(testProject), ), }, Key: testNS + "/" + sourceName, @@ -378,23 +378,23 @@ func TestAllCases(t *testing.T) { ), }}, WantCreates: []runtime.Object{ - NewPullSubscriptionWithNoDefaults(sourceName, testNS, - WithPullSubscriptionSpecWithNoDefaults(pubsubv1alpha1.PullSubscriptionSpec{ + NewPubSubPullSubscriptionWithNoDefaults(sourceName, testNS, + WithPubSubPullSubscriptionSpecWithNoDefaults(pubsubv1alpha1.PullSubscriptionSpec{ Topic: testTopicID, PubSubSpec: duckv1alpha1.PubSubSpec{ Secret: &secret, }, AdapterType: converters.CloudAuditLogsConverter, }), - WithPullSubscriptionSink(sinkGVK, sinkName), - WithPullSubscriptionLabels(map[string]string{ + WithPubSubPullSubscriptionSink(sinkGVK, sinkName), + WithPubSubPullSubscriptionLabels(map[string]string{ "receive-adapter": receiveAdapterName, "events.cloud.google.com/source-name": sourceName, }), - WithPullSubscriptionAnnotations(map[string]string{ + WithPubSubPullSubscriptionAnnotations(map[string]string{ "metrics-resource-group": resourceGroup, }), - WithPullSubscriptionOwnerReferences([]metav1.OwnerReference{sourceOwnerRef(sourceName, sourceUID)}), + WithPubSubPullSubscriptionOwnerReferences([]metav1.OwnerReference{sourceOwnerRef(sourceName, sourceUID)}), ), }, WantPatches: []clientgotesting.PatchActionImpl{ @@ -412,12 +412,12 @@ func TestAllCases(t *testing.T) { WithCloudAuditLogsSourceServiceName(testServiceName), WithCloudAuditLogsSourceSink(sinkGVK, sinkName), ), - NewTopic(sourceName, testNS, - WithTopicReady(testTopicID), - WithTopicAddress(testTopicURI), - WithTopicProjectID(testProject), + NewPubSubTopic(sourceName, testNS, + WithPubSubTopicReady(testTopicID), + WithPubSubTopicAddress(testTopicURI), + WithPubSubTopicProjectID(testProject), ), - NewPullSubscriptionWithNoDefaults(sourceName, testNS), + NewPubSubPullSubscriptionWithNoDefaults(sourceName, testNS), }, Key: testNS + "/" + sourceName, WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ @@ -446,12 +446,12 @@ func TestAllCases(t *testing.T) { WithCloudAuditLogsSourceServiceName(testServiceName), WithCloudAuditLogsSourceSink(sinkGVK, sinkName), ), - NewTopic(sourceName, testNS, - WithTopicReady(testTopicID), - WithTopicAddress(testTopicURI), - WithTopicProjectID(testProject), + NewPubSubTopic(sourceName, testNS, + WithPubSubTopicReady(testTopicID), + WithPubSubTopicAddress(testTopicURI), + WithPubSubTopicProjectID(testProject), ), - NewPullSubscriptionWithNoDefaults(sourceName, testNS, WithPullSubscriptionFailed()), + NewPubSubPullSubscriptionWithNoDefaults(sourceName, testNS, WithPubSubPullSubscriptionFailed()), }, Key: testNS + "/" + sourceName, WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ @@ -480,12 +480,12 @@ func TestAllCases(t *testing.T) { WithCloudAuditLogsSourceServiceName(testServiceName), WithCloudAuditLogsSourceSink(sinkGVK, sinkName), ), - NewTopic(sourceName, testNS, - WithTopicReady(testTopicID), - WithTopicAddress(testTopicURI), - WithTopicProjectID(testProject), + NewPubSubTopic(sourceName, testNS, + WithPubSubTopicReady(testTopicID), + WithPubSubTopicAddress(testTopicURI), + WithPubSubTopicProjectID(testProject), ), - NewPullSubscriptionWithNoDefaults(sourceName, testNS, WithPullSubscriptionUnknown()), + NewPubSubPullSubscriptionWithNoDefaults(sourceName, testNS, WithPubSubPullSubscriptionUnknown()), }, Key: testNS + "/" + sourceName, WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ @@ -514,13 +514,13 @@ func TestAllCases(t *testing.T) { WithCloudAuditLogsSourceServiceName(testServiceName), WithCloudAuditLogsSourceSink(sinkGVK, sinkName), ), - NewTopic(sourceName, testNS, - WithTopicReady(testTopicID), - WithTopicAddress(testTopicURI), - WithTopicProjectID(testProject), + NewPubSubTopic(sourceName, testNS, + WithPubSubTopicReady(testTopicID), + WithPubSubTopicAddress(testTopicURI), + WithPubSubTopicProjectID(testProject), ), - NewPullSubscriptionWithNoDefaults(sourceName, testNS, - WithPullSubscriptionReady(sinkURI), + NewPubSubPullSubscriptionWithNoDefaults(sourceName, testNS, + WithPubSubPullSubscriptionReady(sinkURI), ), }, Key: testNS + "/" + sourceName, @@ -557,13 +557,13 @@ func TestAllCases(t *testing.T) { WithCloudAuditLogsSourceServiceName(testServiceName), WithCloudAuditLogsSourceSink(sinkGVK, sinkName), ), - NewTopic(sourceName, testNS, - WithTopicReady(testTopicID), - WithTopicAddress(testTopicURI), - WithTopicProjectID(testProject), + NewPubSubTopic(sourceName, testNS, + WithPubSubTopicReady(testTopicID), + WithPubSubTopicAddress(testTopicURI), + WithPubSubTopicProjectID(testProject), ), - NewPullSubscriptionWithNoDefaults(sourceName, testNS, - WithPullSubscriptionReady(sinkURI), + NewPubSubPullSubscriptionWithNoDefaults(sourceName, testNS, + WithPubSubPullSubscriptionReady(sinkURI), ), }, Key: testNS + "/" + sourceName, @@ -600,13 +600,13 @@ func TestAllCases(t *testing.T) { WithCloudAuditLogsSourceServiceName(testServiceName), WithCloudAuditLogsSourceSink(sinkGVK, sinkName), ), - NewTopic(sourceName, testNS, - WithTopicReady(testTopicID), - WithTopicAddress(testTopicURI), - WithTopicProjectID(testProject), + NewPubSubTopic(sourceName, testNS, + WithPubSubTopicReady(testTopicID), + WithPubSubTopicAddress(testTopicURI), + WithPubSubTopicProjectID(testProject), ), - NewPullSubscriptionWithNoDefaults(sourceName, testNS, - WithPullSubscriptionReady(sinkURI), + NewPubSubPullSubscriptionWithNoDefaults(sourceName, testNS, + WithPubSubPullSubscriptionReady(sinkURI), ), }, Key: testNS + "/" + sourceName, @@ -643,13 +643,13 @@ func TestAllCases(t *testing.T) { WithCloudAuditLogsSourceServiceName(testServiceName), WithCloudAuditLogsSourceSink(sinkGVK, sinkName), ), - NewTopic(sourceName, testNS, - WithTopicReady(testTopicID), - WithTopicAddress(testTopicURI), - WithTopicProjectID(testProject), + NewPubSubTopic(sourceName, testNS, + WithPubSubTopicReady(testTopicID), + WithPubSubTopicAddress(testTopicURI), + WithPubSubTopicProjectID(testProject), ), - NewPullSubscriptionWithNoDefaults(sourceName, testNS, - WithPullSubscriptionReady(sinkURI), + NewPubSubPullSubscriptionWithNoDefaults(sourceName, testNS, + WithPubSubPullSubscriptionReady(sinkURI), ), }, Key: testNS + "/" + sourceName, @@ -687,13 +687,13 @@ func TestAllCases(t *testing.T) { WithCloudAuditLogsSourceSink(sinkGVK, sinkName), WithCloudAuditLogsSourceServiceName(testServiceName), WithCloudAuditLogsSourceMethodName(testMethodName)), - NewTopic(sourceName, testNS, - WithTopicReady(testTopicID), - WithTopicAddress(testTopicURI), - WithTopicProjectID(testProject), + NewPubSubTopic(sourceName, testNS, + WithPubSubTopicReady(testTopicID), + WithPubSubTopicAddress(testTopicURI), + WithPubSubTopicProjectID(testProject), ), - NewPullSubscriptionWithNoDefaults(sourceName, testNS, - WithPullSubscriptionReady(sinkURI), + NewPubSubPullSubscriptionWithNoDefaults(sourceName, testNS, + WithPubSubPullSubscriptionReady(sinkURI), ), }, Key: testNS + "/" + sourceName, @@ -741,13 +741,13 @@ func TestAllCases(t *testing.T) { WithCloudAuditLogsSourceSink(sinkGVK, sinkName), WithCloudAuditLogsSourceServiceName(testServiceName), WithCloudAuditLogsSourceMethodName(testMethodName)), - NewTopic(sourceName, testNS, - WithTopicReady(testTopicID), - WithTopicAddress(testTopicURI), - WithTopicProjectID(testProject), + NewPubSubTopic(sourceName, testNS, + WithPubSubTopicReady(testTopicID), + WithPubSubTopicAddress(testTopicURI), + WithPubSubTopicProjectID(testProject), ), - NewPullSubscriptionWithNoDefaults(sourceName, testNS, - WithPullSubscriptionReady(sinkURI), + NewPubSubPullSubscriptionWithNoDefaults(sourceName, testNS, + WithPubSubPullSubscriptionReady(sinkURI), ), }, Key: testNS + "/" + sourceName, @@ -795,13 +795,13 @@ func TestAllCases(t *testing.T) { WithCloudAuditLogsSourceSink(sinkGVK, sinkName), WithCloudAuditLogsSourceServiceName(testServiceName), WithCloudAuditLogsSourceMethodName(testMethodName)), - NewTopic(sourceName, testNS, - WithTopicReady(testTopicID), - WithTopicAddress(testTopicURI), - WithTopicProjectID(testProject), + NewPubSubTopic(sourceName, testNS, + WithPubSubTopicReady(testTopicID), + WithPubSubTopicAddress(testTopicURI), + WithPubSubTopicProjectID(testProject), ), - NewPullSubscriptionWithNoDefaults(sourceName, testNS, - WithPullSubscriptionReady(sinkURI), + NewPubSubPullSubscriptionWithNoDefaults(sourceName, testNS, + WithPubSubPullSubscriptionReady(sinkURI), ), }, Key: testNS + "/" + sourceName, @@ -844,13 +844,13 @@ func TestAllCases(t *testing.T) { WithCloudAuditLogsSourceServiceName(testServiceName), WithCloudAuditLogsSourceSink(sinkGVK, sinkName), ), - NewTopic(sourceName, testNS, - WithTopicReady(testTopicID), - WithTopicAddress(testTopicURI), - WithTopicProjectID(testProject), + NewPubSubTopic(sourceName, testNS, + WithPubSubTopicReady(testTopicID), + WithPubSubTopicAddress(testTopicURI), + WithPubSubTopicProjectID(testProject), ), - NewPullSubscriptionWithNoDefaults(sourceName, testNS, - WithPullSubscriptionReady(sinkURI), + NewPubSubPullSubscriptionWithNoDefaults(sourceName, testNS, + WithPubSubPullSubscriptionReady(sinkURI), ), }, Key: testNS + "/" + sourceName, @@ -904,13 +904,13 @@ func TestAllCases(t *testing.T) { WithCloudAuditLogsSourceSinkID(testSinkID), WithCloudAuditLogsSourceDeletionTimestamp, ), - NewTopic(sourceName, testNS, - WithTopicReady(testTopicID), - WithTopicAddress(testTopicURI), - WithTopicProjectID(testProject), + NewPubSubTopic(sourceName, testNS, + WithPubSubTopicReady(testTopicID), + WithPubSubTopicAddress(testTopicURI), + WithPubSubTopicProjectID(testProject), ), - NewPullSubscriptionWithNoDefaults(sourceName, testNS, - WithPullSubscriptionReady(sinkURI), + NewPubSubPullSubscriptionWithNoDefaults(sourceName, testNS, + WithPubSubPullSubscriptionReady(sinkURI), ), }, Key: testNS + "/" + sourceName, @@ -950,13 +950,13 @@ func TestAllCases(t *testing.T) { WithCloudAuditLogsSourceSinkID(testSinkID), WithCloudAuditLogsSourceDeletionTimestamp, ), - NewTopic(sourceName, testNS, - WithTopicReady(testTopicID), - WithTopicAddress(testTopicURI), - WithTopicProjectID(testProject), + NewPubSubTopic(sourceName, testNS, + WithPubSubTopicReady(testTopicID), + WithPubSubTopicAddress(testTopicURI), + WithPubSubTopicProjectID(testProject), ), - NewPullSubscriptionWithNoDefaults(sourceName, testNS, - WithPullSubscriptionReady(sinkURI), + NewPubSubPullSubscriptionWithNoDefaults(sourceName, testNS, + WithPubSubPullSubscriptionReady(sinkURI), ), }, Key: testNS + "/" + sourceName, @@ -1008,13 +1008,13 @@ func TestAllCases(t *testing.T) { WithCloudAuditLogsSourceSinkID(testSinkID), WithCloudAuditLogsSourceDeletionTimestamp, ), - NewTopic(sourceName, testNS, - WithTopicReady(testTopicID), - WithTopicAddress(testTopicURI), - WithTopicProjectID(testProject), + NewPubSubTopic(sourceName, testNS, + WithPubSubTopicReady(testTopicID), + WithPubSubTopicAddress(testTopicURI), + WithPubSubTopicProjectID(testProject), ), - NewPullSubscriptionWithNoDefaults(sourceName, testNS, - WithPullSubscriptionReady(sinkURI), + NewPubSubPullSubscriptionWithNoDefaults(sourceName, testNS, + WithPubSubPullSubscriptionReady(sinkURI), ), }, Key: testNS + "/" + sourceName, diff --git a/pkg/reconciler/events/build/build_test.go b/pkg/reconciler/events/build/build_test.go index 1ff488d2be..7d36e23255 100644 --- a/pkg/reconciler/events/build/build_test.go +++ b/pkg/reconciler/events/build/build_test.go @@ -166,22 +166,22 @@ func TestAllCases(t *testing.T) { ), }}, WantCreates: []runtime.Object{ - NewPullSubscriptionWithNoDefaults(buildName, testNS, - WithPullSubscriptionSpecWithNoDefaults(pubsubv1alpha1.PullSubscriptionSpec{ + NewPubSubPullSubscriptionWithNoDefaults(buildName, testNS, + WithPubSubPullSubscriptionSpecWithNoDefaults(pubsubv1alpha1.PullSubscriptionSpec{ Topic: testTopicID, PubSubSpec: duckv1alpha1.PubSubSpec{ Secret: &secret, }, }), - WithPullSubscriptionSink(sinkGVK, sinkName), - WithPullSubscriptionLabels(map[string]string{ + WithPubSubPullSubscriptionSink(sinkGVK, sinkName), + WithPubSubPullSubscriptionLabels(map[string]string{ "receive-adapter": receiveAdapterName, "events.cloud.google.com/source-name": buildName, }), - WithPullSubscriptionAnnotations(map[string]string{ + WithPubSubPullSubscriptionAnnotations(map[string]string{ "metrics-resource-group": resourceGroup, }), - WithPullSubscriptionOwnerReferences([]metav1.OwnerReference{ownerRef()}), + WithPubSubPullSubscriptionOwnerReferences([]metav1.OwnerReference{ownerRef()}), ), }, WantPatches: []clientgotesting.PatchActionImpl{ @@ -199,8 +199,8 @@ func TestAllCases(t *testing.T) { WithCloudBuildSourceTopic(testTopicID), WithCloudBuildSourceSink(sinkGVK, sinkName), ), - NewPullSubscriptionWithNoDefaults(buildName, testNS, - WithPullSubscriptionReadyStatus(corev1.ConditionFalse, "PullSubscriptionFalse", "status false test message")), + NewPubSubPullSubscriptionWithNoDefaults(buildName, testNS, + WithPubSubPullSubscriptionReadyStatus(corev1.ConditionFalse, "PullSubscriptionFalse", "status false test message")), newSink(), }, Key: testNS + "/" + buildName, @@ -230,8 +230,8 @@ func TestAllCases(t *testing.T) { WithCloudBuildSourceTopic(testTopicID), WithCloudBuildSourceSink(sinkGVK, sinkName), ), - NewPullSubscriptionWithNoDefaults(buildName, testNS, - WithPullSubscriptionReadyStatus(corev1.ConditionUnknown, "PullSubscriptionUnknown", "status unknown test message")), + NewPubSubPullSubscriptionWithNoDefaults(buildName, testNS, + WithPubSubPullSubscriptionReadyStatus(corev1.ConditionUnknown, "PullSubscriptionUnknown", "status unknown test message")), newSink(), }, Key: testNS + "/" + buildName, @@ -261,9 +261,9 @@ func TestAllCases(t *testing.T) { WithCloudBuildSourceTopic(testTopicID), WithCloudBuildSourceSink(sinkGVK, sinkName), ), - NewPullSubscriptionWithNoDefaults(buildName, testNS, - WithPullSubscriptionReady(sinkURI), - WithPullSubscriptionReadyStatus(corev1.ConditionTrue, "PullSubscriptionNoReady", ""), + NewPubSubPullSubscriptionWithNoDefaults(buildName, testNS, + WithPubSubPullSubscriptionReady(sinkURI), + WithPubSubPullSubscriptionReadyStatus(corev1.ConditionTrue, "PullSubscriptionNoReady", ""), ), newSink(), }, @@ -342,7 +342,7 @@ func TestAllCases(t *testing.T) { PubSubBase: pubsub.NewPubSubBase(ctx, controllerAgentName, receiveAdapterName, cmw), Identity: identity.NewIdentity(ctx, NoopIAMPolicyManager), buildLister: listers.GetCloudBuildSourceLister(), - pullsubscriptionLister: listers.GetPullSubscriptionLister(), + pullsubscriptionLister: listers.GetPubSubPullSubscriptionLister(), serviceAccountLister: listers.GetServiceAccountLister(), } return cloudbuildsource.NewReconciler(ctx, r.Logger, r.RunClientSet, listers.GetCloudBuildSourceLister(), r.Recorder, r) diff --git a/pkg/reconciler/events/pubsub/pubsub_test.go b/pkg/reconciler/events/pubsub/pubsub_test.go index f8fbf6c2e1..061e4b08f0 100644 --- a/pkg/reconciler/events/pubsub/pubsub_test.go +++ b/pkg/reconciler/events/pubsub/pubsub_test.go @@ -164,23 +164,23 @@ func TestAllCases(t *testing.T) { ), }}, WantCreates: []runtime.Object{ - NewPullSubscriptionWithNoDefaults(pubsubName, testNS, - WithPullSubscriptionSpecWithNoDefaults(pubsubv1alpha1.PullSubscriptionSpec{ + NewPubSubPullSubscriptionWithNoDefaults(pubsubName, testNS, + WithPubSubPullSubscriptionSpecWithNoDefaults(pubsubv1alpha1.PullSubscriptionSpec{ Topic: testTopicID, PubSubSpec: duckv1alpha1.PubSubSpec{ Secret: &secret, }, }), - WithPullSubscriptionSink(sinkGVK, sinkName), - WithPullSubscriptionMode(pubsubv1alpha1.ModePushCompatible), - WithPullSubscriptionLabels(map[string]string{ + WithPubSubPullSubscriptionSink(sinkGVK, sinkName), + WithPubSubPullSubscriptionMode(pubsubv1alpha1.ModePushCompatible), + WithPubSubPullSubscriptionLabels(map[string]string{ "receive-adapter": receiveAdapterName, "events.cloud.google.com/source-name": pubsubName, }), - WithPullSubscriptionAnnotations(map[string]string{ + WithPubSubPullSubscriptionAnnotations(map[string]string{ "metrics-resource-group": resourceGroup, }), - WithPullSubscriptionOwnerReferences([]metav1.OwnerReference{ownerRef()}), + WithPubSubPullSubscriptionOwnerReferences([]metav1.OwnerReference{ownerRef()}), ), }, WantPatches: []clientgotesting.PatchActionImpl{ @@ -198,8 +198,8 @@ func TestAllCases(t *testing.T) { WithCloudPubSubSourceTopic(testTopicID), WithCloudPubSubSourceSink(sinkGVK, sinkName), ), - NewPullSubscriptionWithNoDefaults(pubsubName, testNS, - WithPullSubscriptionReadyStatus(corev1.ConditionFalse, "PullSubscriptionFalse", "status false test message")), + NewPubSubPullSubscriptionWithNoDefaults(pubsubName, testNS, + WithPubSubPullSubscriptionReadyStatus(corev1.ConditionFalse, "PullSubscriptionFalse", "status false test message")), newSink(), }, Key: testNS + "/" + pubsubName, @@ -229,8 +229,8 @@ func TestAllCases(t *testing.T) { WithCloudPubSubSourceTopic(testTopicID), WithCloudPubSubSourceSink(sinkGVK, sinkName), ), - NewPullSubscriptionWithNoDefaults(pubsubName, testNS, - WithPullSubscriptionReadyStatus(corev1.ConditionUnknown, "PullSubscriptionUnknown", "status unknown test message")), + NewPubSubPullSubscriptionWithNoDefaults(pubsubName, testNS, + WithPubSubPullSubscriptionReadyStatus(corev1.ConditionUnknown, "PullSubscriptionUnknown", "status unknown test message")), newSink(), }, Key: testNS + "/" + pubsubName, @@ -260,9 +260,9 @@ func TestAllCases(t *testing.T) { WithCloudPubSubSourceTopic(testTopicID), WithCloudPubSubSourceSink(sinkGVK, sinkName), ), - NewPullSubscriptionWithNoDefaults(pubsubName, testNS, - WithPullSubscriptionReady(sinkURI), - WithPullSubscriptionReadyStatus(corev1.ConditionTrue, "PullSubscriptionNoReady", ""), + NewPubSubPullSubscriptionWithNoDefaults(pubsubName, testNS, + WithPubSubPullSubscriptionReady(sinkURI), + WithPubSubPullSubscriptionReadyStatus(corev1.ConditionTrue, "PullSubscriptionNoReady", ""), ), newSink(), }, @@ -341,7 +341,7 @@ func TestAllCases(t *testing.T) { PubSubBase: pubsub.NewPubSubBase(ctx, controllerAgentName, receiveAdapterName, cmw), Identity: identity.NewIdentity(ctx, NoopIAMPolicyManager), pubsubLister: listers.GetCloudPubSubSourceLister(), - pullsubscriptionLister: listers.GetPullSubscriptionLister(), + pullsubscriptionLister: listers.GetPubSubPullSubscriptionLister(), serviceAccountLister: listers.GetServiceAccountLister(), } return cloudpubsubsource.NewReconciler(ctx, r.Logger, r.RunClientSet, listers.GetCloudPubSubSourceLister(), r.Recorder, r) diff --git a/pkg/reconciler/events/scheduler/scheduler_test.go b/pkg/reconciler/events/scheduler/scheduler_test.go index 08e3f61777..81392aca0f 100644 --- a/pkg/reconciler/events/scheduler/scheduler_test.go +++ b/pkg/reconciler/events/scheduler/scheduler_test.go @@ -178,16 +178,16 @@ func TestAllCases(t *testing.T) { ), }}, WantCreates: []runtime.Object{ - NewTopic(schedulerName, testNS, - WithTopicSpec(pubsubv1alpha1.TopicSpec{ + NewPubSubTopic(schedulerName, testNS, + WithPubSubTopicSpec(pubsubv1alpha1.TopicSpec{ Topic: testTopicID, PropagationPolicy: "CreateDelete", }), - WithTopicLabels(map[string]string{ + WithPubSubTopicLabels(map[string]string{ "receive-adapter": receiveAdapterName, "events.cloud.google.com/source-name": schedulerName, }), - WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), + WithPubSubTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), ), }, WantPatches: []clientgotesting.PatchActionImpl{ @@ -206,8 +206,8 @@ func TestAllCases(t *testing.T) { WithCloudSchedulerSourceData(testData), WithCloudSchedulerSourceSchedule(onceAMinuteSchedule), ), - NewTopic(schedulerName, testNS, - WithTopicTopicID(testTopicID), + NewPubSubTopic(schedulerName, testNS, + WithPubSubTopicTopicID(testTopicID), ), newSink(), }, @@ -237,9 +237,9 @@ func TestAllCases(t *testing.T) { WithCloudSchedulerSourceData(testData), WithCloudSchedulerSourceSchedule(onceAMinuteSchedule), ), - NewTopic(schedulerName, testNS, - WithTopicReady(testTopicID), - WithTopicAddress(testTopicURI), + NewPubSubTopic(schedulerName, testNS, + WithPubSubTopicReady(testTopicID), + WithPubSubTopicAddress(testTopicURI), ), newSink(), }, @@ -270,10 +270,10 @@ func TestAllCases(t *testing.T) { WithCloudSchedulerSourceData(testData), WithCloudSchedulerSourceSchedule(onceAMinuteSchedule), ), - NewTopic(schedulerName, testNS, - WithTopicReady(""), - WithTopicProjectID(testProject), - WithTopicAddress(testTopicURI), + NewPubSubTopic(schedulerName, testNS, + WithPubSubTopicReady(""), + WithPubSubTopicProjectID(testProject), + WithPubSubTopicAddress(testTopicURI), ), newSink(), }, @@ -304,10 +304,10 @@ func TestAllCases(t *testing.T) { WithCloudSchedulerSourceData(testData), WithCloudSchedulerSourceSchedule(onceAMinuteSchedule), ), - NewTopic(schedulerName, testNS, - WithTopicReady("garbaaaaage"), - WithTopicProjectID(testProject), - WithTopicAddress(testTopicURI), + NewPubSubTopic(schedulerName, testNS, + WithPubSubTopicReady("garbaaaaage"), + WithPubSubTopicProjectID(testProject), + WithPubSubTopicAddress(testTopicURI), ), newSink(), }, @@ -338,9 +338,9 @@ func TestAllCases(t *testing.T) { WithCloudSchedulerSourceData(testData), WithCloudSchedulerSourceSchedule(onceAMinuteSchedule), ), - NewTopic(schedulerName, testNS, - WithTopicFailed(), - WithTopicProjectID(testProject), + NewPubSubTopic(schedulerName, testNS, + WithPubSubTopicFailed(), + WithPubSubTopicProjectID(testProject), ), newSink(), }, @@ -371,9 +371,9 @@ func TestAllCases(t *testing.T) { WithCloudSchedulerSourceData(testData), WithCloudSchedulerSourceSchedule(onceAMinuteSchedule), ), - NewTopic(schedulerName, testNS, - WithTopicUnknown(), - WithTopicProjectID(testProject), + NewPubSubTopic(schedulerName, testNS, + WithPubSubTopicUnknown(), + WithPubSubTopicProjectID(testProject), ), newSink(), }, @@ -405,10 +405,10 @@ func TestAllCases(t *testing.T) { WithCloudSchedulerSourceData(testData), WithCloudSchedulerSourceSchedule(onceAMinuteSchedule), ), - NewTopic(schedulerName, testNS, - WithTopicReady(testTopicID), - WithTopicAddress(testTopicURI), - WithTopicProjectID(testProject), + NewPubSubTopic(schedulerName, testNS, + WithPubSubTopicReady(testTopicID), + WithPubSubTopicAddress(testTopicURI), + WithPubSubTopicProjectID(testProject), ), newSink(), }, @@ -425,21 +425,21 @@ func TestAllCases(t *testing.T) { ), }}, WantCreates: []runtime.Object{ - NewPullSubscriptionWithNoDefaults(schedulerName, testNS, - WithPullSubscriptionSpecWithNoDefaults(pubsubv1alpha1.PullSubscriptionSpec{ + NewPubSubPullSubscriptionWithNoDefaults(schedulerName, testNS, + WithPubSubPullSubscriptionSpecWithNoDefaults(pubsubv1alpha1.PullSubscriptionSpec{ Topic: testTopicID, PubSubSpec: duckv1alpha1.PubSubSpec{ Secret: &secret, }, }), - WithPullSubscriptionSink(sinkGVK, sinkName), - WithPullSubscriptionLabels(map[string]string{ + WithPubSubPullSubscriptionSink(sinkGVK, sinkName), + WithPubSubPullSubscriptionLabels(map[string]string{ "receive-adapter": receiveAdapterName, "events.cloud.google.com/source-name": schedulerName}), - WithPullSubscriptionAnnotations(map[string]string{ + WithPubSubPullSubscriptionAnnotations(map[string]string{ "metrics-resource-group": resourceGroup, }), - WithPullSubscriptionOwnerReferences([]metav1.OwnerReference{ownerRef()}), + WithPubSubPullSubscriptionOwnerReferences([]metav1.OwnerReference{ownerRef()}), ), }, WantPatches: []clientgotesting.PatchActionImpl{ @@ -458,12 +458,12 @@ func TestAllCases(t *testing.T) { WithCloudSchedulerSourceData(testData), WithCloudSchedulerSourceSchedule(onceAMinuteSchedule), ), - NewTopic(schedulerName, testNS, - WithTopicReady(testTopicID), - WithTopicAddress(testTopicURI), - WithTopicProjectID(testProject), + NewPubSubTopic(schedulerName, testNS, + WithPubSubTopicReady(testTopicID), + WithPubSubTopicAddress(testTopicURI), + WithPubSubTopicProjectID(testProject), ), - NewPullSubscriptionWithNoDefaults(schedulerName, testNS), + NewPubSubPullSubscriptionWithNoDefaults(schedulerName, testNS), newSink(), }, Key: testNS + "/" + schedulerName, @@ -494,12 +494,12 @@ func TestAllCases(t *testing.T) { WithCloudSchedulerSourceData(testData), WithCloudSchedulerSourceSchedule(onceAMinuteSchedule), ), - NewTopic(schedulerName, testNS, - WithTopicReady(testTopicID), - WithTopicAddress(testTopicURI), - WithTopicProjectID(testProject), + NewPubSubTopic(schedulerName, testNS, + WithPubSubTopicReady(testTopicID), + WithPubSubTopicAddress(testTopicURI), + WithPubSubTopicProjectID(testProject), ), - NewPullSubscriptionWithNoDefaults(schedulerName, testNS, WithPullSubscriptionFailed()), + NewPubSubPullSubscriptionWithNoDefaults(schedulerName, testNS, WithPubSubPullSubscriptionFailed()), newSink(), }, Key: testNS + "/" + schedulerName, @@ -530,12 +530,12 @@ func TestAllCases(t *testing.T) { WithCloudSchedulerSourceData(testData), WithCloudSchedulerSourceSchedule(onceAMinuteSchedule), ), - NewTopic(schedulerName, testNS, - WithTopicReady(testTopicID), - WithTopicAddress(testTopicURI), - WithTopicProjectID(testProject), + NewPubSubTopic(schedulerName, testNS, + WithPubSubTopicReady(testTopicID), + WithPubSubTopicAddress(testTopicURI), + WithPubSubTopicProjectID(testProject), ), - NewPullSubscriptionWithNoDefaults(schedulerName, testNS, WithPullSubscriptionUnknown()), + NewPubSubPullSubscriptionWithNoDefaults(schedulerName, testNS, WithPubSubPullSubscriptionUnknown()), newSink(), }, Key: testNS + "/" + schedulerName, @@ -567,13 +567,13 @@ func TestAllCases(t *testing.T) { WithCloudSchedulerSourceData(testData), WithCloudSchedulerSourceSchedule(onceAMinuteSchedule), ), - NewTopic(schedulerName, testNS, - WithTopicReady(testTopicID), - WithTopicAddress(testTopicURI), - WithTopicProjectID(testProject), + NewPubSubTopic(schedulerName, testNS, + WithPubSubTopicReady(testTopicID), + WithPubSubTopicAddress(testTopicURI), + WithPubSubTopicProjectID(testProject), ), - NewPullSubscriptionWithNoDefaults(schedulerName, testNS, - WithPullSubscriptionReady(sinkURI), + NewPubSubPullSubscriptionWithNoDefaults(schedulerName, testNS, + WithPubSubPullSubscriptionReady(sinkURI), ), newSink(), }, @@ -613,13 +613,13 @@ func TestAllCases(t *testing.T) { WithCloudSchedulerSourceData(testData), WithCloudSchedulerSourceSchedule(onceAMinuteSchedule), ), - NewTopic(schedulerName, testNS, - WithTopicReady(testTopicID), - WithTopicAddress(testTopicURI), - WithTopicProjectID(testProject), + NewPubSubTopic(schedulerName, testNS, + WithPubSubTopicReady(testTopicID), + WithPubSubTopicAddress(testTopicURI), + WithPubSubTopicProjectID(testProject), ), - NewPullSubscriptionWithNoDefaults(schedulerName, testNS, - WithPullSubscriptionReady(sinkURI), + NewPubSubPullSubscriptionWithNoDefaults(schedulerName, testNS, + WithPubSubPullSubscriptionReady(sinkURI), ), newSink(), }, @@ -659,13 +659,13 @@ func TestAllCases(t *testing.T) { WithCloudSchedulerSourceData(testData), WithCloudSchedulerSourceSchedule(onceAMinuteSchedule), ), - NewTopic(schedulerName, testNS, - WithTopicReady(testTopicID), - WithTopicAddress(testTopicURI), - WithTopicProjectID(testProject), + NewPubSubTopic(schedulerName, testNS, + WithPubSubTopicReady(testTopicID), + WithPubSubTopicAddress(testTopicURI), + WithPubSubTopicProjectID(testProject), ), - NewPullSubscriptionWithNoDefaults(schedulerName, testNS, - WithPullSubscriptionReady(sinkURI), + NewPubSubPullSubscriptionWithNoDefaults(schedulerName, testNS, + WithPubSubPullSubscriptionReady(sinkURI), ), newSink(), }, @@ -705,13 +705,13 @@ func TestAllCases(t *testing.T) { WithCloudSchedulerSourceData(testData), WithCloudSchedulerSourceSchedule(onceAMinuteSchedule), ), - NewTopic(schedulerName, testNS, - WithTopicReady(testTopicID), - WithTopicAddress(testTopicURI), - WithTopicProjectID(testProject), + NewPubSubTopic(schedulerName, testNS, + WithPubSubTopicReady(testTopicID), + WithPubSubTopicAddress(testTopicURI), + WithPubSubTopicProjectID(testProject), ), - NewPullSubscriptionWithNoDefaults(schedulerName, testNS, - WithPullSubscriptionReady(sinkURI), + NewPubSubPullSubscriptionWithNoDefaults(schedulerName, testNS, + WithPubSubPullSubscriptionReady(sinkURI), ), newSink(), }, @@ -752,13 +752,13 @@ func TestAllCases(t *testing.T) { WithCloudSchedulerSourceData(testData), WithCloudSchedulerSourceSchedule(onceAMinuteSchedule), ), - NewTopic(schedulerName, testNS, - WithTopicReady(testTopicID), - WithTopicAddress(testTopicURI), - WithTopicProjectID(testProject), + NewPubSubTopic(schedulerName, testNS, + WithPubSubTopicReady(testTopicID), + WithPubSubTopicAddress(testTopicURI), + WithPubSubTopicProjectID(testProject), ), - NewPullSubscriptionWithNoDefaults(schedulerName, testNS, - WithPullSubscriptionReady(sinkURI), + NewPubSubPullSubscriptionWithNoDefaults(schedulerName, testNS, + WithPubSubPullSubscriptionReady(sinkURI), ), newSink(), }, @@ -798,13 +798,13 @@ func TestAllCases(t *testing.T) { WithCloudSchedulerSourceData(testData), WithCloudSchedulerSourceSchedule(onceAMinuteSchedule), ), - NewTopic(schedulerName, testNS, - WithTopicReady(testTopicID), - WithTopicAddress(testTopicURI), - WithTopicProjectID(testProject), + NewPubSubTopic(schedulerName, testNS, + WithPubSubTopicReady(testTopicID), + WithPubSubTopicAddress(testTopicURI), + WithPubSubTopicProjectID(testProject), ), - NewPullSubscriptionWithNoDefaults(schedulerName, testNS, - WithPullSubscriptionReady(sinkURI), + NewPubSubPullSubscriptionWithNoDefaults(schedulerName, testNS, + WithPubSubPullSubscriptionReady(sinkURI), ), newSink(), }, @@ -845,13 +845,13 @@ func TestAllCases(t *testing.T) { WithCloudSchedulerSourceSinkURI(schedulerSinkURL), WithCloudSchedulerSourceDeletionTimestamp, ), - NewTopic(schedulerName, testNS, - WithTopicReady(testTopicID), - WithTopicAddress(testTopicURI), - WithTopicProjectID(testProject), + NewPubSubTopic(schedulerName, testNS, + WithPubSubTopicReady(testTopicID), + WithPubSubTopicAddress(testTopicURI), + WithPubSubTopicProjectID(testProject), ), - NewPullSubscriptionWithNoDefaults(schedulerName, testNS, - WithPullSubscriptionReady(sinkURI), + NewPubSubPullSubscriptionWithNoDefaults(schedulerName, testNS, + WithPubSubPullSubscriptionReady(sinkURI), ), newSink(), }, @@ -881,13 +881,13 @@ func TestAllCases(t *testing.T) { WithCloudSchedulerSourceSinkURI(schedulerSinkURL), WithCloudSchedulerSourceDeletionTimestamp, ), - NewTopic(schedulerName, testNS, - WithTopicReady(testTopicID), - WithTopicAddress(testTopicURI), - WithTopicProjectID(testProject), + NewPubSubTopic(schedulerName, testNS, + WithPubSubTopicReady(testTopicID), + WithPubSubTopicAddress(testTopicURI), + WithPubSubTopicProjectID(testProject), ), - NewPullSubscriptionWithNoDefaults(schedulerName, testNS, - WithPullSubscriptionReady(sinkURI), + NewPubSubPullSubscriptionWithNoDefaults(schedulerName, testNS, + WithPubSubPullSubscriptionReady(sinkURI), ), newSink(), }, @@ -917,13 +917,13 @@ func TestAllCases(t *testing.T) { WithCloudSchedulerSourceSinkURI(schedulerSinkURL), WithCloudSchedulerSourceDeletionTimestamp, ), - NewTopic(schedulerName, testNS, - WithTopicReady(testTopicID), - WithTopicAddress(testTopicURI), - WithTopicProjectID(testProject), + NewPubSubTopic(schedulerName, testNS, + WithPubSubTopicReady(testTopicID), + WithPubSubTopicAddress(testTopicURI), + WithPubSubTopicProjectID(testProject), ), - NewPullSubscriptionWithNoDefaults(schedulerName, testNS, - WithPullSubscriptionReady(sinkURI), + NewPubSubPullSubscriptionWithNoDefaults(schedulerName, testNS, + WithPubSubPullSubscriptionReady(sinkURI), ), newSink(), }, diff --git a/pkg/reconciler/events/storage/storage_test.go b/pkg/reconciler/events/storage/storage_test.go index 6b1b995ce2..e5639040ce 100644 --- a/pkg/reconciler/events/storage/storage_test.go +++ b/pkg/reconciler/events/storage/storage_test.go @@ -176,16 +176,16 @@ func TestAllCases(t *testing.T) { ), }}, WantCreates: []runtime.Object{ - NewTopic(storageName, testNS, - WithTopicSpec(pubsubv1alpha1.TopicSpec{ + NewPubSubTopic(storageName, testNS, + WithPubSubTopicSpec(pubsubv1alpha1.TopicSpec{ Topic: testTopicID, PropagationPolicy: "CreateDelete", }), - WithTopicLabels(map[string]string{ + WithPubSubTopicLabels(map[string]string{ "receive-adapter": receiveAdapterName, "events.cloud.google.com/source-name": storageName, }), - WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), + WithPubSubTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), ), }, WantPatches: []clientgotesting.PatchActionImpl{ @@ -203,8 +203,8 @@ func TestAllCases(t *testing.T) { WithCloudStorageSourceBucket(bucket), WithCloudStorageSourceSink(sinkGVK, sinkName), ), - NewTopic(storageName, testNS, - WithTopicTopicID(testTopicID), + NewPubSubTopic(storageName, testNS, + WithPubSubTopicTopicID(testTopicID), ), newSink(), }, @@ -233,9 +233,9 @@ func TestAllCases(t *testing.T) { WithCloudStorageSourceBucket(bucket), WithCloudStorageSourceSink(sinkGVK, sinkName), ), - NewTopic(storageName, testNS, - WithTopicReady(testTopicID), - WithTopicAddress(testTopicURI), + NewPubSubTopic(storageName, testNS, + WithPubSubTopicReady(testTopicID), + WithPubSubTopicAddress(testTopicURI), ), newSink(), }, @@ -265,10 +265,10 @@ func TestAllCases(t *testing.T) { WithCloudStorageSourceBucket(bucket), WithCloudStorageSourceSink(sinkGVK, sinkName), ), - NewTopic(storageName, testNS, - WithTopicReady(""), - WithTopicProjectID(testProject), - WithTopicAddress(testTopicURI), + NewPubSubTopic(storageName, testNS, + WithPubSubTopicReady(""), + WithPubSubTopicProjectID(testProject), + WithPubSubTopicAddress(testTopicURI), ), newSink(), }, @@ -298,10 +298,10 @@ func TestAllCases(t *testing.T) { WithCloudStorageSourceBucket(bucket), WithCloudStorageSourceSink(sinkGVK, sinkName), ), - NewTopic(storageName, testNS, - WithTopicReady("garbaaaaage"), - WithTopicProjectID(testProject), - WithTopicAddress(testTopicURI), + NewPubSubTopic(storageName, testNS, + WithPubSubTopicReady("garbaaaaage"), + WithPubSubTopicProjectID(testProject), + WithPubSubTopicAddress(testTopicURI), ), newSink(), }, @@ -331,9 +331,9 @@ func TestAllCases(t *testing.T) { WithCloudStorageSourceBucket(bucket), WithCloudStorageSourceSink(sinkGVK, sinkName), ), - NewTopic(storageName, testNS, - WithTopicFailed(), - WithTopicProjectID(testProject), + NewPubSubTopic(storageName, testNS, + WithPubSubTopicFailed(), + WithPubSubTopicProjectID(testProject), ), newSink(), }, @@ -363,9 +363,9 @@ func TestAllCases(t *testing.T) { WithCloudStorageSourceBucket(bucket), WithCloudStorageSourceSink(sinkGVK, sinkName), ), - NewTopic(storageName, testNS, - WithTopicUnknown(), - WithTopicProjectID(testProject), + NewPubSubTopic(storageName, testNS, + WithPubSubTopicUnknown(), + WithPubSubTopicProjectID(testProject), ), newSink(), }, @@ -395,10 +395,10 @@ func TestAllCases(t *testing.T) { WithCloudStorageSourceBucket(bucket), WithCloudStorageSourceSink(sinkGVK, sinkName), ), - NewTopic(storageName, testNS, - WithTopicReady(testTopicID), - WithTopicAddress(testTopicURI), - WithTopicProjectID(testProject), + NewPubSubTopic(storageName, testNS, + WithPubSubTopicReady(testTopicID), + WithPubSubTopicAddress(testTopicURI), + WithPubSubTopicProjectID(testProject), ), newSink(), }, @@ -416,22 +416,22 @@ func TestAllCases(t *testing.T) { ), }}, WantCreates: []runtime.Object{ - NewPullSubscriptionWithNoDefaults(storageName, testNS, - WithPullSubscriptionSpecWithNoDefaults(pubsubv1alpha1.PullSubscriptionSpec{ + NewPubSubPullSubscriptionWithNoDefaults(storageName, testNS, + WithPubSubPullSubscriptionSpecWithNoDefaults(pubsubv1alpha1.PullSubscriptionSpec{ Topic: testTopicID, PubSubSpec: duckv1alpha1.PubSubSpec{ Secret: &secret, }, }), - WithPullSubscriptionSink(sinkGVK, sinkName), - WithPullSubscriptionLabels(map[string]string{ + WithPubSubPullSubscriptionSink(sinkGVK, sinkName), + WithPubSubPullSubscriptionLabels(map[string]string{ "receive-adapter": receiveAdapterName, "events.cloud.google.com/source-name": storageName, }), - WithPullSubscriptionAnnotations(map[string]string{ + WithPubSubPullSubscriptionAnnotations(map[string]string{ "metrics-resource-group": resourceGroup, }), - WithPullSubscriptionOwnerReferences([]metav1.OwnerReference{ownerRef()}), + WithPubSubPullSubscriptionOwnerReferences([]metav1.OwnerReference{ownerRef()}), ), }, WantPatches: []clientgotesting.PatchActionImpl{ @@ -450,12 +450,12 @@ func TestAllCases(t *testing.T) { WithCloudStorageSourceBucket(bucket), WithCloudStorageSourceSink(sinkGVK, sinkName), ), - NewTopic(storageName, testNS, - WithTopicReady(testTopicID), - WithTopicAddress(testTopicURI), - WithTopicProjectID(testProject), + NewPubSubTopic(storageName, testNS, + WithPubSubTopicReady(testTopicID), + WithPubSubTopicAddress(testTopicURI), + WithPubSubTopicProjectID(testProject), ), - NewPullSubscriptionWithNoDefaults(storageName, testNS), + NewPubSubPullSubscriptionWithNoDefaults(storageName, testNS), newSink(), }, Key: testNS + "/" + storageName, @@ -486,12 +486,12 @@ func TestAllCases(t *testing.T) { WithCloudStorageSourceBucket(bucket), WithCloudStorageSourceSink(sinkGVK, sinkName), ), - NewTopic(storageName, testNS, - WithTopicReady(testTopicID), - WithTopicAddress(testTopicURI), - WithTopicProjectID(testProject), + NewPubSubTopic(storageName, testNS, + WithPubSubTopicReady(testTopicID), + WithPubSubTopicAddress(testTopicURI), + WithPubSubTopicProjectID(testProject), ), - NewPullSubscriptionWithNoDefaults(storageName, testNS, WithPullSubscriptionFailed()), + NewPubSubPullSubscriptionWithNoDefaults(storageName, testNS, WithPubSubPullSubscriptionFailed()), }, Key: testNS + "/" + storageName, WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ @@ -521,12 +521,12 @@ func TestAllCases(t *testing.T) { WithCloudStorageSourceBucket(bucket), WithCloudStorageSourceSink(sinkGVK, sinkName), ), - NewTopic(storageName, testNS, - WithTopicReady(testTopicID), - WithTopicAddress(testTopicURI), - WithTopicProjectID(testProject), + NewPubSubTopic(storageName, testNS, + WithPubSubTopicReady(testTopicID), + WithPubSubTopicAddress(testTopicURI), + WithPubSubTopicProjectID(testProject), ), - NewPullSubscriptionWithNoDefaults(storageName, testNS, WithPullSubscriptionUnknown()), + NewPubSubPullSubscriptionWithNoDefaults(storageName, testNS, WithPubSubPullSubscriptionUnknown()), }, Key: testNS + "/" + storageName, WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ @@ -559,13 +559,13 @@ func TestAllCases(t *testing.T) { WithCloudStorageSourceSink(sinkGVK, sinkName), WithCloudStorageSourceEventTypes([]string{storagev1alpha1.CloudStorageSourceFinalize}), ), - NewTopic(storageName, testNS, - WithTopicReady(testTopicID), - WithTopicAddress(testTopicURI), - WithTopicProjectID(testProject), + NewPubSubTopic(storageName, testNS, + WithPubSubTopicReady(testTopicID), + WithPubSubTopicAddress(testTopicURI), + WithPubSubTopicProjectID(testProject), ), - NewPullSubscriptionWithNoDefaults(storageName, testNS, - WithPullSubscriptionReady(sinkURI), + NewPubSubPullSubscriptionWithNoDefaults(storageName, testNS, + WithPubSubPullSubscriptionReady(sinkURI), ), newSink(), }, @@ -609,13 +609,13 @@ func TestAllCases(t *testing.T) { WithCloudStorageSourceSink(sinkGVK, sinkName), WithCloudStorageSourceEventTypes([]string{storagev1alpha1.CloudStorageSourceFinalize}), ), - NewTopic(storageName, testNS, - WithTopicReady(testTopicID), - WithTopicAddress(testTopicURI), - WithTopicProjectID(testProject), + NewPubSubTopic(storageName, testNS, + WithPubSubTopicReady(testTopicID), + WithPubSubTopicAddress(testTopicURI), + WithPubSubTopicProjectID(testProject), ), - NewPullSubscriptionWithNoDefaults(storageName, testNS, - WithPullSubscriptionReady(sinkURI), + NewPubSubPullSubscriptionWithNoDefaults(storageName, testNS, + WithPubSubPullSubscriptionReady(sinkURI), ), newSink(), }, @@ -661,13 +661,13 @@ func TestAllCases(t *testing.T) { WithCloudStorageSourceSink(sinkGVK, sinkName), WithCloudStorageSourceEventTypes([]string{storagev1alpha1.CloudStorageSourceFinalize}), ), - NewTopic(storageName, testNS, - WithTopicReady(testTopicID), - WithTopicAddress(testTopicURI), - WithTopicProjectID(testProject), + NewPubSubTopic(storageName, testNS, + WithPubSubTopicReady(testTopicID), + WithPubSubTopicAddress(testTopicURI), + WithPubSubTopicProjectID(testProject), ), - NewPullSubscriptionWithNoDefaults(storageName, testNS, - WithPullSubscriptionReady(sinkURI), + NewPubSubPullSubscriptionWithNoDefaults(storageName, testNS, + WithPubSubPullSubscriptionReady(sinkURI), ), newSink(), }, @@ -713,13 +713,13 @@ func TestAllCases(t *testing.T) { WithCloudStorageSourceSink(sinkGVK, sinkName), WithCloudStorageSourceEventTypes([]string{storagev1alpha1.CloudStorageSourceFinalize}), ), - NewTopic(storageName, testNS, - WithTopicReady(testTopicID), - WithTopicAddress(testTopicURI), - WithTopicProjectID(testProject), + NewPubSubTopic(storageName, testNS, + WithPubSubTopicReady(testTopicID), + WithPubSubTopicAddress(testTopicURI), + WithPubSubTopicProjectID(testProject), ), - NewPullSubscriptionWithNoDefaults(storageName, testNS, - WithPullSubscriptionReady(sinkURI), + NewPubSubPullSubscriptionWithNoDefaults(storageName, testNS, + WithPubSubPullSubscriptionReady(sinkURI), ), newSink(), }, @@ -768,13 +768,13 @@ func TestAllCases(t *testing.T) { WithCloudStorageSourceTopicReady(testTopicID), WithDeletionTimestamp(), ), - NewTopic(storageName, testNS, - WithTopicReady(testTopicID), - WithTopicAddress(testTopicURI), - WithTopicProjectID(testProject), + NewPubSubTopic(storageName, testNS, + WithPubSubTopicReady(testTopicID), + WithPubSubTopicAddress(testTopicURI), + WithPubSubTopicProjectID(testProject), ), - NewPullSubscriptionWithNoDefaults(storageName, testNS, - WithPullSubscriptionReady(sinkURI), + NewPubSubPullSubscriptionWithNoDefaults(storageName, testNS, + WithPubSubPullSubscriptionReady(sinkURI), ), newSink(), }, @@ -809,13 +809,13 @@ func TestAllCases(t *testing.T) { WithCloudStorageSourceTopicReady(testTopicID), WithDeletionTimestamp(), ), - NewTopic(storageName, testNS, - WithTopicReady(testTopicID), - WithTopicAddress(testTopicURI), - WithTopicProjectID(testProject), + NewPubSubTopic(storageName, testNS, + WithPubSubTopicReady(testTopicID), + WithPubSubTopicAddress(testTopicURI), + WithPubSubTopicProjectID(testProject), ), - NewPullSubscriptionWithNoDefaults(storageName, testNS, - WithPullSubscriptionReady(sinkURI), + NewPubSubPullSubscriptionWithNoDefaults(storageName, testNS, + WithPubSubPullSubscriptionReady(sinkURI), ), newSink(), }, @@ -881,13 +881,13 @@ func TestAllCases(t *testing.T) { WithCloudStorageSourceTopicReady(testTopicID), WithDeletionTimestamp(), ), - NewTopic(storageName, testNS, - WithTopicReady(testTopicID), - WithTopicAddress(testTopicURI), - WithTopicProjectID(testProject), + NewPubSubTopic(storageName, testNS, + WithPubSubTopicReady(testTopicID), + WithPubSubTopicAddress(testTopicURI), + WithPubSubTopicProjectID(testProject), ), - NewPullSubscriptionWithNoDefaults(storageName, testNS, - WithPullSubscriptionReady(sinkURI), + NewPubSubPullSubscriptionWithNoDefaults(storageName, testNS, + WithPubSubPullSubscriptionReady(sinkURI), ), newSink(), }, diff --git a/pkg/reconciler/messaging/channel/channel_test.go b/pkg/reconciler/messaging/channel/channel_test.go index 702e09b290..6af85adc81 100644 --- a/pkg/reconciler/messaging/channel/channel_test.go +++ b/pkg/reconciler/messaging/channel/channel_test.go @@ -534,8 +534,8 @@ func TestAllCases(t *testing.T) { Base: reconciler.NewBase(ctx, controllerAgentName, cmw), Identity: identity.NewIdentity(ctx, NoopIAMPolicyManager), channelLister: listers.GetChannelLister(), - topicLister: listers.GetTopicLister(), - pullSubscriptionLister: listers.GetPullSubscriptionLister(), + topicLister: listers.GetPubSubTopicLister(), + pullSubscriptionLister: listers.GetPubSubPullSubscriptionLister(), serviceAccountLister: listers.GetServiceAccountLister(), } return channel.NewReconciler(ctx, r.Logger, r.RunClientSet, listers.GetChannelLister(), r.Recorder, r) diff --git a/pkg/reconciler/pubsub/pullsubscription/keda/pullsubscription_test.go b/pkg/reconciler/pubsub/pullsubscription/keda/pullsubscription_test.go index f2e0a2f271..3679b89c38 100644 --- a/pkg/reconciler/pubsub/pullsubscription/keda/pullsubscription_test.go +++ b/pkg/reconciler/pubsub/pullsubscription/keda/pullsubscription_test.go @@ -126,21 +126,21 @@ func newSecret() *corev1.Secret { } func newPullSubscription(subscriptionId string) *pubsubv1alpha1.PullSubscription { - return NewPullSubscription(sourceName, testNS, - WithPullSubscriptionUID(sourceUID), - WithPullSubscriptionAnnotations(newAnnotations()), - WithPullSubscriptionObjectMetaGeneration(generation), - WithPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ + return NewPubSubPullSubscription(sourceName, testNS, + WithPubSubPullSubscriptionUID(sourceUID), + WithPubSubPullSubscriptionAnnotations(newAnnotations()), + WithPubSubPullSubscriptionObjectMetaGeneration(generation), + WithPubSubPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ Topic: testTopicID, PubSubSpec: v1alpha1.PubSubSpec{ Secret: &secret, Project: testProject, }, }), - WithPullSubscriptionSubscriptionID(subscriptionId), - WithInitPullSubscriptionConditions, - WithPullSubscriptionSink(sinkGVK, sinkName), - WithPullSubscriptionMarkSink(sinkURI), + WithPubSubPullSubscriptionSubscriptionID(subscriptionId), + WithPubSubInitPullSubscriptionConditions, + WithPubSubPullSubscriptionSink(sinkGVK, sinkName), + WithPubSubPullSubscriptionMarkSink(sinkURI), ) } @@ -203,17 +203,17 @@ func TestAllCases(t *testing.T) { }, { Name: "cannot get sink", Objects: []runtime.Object{ - NewPullSubscription(sourceName, testNS, - WithPullSubscriptionAnnotations(newAnnotations()), - WithPullSubscriptionObjectMetaGeneration(generation), - WithPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ + NewPubSubPullSubscription(sourceName, testNS, + WithPubSubPullSubscriptionAnnotations(newAnnotations()), + WithPubSubPullSubscriptionObjectMetaGeneration(generation), + WithPubSubPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ PubSubSpec: v1alpha1.PubSubSpec{ Secret: &secret, Project: testProject, }, Topic: testTopicID, }), - WithPullSubscriptionSink(sinkGVK, sinkName), + WithPubSubPullSubscriptionSink(sinkGVK, sinkName), ), newSecret(), }, @@ -227,40 +227,40 @@ func TestAllCases(t *testing.T) { patchFinalizers(testNS, sourceName, resourceGroup), }, WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ - Object: NewPullSubscription(sourceName, testNS, - WithPullSubscriptionAnnotations(newAnnotations()), - WithPullSubscriptionObjectMetaGeneration(generation), - WithPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ + Object: NewPubSubPullSubscription(sourceName, testNS, + WithPubSubPullSubscriptionAnnotations(newAnnotations()), + WithPubSubPullSubscriptionObjectMetaGeneration(generation), + WithPubSubPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ PubSubSpec: v1alpha1.PubSubSpec{ Secret: &secret, Project: testProject, }, Topic: testTopicID, }), - WithPullSubscriptionSink(sinkGVK, sinkName), + WithPubSubPullSubscriptionSink(sinkGVK, sinkName), // Updates - WithPullSubscriptionStatusObservedGeneration(generation), - WithInitPullSubscriptionConditions, - WithPullSubscriptionSinkNotFound(), + WithPubSubPullSubscriptionStatusObservedGeneration(generation), + WithPubSubInitPullSubscriptionConditions, + WithPubSubPullSubscriptionSinkNotFound(), ), }}, }, { Name: "create client fails", Objects: []runtime.Object{ - NewPullSubscription(sourceName, testNS, - WithPullSubscriptionUID(sourceUID), - WithPullSubscriptionAnnotations(newAnnotations()), - WithPullSubscriptionObjectMetaGeneration(generation), - WithPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ + NewPubSubPullSubscription(sourceName, testNS, + WithPubSubPullSubscriptionUID(sourceUID), + WithPubSubPullSubscriptionAnnotations(newAnnotations()), + WithPubSubPullSubscriptionObjectMetaGeneration(generation), + WithPubSubPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ PubSubSpec: v1alpha1.PubSubSpec{ Secret: &secret, Project: testProject, }, Topic: testTopicID, }), - WithInitPullSubscriptionConditions, - WithPullSubscriptionSink(sinkGVK, sinkName), - WithPullSubscriptionMarkSink(sinkURI), + WithPubSubInitPullSubscriptionConditions, + WithPubSubPullSubscriptionSink(sinkGVK, sinkName), + WithPubSubPullSubscriptionMarkSink(sinkURI), ), newSink(), newSecret(), @@ -276,25 +276,25 @@ func TestAllCases(t *testing.T) { }, }, WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ - Object: NewPullSubscription(sourceName, testNS, - WithPullSubscriptionUID(sourceUID), - WithPullSubscriptionAnnotations(newAnnotations()), - WithPullSubscriptionObjectMetaGeneration(generation), - WithPullSubscriptionStatusObservedGeneration(generation), - WithPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ + Object: NewPubSubPullSubscription(sourceName, testNS, + WithPubSubPullSubscriptionUID(sourceUID), + WithPubSubPullSubscriptionAnnotations(newAnnotations()), + WithPubSubPullSubscriptionObjectMetaGeneration(generation), + WithPubSubPullSubscriptionStatusObservedGeneration(generation), + WithPubSubPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ PubSubSpec: v1alpha1.PubSubSpec{ Secret: &secret, Project: testProject, }, Topic: testTopicID, }), - WithInitPullSubscriptionConditions, - WithPullSubscriptionProjectID(testProject), - WithPullSubscriptionSink(sinkGVK, sinkName), - WithPullSubscriptionMarkSink(sinkURI), - WithPullSubscriptionMarkNoTransformer("TransformerNil", "Transformer is nil"), - WithPullSubscriptionTransformerURI(nil), - WithPullSubscriptionMarkNoSubscription("SubscriptionReconcileFailed", fmt.Sprintf("%s: %s", failedToReconcileSubscriptionMsg, "client-create-induced-error"))), + WithPubSubInitPullSubscriptionConditions, + WithPubSubPullSubscriptionProjectID(testProject), + WithPubSubPullSubscriptionSink(sinkGVK, sinkName), + WithPubSubPullSubscriptionMarkSink(sinkURI), + WithPubSubPullSubscriptionMarkNoTransformer("TransformerNil", "Transformer is nil"), + WithPubSubPullSubscriptionTransformerURI(nil), + WithPubSubPullSubscriptionMarkNoSubscription("SubscriptionReconcileFailed", fmt.Sprintf("%s: %s", failedToReconcileSubscriptionMsg, "client-create-induced-error"))), }}, WantPatches: []clientgotesting.PatchActionImpl{ patchFinalizers(testNS, sourceName, resourceGroup), @@ -302,20 +302,20 @@ func TestAllCases(t *testing.T) { }, { Name: "topic exists fails", Objects: []runtime.Object{ - NewPullSubscription(sourceName, testNS, - WithPullSubscriptionUID(sourceUID), - WithPullSubscriptionAnnotations(newAnnotations()), - WithPullSubscriptionObjectMetaGeneration(generation), - WithPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ + NewPubSubPullSubscription(sourceName, testNS, + WithPubSubPullSubscriptionUID(sourceUID), + WithPubSubPullSubscriptionAnnotations(newAnnotations()), + WithPubSubPullSubscriptionObjectMetaGeneration(generation), + WithPubSubPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ PubSubSpec: v1alpha1.PubSubSpec{ Secret: &secret, Project: testProject, }, Topic: testTopicID, }), - WithInitPullSubscriptionConditions, - WithPullSubscriptionSink(sinkGVK, sinkName), - WithPullSubscriptionMarkSink(sinkURI), + WithPubSubInitPullSubscriptionConditions, + WithPubSubPullSubscriptionSink(sinkGVK, sinkName), + WithPubSubPullSubscriptionMarkSink(sinkURI), ), newSink(), newSecret(), @@ -333,25 +333,25 @@ func TestAllCases(t *testing.T) { }, }, WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ - Object: NewPullSubscription(sourceName, testNS, - WithPullSubscriptionUID(sourceUID), - WithPullSubscriptionAnnotations(newAnnotations()), - WithPullSubscriptionObjectMetaGeneration(generation), - WithPullSubscriptionStatusObservedGeneration(generation), - WithPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ + Object: NewPubSubPullSubscription(sourceName, testNS, + WithPubSubPullSubscriptionUID(sourceUID), + WithPubSubPullSubscriptionAnnotations(newAnnotations()), + WithPubSubPullSubscriptionObjectMetaGeneration(generation), + WithPubSubPullSubscriptionStatusObservedGeneration(generation), + WithPubSubPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ PubSubSpec: v1alpha1.PubSubSpec{ Secret: &secret, Project: testProject, }, Topic: testTopicID, }), - WithInitPullSubscriptionConditions, - WithPullSubscriptionProjectID(testProject), - WithPullSubscriptionSink(sinkGVK, sinkName), - WithPullSubscriptionMarkSink(sinkURI), - WithPullSubscriptionMarkNoTransformer("TransformerNil", "Transformer is nil"), - WithPullSubscriptionTransformerURI(nil), - WithPullSubscriptionMarkNoSubscription("SubscriptionReconcileFailed", fmt.Sprintf("%s: %s", failedToReconcileSubscriptionMsg, "topic-exists-induced-error"))), + WithPubSubInitPullSubscriptionConditions, + WithPubSubPullSubscriptionProjectID(testProject), + WithPubSubPullSubscriptionSink(sinkGVK, sinkName), + WithPubSubPullSubscriptionMarkSink(sinkURI), + WithPubSubPullSubscriptionMarkNoTransformer("TransformerNil", "Transformer is nil"), + WithPubSubPullSubscriptionTransformerURI(nil), + WithPubSubPullSubscriptionMarkNoSubscription("SubscriptionReconcileFailed", fmt.Sprintf("%s: %s", failedToReconcileSubscriptionMsg, "topic-exists-induced-error"))), }}, WantPatches: []clientgotesting.PatchActionImpl{ patchFinalizers(testNS, sourceName, resourceGroup), @@ -359,20 +359,20 @@ func TestAllCases(t *testing.T) { }, { Name: "topic does not exist", Objects: []runtime.Object{ - NewPullSubscription(sourceName, testNS, - WithPullSubscriptionUID(sourceUID), - WithPullSubscriptionAnnotations(newAnnotations()), - WithPullSubscriptionObjectMetaGeneration(generation), - WithPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ + NewPubSubPullSubscription(sourceName, testNS, + WithPubSubPullSubscriptionUID(sourceUID), + WithPubSubPullSubscriptionAnnotations(newAnnotations()), + WithPubSubPullSubscriptionObjectMetaGeneration(generation), + WithPubSubPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ PubSubSpec: v1alpha1.PubSubSpec{ Secret: &secret, Project: testProject, }, Topic: testTopicID, }), - WithInitPullSubscriptionConditions, - WithPullSubscriptionSink(sinkGVK, sinkName), - WithPullSubscriptionMarkSink(sinkURI), + WithPubSubInitPullSubscriptionConditions, + WithPubSubPullSubscriptionSink(sinkGVK, sinkName), + WithPubSubPullSubscriptionMarkSink(sinkURI), ), newSink(), newSecret(), @@ -390,25 +390,25 @@ func TestAllCases(t *testing.T) { }, }, WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ - Object: NewPullSubscription(sourceName, testNS, - WithPullSubscriptionUID(sourceUID), - WithPullSubscriptionAnnotations(newAnnotations()), - WithPullSubscriptionObjectMetaGeneration(generation), - WithPullSubscriptionStatusObservedGeneration(generation), - WithPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ + Object: NewPubSubPullSubscription(sourceName, testNS, + WithPubSubPullSubscriptionUID(sourceUID), + WithPubSubPullSubscriptionAnnotations(newAnnotations()), + WithPubSubPullSubscriptionObjectMetaGeneration(generation), + WithPubSubPullSubscriptionStatusObservedGeneration(generation), + WithPubSubPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ PubSubSpec: v1alpha1.PubSubSpec{ Secret: &secret, Project: testProject, }, Topic: testTopicID, }), - WithInitPullSubscriptionConditions, - WithPullSubscriptionProjectID(testProject), - WithPullSubscriptionSink(sinkGVK, sinkName), - WithPullSubscriptionMarkSink(sinkURI), - WithPullSubscriptionMarkNoTransformer("TransformerNil", "Transformer is nil"), - WithPullSubscriptionTransformerURI(nil), - WithPullSubscriptionMarkNoSubscription("SubscriptionReconcileFailed", fmt.Sprintf("%s: Topic %q does not exist", failedToReconcileSubscriptionMsg, testTopicID))), + WithPubSubInitPullSubscriptionConditions, + WithPubSubPullSubscriptionProjectID(testProject), + WithPubSubPullSubscriptionSink(sinkGVK, sinkName), + WithPubSubPullSubscriptionMarkSink(sinkURI), + WithPubSubPullSubscriptionMarkNoTransformer("TransformerNil", "Transformer is nil"), + WithPubSubPullSubscriptionTransformerURI(nil), + WithPubSubPullSubscriptionMarkNoSubscription("SubscriptionReconcileFailed", fmt.Sprintf("%s: Topic %q does not exist", failedToReconcileSubscriptionMsg, testTopicID))), }}, WantPatches: []clientgotesting.PatchActionImpl{ patchFinalizers(testNS, sourceName, resourceGroup), @@ -416,20 +416,20 @@ func TestAllCases(t *testing.T) { }, { Name: "subscription exists fails", Objects: []runtime.Object{ - NewPullSubscription(sourceName, testNS, - WithPullSubscriptionUID(sourceUID), - WithPullSubscriptionAnnotations(newAnnotations()), - WithPullSubscriptionObjectMetaGeneration(generation), - WithPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ + NewPubSubPullSubscription(sourceName, testNS, + WithPubSubPullSubscriptionUID(sourceUID), + WithPubSubPullSubscriptionAnnotations(newAnnotations()), + WithPubSubPullSubscriptionObjectMetaGeneration(generation), + WithPubSubPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ PubSubSpec: v1alpha1.PubSubSpec{ Secret: &secret, Project: testProject, }, Topic: testTopicID, }), - WithInitPullSubscriptionConditions, - WithPullSubscriptionSink(sinkGVK, sinkName), - WithPullSubscriptionMarkSink(sinkURI), + WithPubSubInitPullSubscriptionConditions, + WithPubSubPullSubscriptionSink(sinkGVK, sinkName), + WithPubSubPullSubscriptionMarkSink(sinkURI), ), newSink(), newSecret(), @@ -447,25 +447,25 @@ func TestAllCases(t *testing.T) { }, }, WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ - Object: NewPullSubscription(sourceName, testNS, - WithPullSubscriptionUID(sourceUID), - WithPullSubscriptionAnnotations(newAnnotations()), - WithPullSubscriptionObjectMetaGeneration(generation), - WithPullSubscriptionStatusObservedGeneration(generation), - WithPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ + Object: NewPubSubPullSubscription(sourceName, testNS, + WithPubSubPullSubscriptionUID(sourceUID), + WithPubSubPullSubscriptionAnnotations(newAnnotations()), + WithPubSubPullSubscriptionObjectMetaGeneration(generation), + WithPubSubPullSubscriptionStatusObservedGeneration(generation), + WithPubSubPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ PubSubSpec: v1alpha1.PubSubSpec{ Secret: &secret, Project: testProject, }, Topic: testTopicID, }), - WithInitPullSubscriptionConditions, - WithPullSubscriptionProjectID(testProject), - WithPullSubscriptionSink(sinkGVK, sinkName), - WithPullSubscriptionMarkSink(sinkURI), - WithPullSubscriptionMarkNoTransformer("TransformerNil", "Transformer is nil"), - WithPullSubscriptionTransformerURI(nil), - WithPullSubscriptionMarkNoSubscription("SubscriptionReconcileFailed", fmt.Sprintf("%s: %s", failedToReconcileSubscriptionMsg, "subscription-exists-induced-error"))), + WithPubSubInitPullSubscriptionConditions, + WithPubSubPullSubscriptionProjectID(testProject), + WithPubSubPullSubscriptionSink(sinkGVK, sinkName), + WithPubSubPullSubscriptionMarkSink(sinkURI), + WithPubSubPullSubscriptionMarkNoTransformer("TransformerNil", "Transformer is nil"), + WithPubSubPullSubscriptionTransformerURI(nil), + WithPubSubPullSubscriptionMarkNoSubscription("SubscriptionReconcileFailed", fmt.Sprintf("%s: %s", failedToReconcileSubscriptionMsg, "subscription-exists-induced-error"))), }}, WantPatches: []clientgotesting.PatchActionImpl{ patchFinalizers(testNS, sourceName, resourceGroup), @@ -473,20 +473,20 @@ func TestAllCases(t *testing.T) { }, { Name: "create subscription fails", Objects: []runtime.Object{ - NewPullSubscription(sourceName, testNS, - WithPullSubscriptionUID(sourceUID), - WithPullSubscriptionAnnotations(newAnnotations()), - WithPullSubscriptionObjectMetaGeneration(generation), - WithPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ + NewPubSubPullSubscription(sourceName, testNS, + WithPubSubPullSubscriptionUID(sourceUID), + WithPubSubPullSubscriptionAnnotations(newAnnotations()), + WithPubSubPullSubscriptionObjectMetaGeneration(generation), + WithPubSubPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ PubSubSpec: v1alpha1.PubSubSpec{ Secret: &secret, Project: testProject, }, Topic: testTopicID, }), - WithInitPullSubscriptionConditions, - WithPullSubscriptionSink(sinkGVK, sinkName), - WithPullSubscriptionMarkSink(sinkURI), + WithPubSubInitPullSubscriptionConditions, + WithPubSubPullSubscriptionSink(sinkGVK, sinkName), + WithPubSubPullSubscriptionMarkSink(sinkURI), ), newSink(), newSecret(), @@ -505,25 +505,25 @@ func TestAllCases(t *testing.T) { }, }, WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ - Object: NewPullSubscription(sourceName, testNS, - WithPullSubscriptionUID(sourceUID), - WithPullSubscriptionAnnotations(newAnnotations()), - WithPullSubscriptionObjectMetaGeneration(generation), - WithPullSubscriptionStatusObservedGeneration(generation), - WithPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ + Object: NewPubSubPullSubscription(sourceName, testNS, + WithPubSubPullSubscriptionUID(sourceUID), + WithPubSubPullSubscriptionAnnotations(newAnnotations()), + WithPubSubPullSubscriptionObjectMetaGeneration(generation), + WithPubSubPullSubscriptionStatusObservedGeneration(generation), + WithPubSubPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ PubSubSpec: v1alpha1.PubSubSpec{ Secret: &secret, Project: testProject, }, Topic: testTopicID, }), - WithInitPullSubscriptionConditions, - WithPullSubscriptionProjectID(testProject), - WithPullSubscriptionSink(sinkGVK, sinkName), - WithPullSubscriptionMarkSink(sinkURI), - WithPullSubscriptionMarkNoTransformer("TransformerNil", "Transformer is nil"), - WithPullSubscriptionTransformerURI(nil), - WithPullSubscriptionMarkNoSubscription("SubscriptionReconcileFailed", fmt.Sprintf("%s: %s", failedToReconcileSubscriptionMsg, "subscription-create-induced-error"))), + WithPubSubInitPullSubscriptionConditions, + WithPubSubPullSubscriptionProjectID(testProject), + WithPubSubPullSubscriptionSink(sinkGVK, sinkName), + WithPubSubPullSubscriptionMarkSink(sinkURI), + WithPubSubPullSubscriptionMarkNoTransformer("TransformerNil", "Transformer is nil"), + WithPubSubPullSubscriptionTransformerURI(nil), + WithPubSubPullSubscriptionMarkNoSubscription("SubscriptionReconcileFailed", fmt.Sprintf("%s: %s", failedToReconcileSubscriptionMsg, "subscription-create-induced-error"))), }}, WantPatches: []clientgotesting.PatchActionImpl{ patchFinalizers(testNS, sourceName, resourceGroup), @@ -552,27 +552,27 @@ func TestAllCases(t *testing.T) { newReceiveAdapter(context.Background(), testImage, nil), }, WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ - Object: NewPullSubscription(sourceName, testNS, - WithPullSubscriptionUID(sourceUID), - WithPullSubscriptionAnnotations(newAnnotations()), - WithPullSubscriptionObjectMetaGeneration(generation), - WithPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ + Object: NewPubSubPullSubscription(sourceName, testNS, + WithPubSubPullSubscriptionUID(sourceUID), + WithPubSubPullSubscriptionAnnotations(newAnnotations()), + WithPubSubPullSubscriptionObjectMetaGeneration(generation), + WithPubSubPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ PubSubSpec: v1alpha1.PubSubSpec{ Secret: &secret, Project: testProject, }, Topic: testTopicID, }), - WithInitPullSubscriptionConditions, - WithPullSubscriptionProjectID(testProject), - WithPullSubscriptionSink(sinkGVK, sinkName), - WithPullSubscriptionMarkSink(sinkURI), - WithPullSubscriptionMarkNoTransformer("TransformerNil", "Transformer is nil"), - WithPullSubscriptionTransformerURI(nil), + WithPubSubInitPullSubscriptionConditions, + WithPubSubPullSubscriptionProjectID(testProject), + WithPubSubPullSubscriptionSink(sinkGVK, sinkName), + WithPubSubPullSubscriptionMarkSink(sinkURI), + WithPubSubPullSubscriptionMarkNoTransformer("TransformerNil", "Transformer is nil"), + WithPubSubPullSubscriptionTransformerURI(nil), // Updates - WithPullSubscriptionStatusObservedGeneration(generation), - WithPullSubscriptionMarkSubscribed(testSubscriptionID), - WithPullSubscriptionMarkDeployed, + WithPubSubPullSubscriptionStatusObservedGeneration(generation), + WithPubSubPullSubscriptionMarkSubscribed(testSubscriptionID), + WithPubSubPullSubscriptionMarkDeployed, ), }}, WantPatches: []clientgotesting.PatchActionImpl{ @@ -581,18 +581,18 @@ func TestAllCases(t *testing.T) { }, { Name: "successful create - reuse existing receive adapter - match", Objects: []runtime.Object{ - NewPullSubscription(sourceName, testNS, - WithPullSubscriptionUID(sourceUID), - WithPullSubscriptionAnnotations(newAnnotations()), - WithPullSubscriptionObjectMetaGeneration(generation), - WithPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ + NewPubSubPullSubscription(sourceName, testNS, + WithPubSubPullSubscriptionUID(sourceUID), + WithPubSubPullSubscriptionAnnotations(newAnnotations()), + WithPubSubPullSubscriptionObjectMetaGeneration(generation), + WithPubSubPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ PubSubSpec: v1alpha1.PubSubSpec{ Secret: &secret, Project: testProject, }, Topic: testTopicID, }), - WithPullSubscriptionSink(sinkGVK, sinkName), + WithPubSubPullSubscriptionSink(sinkGVK, sinkName), ), newSink(), newSecret(), @@ -614,26 +614,26 @@ func TestAllCases(t *testing.T) { Eventf(corev1.EventTypeNormal, "PullSubscriptionReconciled", `PullSubscription reconciled: "%s/%s"`, testNS, sourceName), }, WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ - Object: NewPullSubscription(sourceName, testNS, - WithPullSubscriptionUID(sourceUID), - WithPullSubscriptionAnnotations(newAnnotations()), - WithPullSubscriptionObjectMetaGeneration(generation), - WithPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ + Object: NewPubSubPullSubscription(sourceName, testNS, + WithPubSubPullSubscriptionUID(sourceUID), + WithPubSubPullSubscriptionAnnotations(newAnnotations()), + WithPubSubPullSubscriptionObjectMetaGeneration(generation), + WithPubSubPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ PubSubSpec: v1alpha1.PubSubSpec{ Secret: &secret, Project: testProject, }, Topic: testTopicID, }), - WithInitPullSubscriptionConditions, - WithPullSubscriptionProjectID(testProject), - WithPullSubscriptionSink(sinkGVK, sinkName), - WithPullSubscriptionMarkSubscribed(testSubscriptionID), - WithPullSubscriptionMarkDeployed, - WithPullSubscriptionMarkSink(sinkURI), - WithPullSubscriptionMarkNoTransformer("TransformerNil", "Transformer is nil"), - WithPullSubscriptionTransformerURI(nil), - WithPullSubscriptionStatusObservedGeneration(generation), + WithPubSubInitPullSubscriptionConditions, + WithPubSubPullSubscriptionProjectID(testProject), + WithPubSubPullSubscriptionSink(sinkGVK, sinkName), + WithPubSubPullSubscriptionMarkSubscribed(testSubscriptionID), + WithPubSubPullSubscriptionMarkDeployed, + WithPubSubPullSubscriptionMarkSink(sinkURI), + WithPubSubPullSubscriptionMarkNoTransformer("TransformerNil", "Transformer is nil"), + WithPubSubPullSubscriptionTransformerURI(nil), + WithPubSubPullSubscriptionStatusObservedGeneration(generation), ), }}, WantPatches: []clientgotesting.PatchActionImpl{ @@ -642,19 +642,19 @@ func TestAllCases(t *testing.T) { }, { Name: "successful create - reuse existing receive adapter - mismatch", Objects: []runtime.Object{ - NewPullSubscription(sourceName, testNS, - WithPullSubscriptionUID(sourceUID), - WithPullSubscriptionAnnotations(newAnnotations()), - WithPullSubscriptionObjectMetaGeneration(generation), - WithPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ + NewPubSubPullSubscription(sourceName, testNS, + WithPubSubPullSubscriptionUID(sourceUID), + WithPubSubPullSubscriptionAnnotations(newAnnotations()), + WithPubSubPullSubscriptionObjectMetaGeneration(generation), + WithPubSubPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ PubSubSpec: v1alpha1.PubSubSpec{ Secret: &secret, Project: testProject, }, Topic: testTopicID, }), - WithPullSubscriptionSink(sinkGVK, sinkName), - WithPullSubscriptionTransformer(transformerGVK, transformerName), + WithPubSubPullSubscriptionSink(sinkGVK, sinkName), + WithPubSubPullSubscriptionTransformer(transformerGVK, transformerName), ), newSink(), newTransformer(), @@ -685,26 +685,26 @@ func TestAllCases(t *testing.T) { Object: newReceiveAdapter(context.Background(), testImage, transformerURI), }}, WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ - Object: NewPullSubscription(sourceName, testNS, - WithPullSubscriptionUID(sourceUID), - WithPullSubscriptionAnnotations(newAnnotations()), - WithPullSubscriptionObjectMetaGeneration(generation), - WithPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ + Object: NewPubSubPullSubscription(sourceName, testNS, + WithPubSubPullSubscriptionUID(sourceUID), + WithPubSubPullSubscriptionAnnotations(newAnnotations()), + WithPubSubPullSubscriptionObjectMetaGeneration(generation), + WithPubSubPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ PubSubSpec: v1alpha1.PubSubSpec{ Secret: &secret, Project: testProject, }, Topic: testTopicID, }), - WithInitPullSubscriptionConditions, - WithPullSubscriptionProjectID(testProject), - WithPullSubscriptionSink(sinkGVK, sinkName), - WithPullSubscriptionTransformer(transformerGVK, transformerName), - WithPullSubscriptionMarkSubscribed(testSubscriptionID), - WithPullSubscriptionMarkDeployed, - WithPullSubscriptionMarkSink(sinkURI), - WithPullSubscriptionMarkTransformer(transformerURI), - WithPullSubscriptionStatusObservedGeneration(generation), + WithPubSubInitPullSubscriptionConditions, + WithPubSubPullSubscriptionProjectID(testProject), + WithPubSubPullSubscriptionSink(sinkGVK, sinkName), + WithPubSubPullSubscriptionTransformer(transformerGVK, transformerName), + WithPubSubPullSubscriptionMarkSubscribed(testSubscriptionID), + WithPubSubPullSubscriptionMarkDeployed, + WithPubSubPullSubscriptionMarkSink(sinkURI), + WithPubSubPullSubscriptionMarkTransformer(transformerURI), + WithPubSubPullSubscriptionStatusObservedGeneration(generation), ), }}, WantPatches: []clientgotesting.PatchActionImpl{ @@ -713,22 +713,22 @@ func TestAllCases(t *testing.T) { }, { Name: "deleting - failed to delete subscription", Objects: []runtime.Object{ - NewPullSubscription(sourceName, testNS, - WithPullSubscriptionUID(sourceUID), - WithPullSubscriptionAnnotations(newAnnotations()), - WithPullSubscriptionObjectMetaGeneration(generation), - WithPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ + NewPubSubPullSubscription(sourceName, testNS, + WithPubSubPullSubscriptionUID(sourceUID), + WithPubSubPullSubscriptionAnnotations(newAnnotations()), + WithPubSubPullSubscriptionObjectMetaGeneration(generation), + WithPubSubPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ PubSubSpec: v1alpha1.PubSubSpec{ Secret: &secret, Project: testProject, }, Topic: testTopicID, }), - WithPullSubscriptionSink(sinkGVK, sinkName), - WithPullSubscriptionMarkSubscribed(testSubscriptionID), - WithPullSubscriptionMarkDeployed, - WithPullSubscriptionMarkSink(sinkURI), - WithPullSubscriptionDeleted, + WithPubSubPullSubscriptionSink(sinkGVK, sinkName), + WithPubSubPullSubscriptionMarkSubscribed(testSubscriptionID), + WithPubSubPullSubscriptionMarkDeployed, + WithPubSubPullSubscriptionMarkSink(sinkURI), + WithPubSubPullSubscriptionDeleted, ), newSecret(), }, @@ -751,23 +751,23 @@ func TestAllCases(t *testing.T) { }, { Name: "successfully deleted subscription", Objects: []runtime.Object{ - NewPullSubscription(sourceName, testNS, - WithPullSubscriptionUID(sourceUID), - WithPullSubscriptionAnnotations(newAnnotations()), - WithPullSubscriptionObjectMetaGeneration(generation), - WithPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ + NewPubSubPullSubscription(sourceName, testNS, + WithPubSubPullSubscriptionUID(sourceUID), + WithPubSubPullSubscriptionAnnotations(newAnnotations()), + WithPubSubPullSubscriptionObjectMetaGeneration(generation), + WithPubSubPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ PubSubSpec: v1alpha1.PubSubSpec{ Secret: &secret, Project: testProject, }, Topic: testTopicID, }), - WithPullSubscriptionSink(sinkGVK, sinkName), - WithPullSubscriptionMarkSubscribed(testSubscriptionID), - WithPullSubscriptionMarkDeployed, - WithPullSubscriptionMarkSink(sinkURI), - WithPullSubscriptionSubscriptionID(""), - WithPullSubscriptionDeleted, + WithPubSubPullSubscriptionSink(sinkGVK, sinkName), + WithPubSubPullSubscriptionMarkSubscribed(testSubscriptionID), + WithPubSubPullSubscriptionMarkDeployed, + WithPubSubPullSubscriptionMarkSink(sinkURI), + WithPubSubPullSubscriptionSubscriptionID(""), + WithPubSubPullSubscriptionDeleted, ), newSecret(), }, @@ -797,7 +797,7 @@ func TestAllCases(t *testing.T) { Base: &psreconciler.Base{ PubSubBase: pubsubBase, DeploymentLister: listers.GetDeploymentLister(), - PullSubscriptionLister: listers.GetPullSubscriptionLister(), + PullSubscriptionLister: listers.GetPubSubPullSubscriptionLister(), UriResolver: resolver.NewURIResolver(ctx, func(types.NamespacedName) {}), ReceiveAdapterImage: testImage, CreateClientFn: gpubsub.TestClientCreator(testData["ps"]), @@ -808,7 +808,7 @@ func TestAllCases(t *testing.T) { r.ReconcileDataPlaneFn = r.ReconcileScaledObject r.scaledObjectTracker = duck.NewListableTracker(ctx, resource.Get, func(types.NamespacedName) {}, 0) r.discoveryFn = mockDiscoveryFunc - return pullsubscription.NewReconciler(ctx, r.Logger, r.RunClientSet, listers.GetPullSubscriptionLister(), r.Recorder, r) + return pullsubscription.NewReconciler(ctx, r.Logger, r.RunClientSet, listers.GetPubSubPullSubscriptionLister(), r.Recorder, r) })) } @@ -817,9 +817,9 @@ func mockDiscoveryFunc(_ discovery.DiscoveryInterface, _ schema.GroupVersion) er } func newReceiveAdapter(ctx context.Context, image string, transformer *apis.URL) runtime.Object { - source := NewPullSubscription(sourceName, testNS, - WithPullSubscriptionUID(sourceUID), - WithPullSubscriptionAnnotations(map[string]string{ + source := NewPubSubPullSubscription(sourceName, testNS, + WithPubSubPullSubscriptionUID(sourceUID), + WithPubSubPullSubscriptionAnnotations(map[string]string{ v1alpha1.AutoscalingClassAnnotation: v1alpha1.KEDA, v1alpha1.AutoscalingMinScaleAnnotation: "0", v1alpha1.AutoscalingMaxScaleAnnotation: "3", @@ -827,7 +827,7 @@ func newReceiveAdapter(ctx context.Context, image string, transformer *apis.URL) v1alpha1.KedaAutoscalingCooldownPeriodAnnotation: "60", v1alpha1.KedaAutoscalingPollingIntervalAnnotation: "30", }), - WithPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ + WithPubSubPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ PubSubSpec: v1alpha1.PubSubSpec{ Secret: &secret, Project: testProject, diff --git a/pkg/reconciler/pubsub/pullsubscription/keda/resources/scaled_object_test.go b/pkg/reconciler/pubsub/pullsubscription/keda/resources/scaled_object_test.go index dad29a76b7..890100179d 100644 --- a/pkg/reconciler/pubsub/pullsubscription/keda/resources/scaled_object_test.go +++ b/pkg/reconciler/pubsub/pullsubscription/keda/resources/scaled_object_test.go @@ -43,10 +43,10 @@ func newAnnotations() map[string]string { } func newPullSubscription() *v1alpha1.PullSubscription { - return NewPullSubscription("psname", "psnamespace", - WithPullSubscriptionUID("psuid"), - WithPullSubscriptionAnnotations(newAnnotations()), - WithPullSubscriptionSubscriptionID("subscriptionId"), + return NewPubSubPullSubscription("psname", "psnamespace", + WithPubSubPullSubscriptionUID("psuid"), + WithPubSubPullSubscriptionAnnotations(newAnnotations()), + WithPubSubPullSubscriptionSubscriptionID("subscriptionId"), ) } diff --git a/pkg/reconciler/pubsub/pullsubscription/static/pullsubscription_test.go b/pkg/reconciler/pubsub/pullsubscription/static/pullsubscription_test.go index b8263e89a7..39caa90db4 100644 --- a/pkg/reconciler/pubsub/pullsubscription/static/pullsubscription_test.go +++ b/pkg/reconciler/pubsub/pullsubscription/static/pullsubscription_test.go @@ -167,16 +167,16 @@ func TestAllCases(t *testing.T) { }, { Name: "cannot get sink", Objects: []runtime.Object{ - NewPullSubscription(sourceName, testNS, - WithPullSubscriptionObjectMetaGeneration(generation), - WithPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ + NewPubSubPullSubscription(sourceName, testNS, + WithPubSubPullSubscriptionObjectMetaGeneration(generation), + WithPubSubPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ PubSubSpec: duckv1alpha1.PubSubSpec{ Secret: &secret, Project: testProject, }, Topic: testTopicID, }), - WithPullSubscriptionSink(sinkGVK, sinkName), + WithPubSubPullSubscriptionSink(sinkGVK, sinkName), ), newSecret(), }, @@ -190,38 +190,38 @@ func TestAllCases(t *testing.T) { patchFinalizers(testNS, sourceName, resourceGroup), }, WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ - Object: NewPullSubscription(sourceName, testNS, - WithPullSubscriptionObjectMetaGeneration(generation), - WithPullSubscriptionStatusObservedGeneration(generation), - WithPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ + Object: NewPubSubPullSubscription(sourceName, testNS, + WithPubSubPullSubscriptionObjectMetaGeneration(generation), + WithPubSubPullSubscriptionStatusObservedGeneration(generation), + WithPubSubPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ PubSubSpec: duckv1alpha1.PubSubSpec{ Secret: &secret, Project: testProject, }, Topic: testTopicID, }), - WithPullSubscriptionSink(sinkGVK, sinkName), + WithPubSubPullSubscriptionSink(sinkGVK, sinkName), // updates - WithInitPullSubscriptionConditions, - WithPullSubscriptionSinkNotFound(), + WithPubSubInitPullSubscriptionConditions, + WithPubSubPullSubscriptionSinkNotFound(), ), }}, }, { Name: "create client fails", Objects: []runtime.Object{ - NewPullSubscription(sourceName, testNS, - WithPullSubscriptionUID(sourceUID), - WithPullSubscriptionObjectMetaGeneration(generation), - WithPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ + NewPubSubPullSubscription(sourceName, testNS, + WithPubSubPullSubscriptionUID(sourceUID), + WithPubSubPullSubscriptionObjectMetaGeneration(generation), + WithPubSubPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ PubSubSpec: duckv1alpha1.PubSubSpec{ Secret: &secret, Project: testProject, }, Topic: testTopicID, }), - WithInitPullSubscriptionConditions, - WithPullSubscriptionSink(sinkGVK, sinkName), - WithPullSubscriptionMarkSink(sinkURI), + WithPubSubInitPullSubscriptionConditions, + WithPubSubPullSubscriptionSink(sinkGVK, sinkName), + WithPubSubPullSubscriptionMarkSink(sinkURI), ), newSink(), newSecret(), @@ -237,24 +237,24 @@ func TestAllCases(t *testing.T) { }, }, WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ - Object: NewPullSubscription(sourceName, testNS, - WithPullSubscriptionUID(sourceUID), - WithPullSubscriptionObjectMetaGeneration(generation), - WithPullSubscriptionStatusObservedGeneration(generation), - WithPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ + Object: NewPubSubPullSubscription(sourceName, testNS, + WithPubSubPullSubscriptionUID(sourceUID), + WithPubSubPullSubscriptionObjectMetaGeneration(generation), + WithPubSubPullSubscriptionStatusObservedGeneration(generation), + WithPubSubPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ PubSubSpec: duckv1alpha1.PubSubSpec{ Secret: &secret, Project: testProject, }, Topic: testTopicID, }), - WithInitPullSubscriptionConditions, - WithPullSubscriptionProjectID(testProject), - WithPullSubscriptionSink(sinkGVK, sinkName), - WithPullSubscriptionMarkSink(sinkURI), - WithPullSubscriptionMarkNoTransformer("TransformerNil", "Transformer is nil"), - WithPullSubscriptionTransformerURI(nil), - WithPullSubscriptionMarkNoSubscription("SubscriptionReconcileFailed", fmt.Sprintf("%s: %s", failedToReconcileSubscriptionMsg, "client-create-induced-error"))), + WithPubSubInitPullSubscriptionConditions, + WithPubSubPullSubscriptionProjectID(testProject), + WithPubSubPullSubscriptionSink(sinkGVK, sinkName), + WithPubSubPullSubscriptionMarkSink(sinkURI), + WithPubSubPullSubscriptionMarkNoTransformer("TransformerNil", "Transformer is nil"), + WithPubSubPullSubscriptionTransformerURI(nil), + WithPubSubPullSubscriptionMarkNoSubscription("SubscriptionReconcileFailed", fmt.Sprintf("%s: %s", failedToReconcileSubscriptionMsg, "client-create-induced-error"))), }}, WantPatches: []clientgotesting.PatchActionImpl{ patchFinalizers(testNS, sourceName, resourceGroup), @@ -262,19 +262,19 @@ func TestAllCases(t *testing.T) { }, { Name: "topic exists fails", Objects: []runtime.Object{ - NewPullSubscription(sourceName, testNS, - WithPullSubscriptionUID(sourceUID), - WithPullSubscriptionObjectMetaGeneration(generation), - WithPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ + NewPubSubPullSubscription(sourceName, testNS, + WithPubSubPullSubscriptionUID(sourceUID), + WithPubSubPullSubscriptionObjectMetaGeneration(generation), + WithPubSubPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ PubSubSpec: duckv1alpha1.PubSubSpec{ Secret: &secret, Project: testProject, }, Topic: testTopicID, }), - WithInitPullSubscriptionConditions, - WithPullSubscriptionSink(sinkGVK, sinkName), - WithPullSubscriptionMarkSink(sinkURI), + WithPubSubInitPullSubscriptionConditions, + WithPubSubPullSubscriptionSink(sinkGVK, sinkName), + WithPubSubPullSubscriptionMarkSink(sinkURI), ), newSink(), newSecret(), @@ -295,41 +295,41 @@ func TestAllCases(t *testing.T) { patchFinalizers(testNS, sourceName, resourceGroup), }, WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ - Object: NewPullSubscription(sourceName, testNS, - WithPullSubscriptionUID(sourceUID), - WithPullSubscriptionObjectMetaGeneration(generation), - WithPullSubscriptionStatusObservedGeneration(generation), - WithPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ + Object: NewPubSubPullSubscription(sourceName, testNS, + WithPubSubPullSubscriptionUID(sourceUID), + WithPubSubPullSubscriptionObjectMetaGeneration(generation), + WithPubSubPullSubscriptionStatusObservedGeneration(generation), + WithPubSubPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ PubSubSpec: duckv1alpha1.PubSubSpec{ Secret: &secret, Project: testProject, }, Topic: testTopicID, }), - WithInitPullSubscriptionConditions, - WithPullSubscriptionProjectID(testProject), - WithPullSubscriptionSink(sinkGVK, sinkName), - WithPullSubscriptionMarkSink(sinkURI), - WithPullSubscriptionMarkNoTransformer("TransformerNil", "Transformer is nil"), - WithPullSubscriptionTransformerURI(nil), - WithPullSubscriptionMarkNoSubscription("SubscriptionReconcileFailed", fmt.Sprintf("%s: %s", failedToReconcileSubscriptionMsg, "topic-exists-induced-error"))), + WithPubSubInitPullSubscriptionConditions, + WithPubSubPullSubscriptionProjectID(testProject), + WithPubSubPullSubscriptionSink(sinkGVK, sinkName), + WithPubSubPullSubscriptionMarkSink(sinkURI), + WithPubSubPullSubscriptionMarkNoTransformer("TransformerNil", "Transformer is nil"), + WithPubSubPullSubscriptionTransformerURI(nil), + WithPubSubPullSubscriptionMarkNoSubscription("SubscriptionReconcileFailed", fmt.Sprintf("%s: %s", failedToReconcileSubscriptionMsg, "topic-exists-induced-error"))), }}, }, { Name: "topic does not exist", Objects: []runtime.Object{ - NewPullSubscription(sourceName, testNS, - WithPullSubscriptionUID(sourceUID), - WithPullSubscriptionObjectMetaGeneration(generation), - WithPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ + NewPubSubPullSubscription(sourceName, testNS, + WithPubSubPullSubscriptionUID(sourceUID), + WithPubSubPullSubscriptionObjectMetaGeneration(generation), + WithPubSubPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ PubSubSpec: duckv1alpha1.PubSubSpec{ Secret: &secret, Project: testProject, }, Topic: testTopicID, }), - WithInitPullSubscriptionConditions, - WithPullSubscriptionSink(sinkGVK, sinkName), - WithPullSubscriptionMarkSink(sinkURI), + WithPubSubInitPullSubscriptionConditions, + WithPubSubPullSubscriptionSink(sinkGVK, sinkName), + WithPubSubPullSubscriptionMarkSink(sinkURI), ), newSink(), newSecret(), @@ -350,41 +350,41 @@ func TestAllCases(t *testing.T) { patchFinalizers(testNS, sourceName, resourceGroup), }, WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ - Object: NewPullSubscription(sourceName, testNS, - WithPullSubscriptionUID(sourceUID), - WithPullSubscriptionObjectMetaGeneration(generation), - WithPullSubscriptionStatusObservedGeneration(generation), - WithPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ + Object: NewPubSubPullSubscription(sourceName, testNS, + WithPubSubPullSubscriptionUID(sourceUID), + WithPubSubPullSubscriptionObjectMetaGeneration(generation), + WithPubSubPullSubscriptionStatusObservedGeneration(generation), + WithPubSubPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ PubSubSpec: duckv1alpha1.PubSubSpec{ Secret: &secret, Project: testProject, }, Topic: testTopicID, }), - WithInitPullSubscriptionConditions, - WithPullSubscriptionProjectID(testProject), - WithPullSubscriptionSink(sinkGVK, sinkName), - WithPullSubscriptionMarkSink(sinkURI), - WithPullSubscriptionMarkNoTransformer("TransformerNil", "Transformer is nil"), - WithPullSubscriptionTransformerURI(nil), - WithPullSubscriptionMarkNoSubscription("SubscriptionReconcileFailed", fmt.Sprintf("%s: Topic %q does not exist", failedToReconcileSubscriptionMsg, testTopicID))), + WithPubSubInitPullSubscriptionConditions, + WithPubSubPullSubscriptionProjectID(testProject), + WithPubSubPullSubscriptionSink(sinkGVK, sinkName), + WithPubSubPullSubscriptionMarkSink(sinkURI), + WithPubSubPullSubscriptionMarkNoTransformer("TransformerNil", "Transformer is nil"), + WithPubSubPullSubscriptionTransformerURI(nil), + WithPubSubPullSubscriptionMarkNoSubscription("SubscriptionReconcileFailed", fmt.Sprintf("%s: Topic %q does not exist", failedToReconcileSubscriptionMsg, testTopicID))), }}, }, { Name: "subscription exists fails", Objects: []runtime.Object{ - NewPullSubscription(sourceName, testNS, - WithPullSubscriptionUID(sourceUID), - WithPullSubscriptionObjectMetaGeneration(generation), - WithPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ + NewPubSubPullSubscription(sourceName, testNS, + WithPubSubPullSubscriptionUID(sourceUID), + WithPubSubPullSubscriptionObjectMetaGeneration(generation), + WithPubSubPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ PubSubSpec: duckv1alpha1.PubSubSpec{ Secret: &secret, Project: testProject, }, Topic: testTopicID, }), - WithInitPullSubscriptionConditions, - WithPullSubscriptionSink(sinkGVK, sinkName), - WithPullSubscriptionMarkSink(sinkURI), + WithPubSubInitPullSubscriptionConditions, + WithPubSubPullSubscriptionSink(sinkGVK, sinkName), + WithPubSubPullSubscriptionMarkSink(sinkURI), ), newSink(), newSecret(), @@ -405,41 +405,41 @@ func TestAllCases(t *testing.T) { patchFinalizers(testNS, sourceName, resourceGroup), }, WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ - Object: NewPullSubscription(sourceName, testNS, - WithPullSubscriptionUID(sourceUID), - WithPullSubscriptionObjectMetaGeneration(generation), - WithPullSubscriptionStatusObservedGeneration(generation), - WithPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ + Object: NewPubSubPullSubscription(sourceName, testNS, + WithPubSubPullSubscriptionUID(sourceUID), + WithPubSubPullSubscriptionObjectMetaGeneration(generation), + WithPubSubPullSubscriptionStatusObservedGeneration(generation), + WithPubSubPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ PubSubSpec: duckv1alpha1.PubSubSpec{ Secret: &secret, Project: testProject, }, Topic: testTopicID, }), - WithInitPullSubscriptionConditions, - WithPullSubscriptionProjectID(testProject), - WithPullSubscriptionSink(sinkGVK, sinkName), - WithPullSubscriptionMarkSink(sinkURI), - WithPullSubscriptionMarkNoTransformer("TransformerNil", "Transformer is nil"), - WithPullSubscriptionTransformerURI(nil), - WithPullSubscriptionMarkNoSubscription("SubscriptionReconcileFailed", fmt.Sprintf("%s: %s", failedToReconcileSubscriptionMsg, "subscription-exists-induced-error"))), + WithPubSubInitPullSubscriptionConditions, + WithPubSubPullSubscriptionProjectID(testProject), + WithPubSubPullSubscriptionSink(sinkGVK, sinkName), + WithPubSubPullSubscriptionMarkSink(sinkURI), + WithPubSubPullSubscriptionMarkNoTransformer("TransformerNil", "Transformer is nil"), + WithPubSubPullSubscriptionTransformerURI(nil), + WithPubSubPullSubscriptionMarkNoSubscription("SubscriptionReconcileFailed", fmt.Sprintf("%s: %s", failedToReconcileSubscriptionMsg, "subscription-exists-induced-error"))), }}, }, { Name: "create subscription fails", Objects: []runtime.Object{ - NewPullSubscription(sourceName, testNS, - WithPullSubscriptionUID(sourceUID), - WithPullSubscriptionObjectMetaGeneration(generation), - WithPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ + NewPubSubPullSubscription(sourceName, testNS, + WithPubSubPullSubscriptionUID(sourceUID), + WithPubSubPullSubscriptionObjectMetaGeneration(generation), + WithPubSubPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ PubSubSpec: duckv1alpha1.PubSubSpec{ Secret: &secret, Project: testProject, }, Topic: testTopicID, }), - WithInitPullSubscriptionConditions, - WithPullSubscriptionSink(sinkGVK, sinkName), - WithPullSubscriptionMarkSink(sinkURI), + WithPubSubInitPullSubscriptionConditions, + WithPubSubPullSubscriptionSink(sinkGVK, sinkName), + WithPubSubPullSubscriptionMarkSink(sinkURI), ), newSink(), newSecret(), @@ -461,41 +461,41 @@ func TestAllCases(t *testing.T) { patchFinalizers(testNS, sourceName, resourceGroup), }, WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ - Object: NewPullSubscription(sourceName, testNS, - WithPullSubscriptionUID(sourceUID), - WithPullSubscriptionObjectMetaGeneration(generation), - WithPullSubscriptionStatusObservedGeneration(generation), - WithPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ + Object: NewPubSubPullSubscription(sourceName, testNS, + WithPubSubPullSubscriptionUID(sourceUID), + WithPubSubPullSubscriptionObjectMetaGeneration(generation), + WithPubSubPullSubscriptionStatusObservedGeneration(generation), + WithPubSubPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ PubSubSpec: duckv1alpha1.PubSubSpec{ Secret: &secret, Project: testProject, }, Topic: testTopicID, }), - WithInitPullSubscriptionConditions, - WithPullSubscriptionProjectID(testProject), - WithPullSubscriptionSink(sinkGVK, sinkName), - WithPullSubscriptionMarkSink(sinkURI), - WithPullSubscriptionMarkNoTransformer("TransformerNil", "Transformer is nil"), - WithPullSubscriptionTransformerURI(nil), - WithPullSubscriptionMarkNoSubscription("SubscriptionReconcileFailed", fmt.Sprintf("%s: %s", failedToReconcileSubscriptionMsg, "subscription-create-induced-error"))), + WithPubSubInitPullSubscriptionConditions, + WithPubSubPullSubscriptionProjectID(testProject), + WithPubSubPullSubscriptionSink(sinkGVK, sinkName), + WithPubSubPullSubscriptionMarkSink(sinkURI), + WithPubSubPullSubscriptionMarkNoTransformer("TransformerNil", "Transformer is nil"), + WithPubSubPullSubscriptionTransformerURI(nil), + WithPubSubPullSubscriptionMarkNoSubscription("SubscriptionReconcileFailed", fmt.Sprintf("%s: %s", failedToReconcileSubscriptionMsg, "subscription-create-induced-error"))), }}, }, { Name: "successfully created subscription", Objects: []runtime.Object{ - NewPullSubscription(sourceName, testNS, - WithPullSubscriptionUID(sourceUID), - WithPullSubscriptionObjectMetaGeneration(generation), - WithPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ + NewPubSubPullSubscription(sourceName, testNS, + WithPubSubPullSubscriptionUID(sourceUID), + WithPubSubPullSubscriptionObjectMetaGeneration(generation), + WithPubSubPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ PubSubSpec: duckv1alpha1.PubSubSpec{ Secret: &secret, Project: testProject, }, Topic: testTopicID, }), - WithInitPullSubscriptionConditions, - WithPullSubscriptionSink(sinkGVK, sinkName), - WithPullSubscriptionMarkSink(sinkURI), + WithPubSubInitPullSubscriptionConditions, + WithPubSubPullSubscriptionSink(sinkGVK, sinkName), + WithPubSubPullSubscriptionMarkSink(sinkURI), ), newSink(), newSecret(), @@ -516,26 +516,26 @@ func TestAllCases(t *testing.T) { newReceiveAdapter(context.Background(), testImage, nil), }, WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ - Object: NewPullSubscription(sourceName, testNS, - WithPullSubscriptionUID(sourceUID), - WithPullSubscriptionObjectMetaGeneration(generation), - WithPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ + Object: NewPubSubPullSubscription(sourceName, testNS, + WithPubSubPullSubscriptionUID(sourceUID), + WithPubSubPullSubscriptionObjectMetaGeneration(generation), + WithPubSubPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ PubSubSpec: duckv1alpha1.PubSubSpec{ Secret: &secret, Project: testProject, }, Topic: testTopicID, }), - WithInitPullSubscriptionConditions, - WithPullSubscriptionProjectID(testProject), - WithPullSubscriptionSink(sinkGVK, sinkName), - WithPullSubscriptionMarkSink(sinkURI), - WithPullSubscriptionMarkNoTransformer("TransformerNil", "Transformer is nil"), - WithPullSubscriptionTransformerURI(nil), + WithPubSubInitPullSubscriptionConditions, + WithPubSubPullSubscriptionProjectID(testProject), + WithPubSubPullSubscriptionSink(sinkGVK, sinkName), + WithPubSubPullSubscriptionMarkSink(sinkURI), + WithPubSubPullSubscriptionMarkNoTransformer("TransformerNil", "Transformer is nil"), + WithPubSubPullSubscriptionTransformerURI(nil), // Updates - WithPullSubscriptionStatusObservedGeneration(generation), - WithPullSubscriptionMarkSubscribed(testSubscriptionID), - WithPullSubscriptionMarkDeployed, + WithPubSubPullSubscriptionStatusObservedGeneration(generation), + WithPubSubPullSubscriptionMarkSubscribed(testSubscriptionID), + WithPubSubPullSubscriptionMarkDeployed, ), }}, WantPatches: []clientgotesting.PatchActionImpl{ @@ -544,17 +544,17 @@ func TestAllCases(t *testing.T) { }, { Name: "successful create - reuse existing receive adapter - match", Objects: []runtime.Object{ - NewPullSubscription(sourceName, testNS, - WithPullSubscriptionUID(sourceUID), - WithPullSubscriptionObjectMetaGeneration(generation), - WithPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ + NewPubSubPullSubscription(sourceName, testNS, + WithPubSubPullSubscriptionUID(sourceUID), + WithPubSubPullSubscriptionObjectMetaGeneration(generation), + WithPubSubPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ PubSubSpec: duckv1alpha1.PubSubSpec{ Secret: &secret, Project: testProject, }, Topic: testTopicID, }), - WithPullSubscriptionSink(sinkGVK, sinkName), + WithPubSubPullSubscriptionSink(sinkGVK, sinkName), ), newSink(), newSecret(), @@ -576,42 +576,42 @@ func TestAllCases(t *testing.T) { patchFinalizers(testNS, sourceName, resourceGroup), }, WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ - Object: NewPullSubscription(sourceName, testNS, - WithPullSubscriptionUID(sourceUID), - WithPullSubscriptionObjectMetaGeneration(generation), - WithPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ + Object: NewPubSubPullSubscription(sourceName, testNS, + WithPubSubPullSubscriptionUID(sourceUID), + WithPubSubPullSubscriptionObjectMetaGeneration(generation), + WithPubSubPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ PubSubSpec: duckv1alpha1.PubSubSpec{ Secret: &secret, Project: testProject, }, Topic: testTopicID, }), - WithInitPullSubscriptionConditions, - WithPullSubscriptionProjectID(testProject), - WithPullSubscriptionSink(sinkGVK, sinkName), - WithPullSubscriptionMarkSubscribed(testSubscriptionID), - WithPullSubscriptionMarkDeployed, - WithPullSubscriptionMarkSink(sinkURI), - WithPullSubscriptionMarkNoTransformer("TransformerNil", "Transformer is nil"), - WithPullSubscriptionTransformerURI(nil), - WithPullSubscriptionStatusObservedGeneration(generation), + WithPubSubInitPullSubscriptionConditions, + WithPubSubPullSubscriptionProjectID(testProject), + WithPubSubPullSubscriptionSink(sinkGVK, sinkName), + WithPubSubPullSubscriptionMarkSubscribed(testSubscriptionID), + WithPubSubPullSubscriptionMarkDeployed, + WithPubSubPullSubscriptionMarkSink(sinkURI), + WithPubSubPullSubscriptionMarkNoTransformer("TransformerNil", "Transformer is nil"), + WithPubSubPullSubscriptionTransformerURI(nil), + WithPubSubPullSubscriptionStatusObservedGeneration(generation), ), }}, }, { Name: "successful create - reuse existing receive adapter - mismatch", Objects: []runtime.Object{ - NewPullSubscription(sourceName, testNS, - WithPullSubscriptionUID(sourceUID), - WithPullSubscriptionObjectMetaGeneration(generation), - WithPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ + NewPubSubPullSubscription(sourceName, testNS, + WithPubSubPullSubscriptionUID(sourceUID), + WithPubSubPullSubscriptionObjectMetaGeneration(generation), + WithPubSubPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ PubSubSpec: duckv1alpha1.PubSubSpec{ Secret: &secret, Project: testProject, }, Topic: testTopicID, }), - WithPullSubscriptionSink(sinkGVK, sinkName), - WithPullSubscriptionTransformer(transformerGVK, transformerName), + WithPubSubPullSubscriptionSink(sinkGVK, sinkName), + WithPubSubPullSubscriptionTransformer(transformerGVK, transformerName), ), newSink(), newTransformer(), @@ -642,46 +642,46 @@ func TestAllCases(t *testing.T) { patchFinalizers(testNS, sourceName, resourceGroup), }, WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ - Object: NewPullSubscription(sourceName, testNS, - WithPullSubscriptionUID(sourceUID), + Object: NewPubSubPullSubscription(sourceName, testNS, + WithPubSubPullSubscriptionUID(sourceUID), //WithPullSubscriptionFinalizers(resourceGroup), - WithPullSubscriptionObjectMetaGeneration(generation), - WithPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ + WithPubSubPullSubscriptionObjectMetaGeneration(generation), + WithPubSubPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ PubSubSpec: duckv1alpha1.PubSubSpec{ Secret: &secret, Project: testProject, }, Topic: testTopicID, }), - WithInitPullSubscriptionConditions, - WithPullSubscriptionProjectID(testProject), - WithPullSubscriptionSink(sinkGVK, sinkName), - WithPullSubscriptionTransformer(transformerGVK, transformerName), - WithPullSubscriptionMarkSubscribed(testSubscriptionID), - WithPullSubscriptionMarkDeployed, - WithPullSubscriptionMarkSink(sinkURI), - WithPullSubscriptionMarkTransformer(transformerURI), - WithPullSubscriptionStatusObservedGeneration(generation), + WithPubSubInitPullSubscriptionConditions, + WithPubSubPullSubscriptionProjectID(testProject), + WithPubSubPullSubscriptionSink(sinkGVK, sinkName), + WithPubSubPullSubscriptionTransformer(transformerGVK, transformerName), + WithPubSubPullSubscriptionMarkSubscribed(testSubscriptionID), + WithPubSubPullSubscriptionMarkDeployed, + WithPubSubPullSubscriptionMarkSink(sinkURI), + WithPubSubPullSubscriptionMarkTransformer(transformerURI), + WithPubSubPullSubscriptionStatusObservedGeneration(generation), ), }}, }, { Name: "deleting - failed to delete subscription", Objects: []runtime.Object{ - NewPullSubscription(sourceName, testNS, - WithPullSubscriptionUID(sourceUID), - WithPullSubscriptionObjectMetaGeneration(generation), - WithPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ + NewPubSubPullSubscription(sourceName, testNS, + WithPubSubPullSubscriptionUID(sourceUID), + WithPubSubPullSubscriptionObjectMetaGeneration(generation), + WithPubSubPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ PubSubSpec: duckv1alpha1.PubSubSpec{ Secret: &secret, Project: testProject, }, Topic: testTopicID, }), - WithPullSubscriptionSink(sinkGVK, sinkName), - WithPullSubscriptionMarkSubscribed(testSubscriptionID), - WithPullSubscriptionMarkDeployed, - WithPullSubscriptionMarkSink(sinkURI), - WithPullSubscriptionDeleted, + WithPubSubPullSubscriptionSink(sinkGVK, sinkName), + WithPubSubPullSubscriptionMarkSubscribed(testSubscriptionID), + WithPubSubPullSubscriptionMarkDeployed, + WithPubSubPullSubscriptionMarkSink(sinkURI), + WithPubSubPullSubscriptionDeleted, ), newSecret(), }, @@ -704,22 +704,22 @@ func TestAllCases(t *testing.T) { }, { Name: "successfully deleted subscription", Objects: []runtime.Object{ - NewPullSubscription(sourceName, testNS, - WithPullSubscriptionUID(sourceUID), - WithPullSubscriptionObjectMetaGeneration(generation), - WithPullSubscriptionStatusObservedGeneration(generation), - WithPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ + NewPubSubPullSubscription(sourceName, testNS, + WithPubSubPullSubscriptionUID(sourceUID), + WithPubSubPullSubscriptionObjectMetaGeneration(generation), + WithPubSubPullSubscriptionStatusObservedGeneration(generation), + WithPubSubPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ PubSubSpec: duckv1alpha1.PubSubSpec{ Secret: &secret, Project: testProject, }, Topic: testTopicID, }), - WithPullSubscriptionSink(sinkGVK, sinkName), - WithPullSubscriptionMarkSubscribed(testSubscriptionID), - WithPullSubscriptionMarkDeployed, - WithPullSubscriptionMarkSink(sinkURI), - WithPullSubscriptionDeleted, + WithPubSubPullSubscriptionSink(sinkGVK, sinkName), + WithPubSubPullSubscriptionMarkSubscribed(testSubscriptionID), + WithPubSubPullSubscriptionMarkDeployed, + WithPubSubPullSubscriptionMarkSink(sinkURI), + WithPubSubPullSubscriptionDeleted, ), newSecret(), }, @@ -736,23 +736,23 @@ func TestAllCases(t *testing.T) { Key: testNS + "/" + sourceName, WantEvents: nil, WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ - Object: NewPullSubscription(sourceName, testNS, - WithPullSubscriptionUID(sourceUID), - WithPullSubscriptionObjectMetaGeneration(generation), - WithPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ + Object: NewPubSubPullSubscription(sourceName, testNS, + WithPubSubPullSubscriptionUID(sourceUID), + WithPubSubPullSubscriptionObjectMetaGeneration(generation), + WithPubSubPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ PubSubSpec: duckv1alpha1.PubSubSpec{ Secret: &secret, Project: testProject, }, Topic: testTopicID, }), - WithPullSubscriptionSink(sinkGVK, sinkName), - WithPullSubscriptionMarkSubscribed(testSubscriptionID), - WithPullSubscriptionSubscriptionID(""), - WithPullSubscriptionMarkDeployed, - WithPullSubscriptionMarkSink(sinkURI), - WithPullSubscriptionStatusObservedGeneration(generation), - WithPullSubscriptionDeleted, + WithPubSubPullSubscriptionSink(sinkGVK, sinkName), + WithPubSubPullSubscriptionMarkSubscribed(testSubscriptionID), + WithPubSubPullSubscriptionSubscriptionID(""), + WithPubSubPullSubscriptionMarkDeployed, + WithPubSubPullSubscriptionMarkSink(sinkURI), + WithPubSubPullSubscriptionStatusObservedGeneration(generation), + WithPubSubPullSubscriptionDeleted, ), }}, }} @@ -767,7 +767,7 @@ func TestAllCases(t *testing.T) { Base: &psreconciler.Base{ PubSubBase: pubsubBase, DeploymentLister: listers.GetDeploymentLister(), - PullSubscriptionLister: listers.GetPullSubscriptionLister(), + PullSubscriptionLister: listers.GetPubSubPullSubscriptionLister(), UriResolver: resolver.NewURIResolver(ctx, func(types.NamespacedName) {}), ReceiveAdapterImage: testImage, CreateClientFn: gpubsub.TestClientCreator(testData["ps"]), @@ -776,14 +776,14 @@ func TestAllCases(t *testing.T) { }, } r.ReconcileDataPlaneFn = r.ReconcileDeployment - return pullsubscription.NewReconciler(ctx, r.Logger, r.RunClientSet, listers.GetPullSubscriptionLister(), r.Recorder, r) + return pullsubscription.NewReconciler(ctx, r.Logger, r.RunClientSet, listers.GetPubSubPullSubscriptionLister(), r.Recorder, r) })) } func newReceiveAdapter(ctx context.Context, image string, transformer *apis.URL) runtime.Object { - source := NewPullSubscription(sourceName, testNS, - WithPullSubscriptionUID(sourceUID), - WithPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ + source := NewPubSubPullSubscription(sourceName, testNS, + WithPubSubPullSubscriptionUID(sourceUID), + WithPubSubPullSubscriptionSpec(pubsubv1alpha1.PullSubscriptionSpec{ PubSubSpec: duckv1alpha1.PubSubSpec{ Secret: &secret, Project: testProject, diff --git a/pkg/reconciler/pubsub/reconciler_test.go b/pkg/reconciler/pubsub/reconciler_test.go index ea31fcdd30..6db6c1c426 100644 --- a/pkg/reconciler/pubsub/reconciler_test.go +++ b/pkg/reconciler/pubsub/reconciler_test.go @@ -90,472 +90,472 @@ func TestCreates(t *testing.T) { wantCreates []runtime.Object }{{ name: "topic does not exist, created, not yet been reconciled", - expectedTopic: rectesting.NewTopic(name, testNS, - rectesting.WithTopicSpec(pubsubsourcev1alpha1.TopicSpec{ + expectedTopic: rectesting.NewPubSubTopic(name, testNS, + rectesting.WithPubSubTopicSpec(pubsubsourcev1alpha1.TopicSpec{ Secret: &secret, Topic: testTopicID, PropagationPolicy: "CreateDelete", }), - rectesting.WithTopicLabels(map[string]string{ + rectesting.WithPubSubTopicLabels(map[string]string{ "receive-adapter": receiveAdapterName, "events.cloud.google.com/source-name": name, }), - rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), + rectesting.WithPubSubTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), ), expectedPS: nil, expectedErr: fmt.Sprintf("Topic %q has not yet been reconciled", name), wantCreates: []runtime.Object{ - rectesting.NewTopic(name, testNS, - rectesting.WithTopicSpec(pubsubsourcev1alpha1.TopicSpec{ + rectesting.NewPubSubTopic(name, testNS, + rectesting.WithPubSubTopicSpec(pubsubsourcev1alpha1.TopicSpec{ Topic: testTopicID, PropagationPolicy: "CreateDelete", }), - rectesting.WithTopicLabels(map[string]string{ + rectesting.WithPubSubTopicLabels(map[string]string{ "receive-adapter": receiveAdapterName, "events.cloud.google.com/source-name": name, }), - rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), + rectesting.WithPubSubTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), ), }, }, { name: "topic exists but is not yet been reconciled", objects: []runtime.Object{ - rectesting.NewTopic(name, testNS, - rectesting.WithTopicSpec(pubsubsourcev1alpha1.TopicSpec{ + rectesting.NewPubSubTopic(name, testNS, + rectesting.WithPubSubTopicSpec(pubsubsourcev1alpha1.TopicSpec{ Topic: testTopicID, PropagationPolicy: "CreateDelete", }), - rectesting.WithTopicLabels(map[string]string{ + rectesting.WithPubSubTopicLabels(map[string]string{ "receive-adapter": receiveAdapterName, "events.cloud.google.com/source-name": name, }), - rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), + rectesting.WithPubSubTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), ), }, - expectedTopic: rectesting.NewTopic(name, testNS, - rectesting.WithTopicSpec(pubsubsourcev1alpha1.TopicSpec{ + expectedTopic: rectesting.NewPubSubTopic(name, testNS, + rectesting.WithPubSubTopicSpec(pubsubsourcev1alpha1.TopicSpec{ Secret: &secret, Topic: testTopicID, PropagationPolicy: "CreateDelete", }), - rectesting.WithTopicLabels(map[string]string{ + rectesting.WithPubSubTopicLabels(map[string]string{ "receive-adapter": receiveAdapterName, "events.cloud.google.com/source-name": name, }), - rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), + rectesting.WithPubSubTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), ), expectedPS: nil, expectedErr: fmt.Sprintf("Topic %q has not yet been reconciled", name), }, { name: "topic exists and is ready but no projectid", objects: []runtime.Object{ - rectesting.NewTopic(name, testNS, - rectesting.WithTopicSpec(pubsubsourcev1alpha1.TopicSpec{ + rectesting.NewPubSubTopic(name, testNS, + rectesting.WithPubSubTopicSpec(pubsubsourcev1alpha1.TopicSpec{ Topic: testTopicID, PropagationPolicy: "CreateDelete", }), - rectesting.WithTopicLabels(map[string]string{ + rectesting.WithPubSubTopicLabels(map[string]string{ "receive-adapter": receiveAdapterName, "events.cloud.google.com/source-name": name, }), - rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), - rectesting.WithTopicReady(testTopicID), - rectesting.WithTopicAddress(testTopicURI), + rectesting.WithPubSubTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), + rectesting.WithPubSubTopicReady(testTopicID), + rectesting.WithPubSubTopicAddress(testTopicURI), ), }, - expectedTopic: rectesting.NewTopic(name, testNS, - rectesting.WithTopicSpec(pubsubsourcev1alpha1.TopicSpec{ + expectedTopic: rectesting.NewPubSubTopic(name, testNS, + rectesting.WithPubSubTopicSpec(pubsubsourcev1alpha1.TopicSpec{ Secret: &secret, Topic: testTopicID, PropagationPolicy: "CreateDelete", }), - rectesting.WithTopicLabels(map[string]string{ + rectesting.WithPubSubTopicLabels(map[string]string{ "receive-adapter": receiveAdapterName, "events.cloud.google.com/source-name": name, }), - rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), - rectesting.WithTopicReady(testTopicID), - rectesting.WithTopicAddress(testTopicURI), - rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), + rectesting.WithPubSubTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), + rectesting.WithPubSubTopicReady(testTopicID), + rectesting.WithPubSubTopicAddress(testTopicURI), + rectesting.WithPubSubTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), ), expectedPS: nil, expectedErr: fmt.Sprintf("Topic %q did not expose projectid", name), }, { name: "topic exists and the status of topic is false", objects: []runtime.Object{ - rectesting.NewTopic(name, testNS, - rectesting.WithTopicSpec(pubsubsourcev1alpha1.TopicSpec{ + rectesting.NewPubSubTopic(name, testNS, + rectesting.WithPubSubTopicSpec(pubsubsourcev1alpha1.TopicSpec{ Topic: testTopicID, PropagationPolicy: "CreateDelete", }), - rectesting.WithTopicLabels(map[string]string{ + rectesting.WithPubSubTopicLabels(map[string]string{ "receive-adapter": receiveAdapterName, "events.cloud.google.com/source-name": name, }), - rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), - rectesting.WithTopicProjectID(testProjectID), - rectesting.WithTopicFailed(), + rectesting.WithPubSubTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), + rectesting.WithPubSubTopicProjectID(testProjectID), + rectesting.WithPubSubTopicFailed(), ), }, - expectedTopic: rectesting.NewTopic(name, testNS, - rectesting.WithTopicSpec(pubsubsourcev1alpha1.TopicSpec{ + expectedTopic: rectesting.NewPubSubTopic(name, testNS, + rectesting.WithPubSubTopicSpec(pubsubsourcev1alpha1.TopicSpec{ Secret: &secret, Topic: testTopicID, PropagationPolicy: "CreateDelete", }), - rectesting.WithTopicLabels(map[string]string{ + rectesting.WithPubSubTopicLabels(map[string]string{ "receive-adapter": receiveAdapterName, "events.cloud.google.com/source-name": name, }), - rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), - rectesting.WithTopicFailed(), - rectesting.WithTopicProjectID(testProjectID), - rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), + rectesting.WithPubSubTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), + rectesting.WithPubSubTopicFailed(), + rectesting.WithPubSubTopicProjectID(testProjectID), + rectesting.WithPubSubTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), ), expectedPS: nil, expectedErr: fmt.Sprintf("the status of Topic %q is False", name), }, { name: "topic exists and the status of topic is unknown", objects: []runtime.Object{ - rectesting.NewTopic(name, testNS, - rectesting.WithTopicSpec(pubsubsourcev1alpha1.TopicSpec{ + rectesting.NewPubSubTopic(name, testNS, + rectesting.WithPubSubTopicSpec(pubsubsourcev1alpha1.TopicSpec{ Topic: testTopicID, PropagationPolicy: "CreateDelete", }), - rectesting.WithTopicLabels(map[string]string{ + rectesting.WithPubSubTopicLabels(map[string]string{ "receive-adapter": receiveAdapterName, "events.cloud.google.com/source-name": name, }), - rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), - rectesting.WithTopicProjectID(testProjectID), - rectesting.WithTopicUnknown(), + rectesting.WithPubSubTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), + rectesting.WithPubSubTopicProjectID(testProjectID), + rectesting.WithPubSubTopicUnknown(), ), }, - expectedTopic: rectesting.NewTopic(name, testNS, - rectesting.WithTopicSpec(pubsubsourcev1alpha1.TopicSpec{ + expectedTopic: rectesting.NewPubSubTopic(name, testNS, + rectesting.WithPubSubTopicSpec(pubsubsourcev1alpha1.TopicSpec{ Secret: &secret, Topic: testTopicID, PropagationPolicy: "CreateDelete", }), - rectesting.WithTopicLabels(map[string]string{ + rectesting.WithPubSubTopicLabels(map[string]string{ "receive-adapter": receiveAdapterName, "events.cloud.google.com/source-name": name, }), - rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), - rectesting.WithTopicUnknown(), - rectesting.WithTopicProjectID(testProjectID), - rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), + rectesting.WithPubSubTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), + rectesting.WithPubSubTopicUnknown(), + rectesting.WithPubSubTopicProjectID(testProjectID), + rectesting.WithPubSubTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), ), expectedPS: nil, expectedErr: fmt.Sprintf("the status of Topic %q is Unknown", name), }, { name: "topic exists and is ready but no topicid", objects: []runtime.Object{ - rectesting.NewTopic(name, testNS, - rectesting.WithTopicSpec(pubsubsourcev1alpha1.TopicSpec{ + rectesting.NewPubSubTopic(name, testNS, + rectesting.WithPubSubTopicSpec(pubsubsourcev1alpha1.TopicSpec{ Topic: testTopicID, PropagationPolicy: "CreateDelete", }), - rectesting.WithTopicLabels(map[string]string{ + rectesting.WithPubSubTopicLabels(map[string]string{ "receive-adapter": receiveAdapterName, "events.cloud.google.com/source-name": name, }), - rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), - rectesting.WithTopicProjectID(testProjectID), - rectesting.WithTopicReady(""), - rectesting.WithTopicAddress(testTopicURI), + rectesting.WithPubSubTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), + rectesting.WithPubSubTopicProjectID(testProjectID), + rectesting.WithPubSubTopicReady(""), + rectesting.WithPubSubTopicAddress(testTopicURI), ), }, - expectedTopic: rectesting.NewTopic(name, testNS, - rectesting.WithTopicSpec(pubsubsourcev1alpha1.TopicSpec{ + expectedTopic: rectesting.NewPubSubTopic(name, testNS, + rectesting.WithPubSubTopicSpec(pubsubsourcev1alpha1.TopicSpec{ Secret: &secret, Topic: testTopicID, PropagationPolicy: "CreateDelete", }), - rectesting.WithTopicLabels(map[string]string{ + rectesting.WithPubSubTopicLabels(map[string]string{ "receive-adapter": receiveAdapterName, "events.cloud.google.com/source-name": name, }), - rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), - rectesting.WithTopicReady(""), - rectesting.WithTopicProjectID(testProjectID), - rectesting.WithTopicAddress(testTopicURI), - rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), + rectesting.WithPubSubTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), + rectesting.WithPubSubTopicReady(""), + rectesting.WithPubSubTopicProjectID(testProjectID), + rectesting.WithPubSubTopicAddress(testTopicURI), + rectesting.WithPubSubTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), ), expectedPS: nil, expectedErr: fmt.Sprintf("Topic %q did not expose topicid", name), }, { name: "topic exists and is ready, pullsubscription created, not yet been reconciled", objects: []runtime.Object{ - rectesting.NewTopic(name, testNS, - rectesting.WithTopicSpec(pubsubsourcev1alpha1.TopicSpec{ + rectesting.NewPubSubTopic(name, testNS, + rectesting.WithPubSubTopicSpec(pubsubsourcev1alpha1.TopicSpec{ Topic: testTopicID, PropagationPolicy: "CreateDelete", }), - rectesting.WithTopicLabels(map[string]string{ + rectesting.WithPubSubTopicLabels(map[string]string{ "receive-adapter": receiveAdapterName, "events.cloud.google.com/source-name": name, }), - rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), - rectesting.WithTopicProjectID(testProjectID), - rectesting.WithTopicReady(testTopicID), - rectesting.WithTopicAddress(testTopicURI), + rectesting.WithPubSubTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), + rectesting.WithPubSubTopicProjectID(testProjectID), + rectesting.WithPubSubTopicReady(testTopicID), + rectesting.WithPubSubTopicAddress(testTopicURI), ), }, - expectedTopic: rectesting.NewTopic(name, testNS, - rectesting.WithTopicSpec(pubsubsourcev1alpha1.TopicSpec{ + expectedTopic: rectesting.NewPubSubTopic(name, testNS, + rectesting.WithPubSubTopicSpec(pubsubsourcev1alpha1.TopicSpec{ Secret: &secret, Topic: testTopicID, PropagationPolicy: "CreateDelete", }), - rectesting.WithTopicLabels(map[string]string{ + rectesting.WithPubSubTopicLabels(map[string]string{ "receive-adapter": receiveAdapterName, "events.cloud.google.com/source-name": name, }), - rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), - rectesting.WithTopicReady(testTopicID), - rectesting.WithTopicProjectID(testProjectID), - rectesting.WithTopicAddress(testTopicURI), - rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), + rectesting.WithPubSubTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), + rectesting.WithPubSubTopicReady(testTopicID), + rectesting.WithPubSubTopicProjectID(testProjectID), + rectesting.WithPubSubTopicAddress(testTopicURI), + rectesting.WithPubSubTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), ), - expectedPS: rectesting.NewPullSubscriptionWithNoDefaults(name, testNS, - rectesting.WithPullSubscriptionSpecWithNoDefaults(pubsubsourcev1alpha1.PullSubscriptionSpec{ + expectedPS: rectesting.NewPubSubPullSubscriptionWithNoDefaults(name, testNS, + rectesting.WithPubSubPullSubscriptionSpecWithNoDefaults(pubsubsourcev1alpha1.PullSubscriptionSpec{ Topic: testTopicID, PubSubSpec: v1alpha1.PubSubSpec{ Secret: &secret, }, }), - rectesting.WithPullSubscriptionLabels(map[string]string{ + rectesting.WithPubSubPullSubscriptionLabels(map[string]string{ "receive-adapter": receiveAdapterName, "events.cloud.google.com/source-name": name, }), - rectesting.WithPullSubscriptionAnnotations(map[string]string{ + rectesting.WithPubSubPullSubscriptionAnnotations(map[string]string{ "metrics-resource-group": resourceGroup, }), - rectesting.WithPullSubscriptionOwnerReferences([]metav1.OwnerReference{ownerRef()}), + rectesting.WithPubSubPullSubscriptionOwnerReferences([]metav1.OwnerReference{ownerRef()}), ), expectedErr: fmt.Sprintf("%s: PullSubscription %q has not yet been reconciled", failedToPropagatePullSubscriptionStatusMsg, name), wantCreates: []runtime.Object{ - rectesting.NewPullSubscriptionWithNoDefaults(name, testNS, - rectesting.WithPullSubscriptionSpecWithNoDefaults(pubsubsourcev1alpha1.PullSubscriptionSpec{ + rectesting.NewPubSubPullSubscriptionWithNoDefaults(name, testNS, + rectesting.WithPubSubPullSubscriptionSpecWithNoDefaults(pubsubsourcev1alpha1.PullSubscriptionSpec{ Topic: testTopicID, PubSubSpec: v1alpha1.PubSubSpec{ Secret: &secret, }, }), - rectesting.WithPullSubscriptionLabels(map[string]string{ + rectesting.WithPubSubPullSubscriptionLabels(map[string]string{ "receive-adapter": receiveAdapterName, "events.cloud.google.com/source-name": name, }), - rectesting.WithPullSubscriptionAnnotations(map[string]string{ + rectesting.WithPubSubPullSubscriptionAnnotations(map[string]string{ "metrics-resource-group": resourceGroup, }), - rectesting.WithPullSubscriptionOwnerReferences([]metav1.OwnerReference{ownerRef()}), + rectesting.WithPubSubPullSubscriptionOwnerReferences([]metav1.OwnerReference{ownerRef()}), ), }, }, { name: "topic exists and is ready, pullsubscription exists, not yet been reconciled", objects: []runtime.Object{ - rectesting.NewTopic(name, testNS, - rectesting.WithTopicSpec(pubsubsourcev1alpha1.TopicSpec{ + rectesting.NewPubSubTopic(name, testNS, + rectesting.WithPubSubTopicSpec(pubsubsourcev1alpha1.TopicSpec{ Topic: testTopicID, PropagationPolicy: "CreateDelete", }), - rectesting.WithTopicLabels(map[string]string{ + rectesting.WithPubSubTopicLabels(map[string]string{ "receive-adapter": receiveAdapterName, "events.cloud.google.com/source-name": name, }), - rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), - rectesting.WithTopicProjectID(testProjectID), - rectesting.WithTopicReady(testTopicID), - rectesting.WithTopicAddress(testTopicURI), + rectesting.WithPubSubTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), + rectesting.WithPubSubTopicProjectID(testProjectID), + rectesting.WithPubSubTopicReady(testTopicID), + rectesting.WithPubSubTopicAddress(testTopicURI), ), - rectesting.NewPullSubscriptionWithNoDefaults(name, testNS, - rectesting.WithPullSubscriptionSpecWithNoDefaults(pubsubsourcev1alpha1.PullSubscriptionSpec{ + rectesting.NewPubSubPullSubscriptionWithNoDefaults(name, testNS, + rectesting.WithPubSubPullSubscriptionSpecWithNoDefaults(pubsubsourcev1alpha1.PullSubscriptionSpec{ Topic: testTopicID, PubSubSpec: v1alpha1.PubSubSpec{ Secret: &secret, }, }), - rectesting.WithPullSubscriptionLabels(map[string]string{ + rectesting.WithPubSubPullSubscriptionLabels(map[string]string{ "receive-adapter": receiveAdapterName, "events.cloud.google.com/source-name": name, }), - rectesting.WithPullSubscriptionAnnotations(map[string]string{ + rectesting.WithPubSubPullSubscriptionAnnotations(map[string]string{ "metrics-resource-group": resourceGroup, }), - rectesting.WithPullSubscriptionOwnerReferences([]metav1.OwnerReference{ownerRef()}), + rectesting.WithPubSubPullSubscriptionOwnerReferences([]metav1.OwnerReference{ownerRef()}), ), }, - expectedTopic: rectesting.NewTopic(name, testNS, - rectesting.WithTopicSpec(pubsubsourcev1alpha1.TopicSpec{ + expectedTopic: rectesting.NewPubSubTopic(name, testNS, + rectesting.WithPubSubTopicSpec(pubsubsourcev1alpha1.TopicSpec{ Secret: &secret, Topic: testTopicID, PropagationPolicy: "CreateDelete", }), - rectesting.WithTopicLabels(map[string]string{ + rectesting.WithPubSubTopicLabels(map[string]string{ "receive-adapter": receiveAdapterName, "events.cloud.google.com/source-name": name, }), - rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), - rectesting.WithTopicReady(testTopicID), - rectesting.WithTopicProjectID(testProjectID), - rectesting.WithTopicAddress(testTopicURI), - rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), + rectesting.WithPubSubTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), + rectesting.WithPubSubTopicReady(testTopicID), + rectesting.WithPubSubTopicProjectID(testProjectID), + rectesting.WithPubSubTopicAddress(testTopicURI), + rectesting.WithPubSubTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), ), - expectedPS: rectesting.NewPullSubscriptionWithNoDefaults(name, testNS, - rectesting.WithPullSubscriptionSpecWithNoDefaults(pubsubsourcev1alpha1.PullSubscriptionSpec{ + expectedPS: rectesting.NewPubSubPullSubscriptionWithNoDefaults(name, testNS, + rectesting.WithPubSubPullSubscriptionSpecWithNoDefaults(pubsubsourcev1alpha1.PullSubscriptionSpec{ Topic: testTopicID, PubSubSpec: v1alpha1.PubSubSpec{ Secret: &secret, }, }), - rectesting.WithPullSubscriptionLabels(map[string]string{ + rectesting.WithPubSubPullSubscriptionLabels(map[string]string{ "receive-adapter": receiveAdapterName, "events.cloud.google.com/source-name": name, }), - rectesting.WithPullSubscriptionAnnotations(map[string]string{ + rectesting.WithPubSubPullSubscriptionAnnotations(map[string]string{ "metrics-resource-group": resourceGroup, }), - rectesting.WithPullSubscriptionOwnerReferences([]metav1.OwnerReference{ownerRef()}), + rectesting.WithPubSubPullSubscriptionOwnerReferences([]metav1.OwnerReference{ownerRef()}), ), expectedErr: fmt.Sprintf("%s: PullSubscription %q has not yet been reconciled", failedToPropagatePullSubscriptionStatusMsg, name), }, { name: "topic exists and is ready, pullsubscription exists and the status is false", objects: []runtime.Object{ - rectesting.NewTopic(name, testNS, - rectesting.WithTopicSpec(pubsubsourcev1alpha1.TopicSpec{ + rectesting.NewPubSubTopic(name, testNS, + rectesting.WithPubSubTopicSpec(pubsubsourcev1alpha1.TopicSpec{ Topic: testTopicID, PropagationPolicy: "CreateDelete", }), - rectesting.WithTopicLabels(map[string]string{ + rectesting.WithPubSubTopicLabels(map[string]string{ "receive-adapter": receiveAdapterName, "events.cloud.google.com/source-name": name, }), - rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), - rectesting.WithTopicProjectID(testProjectID), - rectesting.WithTopicReady(testTopicID), - rectesting.WithTopicAddress(testTopicURI), + rectesting.WithPubSubTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), + rectesting.WithPubSubTopicProjectID(testProjectID), + rectesting.WithPubSubTopicReady(testTopicID), + rectesting.WithPubSubTopicAddress(testTopicURI), ), - rectesting.NewPullSubscriptionWithNoDefaults(name, testNS, - rectesting.WithPullSubscriptionSpecWithNoDefaults(pubsubsourcev1alpha1.PullSubscriptionSpec{ + rectesting.NewPubSubPullSubscriptionWithNoDefaults(name, testNS, + rectesting.WithPubSubPullSubscriptionSpecWithNoDefaults(pubsubsourcev1alpha1.PullSubscriptionSpec{ Topic: testTopicID, PubSubSpec: v1alpha1.PubSubSpec{ Secret: &secret, }, }), - rectesting.WithPullSubscriptionLabels(map[string]string{ + rectesting.WithPubSubPullSubscriptionLabels(map[string]string{ "receive-adapter": receiveAdapterName, "events.cloud.google.com/source-name": name, }), - rectesting.WithPullSubscriptionAnnotations(map[string]string{ + rectesting.WithPubSubPullSubscriptionAnnotations(map[string]string{ "metrics-resource-group": resourceGroup, }), - rectesting.WithPullSubscriptionOwnerReferences([]metav1.OwnerReference{ownerRef()}), - rectesting.WithPullSubscriptionFailed(), + rectesting.WithPubSubPullSubscriptionOwnerReferences([]metav1.OwnerReference{ownerRef()}), + rectesting.WithPubSubPullSubscriptionFailed(), ), }, - expectedTopic: rectesting.NewTopic(name, testNS, - rectesting.WithTopicSpec(pubsubsourcev1alpha1.TopicSpec{ + expectedTopic: rectesting.NewPubSubTopic(name, testNS, + rectesting.WithPubSubTopicSpec(pubsubsourcev1alpha1.TopicSpec{ Secret: &secret, Topic: testTopicID, PropagationPolicy: "CreateDelete", }), - rectesting.WithTopicLabels(map[string]string{ + rectesting.WithPubSubTopicLabels(map[string]string{ "receive-adapter": receiveAdapterName, "events.cloud.google.com/source-name": name, }), - rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), - rectesting.WithTopicReady(testTopicID), - rectesting.WithTopicProjectID(testProjectID), - rectesting.WithTopicAddress(testTopicURI), - rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), + rectesting.WithPubSubTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), + rectesting.WithPubSubTopicReady(testTopicID), + rectesting.WithPubSubTopicProjectID(testProjectID), + rectesting.WithPubSubTopicAddress(testTopicURI), + rectesting.WithPubSubTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), ), - expectedPS: rectesting.NewPullSubscriptionWithNoDefaults(name, testNS, - rectesting.WithPullSubscriptionSpecWithNoDefaults(pubsubsourcev1alpha1.PullSubscriptionSpec{ + expectedPS: rectesting.NewPubSubPullSubscriptionWithNoDefaults(name, testNS, + rectesting.WithPubSubPullSubscriptionSpecWithNoDefaults(pubsubsourcev1alpha1.PullSubscriptionSpec{ Topic: testTopicID, PubSubSpec: v1alpha1.PubSubSpec{ Secret: &secret, }, }), - rectesting.WithPullSubscriptionLabels(map[string]string{ + rectesting.WithPubSubPullSubscriptionLabels(map[string]string{ "receive-adapter": receiveAdapterName, "events.cloud.google.com/source-name": name, }), - rectesting.WithPullSubscriptionAnnotations(map[string]string{ + rectesting.WithPubSubPullSubscriptionAnnotations(map[string]string{ "metrics-resource-group": resourceGroup, }), - rectesting.WithPullSubscriptionOwnerReferences([]metav1.OwnerReference{ownerRef()}), - rectesting.WithPullSubscriptionFailed(), + rectesting.WithPubSubPullSubscriptionOwnerReferences([]metav1.OwnerReference{ownerRef()}), + rectesting.WithPubSubPullSubscriptionFailed(), ), expectedErr: fmt.Sprintf("%s: the status of PullSubscription %q is False", failedToPropagatePullSubscriptionStatusMsg, name), }, { name: "topic exists and is ready, pullsubscription exists and the status is unknown", objects: []runtime.Object{ - rectesting.NewTopic(name, testNS, - rectesting.WithTopicSpec(pubsubsourcev1alpha1.TopicSpec{ + rectesting.NewPubSubTopic(name, testNS, + rectesting.WithPubSubTopicSpec(pubsubsourcev1alpha1.TopicSpec{ Topic: testTopicID, PropagationPolicy: "CreateDelete", }), - rectesting.WithTopicLabels(map[string]string{ + rectesting.WithPubSubTopicLabels(map[string]string{ "receive-adapter": receiveAdapterName, "events.cloud.google.com/source-name": name, }), - rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), - rectesting.WithTopicProjectID(testProjectID), - rectesting.WithTopicReady(testTopicID), - rectesting.WithTopicAddress(testTopicURI), + rectesting.WithPubSubTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), + rectesting.WithPubSubTopicProjectID(testProjectID), + rectesting.WithPubSubTopicReady(testTopicID), + rectesting.WithPubSubTopicAddress(testTopicURI), ), - rectesting.NewPullSubscriptionWithNoDefaults(name, testNS, - rectesting.WithPullSubscriptionSpecWithNoDefaults(pubsubsourcev1alpha1.PullSubscriptionSpec{ + rectesting.NewPubSubPullSubscriptionWithNoDefaults(name, testNS, + rectesting.WithPubSubPullSubscriptionSpecWithNoDefaults(pubsubsourcev1alpha1.PullSubscriptionSpec{ Topic: testTopicID, PubSubSpec: v1alpha1.PubSubSpec{ Secret: &secret, }, }), - rectesting.WithPullSubscriptionLabels(map[string]string{ + rectesting.WithPubSubPullSubscriptionLabels(map[string]string{ "receive-adapter": receiveAdapterName, "events.cloud.google.com/source-name": name, }), - rectesting.WithPullSubscriptionAnnotations(map[string]string{ + rectesting.WithPubSubPullSubscriptionAnnotations(map[string]string{ "metrics-resource-group": resourceGroup, }), - rectesting.WithPullSubscriptionOwnerReferences([]metav1.OwnerReference{ownerRef()}), - rectesting.WithPullSubscriptionUnknown(), + rectesting.WithPubSubPullSubscriptionOwnerReferences([]metav1.OwnerReference{ownerRef()}), + rectesting.WithPubSubPullSubscriptionUnknown(), ), }, - expectedTopic: rectesting.NewTopic(name, testNS, - rectesting.WithTopicSpec(pubsubsourcev1alpha1.TopicSpec{ + expectedTopic: rectesting.NewPubSubTopic(name, testNS, + rectesting.WithPubSubTopicSpec(pubsubsourcev1alpha1.TopicSpec{ Secret: &secret, Topic: testTopicID, PropagationPolicy: "CreateDelete", }), - rectesting.WithTopicLabels(map[string]string{ + rectesting.WithPubSubTopicLabels(map[string]string{ "receive-adapter": receiveAdapterName, "events.cloud.google.com/source-name": name, }), - rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), - rectesting.WithTopicReady(testTopicID), - rectesting.WithTopicProjectID(testProjectID), - rectesting.WithTopicAddress(testTopicURI), - rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), + rectesting.WithPubSubTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), + rectesting.WithPubSubTopicReady(testTopicID), + rectesting.WithPubSubTopicProjectID(testProjectID), + rectesting.WithPubSubTopicAddress(testTopicURI), + rectesting.WithPubSubTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}), ), - expectedPS: rectesting.NewPullSubscriptionWithNoDefaults(name, testNS, - rectesting.WithPullSubscriptionSpecWithNoDefaults(pubsubsourcev1alpha1.PullSubscriptionSpec{ + expectedPS: rectesting.NewPubSubPullSubscriptionWithNoDefaults(name, testNS, + rectesting.WithPubSubPullSubscriptionSpecWithNoDefaults(pubsubsourcev1alpha1.PullSubscriptionSpec{ Topic: testTopicID, PubSubSpec: v1alpha1.PubSubSpec{ Secret: &secret, }, }), - rectesting.WithPullSubscriptionLabels(map[string]string{ + rectesting.WithPubSubPullSubscriptionLabels(map[string]string{ "receive-adapter": receiveAdapterName, "events.cloud.google.com/source-name": name, }), - rectesting.WithPullSubscriptionAnnotations(map[string]string{ + rectesting.WithPubSubPullSubscriptionAnnotations(map[string]string{ "metrics-resource-group": resourceGroup, }), - rectesting.WithPullSubscriptionOwnerReferences([]metav1.OwnerReference{ownerRef()}), - rectesting.WithPullSubscriptionUnknown(), + rectesting.WithPubSubPullSubscriptionOwnerReferences([]metav1.OwnerReference{ownerRef()}), + rectesting.WithPubSubPullSubscriptionUnknown(), ), expectedErr: fmt.Sprintf("%s: the status of PullSubscription %q is Unknown", failedToPropagatePullSubscriptionStatusMsg, name), }} diff --git a/pkg/reconciler/pubsub/topic/topic_test.go b/pkg/reconciler/pubsub/topic/topic_test.go index 7516f94f46..8a82542070 100644 --- a/pkg/reconciler/pubsub/topic/topic_test.go +++ b/pkg/reconciler/pubsub/topic/topic_test.go @@ -132,14 +132,14 @@ func TestAllCases(t *testing.T) { }, { Name: "create client fails", Objects: []runtime.Object{ - NewTopic(topicName, testNS, - WithTopicUID(topicUID), - WithTopicSpec(pubsubv1alpha1.TopicSpec{ + NewPubSubTopic(topicName, testNS, + WithPubSubTopicUID(topicUID), + WithPubSubTopicSpec(pubsubv1alpha1.TopicSpec{ Project: testProject, Topic: testTopicID, Secret: &secret, }), - WithTopicPropagationPolicy("NoCreateNoDelete"), + WithPubSubTopicPropagationPolicy("NoCreateNoDelete"), ), newSink(), newSecret(), @@ -158,30 +158,30 @@ func TestAllCases(t *testing.T) { patchFinalizers(testNS, topicName, resourceGroup), }, WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ - Object: NewTopic(topicName, testNS, - WithTopicUID(topicUID), - WithTopicProjectID(testProject), - WithTopicSpec(pubsubv1alpha1.TopicSpec{ + Object: NewPubSubTopic(topicName, testNS, + WithPubSubTopicUID(topicUID), + WithPubSubTopicProjectID(testProject), + WithPubSubTopicSpec(pubsubv1alpha1.TopicSpec{ Project: testProject, Topic: testTopicID, Secret: &secret, }), - WithTopicPropagationPolicy("NoCreateNoDelete"), + WithPubSubTopicPropagationPolicy("NoCreateNoDelete"), // Updates - WithInitTopicConditions, - WithTopicNoTopic("TopicReconcileFailed", fmt.Sprintf("%s: %s", failedToReconcileTopicMsg, "create-client-induced-error"))), + WithPubSubInitTopicConditions, + WithPubSubTopicNoTopic("TopicReconcileFailed", fmt.Sprintf("%s: %s", failedToReconcileTopicMsg, "create-client-induced-error"))), }}, }, { Name: "verify topic exists fails", Objects: []runtime.Object{ - NewTopic(topicName, testNS, - WithTopicUID(topicUID), - WithTopicSpec(pubsubv1alpha1.TopicSpec{ + NewPubSubTopic(topicName, testNS, + WithPubSubTopicUID(topicUID), + WithPubSubTopicSpec(pubsubv1alpha1.TopicSpec{ Project: testProject, Topic: testTopicID, Secret: &secret, }), - WithTopicPropagationPolicy("NoCreateNoDelete"), + WithPubSubTopicPropagationPolicy("NoCreateNoDelete"), ), newSink(), newSecret(), @@ -202,30 +202,30 @@ func TestAllCases(t *testing.T) { patchFinalizers(testNS, topicName, resourceGroup), }, WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ - Object: NewTopic(topicName, testNS, - WithTopicUID(topicUID), - WithTopicProjectID(testProject), - WithTopicSpec(pubsubv1alpha1.TopicSpec{ + Object: NewPubSubTopic(topicName, testNS, + WithPubSubTopicUID(topicUID), + WithPubSubTopicProjectID(testProject), + WithPubSubTopicSpec(pubsubv1alpha1.TopicSpec{ Project: testProject, Topic: testTopicID, Secret: &secret, }), - WithTopicPropagationPolicy("NoCreateNoDelete"), + WithPubSubTopicPropagationPolicy("NoCreateNoDelete"), // Updates - WithInitTopicConditions, - WithTopicNoTopic("TopicReconcileFailed", fmt.Sprintf("%s: %s", failedToReconcileTopicMsg, "topic-exists-induced-error"))), + WithPubSubInitTopicConditions, + WithPubSubTopicNoTopic("TopicReconcileFailed", fmt.Sprintf("%s: %s", failedToReconcileTopicMsg, "topic-exists-induced-error"))), }}, }, { Name: "topic does not exist and propagation policy is NoCreateNoDelete", Objects: []runtime.Object{ - NewTopic(topicName, testNS, - WithTopicUID(topicUID), - WithTopicSpec(pubsubv1alpha1.TopicSpec{ + NewPubSubTopic(topicName, testNS, + WithPubSubTopicUID(topicUID), + WithPubSubTopicSpec(pubsubv1alpha1.TopicSpec{ Project: testProject, Topic: testTopicID, Secret: &secret, }), - WithTopicPropagationPolicy("NoCreateNoDelete"), + WithPubSubTopicPropagationPolicy("NoCreateNoDelete"), ), newSink(), newSecret(), @@ -239,30 +239,30 @@ func TestAllCases(t *testing.T) { patchFinalizers(testNS, topicName, resourceGroup), }, WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ - Object: NewTopic(topicName, testNS, - WithTopicUID(topicUID), - WithTopicProjectID(testProject), - WithTopicSpec(pubsubv1alpha1.TopicSpec{ + Object: NewPubSubTopic(topicName, testNS, + WithPubSubTopicUID(topicUID), + WithPubSubTopicProjectID(testProject), + WithPubSubTopicSpec(pubsubv1alpha1.TopicSpec{ Project: testProject, Topic: testTopicID, Secret: &secret, }), - WithTopicPropagationPolicy("NoCreateNoDelete"), + WithPubSubTopicPropagationPolicy("NoCreateNoDelete"), // Updates - WithInitTopicConditions, - WithTopicNoTopic("TopicReconcileFailed", fmt.Sprintf("%s: Topic %q does not exist and the topic policy doesn't allow creation", failedToReconcileTopicMsg, testTopicID))), + WithPubSubInitTopicConditions, + WithPubSubTopicNoTopic("TopicReconcileFailed", fmt.Sprintf("%s: Topic %q does not exist and the topic policy doesn't allow creation", failedToReconcileTopicMsg, testTopicID))), }}, }, { Name: "create topic fails", Objects: []runtime.Object{ - NewTopic(topicName, testNS, - WithTopicUID(topicUID), - WithTopicSpec(pubsubv1alpha1.TopicSpec{ + NewPubSubTopic(topicName, testNS, + WithPubSubTopicUID(topicUID), + WithPubSubTopicSpec(pubsubv1alpha1.TopicSpec{ Project: testProject, Topic: testTopicID, Secret: &secret, }), - WithTopicPropagationPolicy("CreateNoDelete"), + WithPubSubTopicPropagationPolicy("CreateNoDelete"), ), newSink(), newSecret(), @@ -281,30 +281,30 @@ func TestAllCases(t *testing.T) { patchFinalizers(testNS, topicName, resourceGroup), }, WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ - Object: NewTopic(topicName, testNS, - WithTopicUID(topicUID), - WithTopicProjectID(testProject), - WithTopicSpec(pubsubv1alpha1.TopicSpec{ + Object: NewPubSubTopic(topicName, testNS, + WithPubSubTopicUID(topicUID), + WithPubSubTopicProjectID(testProject), + WithPubSubTopicSpec(pubsubv1alpha1.TopicSpec{ Project: testProject, Topic: testTopicID, Secret: &secret, }), - WithTopicPropagationPolicy("CreateNoDelete"), + WithPubSubTopicPropagationPolicy("CreateNoDelete"), // Updates - WithInitTopicConditions, - WithTopicNoTopic("TopicReconcileFailed", fmt.Sprintf("%s: %s", failedToReconcileTopicMsg, "create-topic-induced-error"))), + WithPubSubInitTopicConditions, + WithPubSubTopicNoTopic("TopicReconcileFailed", fmt.Sprintf("%s: %s", failedToReconcileTopicMsg, "create-topic-induced-error"))), }}, }, { Name: "publisher has not yet been reconciled", Objects: []runtime.Object{ - NewTopic(topicName, testNS, - WithTopicUID(topicUID), - WithTopicSpec(pubsubv1alpha1.TopicSpec{ + NewPubSubTopic(topicName, testNS, + WithPubSubTopicUID(topicUID), + WithPubSubTopicSpec(pubsubv1alpha1.TopicSpec{ Project: testProject, Topic: testTopicID, Secret: &secret, }), - WithTopicPropagationPolicy("CreateNoDelete"), + WithPubSubTopicPropagationPolicy("CreateNoDelete"), ), newSink(), newSecret(), @@ -321,32 +321,32 @@ func TestAllCases(t *testing.T) { newPublisher(), }, WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ - Object: NewTopic(topicName, testNS, - WithTopicUID(topicUID), - WithTopicProjectID(testProject), - WithTopicSpec(pubsubv1alpha1.TopicSpec{ + Object: NewPubSubTopic(topicName, testNS, + WithPubSubTopicUID(topicUID), + WithPubSubTopicProjectID(testProject), + WithPubSubTopicSpec(pubsubv1alpha1.TopicSpec{ Project: testProject, Topic: testTopicID, Secret: &secret, }), - WithTopicPropagationPolicy("CreateNoDelete"), + WithPubSubTopicPropagationPolicy("CreateNoDelete"), // Updates - WithInitTopicConditions, - WithTopicReady(testTopicID), - WithTopicPublisherNotConfigured()), + WithPubSubInitTopicConditions, + WithPubSubTopicReady(testTopicID), + WithPubSubTopicPublisherNotConfigured()), }}, }, { Name: "the status of publisher is false", Objects: []runtime.Object{ - NewTopic(topicName, testNS, - WithTopicUID(topicUID), - WithTopicSpec(pubsubv1alpha1.TopicSpec{ + NewPubSubTopic(topicName, testNS, + WithPubSubTopicUID(topicUID), + WithPubSubTopicSpec(pubsubv1alpha1.TopicSpec{ Project: testProject, Topic: testTopicID, Secret: &secret, }), - WithTopicPropagationPolicy("CreateNoDelete"), + WithPubSubTopicPropagationPolicy("CreateNoDelete"), ), newSink(), newSecret(), @@ -366,31 +366,31 @@ func TestAllCases(t *testing.T) { newPublisher(), }, WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ - Object: NewTopic(topicName, testNS, - WithTopicUID(topicUID), - WithTopicProjectID(testProject), - WithTopicSpec(pubsubv1alpha1.TopicSpec{ + Object: NewPubSubTopic(topicName, testNS, + WithPubSubTopicUID(topicUID), + WithPubSubTopicProjectID(testProject), + WithPubSubTopicSpec(pubsubv1alpha1.TopicSpec{ Project: testProject, Topic: testTopicID, Secret: &secret, }), - WithTopicPropagationPolicy("CreateNoDelete"), + WithPubSubTopicPropagationPolicy("CreateNoDelete"), // Updates - WithInitTopicConditions, - WithTopicReady(testTopicID), - WithTopicPublisherNotDeployed("PublisherNotDeployed", "PublisherNotDeployed")), + WithPubSubInitTopicConditions, + WithPubSubTopicReady(testTopicID), + WithPubSubTopicPublisherNotDeployed("PublisherNotDeployed", "PublisherNotDeployed")), }}, }, { Name: "the status of publisher is unknown", Objects: []runtime.Object{ - NewTopic(topicName, testNS, - WithTopicUID(topicUID), - WithTopicSpec(pubsubv1alpha1.TopicSpec{ + NewPubSubTopic(topicName, testNS, + WithPubSubTopicUID(topicUID), + WithPubSubTopicSpec(pubsubv1alpha1.TopicSpec{ Project: testProject, Topic: testTopicID, Secret: &secret, }), - WithTopicPropagationPolicy("CreateNoDelete"), + WithPubSubTopicPropagationPolicy("CreateNoDelete"), ), newSink(), newSecret(), @@ -410,31 +410,31 @@ func TestAllCases(t *testing.T) { newPublisher(), }, WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ - Object: NewTopic(topicName, testNS, - WithTopicUID(topicUID), - WithTopicProjectID(testProject), - WithTopicSpec(pubsubv1alpha1.TopicSpec{ + Object: NewPubSubTopic(topicName, testNS, + WithPubSubTopicUID(topicUID), + WithPubSubTopicProjectID(testProject), + WithPubSubTopicSpec(pubsubv1alpha1.TopicSpec{ Project: testProject, Topic: testTopicID, Secret: &secret, }), - WithTopicPropagationPolicy("CreateNoDelete"), + WithPubSubTopicPropagationPolicy("CreateNoDelete"), // Updates - WithInitTopicConditions, - WithTopicReady(testTopicID), - WithTopicPublisherUnknown("PublisherUnknown", "PublisherUnknown")), + WithPubSubInitTopicConditions, + WithPubSubTopicReady(testTopicID), + WithPubSubTopicPublisherUnknown("PublisherUnknown", "PublisherUnknown")), }}, }, { Name: "topic successfully reconciles and is ready", Objects: []runtime.Object{ - NewTopic(topicName, testNS, - WithTopicUID(topicUID), - WithTopicSpec(pubsubv1alpha1.TopicSpec{ + NewPubSubTopic(topicName, testNS, + WithPubSubTopicUID(topicUID), + WithPubSubTopicSpec(pubsubv1alpha1.TopicSpec{ Project: testProject, Topic: testTopicID, Secret: &secret, }), - WithTopicPropagationPolicy("CreateNoDelete"), + WithPubSubTopicPropagationPolicy("CreateNoDelete"), ), newSink(), newSecret(), @@ -454,32 +454,32 @@ func TestAllCases(t *testing.T) { newPublisher(), }, WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ - Object: NewTopic(topicName, testNS, - WithTopicUID(topicUID), - WithTopicProjectID(testProject), - WithTopicSpec(pubsubv1alpha1.TopicSpec{ + Object: NewPubSubTopic(topicName, testNS, + WithPubSubTopicUID(topicUID), + WithPubSubTopicProjectID(testProject), + WithPubSubTopicSpec(pubsubv1alpha1.TopicSpec{ Project: testProject, Topic: testTopicID, Secret: &secret, }), - WithTopicPropagationPolicy("CreateNoDelete"), + WithPubSubTopicPropagationPolicy("CreateNoDelete"), // Updates - WithInitTopicConditions, - WithTopicReady(testTopicID), - WithTopicPublisherDeployed, - WithTopicAddress(testTopicURI)), + WithPubSubInitTopicConditions, + WithPubSubTopicReady(testTopicID), + WithPubSubTopicPublisherDeployed, + WithPubSubTopicAddress(testTopicURI)), }}, }, { Name: "topic successfully reconciles and reuses existing publisher", Objects: []runtime.Object{ - NewTopic(topicName, testNS, - WithTopicUID(topicUID), - WithTopicSpec(pubsubv1alpha1.TopicSpec{ + NewPubSubTopic(topicName, testNS, + WithPubSubTopicUID(topicUID), + WithPubSubTopicSpec(pubsubv1alpha1.TopicSpec{ Project: testProject, Topic: testTopicID, Secret: &secret, }), - WithTopicPropagationPolicy("CreateNoDelete"), + WithPubSubTopicPropagationPolicy("CreateNoDelete"), ), newSink(), newSecret(), @@ -499,33 +499,33 @@ func TestAllCases(t *testing.T) { }, WithReactors: []clientgotesting.ReactionFunc{}, WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ - Object: NewTopic(topicName, testNS, - WithTopicUID(topicUID), - WithTopicProjectID(testProject), - WithTopicSpec(pubsubv1alpha1.TopicSpec{ + Object: NewPubSubTopic(topicName, testNS, + WithPubSubTopicUID(topicUID), + WithPubSubTopicProjectID(testProject), + WithPubSubTopicSpec(pubsubv1alpha1.TopicSpec{ Project: testProject, Topic: testTopicID, Secret: &secret, }), - WithTopicPropagationPolicy("CreateNoDelete"), + WithPubSubTopicPropagationPolicy("CreateNoDelete"), // Updates - WithInitTopicConditions, - WithTopicReady(testTopicID), - WithTopicPublisherDeployed, - WithTopicAddress(testTopicURI)), + WithPubSubInitTopicConditions, + WithPubSubTopicReady(testTopicID), + WithPubSubTopicPublisherDeployed, + WithPubSubTopicAddress(testTopicURI)), }}, }, { Name: "delete topic - policy CreateNoDelete", Objects: []runtime.Object{ - NewTopic(topicName, testNS, - WithTopicUID(topicUID), - WithTopicSpec(pubsubv1alpha1.TopicSpec{ + NewPubSubTopic(topicName, testNS, + WithPubSubTopicUID(topicUID), + WithPubSubTopicSpec(pubsubv1alpha1.TopicSpec{ Project: testProject, Topic: testTopicID, Secret: &secret, }), - WithTopicPropagationPolicy("CreateNoDelete"), - WithTopicDeleted, + WithPubSubTopicPropagationPolicy("CreateNoDelete"), + WithPubSubTopicDeleted, ), newSink(), newSecret(), @@ -536,16 +536,16 @@ func TestAllCases(t *testing.T) { }, { Name: "delete topic - policy CreateDelete", Objects: []runtime.Object{ - NewTopic(topicName, testNS, - WithTopicUID(topicUID), - WithTopicSpec(pubsubv1alpha1.TopicSpec{ + NewPubSubTopic(topicName, testNS, + WithPubSubTopicUID(topicUID), + WithPubSubTopicSpec(pubsubv1alpha1.TopicSpec{ Project: testProject, Topic: testTopicID, Secret: &secret, }), - WithTopicPropagationPolicy("CreateDelete"), - WithTopicTopicID(topicName), - WithTopicDeleted, + WithPubSubTopicPropagationPolicy("CreateDelete"), + WithPubSubTopicTopicID(topicName), + WithPubSubTopicDeleted, ), newSink(), newSecret(), @@ -556,16 +556,16 @@ func TestAllCases(t *testing.T) { }, { Name: "fail to delete - policy CreateDelete", Objects: []runtime.Object{ - NewTopic(topicName, testNS, - WithTopicUID(topicUID), - WithTopicSpec(pubsubv1alpha1.TopicSpec{ + NewPubSubTopic(topicName, testNS, + WithPubSubTopicUID(topicUID), + WithPubSubTopicSpec(pubsubv1alpha1.TopicSpec{ Project: testProject, Topic: testTopicID, Secret: &secret, }), - WithTopicPropagationPolicy("CreateDelete"), - WithTopicTopicID(topicName), - WithTopicDeleted, + WithPubSubTopicPropagationPolicy("CreateDelete"), + WithPubSubTopicTopicID(topicName), + WithPubSubTopicDeleted, ), newSink(), newSecret(), @@ -592,12 +592,12 @@ func TestAllCases(t *testing.T) { } r := &Reconciler{ PubSubBase: pubsubBase, - topicLister: listers.GetTopicLister(), + topicLister: listers.GetPubSubTopicLister(), serviceLister: listers.GetV1ServiceLister(), publisherImage: testImage, createClientFn: gpubsub.TestClientCreator(testData["topic"]), } - return topic.NewReconciler(ctx, r.Logger, r.RunClientSet, listers.GetTopicLister(), r.Recorder, r) + return topic.NewReconciler(ctx, r.Logger, r.RunClientSet, listers.GetPubSubTopicLister(), r.Recorder, r) })) } @@ -689,9 +689,9 @@ func makeFalseStatusPublisher(reason, message string) *servingv1.Service { } func newPublisher() *servingv1.Service { - topic := NewTopic(topicName, testNS, - WithTopicUID(topicUID), - WithTopicSpec(pubsubv1alpha1.TopicSpec{ + topic := NewPubSubTopic(topicName, testNS, + WithPubSubTopicUID(topicUID), + WithPubSubTopicSpec(pubsubv1alpha1.TopicSpec{ Project: testProject, Topic: testTopicID, Secret: &secret, diff --git a/pkg/reconciler/testing/listers.go b/pkg/reconciler/testing/listers.go index 29324df038..ae36a25d28 100644 --- a/pkg/reconciler/testing/listers.go +++ b/pkg/reconciler/testing/listers.go @@ -125,11 +125,11 @@ func (l *Listers) GetIstioObjects() []runtime.Object { return l.sorter.ObjectsForSchemeFunc(fakeistioclientset.AddToScheme) } -func (l *Listers) GetPullSubscriptionLister() pubsublisters.PullSubscriptionLister { +func (l *Listers) GetPubSubPullSubscriptionLister() pubsublisters.PullSubscriptionLister { return pubsublisters.NewPullSubscriptionLister(l.indexerFor(&pubsubv1alpha1.PullSubscription{})) } -func (l *Listers) GetTopicLister() pubsublisters.TopicLister { +func (l *Listers) GetPubSubTopicLister() pubsublisters.TopicLister { return pubsublisters.NewTopicLister(l.indexerFor(&pubsubv1alpha1.Topic{})) } diff --git a/pkg/reconciler/testing/pullsubscription.go b/pkg/reconciler/testing/pubsub_pullsubscription.go similarity index 54% rename from pkg/reconciler/testing/pullsubscription.go rename to pkg/reconciler/testing/pubsub_pullsubscription.go index 0ac7ef7f48..3772f4878a 100644 --- a/pkg/reconciler/testing/pullsubscription.go +++ b/pkg/reconciler/testing/pubsub_pullsubscription.go @@ -30,11 +30,11 @@ import ( "github.com/google/knative-gcp/pkg/apis/pubsub/v1alpha1" ) -// PullSubscriptionOption enables further configuration of a PullSubscription. -type PullSubscriptionOption func(*v1alpha1.PullSubscription) +// PubSubPullSubscriptionOption enables further configuration of a PullSubscription. +type PubSubPullSubscriptionOption func(*v1alpha1.PullSubscription) -// NewPullSubscription creates a PullSubscription with PullSubscriptionOptions -func NewPullSubscription(name, namespace string, so ...PullSubscriptionOption) *v1alpha1.PullSubscription { +// NewPubSubPullSubscription creates a PullSubscription with PullSubscriptionOptions +func NewPubSubPullSubscription(name, namespace string, so ...PubSubPullSubscriptionOption) *v1alpha1.PullSubscription { s := &v1alpha1.PullSubscription{ ObjectMeta: metav1.ObjectMeta{ Name: name, @@ -48,9 +48,9 @@ func NewPullSubscription(name, namespace string, so ...PullSubscriptionOption) * return s } -// NewPullSubscriptionWithNoDefaults creates a PullSubscription with +// NewPubSubPullSubscriptionWithNoDefaults creates a PullSubscription with // PullSubscriptionOptions but does not set defaults. -func NewPullSubscriptionWithNoDefaults(name, namespace string, so ...PullSubscriptionOption) *v1alpha1.PullSubscription { +func NewPubSubPullSubscriptionWithNoDefaults(name, namespace string, so ...PubSubPullSubscriptionOption) *v1alpha1.PullSubscription { s := &v1alpha1.PullSubscription{ ObjectMeta: metav1.ObjectMeta{ Name: name, @@ -63,38 +63,18 @@ func NewPullSubscriptionWithNoDefaults(name, namespace string, so ...PullSubscri return s } -// NewPullSubscriptionWithoutNamespace creates a PullSubscription with PullSubscriptionOptions but without a specific namespace -func NewPullSubscriptionWithoutNamespace(name string, so ...PullSubscriptionOption) *v1alpha1.PullSubscription { - s := &v1alpha1.PullSubscription{ - ObjectMeta: metav1.ObjectMeta{ - Name: name, - }, - } - for _, opt := range so { - opt(s) - } - s.SetDefaults(context.Background()) - return s -} - -func WithPullSubscriptionUID(uid types.UID) PullSubscriptionOption { +func WithPubSubPullSubscriptionUID(uid types.UID) PubSubPullSubscriptionOption { return func(s *v1alpha1.PullSubscription) { s.UID = uid } } -func WithPullSubscriptionGenerateName(generateName string) PullSubscriptionOption { - return func(c *v1alpha1.PullSubscription) { - c.ObjectMeta.GenerateName = generateName - } -} - -// WithInitPullSubscriptionConditions initializes the PullSubscriptions's conditions. -func WithInitPullSubscriptionConditions(s *v1alpha1.PullSubscription) { +// WithPubSubInitPullSubscriptionConditions initializes the PullSubscriptions's conditions. +func WithPubSubInitPullSubscriptionConditions(s *v1alpha1.PullSubscription) { s.Status.InitializeConditions() } -func WithPullSubscriptionSink(gvk metav1.GroupVersionKind, name string) PullSubscriptionOption { +func WithPubSubPullSubscriptionSink(gvk metav1.GroupVersionKind, name string) PubSubPullSubscriptionOption { return func(s *v1alpha1.PullSubscription) { s.Spec.Sink = duckv1.Destination{ Ref: &duckv1.KReference{ @@ -106,7 +86,7 @@ func WithPullSubscriptionSink(gvk metav1.GroupVersionKind, name string) PullSubs } } -func WithPullSubscriptionTransformer(gvk metav1.GroupVersionKind, name string) PullSubscriptionOption { +func WithPubSubPullSubscriptionTransformer(gvk metav1.GroupVersionKind, name string) PubSubPullSubscriptionOption { return func(s *v1alpha1.PullSubscription) { s.Spec.Transformer = &duckv1.Destination{ Ref: &duckv1.KReference{ @@ -118,59 +98,59 @@ func WithPullSubscriptionTransformer(gvk metav1.GroupVersionKind, name string) P } } -func WithPullSubscriptionMarkSink(uri *apis.URL) PullSubscriptionOption { +func WithPubSubPullSubscriptionMarkSink(uri *apis.URL) PubSubPullSubscriptionOption { return func(s *v1alpha1.PullSubscription) { s.Status.MarkSink(uri) } } -func WithPullSubscriptionMarkTransformer(uri *apis.URL) PullSubscriptionOption { +func WithPubSubPullSubscriptionMarkTransformer(uri *apis.URL) PubSubPullSubscriptionOption { return func(s *v1alpha1.PullSubscription) { s.Status.MarkTransformer(uri) } } -func WithPullSubscriptionMarkNoTransformer(reason, message string) PullSubscriptionOption { +func WithPubSubPullSubscriptionMarkNoTransformer(reason, message string) PubSubPullSubscriptionOption { return func(s *v1alpha1.PullSubscription) { s.Status.MarkNoTransformer(reason, message) } } -func WithPullSubscriptionMarkSubscribed(subscriptionID string) PullSubscriptionOption { +func WithPubSubPullSubscriptionMarkSubscribed(subscriptionID string) PubSubPullSubscriptionOption { return func(s *v1alpha1.PullSubscription) { s.Status.MarkSubscribed(subscriptionID) } } -func WithPullSubscriptionSubscriptionID(subscriptionID string) PullSubscriptionOption { +func WithPubSubPullSubscriptionSubscriptionID(subscriptionID string) PubSubPullSubscriptionOption { return func(s *v1alpha1.PullSubscription) { s.Status.SubscriptionID = subscriptionID } } -func WithPullSubscriptionProjectID(projectID string) PullSubscriptionOption { +func WithPubSubPullSubscriptionProjectID(projectID string) PubSubPullSubscriptionOption { return func(s *v1alpha1.PullSubscription) { s.Status.ProjectID = projectID } } -func WithPullSubscriptionTransformerURI(uri *apis.URL) PullSubscriptionOption { +func WithPubSubPullSubscriptionTransformerURI(uri *apis.URL) PubSubPullSubscriptionOption { return func(s *v1alpha1.PullSubscription) { s.Status.TransformerURI = uri } } -func WithPullSubscriptionMarkNoSubscription(reason, message string) PullSubscriptionOption { +func WithPubSubPullSubscriptionMarkNoSubscription(reason, message string) PubSubPullSubscriptionOption { return func(s *v1alpha1.PullSubscription) { s.Status.MarkNoSubscription(reason, message) } } -func WithPullSubscriptionMarkDeployed(ps *v1alpha1.PullSubscription) { +func WithPubSubPullSubscriptionMarkDeployed(ps *v1alpha1.PullSubscription) { ps.Status.MarkDeployed() } -func WithPullSubscriptionSpec(spec v1alpha1.PullSubscriptionSpec) PullSubscriptionOption { +func WithPubSubPullSubscriptionSpec(spec v1alpha1.PullSubscriptionSpec) PubSubPullSubscriptionOption { return func(s *v1alpha1.PullSubscription) { s.Spec = spec s.Spec.SetDefaults(context.Background()) @@ -178,13 +158,13 @@ func WithPullSubscriptionSpec(spec v1alpha1.PullSubscriptionSpec) PullSubscripti } // Same as withPullSubscriptionSpec but does not set defaults -func WithPullSubscriptionSpecWithNoDefaults(spec v1alpha1.PullSubscriptionSpec) PullSubscriptionOption { +func WithPubSubPullSubscriptionSpecWithNoDefaults(spec v1alpha1.PullSubscriptionSpec) PubSubPullSubscriptionOption { return func(s *v1alpha1.PullSubscription) { s.Spec = spec } } -func WithPullSubscriptionReady(sink *apis.URL) PullSubscriptionOption { +func WithPubSubPullSubscriptionReady(sink *apis.URL) PubSubPullSubscriptionOption { return func(s *v1alpha1.PullSubscription) { s.Status.InitializeConditions() s.Status.MarkSink(sink) @@ -193,7 +173,7 @@ func WithPullSubscriptionReady(sink *apis.URL) PullSubscriptionOption { } } -func WithPullSubscriptionFailed() PullSubscriptionOption { +func WithPubSubPullSubscriptionFailed() PubSubPullSubscriptionOption { return func(s *v1alpha1.PullSubscription) { s.Status.InitializeConditions() s.Status.MarkNoSink("InvalidSink", @@ -202,68 +182,55 @@ func WithPullSubscriptionFailed() PullSubscriptionOption { } } -func WithPullSubscriptionUnknown() PullSubscriptionOption { +func WithPubSubPullSubscriptionUnknown() PubSubPullSubscriptionOption { return func(s *v1alpha1.PullSubscription) { s.Status.InitializeConditions() } } -func WithPullSubscriptionJobFailure(subscriptionID, reason, message string) PullSubscriptionOption { - return func(s *v1alpha1.PullSubscription) { - s.Status.SubscriptionID = subscriptionID - s.Status.MarkNoSubscription(reason, message) - } -} - -func WithPullSubscriptionSinkNotFound() PullSubscriptionOption { +func WithPubSubPullSubscriptionSinkNotFound() PubSubPullSubscriptionOption { return func(s *v1alpha1.PullSubscription) { s.Status.MarkNoSink("InvalidSink", `failed to get ref &ObjectReference{Kind:Sink,Namespace:testnamespace,Name:sink,UID:,APIVersion:testing.cloud.google.com/v1alpha1,ResourceVersion:,FieldPath:,}: sinks.testing.cloud.google.com "sink" not found`) } } -func WithPullSubscriptionDeleted(s *v1alpha1.PullSubscription) { +func WithPubSubPullSubscriptionDeleted(s *v1alpha1.PullSubscription) { t := metav1.NewTime(time.Unix(1e9, 0)) s.ObjectMeta.SetDeletionTimestamp(&t) } -func WithPullSubscriptionOwnerReferences(ownerReferences []metav1.OwnerReference) PullSubscriptionOption { +func WithPubSubPullSubscriptionOwnerReferences(ownerReferences []metav1.OwnerReference) PubSubPullSubscriptionOption { return func(c *v1alpha1.PullSubscription) { c.ObjectMeta.OwnerReferences = ownerReferences } } -func WithPullSubscriptionLabels(labels map[string]string) PullSubscriptionOption { +func WithPubSubPullSubscriptionLabels(labels map[string]string) PubSubPullSubscriptionOption { return func(c *v1alpha1.PullSubscription) { c.ObjectMeta.Labels = labels } } -func WithPullSubscriptionAnnotations(annotations map[string]string) PullSubscriptionOption { +func WithPubSubPullSubscriptionAnnotations(annotations map[string]string) PubSubPullSubscriptionOption { return func(c *v1alpha1.PullSubscription) { c.ObjectMeta.Annotations = annotations } } -func WithPullSubscriptionFinalizers(finalizers ...string) PullSubscriptionOption { - return func(s *v1alpha1.PullSubscription) { - s.Finalizers = finalizers - } -} - -func WithPullSubscriptionStatusObservedGeneration(generation int64) PullSubscriptionOption { +func WithPubSubPullSubscriptionStatusObservedGeneration(generation int64) PubSubPullSubscriptionOption { return func(s *v1alpha1.PullSubscription) { s.Status.Status.ObservedGeneration = generation } } -func WithPullSubscriptionObjectMetaGeneration(generation int64) PullSubscriptionOption { +func WithPubSubPullSubscriptionObjectMetaGeneration(generation int64) PubSubPullSubscriptionOption { return func(s *v1alpha1.PullSubscription) { s.ObjectMeta.Generation = generation } } -func WithPullSubscriptionReadyStatus(status corev1.ConditionStatus, reason, message string) PullSubscriptionOption { +func WithPubSubPullSubscriptionReadyStatus(status corev1.ConditionStatus, reason, message string) PubSubPullSubscriptionOption { return func(s *v1alpha1.PullSubscription) { s.Status.Conditions = []apis.Condition{{ Type: apis.ConditionReady, @@ -274,7 +241,7 @@ func WithPullSubscriptionReadyStatus(status corev1.ConditionStatus, reason, mess } } -func WithPullSubscriptionMode(mode v1alpha1.ModeType) PullSubscriptionOption { +func WithPubSubPullSubscriptionMode(mode v1alpha1.ModeType) PubSubPullSubscriptionOption { return func(s *v1alpha1.PullSubscription) { s.Spec.Mode = mode } diff --git a/pkg/reconciler/testing/topic.go b/pkg/reconciler/testing/pubsub_topic.go similarity index 59% rename from pkg/reconciler/testing/topic.go rename to pkg/reconciler/testing/pubsub_topic.go index d38bc549a8..36abf1d57b 100644 --- a/pkg/reconciler/testing/topic.go +++ b/pkg/reconciler/testing/pubsub_topic.go @@ -28,11 +28,11 @@ import ( "github.com/google/knative-gcp/pkg/apis/pubsub/v1alpha1" ) -// TopicOption enables further configuration of a Topic. -type TopicOption func(*v1alpha1.Topic) +// PubSubTopicOption enables further configuration of a Topic. +type PubSubTopicOption func(*v1alpha1.Topic) -// NewTopic creates a Topic with TopicOptions -func NewTopic(name, namespace string, so ...TopicOption) *v1alpha1.Topic { +// NewPubSubTopic creates a Topic with TopicOptions +func NewPubSubTopic(name, namespace string, so ...PubSubTopicOption) *v1alpha1.Topic { s := &v1alpha1.Topic{ ObjectMeta: metav1.ObjectMeta{ Name: name, @@ -46,45 +46,31 @@ func NewTopic(name, namespace string, so ...TopicOption) *v1alpha1.Topic { return s } -func WithTopicUID(uid types.UID) TopicOption { +func WithPubSubTopicUID(uid types.UID) PubSubTopicOption { return func(s *v1alpha1.Topic) { s.UID = uid } } -// WithInitTopicConditions initializes the Topics's conditions. -func WithInitTopicConditions(s *v1alpha1.Topic) { +// WithPubSubInitTopicConditions initializes the Topics's conditions. +func WithPubSubInitTopicConditions(s *v1alpha1.Topic) { s.Status.InitializeConditions() } -func WithTopicTopicID(topicID string) TopicOption { +func WithPubSubTopicTopicID(topicID string) PubSubTopicOption { return func(s *v1alpha1.Topic) { s.Status.MarkTopicReady() s.Status.TopicID = topicID } } -func WithTopicPropagationPolicy(policy string) TopicOption { +func WithPubSubTopicPropagationPolicy(policy string) PubSubTopicOption { return func(s *v1alpha1.Topic) { s.Spec.PropagationPolicy = v1alpha1.PropagationPolicyType(policy) } } -func WithTopicTopicDeleted(topicID string) TopicOption { - return func(s *v1alpha1.Topic) { - s.Status.MarkNoTopic("Deleted", "Successfully deleted topic %q.", topicID) - s.Status.TopicID = "" - } -} - -func WithTopicJobFailure(topicID, reason, message string) TopicOption { - return func(s *v1alpha1.Topic) { - s.Status.TopicID = topicID - s.Status.MarkNoTopic(reason, message) - } -} - -func WithTopicAddress(uri string) TopicOption { +func WithPubSubTopicAddress(uri string) PubSubTopicOption { return func(s *v1alpha1.Topic) { if uri != "" { u, _ := apis.ParseURL(uri) @@ -95,41 +81,41 @@ func WithTopicAddress(uri string) TopicOption { } } -func WithTopicSpec(spec v1alpha1.TopicSpec) TopicOption { +func WithPubSubTopicSpec(spec v1alpha1.TopicSpec) PubSubTopicOption { return func(s *v1alpha1.Topic) { s.Spec = spec } } -func WithTopicPublisherDeployed(s *v1alpha1.Topic) { +func WithPubSubTopicPublisherDeployed(s *v1alpha1.Topic) { s.Status.MarkPublisherDeployed() } -func WithTopicPublisherNotDeployed(reason, message string) TopicOption { +func WithPubSubTopicPublisherNotDeployed(reason, message string) PubSubTopicOption { return func(t *v1alpha1.Topic) { t.Status.MarkPublisherNotDeployed(reason, message) } } -func WithTopicPublisherUnknown(reason, message string) TopicOption { +func WithPubSubTopicPublisherUnknown(reason, message string) PubSubTopicOption { return func(t *v1alpha1.Topic) { t.Status.MarkPublisherUnknown(reason, message) } } -func WithTopicPublisherNotConfigured() TopicOption { +func WithPubSubTopicPublisherNotConfigured() PubSubTopicOption { return func(t *v1alpha1.Topic) { t.Status.MarkPublisherNotConfigured() } } -func WithTopicProjectID(projectID string) TopicOption { +func WithPubSubTopicProjectID(projectID string) PubSubTopicOption { return func(s *v1alpha1.Topic) { s.Status.ProjectID = projectID } } -func WithTopicReady(topicID string) TopicOption { +func WithPubSubTopicReady(topicID string) PubSubTopicOption { return func(s *v1alpha1.Topic) { s.Status.InitializeConditions() s.Status.MarkPublisherDeployed() @@ -138,44 +124,38 @@ func WithTopicReady(topicID string) TopicOption { } } -func WithTopicFailed() TopicOption { +func WithPubSubTopicFailed() PubSubTopicOption { return func(s *v1alpha1.Topic) { s.Status.InitializeConditions() s.Status.MarkPublisherNotDeployed("PublisherStatus", "Publisher has no Ready type status") } } -func WithTopicUnknown() TopicOption { +func WithPubSubTopicUnknown() PubSubTopicOption { return func(s *v1alpha1.Topic) { s.Status.InitializeConditions() } } -func WithTopicDeleted(t *v1alpha1.Topic) { +func WithPubSubTopicDeleted(t *v1alpha1.Topic) { tt := metav1.NewTime(time.Unix(1e9, 0)) t.ObjectMeta.SetDeletionTimestamp(&tt) } -func WithTopicOwnerReferences(ownerReferences []metav1.OwnerReference) TopicOption { +func WithPubSubTopicOwnerReferences(ownerReferences []metav1.OwnerReference) PubSubTopicOption { return func(c *v1alpha1.Topic) { c.ObjectMeta.OwnerReferences = ownerReferences } } -func WithTopicLabels(labels map[string]string) TopicOption { +func WithPubSubTopicLabels(labels map[string]string) PubSubTopicOption { return func(c *v1alpha1.Topic) { c.ObjectMeta.Labels = labels } } -func WithTopicNoTopic(reason, message string) TopicOption { +func WithPubSubTopicNoTopic(reason, message string) PubSubTopicOption { return func(t *v1alpha1.Topic) { t.Status.MarkNoTopic(reason, message) } } - -func WithTopicFinalizers(finalizers ...string) TopicOption { - return func(s *v1alpha1.Topic) { - s.Finalizers = finalizers - } -} diff --git a/test/e2e/test_pullsubscription.go b/test/e2e/test_pullsubscription.go index 24c83310d5..cc41a31946 100644 --- a/test/e2e/test_pullsubscription.go +++ b/test/e2e/test_pullsubscription.go @@ -46,8 +46,8 @@ func SmokePullSubscriptionTestImpl(t *testing.T, authConfig lib.AuthConfig) { defer lib.TearDown(client) // Create PullSubscription. - pullsubscription := kngcptesting.NewPullSubscription(psName, client.Namespace, - kngcptesting.WithPullSubscriptionSpec(v1alpha1.PullSubscriptionSpec{ + pullsubscription := kngcptesting.NewPubSubPullSubscription(psName, client.Namespace, + kngcptesting.WithPubSubPullSubscriptionSpec(v1alpha1.PullSubscriptionSpec{ Topic: topic, PubSubSpec: duckv1alpha1.PubSubSpec{ IdentitySpec: duckv1alpha1.IdentitySpec{ @@ -55,7 +55,7 @@ func SmokePullSubscriptionTestImpl(t *testing.T, authConfig lib.AuthConfig) { }, }, }), - kngcptesting.WithPullSubscriptionSink(lib.ServiceGVK, svcName)) + kngcptesting.WithPubSubPullSubscriptionSink(lib.ServiceGVK, svcName)) client.CreatePullSubscriptionOrFail(pullsubscription) client.Core.WaitForResourceReadyOrFail(psName, lib.PullSubscriptionTypeMeta) @@ -80,15 +80,15 @@ func PullSubscriptionWithTargetTestImpl(t *testing.T, authConfig lib.AuthConfig) client.CreateJobOrFail(job, lib.WithServiceForJob(targetName)) // Create PullSubscription. - pullsubscription := kngcptesting.NewPullSubscription(psName, client.Namespace, - kngcptesting.WithPullSubscriptionSpec(v1alpha1.PullSubscriptionSpec{ + pullsubscription := kngcptesting.NewPubSubPullSubscription(psName, client.Namespace, + kngcptesting.WithPubSubPullSubscriptionSpec(v1alpha1.PullSubscriptionSpec{ Topic: topicName, PubSubSpec: duckv1alpha1.PubSubSpec{ IdentitySpec: duckv1alpha1.IdentitySpec{ authConfig.PubsubServiceAccount, }, }, - }), kngcptesting.WithPullSubscriptionSink(lib.ServiceGVK, targetName)) + }), kngcptesting.WithPubSubPullSubscriptionSink(lib.ServiceGVK, targetName)) client.CreatePullSubscriptionOrFail(pullsubscription) client.Core.WaitForResourceReadyOrFail(psName, lib.PullSubscriptionTypeMeta)