Skip to content

Commit 270f262

Browse files
committed
[FAB-10578] Poll for cc instantiation on all org peers
This CR ensures that each org's peer has received the updated LSCC information after chaincode instantiation to avoid intermittent failures in the e2e tests. Change-Id: I6ce898bf3f1ddfba8040d0a9bf793e20f40ac1cf Signed-off-by: Will Lahti <wtlahti@us.ibm.com>
1 parent d7656e2 commit 270f262

File tree

1 file changed

+29
-10
lines changed

1 file changed

+29
-10
lines changed

integration/world/config.go

+29-10
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
. "github.com/onsi/ginkgo"
2626
. "github.com/onsi/gomega"
2727
"github.com/onsi/gomega/gbytes"
28+
"github.com/onsi/gomega/gexec"
2829
"github.com/tedsuo/ifrit"
2930
yaml "gopkg.in/yaml.v2"
3031
)
@@ -395,17 +396,24 @@ func (w *World) peerNetwork() {
395396
func (w *World) SetupChannel(d Deployment, peers []string) {
396397
var p *runner.Peer
397398

398-
p = w.Components.Peer()
399-
p.ConfigDir = filepath.Join(w.Rootpath, "peer0.org1.example.com")
400-
p.MSPConfigPath = filepath.Join(w.Rootpath, "crypto", "peerOrganizations", "org1.example.com", "users", "Admin@org1.example.com", "msp")
399+
if len(peers) == 0 {
400+
return
401+
}
402+
403+
setupPeerRunner := func(peerID string) *runner.Peer {
404+
p = w.Components.Peer()
405+
peerOrg := strings.SplitN(peerID, ".", 2)[1]
406+
p.ConfigDir = filepath.Join(w.Rootpath, peerID)
407+
p.MSPConfigPath = filepath.Join(w.Rootpath, "crypto", "peerOrganizations", peerOrg, "users", fmt.Sprintf("Admin@%s", peerOrg), "msp")
408+
return p
409+
}
410+
411+
p = setupPeerRunner(peers[0])
401412
adminRunner := p.CreateChannel(d.Channel, filepath.Join(w.Rootpath, fmt.Sprintf("%s_tx.pb", d.Channel)), d.Orderer)
402413
execute(adminRunner)
403414

404415
for _, peer := range peers {
405-
p = w.Components.Peer()
406-
peerOrg := strings.SplitN(peer, ".", 2)[1]
407-
p.ConfigDir = filepath.Join(w.Rootpath, peer)
408-
p.MSPConfigPath = filepath.Join(w.Rootpath, "crypto", "peerOrganizations", peerOrg, "users", fmt.Sprintf("Admin@%s", peerOrg), "msp")
416+
p = setupPeerRunner(peer)
409417
adminRunner = p.FetchChannel(d.Channel, filepath.Join(w.Rootpath, peer, fmt.Sprintf("%s_block.pb", d.Channel)), "0", d.Orderer)
410418
execute(adminRunner)
411419
ExpectWithOffset(1, adminRunner.Err()).To(gbytes.Say("Received block: 0"))
@@ -419,10 +427,21 @@ func (w *World) SetupChannel(d Deployment, peers []string) {
419427
p.InstallChaincode(d.Chaincode.Name, d.Chaincode.Version, d.Chaincode.Path)
420428
}
421429

422-
p = w.Components.Peer()
423-
p.ConfigDir = filepath.Join(w.Rootpath, "peer0.org1.example.com")
424-
p.MSPConfigPath = filepath.Join(w.Rootpath, "crypto", "peerOrganizations", "org1.example.com", "users", "Admin@org1.example.com", "msp")
430+
p = setupPeerRunner(peers[0])
425431
p.InstantiateChaincode(d.Chaincode.Name, d.Chaincode.Version, d.Orderer, d.Channel, d.InitArgs, d.Policy)
432+
433+
for _, peer := range peers[1:] {
434+
p = setupPeerRunner(peer)
435+
listInstantiated := func() *gbytes.Buffer {
436+
adminRunner = p.ChaincodeListInstantiated(d.Channel)
437+
438+
sess, err := helpers.StartSession(adminRunner.Command, "list instantiated", "4;34m")
439+
ExpectWithOffset(1, err).NotTo(HaveOccurred())
440+
EventuallyWithOffset(1, sess, 10*time.Second).Should(gexec.Exit(0))
441+
return sess.Buffer()
442+
}
443+
EventuallyWithOffset(1, listInstantiated, time.Minute).Should(gbytes.Say(fmt.Sprintf("Name: %s, Version: %s,", d.Chaincode.Name, d.Chaincode.Version)))
444+
}
426445
}
427446

428447
func (w *World) PeerIDs() []string {

0 commit comments

Comments
 (0)