Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

backport 3945 to .16 #3948

Merged
merged 1 commit into from
Aug 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/apis/flows/v1/parallel_lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (ps *ParallelStatus) InitializeConditions() {
// PropagateSubscriptionStatuses sets the ParallelConditionSubscriptionsReady based on
// the status of the incoming subscriptions.
func (ps *ParallelStatus) PropagateSubscriptionStatuses(filterSubscriptions []*messagingv1.Subscription, subscriptions []*messagingv1.Subscription) {
if ps.BranchStatuses == nil {
if ps.BranchStatuses == nil || len(subscriptions) != len(ps.BranchStatuses) {
ps.BranchStatuses = make([]ParallelBranchStatus, len(subscriptions))
}
allReady := true
Expand Down Expand Up @@ -136,7 +136,7 @@ func (ps *ParallelStatus) PropagateSubscriptionStatuses(filterSubscriptions []*m
// PropagateChannelStatuses sets the ChannelStatuses and ParallelConditionChannelsReady based on the
// status of the incoming channels.
func (ps *ParallelStatus) PropagateChannelStatuses(ingressChannel *duckv1.Channelable, channels []*duckv1.Channelable) {
if ps.BranchStatuses == nil {
if ps.BranchStatuses == nil || len(channels) != len(ps.BranchStatuses) {
ps.BranchStatuses = make([]ParallelBranchStatus, len(channels))
}
allReady := true
Expand Down
31 changes: 31 additions & 0 deletions pkg/apis/flows/v1/parallel_lifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,37 @@ func TestParallelPropagateChannelStatuses(t *testing.T) {
}
}

func TestParallelPropagateChannelStatusUpdated(t *testing.T) {
inChannel := getChannelable(true)
initialChannels := []*eventingduckv1.Channelable{getChannelable(true)}
afterChannels := []*eventingduckv1.Channelable{getChannelable(true), getChannelable(true)}
ps := ParallelStatus{}
ps.PropagateChannelStatuses(inChannel, initialChannels)
if len(ps.BranchStatuses) != 1 {
t.Errorf("unexpected branchstatuses want 1 got %d", len(ps.BranchStatuses))
}
ps.PropagateChannelStatuses(inChannel, afterChannels)
if len(ps.BranchStatuses) != 2 {
t.Errorf("unexpected branchstatuses want 2 got %d", len(ps.BranchStatuses))
}
}

func TestParallelPropagateSubscriptionStatusUpdated(t *testing.T) {
initialFsubs := []*messagingv1.Subscription{getSubscription("fsub0", true)}
initialSubs := []*messagingv1.Subscription{getSubscription("sub0", true)}
afterFsubs := []*messagingv1.Subscription{getSubscription("fsub0", true), getSubscription("fsub1", true)}
afterSubs := []*messagingv1.Subscription{getSubscription("sub0", true), getSubscription("sub1", true)}
ps := ParallelStatus{}
ps.PropagateSubscriptionStatuses(initialFsubs, initialSubs)
if len(ps.BranchStatuses) != 1 {
t.Errorf("unexpected branchstatuses want 1 got %d", len(ps.BranchStatuses))
}
ps.PropagateSubscriptionStatuses(afterFsubs, afterSubs)
if len(ps.BranchStatuses) != 2 {
t.Errorf("unexpected branchstatuses want 2 got %d", len(ps.BranchStatuses))
}
}

func TestParallelReady(t *testing.T) {
tests := []struct {
name string
Expand Down