Skip to content

Commit

Permalink
Review updates for trigger reconciler tests
Browse files Browse the repository at this point in the history
Signed-off-by: aavarghese <avarghese@us.ibm.com>
  • Loading branch information
aavarghese committed Jan 21, 2022
1 parent f16b88f commit 3565585
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func (c *ConsumerGroup) GetUntypedSpec() interface{} {
return c.Spec
}

// GetStatus retrieves the status of the ConsumerGroupt. Implements the KRShaped interface.
// GetStatus retrieves the status of the ConsumerGroup. Implements the KRShaped interface.
func (c *ConsumerGroup) GetStatus() *duckv1.Status {
return &c.Status.Status
}
Expand Down
6 changes: 6 additions & 0 deletions control-plane/pkg/reconciler/testing/objects_consumergroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ func ConsumerGroupReady(cg *kafkainternals.ConsumerGroup) {
}
}

func WithConsumerGroupFailed(reason string, msg string) ConsumerGroupOption {
return func(cg *kafkainternals.ConsumerGroup) {
cg.GetConditionSet().Manage(cg.GetStatus()).MarkFalse(kafkainternals.ConditionConsumerGroupConsumers, reason, msg)
}
}

func WithConsumerGroupName(name string) ConsumerGroupOption {
return func(cg *kafkainternals.ConsumerGroup) {
cg.ObjectMeta.Name = name
Expand Down
2 changes: 1 addition & 1 deletion control-plane/pkg/reconciler/trigger/v2/triggerv2.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, trigger *eventing.Trigge

func (r Reconciler) reconcileConsumerGroup(ctx context.Context, trigger *eventing.Trigger) (*internalscg.ConsumerGroup, error) {

var deliveryOrdering = internals.Ordered
var deliveryOrdering = internals.Unordered
var err error
deliveryOrderingAnnotationValue, ok := trigger.Annotations[deliveryOrderAnnotation]
if ok {
Expand Down
48 changes: 42 additions & 6 deletions control-plane/pkg/reconciler/trigger/v2/triggerv2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func TestReconcileKind(t *testing.T) {
ConsumerConfigs(
ConsumerGroupIdConfig(TriggerUUID),
),
ConsumerDelivery(NewConsumerSpecDelivery(internals.Ordered)),
ConsumerDelivery(NewConsumerSpecDelivery(internals.Unordered)),
ConsumerFilters(NewConsumerSpecFilters()),
)),
),
Expand Down Expand Up @@ -242,7 +242,7 @@ func TestReconcileKind(t *testing.T) {
ConsumerConfigs(
ConsumerGroupIdConfig(TriggerUUID),
),
ConsumerDelivery(NewConsumerSpecDelivery(internals.Ordered)),
ConsumerDelivery(NewConsumerSpecDelivery(internals.Unordered)),
ConsumerFilters(NewConsumerSpecFilters()),
)),
ConsumerGroupReady,
Expand Down Expand Up @@ -289,7 +289,7 @@ func TestReconcileKind(t *testing.T) {
ConsumerConfigs(
ConsumerGroupIdConfig(TriggerUUID),
),
ConsumerDelivery(NewConsumerSpecDelivery(internals.Ordered)),
ConsumerDelivery(NewConsumerSpecDelivery(internals.Unordered)),
ConsumerFilters(NewConsumerSpecFilters()),
)),
),
Expand Down Expand Up @@ -324,7 +324,7 @@ func TestReconcileKind(t *testing.T) {
ConsumerConfigs(
ConsumerGroupIdConfig(TriggerUUID),
),
ConsumerDelivery(NewConsumerSpecDelivery(internals.Ordered)),
ConsumerDelivery(NewConsumerSpecDelivery(internals.Unordered)),
ConsumerFilters(NewConsumerSpecFilters()),
)),
ConsumerGroupReady,
Expand Down Expand Up @@ -360,7 +360,7 @@ func TestReconcileKind(t *testing.T) {
ConsumerConfigs(
ConsumerGroupIdConfig(TriggerUUID),
),
ConsumerDelivery(NewConsumerSpecDelivery(internals.Ordered)),
ConsumerDelivery(NewConsumerSpecDelivery(internals.Unordered)),
ConsumerFilters(NewConsumerSpecFilters()),
)),
),
Expand All @@ -378,6 +378,42 @@ func TestReconcileKind(t *testing.T) {
},
},
},
{
Name: "Reconciled normal - existing cg but failed",
Objects: []runtime.Object{
NewBroker(
BrokerReady,
),
newTrigger(),
NewConsumerGroup(
WithConsumerGroupName(TriggerUUID),
WithConsumerGroupNamespace(triggerNamespace),
WithConsumerGroupOwnerRef(kmeta.NewControllerRef(newTrigger())),
WithConsumerGroupLabels(nil),
ConsumerGroupConsumerSpec(NewConsumerSpec(
ConsumerTopics(),
ConsumerConfigs(
ConsumerGroupIdConfig(TriggerUUID),
),
ConsumerDelivery(NewConsumerSpecDelivery(internals.Unordered)),
ConsumerFilters(NewConsumerSpecFilters()),
)),
WithConsumerGroupFailed("failed", "failed"),
),
},
Key: testKey,
WantStatusUpdates: []clientgotesting.UpdateActionImpl{
{
Object: newTrigger(
reconcilertesting.WithInitTriggerConditions,
reconcilertesting.WithTriggerBrokerReady(),
withTriggerSubscriberResolvedSucceeded(),
reconcilertesting.WithTriggerDependencyFailed("failed", "failed"),
withDeadLetterSinkURI(""),
),
},
},
},
{
Name: "Reconciled normal with dead letter sink uri",
Objects: []runtime.Object{
Expand All @@ -395,7 +431,7 @@ func TestReconcileKind(t *testing.T) {
ConsumerConfigs(
ConsumerGroupIdConfig(TriggerUUID),
),
ConsumerDelivery(NewConsumerSpecDelivery(internals.Ordered)),
ConsumerDelivery(NewConsumerSpecDelivery(internals.Unordered)),
ConsumerFilters(NewConsumerSpecFilters()),
)),
WithDeadLetterSinkURI(url.String()),
Expand Down

0 comments on commit 3565585

Please sign in to comment.