Skip to content

Commit d7b1ed1

Browse files
wlahtiBrett Logan
authored andcommitted
Chan.Part.API: config-tracker IT flake fix
Ensure a raft leader has been elected and the channel is active after restarting the orderers by submitting a transaction until it succeeds. This ensures the config update to remove the orderer from the consenter set does not fail. FAB-18305 #done Signed-off-by: Will Lahti <[email protected]>
1 parent b106d05 commit d7b1ed1

File tree

1 file changed

+102
-30
lines changed

1 file changed

+102
-30
lines changed

integration/raft/channel_participation_test.go

Lines changed: 102 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -147,15 +147,15 @@ var _ = Describe("ChannelParticipation", func() {
147147
Expect(channelInfo).To(Equal(expectedChannelInfoPT))
148148
}
149149

150-
submitTxn(orderer1, peer, network, members, 1, channelparticipation.ChannelInfo{
150+
submitPeerTxn(orderer1, peer, network, members, 1, channelparticipation.ChannelInfo{
151151
Name: "participation-trophy",
152152
URL: "/participation/v1/channels/participation-trophy",
153153
Status: "active",
154154
ClusterRelation: "member",
155155
Height: 2,
156156
})
157157

158-
submitTxn(orderer2, peer, network, members, 2, channelparticipation.ChannelInfo{
158+
submitPeerTxn(orderer2, peer, network, members, 2, channelparticipation.ChannelInfo{
159159
Name: "participation-trophy",
160160
URL: "/participation/v1/channels/participation-trophy",
161161
Status: "active",
@@ -197,7 +197,7 @@ var _ = Describe("ChannelParticipation", func() {
197197
}, network.EventuallyTimeout).Should(Equal(expectedChannelInfoPT))
198198

199199
By("submitting transaction to orderer3 to ensure it is active")
200-
submitTxn(orderer3, peer, network, orderers, 4, channelparticipation.ChannelInfo{
200+
submitPeerTxn(orderer3, peer, network, orderers, 4, channelparticipation.ChannelInfo{
201201
Name: "participation-trophy",
202202
URL: "/participation/v1/channels/participation-trophy",
203203
Status: "active",
@@ -240,7 +240,7 @@ var _ = Describe("ChannelParticipation", func() {
240240
}))
241241

242242
members = []*nwo.Orderer{orderer2, orderer3}
243-
submitTxn(orderer2, peer, network, members, 6, channelparticipation.ChannelInfo{
243+
submitPeerTxn(orderer2, peer, network, members, 6, channelparticipation.ChannelInfo{
244244
Name: "participation-trophy",
245245
URL: "/participation/v1/channels/participation-trophy",
246246
Status: "active",
@@ -266,15 +266,15 @@ var _ = Describe("ChannelParticipation", func() {
266266
channelparticipation.List(network, orderer1, []string{"another-participation-trophy"})
267267

268268
By("ensuring the channel is still usable by submitting a transaction to each remaining consenter for the channel")
269-
submitTxn(orderer2, peer, network, members, 7, channelparticipation.ChannelInfo{
269+
submitPeerTxn(orderer2, peer, network, members, 7, channelparticipation.ChannelInfo{
270270
Name: "participation-trophy",
271271
URL: "/participation/v1/channels/participation-trophy",
272272
Status: "active",
273273
ClusterRelation: "member",
274274
Height: 8,
275275
})
276276

277-
submitTxn(orderer3, peer, network, members, 8, channelparticipation.ChannelInfo{
277+
submitPeerTxn(orderer3, peer, network, members, 8, channelparticipation.ChannelInfo{
278278
Name: "participation-trophy",
279279
URL: "/participation/v1/channels/participation-trophy",
280280
Status: "active",
@@ -326,15 +326,15 @@ var _ = Describe("ChannelParticipation", func() {
326326
Expect(channelInfo).To(Equal(expectedChannelInfoPT))
327327
}
328328

329-
submitTxn(orderer1, peer, network, orderers, 1, channelparticipation.ChannelInfo{
329+
submitPeerTxn(orderer1, peer, network, orderers, 1, channelparticipation.ChannelInfo{
330330
Name: "participation-trophy",
331331
URL: "/participation/v1/channels/participation-trophy",
332332
Status: "active",
333333
ClusterRelation: "member",
334334
Height: 2,
335335
})
336336

337-
submitTxn(orderer2, peer, network, orderers, 2, channelparticipation.ChannelInfo{
337+
submitPeerTxn(orderer2, peer, network, orderers, 2, channelparticipation.ChannelInfo{
338338
Name: "participation-trophy",
339339
URL: "/participation/v1/channels/participation-trophy",
340340
Status: "active",
@@ -382,7 +382,7 @@ var _ = Describe("ChannelParticipation", func() {
382382
return channelparticipation.ListOne(network, orderer3, "participation-trophy")
383383
}, network.EventuallyTimeout).Should(Equal(expectedChannelInfoMember))
384384

385-
submitTxn(orderer3, peer, network, orderers, 5, channelparticipation.ChannelInfo{
385+
submitPeerTxn(orderer3, peer, network, orderers, 5, channelparticipation.ChannelInfo{
386386
Name: "participation-trophy",
387387
URL: "/participation/v1/channels/participation-trophy",
388388
Status: "active",
@@ -420,15 +420,15 @@ var _ = Describe("ChannelParticipation", func() {
420420
Expect(channelInfo).To(Equal(expectedChannelInfoPT))
421421
}
422422

423-
submitTxn(orderer1, peer, network, orderers, 1, channelparticipation.ChannelInfo{
423+
submitPeerTxn(orderer1, peer, network, orderers, 1, channelparticipation.ChannelInfo{
424424
Name: "participation-trophy",
425425
URL: "/participation/v1/channels/participation-trophy",
426426
Status: "active",
427427
ClusterRelation: "member",
428428
Height: 2,
429429
})
430430

431-
submitTxn(orderer2, peer, network, orderers, 2, channelparticipation.ChannelInfo{
431+
submitPeerTxn(orderer2, peer, network, orderers, 2, channelparticipation.ChannelInfo{
432432
Name: "participation-trophy",
433433
URL: "/participation/v1/channels/participation-trophy",
434434
Status: "active",
@@ -483,7 +483,7 @@ var _ = Describe("ChannelParticipation", func() {
483483
return channelparticipation.ListOne(network, orderer3, "participation-trophy")
484484
}, network.EventuallyTimeout).Should(Equal(expectedChannelInfoPT))
485485

486-
submitTxn(orderer3, peer, network, orderers, 5, channelparticipation.ChannelInfo{
486+
submitPeerTxn(orderer3, peer, network, orderers, 5, channelparticipation.ChannelInfo{
487487
Name: "participation-trophy",
488488
URL: "/participation/v1/channels/participation-trophy",
489489
Status: "active",
@@ -647,6 +647,24 @@ var _ = Describe("ChannelParticipation", func() {
647647
channelparticipation.List(network, o, []string{"testchannel"}, "systemchannel")
648648
}
649649

650+
By("submitting a transaction to ensure the system channel is active after restart")
651+
submitOrdererTxn(orderer2, peer, network, orderers, 2, channelparticipation.ChannelInfo{
652+
Name: "systemchannel",
653+
URL: "/participation/v1/channels/systemchannel",
654+
Status: "active",
655+
ClusterRelation: "member",
656+
Height: 3,
657+
})
658+
659+
By("submitting a transaction to ensure the application channel is active after restart")
660+
submitPeerTxn(orderer2, peer, network, orderers, 4, channelparticipation.ChannelInfo{
661+
Name: "testchannel",
662+
URL: "/participation/v1/channels/testchannel",
663+
Status: "active",
664+
ClusterRelation: "member",
665+
Height: 5,
666+
})
667+
650668
By("removing orderer3 from the consenters set")
651669
channelConfig := nwo.GetConfig(network, peer, orderer2, "testchannel")
652670
c := configtx.New(channelConfig)
@@ -662,9 +680,40 @@ var _ = Describe("ChannelParticipation", func() {
662680
URL: "/participation/v1/channels/testchannel",
663681
Status: "inactive",
664682
ClusterRelation: "config-tracker",
665-
Height: 5,
683+
Height: 6,
666684
}))
667685

686+
By("ensuring orderers 1 and 2 receive the block")
687+
orderers1and2 := []*nwo.Orderer{orderer1, orderer2}
688+
for _, o := range orderers1and2 {
689+
Eventually(func() channelparticipation.ChannelInfo {
690+
return channelparticipation.ListOne(network, o, "testchannel")
691+
}, network.EventuallyTimeout).Should(Equal(channelparticipation.ChannelInfo{
692+
Name: "testchannel",
693+
URL: "/participation/v1/channels/testchannel",
694+
Status: "active",
695+
ClusterRelation: "member",
696+
Height: 6,
697+
}))
698+
}
699+
700+
By("submitting a transaction to each active orderer")
701+
submitPeerTxn(orderer1, peer, network, orderers1and2, 6, channelparticipation.ChannelInfo{
702+
Name: "testchannel",
703+
URL: "/participation/v1/channels/testchannel",
704+
Status: "active",
705+
ClusterRelation: "member",
706+
Height: 7,
707+
})
708+
709+
submitPeerTxn(orderer2, peer, network, orderers1and2, 7, channelparticipation.ChannelInfo{
710+
Name: "testchannel",
711+
URL: "/participation/v1/channels/testchannel",
712+
Status: "active",
713+
ClusterRelation: "member",
714+
Height: 8,
715+
})
716+
668717
By("restarting orderer3 to ensure it still reports inactive/config-tracker")
669718
restartOrderer(orderer3, 2)
670719
Eventually(func() channelparticipation.ChannelInfo {
@@ -674,7 +723,7 @@ var _ = Describe("ChannelParticipation", func() {
674723
URL: "/participation/v1/channels/testchannel",
675724
Status: "inactive",
676725
ClusterRelation: "config-tracker",
677-
Height: 5,
726+
Height: 6,
678727
}))
679728

680729
By("attempting to join a channel when the system channel is present")
@@ -684,6 +733,15 @@ var _ = Describe("ChannelParticipation", func() {
684733
By("attempting to remove a channel when the system channel is present")
685734
channelparticipationRemoveFailure(network, orderers[0], "testchannel", http.StatusMethodNotAllowed, "cannot remove: system channel exists")
686735

736+
By("submitting a transaction to ensure the system channel is active after restart")
737+
submitOrdererTxn(orderer3, peer, network, orderers, 3, channelparticipation.ChannelInfo{
738+
Name: "systemchannel",
739+
URL: "/participation/v1/channels/systemchannel",
740+
Status: "active",
741+
ClusterRelation: "member",
742+
Height: 4,
743+
})
744+
687745
By("putting the system channel into maintenance mode")
688746
channelConfig = nwo.GetConfig(network, peer, orderer2, "systemchannel")
689747
c = configtx.New(channelConfig)
@@ -696,27 +754,27 @@ var _ = Describe("ChannelParticipation", func() {
696754
channelparticipation.Remove(network, o, "systemchannel")
697755
}
698756

699-
By("listing the channels again")
700-
for _, o := range orderers[:1] {
757+
By("listing the channels after removing the system channel")
758+
for _, o := range orderers1and2 {
701759
channelparticipation.List(network, o, []string{"testchannel"})
702760
}
703761
channelparticipation.List(network, orderer3, []string{})
704762

705-
By("broadcasting envelopes to each active orderer")
706-
submitTxn(orderer1, peer, network, orderers[:1], 5, channelparticipation.ChannelInfo{
763+
By("submitting a transaction to each active orderer after restart")
764+
submitPeerTxn(orderer1, peer, network, orderers1and2, 8, channelparticipation.ChannelInfo{
707765
Name: "testchannel",
708766
URL: "/participation/v1/channels/testchannel",
709767
Status: "active",
710768
ClusterRelation: "member",
711-
Height: 6,
769+
Height: 9,
712770
})
713771

714-
submitTxn(orderer2, peer, network, orderers[:1], 6, channelparticipation.ChannelInfo{
772+
submitPeerTxn(orderer2, peer, network, orderers1and2, 9, channelparticipation.ChannelInfo{
715773
Name: "testchannel",
716774
URL: "/participation/v1/channels/testchannel",
717775
Status: "active",
718776
ClusterRelation: "member",
719-
Height: 7,
777+
Height: 10,
720778
})
721779

722780
By("using the channel participation API to join a new channel")
@@ -735,23 +793,23 @@ var _ = Describe("ChannelParticipation", func() {
735793
Expect(channelInfo).To(Equal(expectedChannelInfoPT))
736794
}
737795

738-
submitTxn(orderer1, peer, network, orderers, 1, channelparticipation.ChannelInfo{
796+
submitPeerTxn(orderer1, peer, network, orderers, 1, channelparticipation.ChannelInfo{
739797
Name: "participation-trophy",
740798
URL: "/participation/v1/channels/participation-trophy",
741799
Status: "active",
742800
ClusterRelation: "member",
743801
Height: 2,
744802
})
745803

746-
submitTxn(orderer2, peer, network, orderers, 2, channelparticipation.ChannelInfo{
804+
submitPeerTxn(orderer2, peer, network, orderers, 2, channelparticipation.ChannelInfo{
747805
Name: "participation-trophy",
748806
URL: "/participation/v1/channels/participation-trophy",
749807
Status: "active",
750808
ClusterRelation: "member",
751809
Height: 3,
752810
})
753811

754-
submitTxn(orderer3, peer, network, orderers, 3, channelparticipation.ChannelInfo{
812+
submitPeerTxn(orderer3, peer, network, orderers, 3, channelparticipation.ChannelInfo{
755813
Name: "participation-trophy",
756814
URL: "/participation/v1/channels/participation-trophy",
757815
Status: "active",
@@ -763,16 +821,30 @@ var _ = Describe("ChannelParticipation", func() {
763821

764822
})
765823

766-
func submitTxn(o *nwo.Orderer, peer *nwo.Peer, n *nwo.Network, orderers []*nwo.Orderer, expectedBlkNum int, expectedChannelInfo channelparticipation.ChannelInfo) {
767-
By("submitting a transaction to " + o.Name)
824+
// submit a transaction signed by the peer and ensure it was
825+
// committed to the ledger
826+
func submitPeerTxn(o *nwo.Orderer, peer *nwo.Peer, n *nwo.Network, orderers []*nwo.Orderer, expectedBlkNum int, expectedChannelInfo channelparticipation.ChannelInfo) {
768827
env := CreateBroadcastEnvelope(n, peer, expectedChannelInfo.Name, []byte("hello"))
828+
submitTxn(o, env, peer, n, orderers, expectedBlkNum, expectedChannelInfo)
829+
}
830+
831+
// submit a transaction signed by the orderer and ensure it is
832+
// committed to the ledger
833+
func submitOrdererTxn(o *nwo.Orderer, peer *nwo.Peer, n *nwo.Network, orderers []*nwo.Orderer, expectedBlkNum int, expectedChannelInfo channelparticipation.ChannelInfo) {
834+
env := CreateBroadcastEnvelope(n, o, expectedChannelInfo.Name, []byte("hello"))
835+
submitTxn(o, env, peer, n, orderers, expectedBlkNum, expectedChannelInfo)
836+
}
837+
838+
// submit the envelope to the orderer and ensure it is committed
839+
// to the ledger
840+
func submitTxn(o *nwo.Orderer, env *common.Envelope, peer *nwo.Peer, n *nwo.Network, orderers []*nwo.Orderer, expectedBlkNum int, expectedChannelInfo channelparticipation.ChannelInfo) {
841+
By("submitting a transaction to " + o.Name)
769842
Eventually(broadcastTransactionFunc(n, o, env), n.EventuallyTimeout, time.Second).Should(Equal(common.Status_SUCCESS))
770-
expectedBlockNumPerChannel := map[string]int{expectedChannelInfo.Name: expectedBlkNum}
771-
assertBlockReception(expectedBlockNumPerChannel, orderers, peer, n)
772843

773844
By("checking the channel info on " + o.Name)
774-
channelInfo := channelparticipation.ListOne(n, o, expectedChannelInfo.Name)
775-
Expect(channelInfo).To(Equal(expectedChannelInfo))
845+
Eventually(func() channelparticipation.ChannelInfo {
846+
return channelparticipation.ListOne(n, o, expectedChannelInfo.Name)
847+
}, n.EventuallyTimeout).Should(Equal(expectedChannelInfo))
776848
}
777849

778850
func applicationChannelGenesisBlock(n *nwo.Network, orderers []*nwo.Orderer, p *nwo.Peer, channel string) *common.Block {

0 commit comments

Comments
 (0)