Skip to content

Commit 2409de0

Browse files
committed
Use network.EventuallyTimeout for network polling
There are a handful of places in the integration tests where we will wait for a process to start, a process to complete, or a condition to be true where a timeout was not specified. When the timeout is not specified, the default timeout of 1s is used. These short timeouts have resulted in some failures in CRs. To help mitigate these, we'll consistently use the network EventuallyTimeout when interacting with the network. While evaluating all of the Eventually calls, a handful of hard-coded timeouts were also changed to use the network timeout. FAB-15955 #done Signed-off-by: Matthew Sykes <sykesmat@us.ibm.com> Change-Id: I7c3628bc5eda22dbfb34ebbc25a68d2fb46bcede
1 parent 72c5197 commit 2409de0

File tree

16 files changed

+96
-104
lines changed

16 files changed

+96
-104
lines changed

integration/discovery/discovery_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ var _ = Describe("DiscoveryService", func() {
8080

8181
networkRunner := network.NetworkGroupRunner()
8282
process = ifrit.Invoke(networkRunner)
83-
Eventually(process.Ready()).Should(BeClosed())
83+
Eventually(process.Ready(), network.EventuallyTimeout).Should(BeClosed())
8484

8585
orderer = network.Orderer("orderer")
8686
network.CreateAndJoinChannel(orderer, "testchannel")

integration/e2e/acl_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"os"
1414
"path/filepath"
1515
"syscall"
16-
"time"
1716

1817
docker "github.com/fsouza/go-dockerclient"
1918
"github.com/golang/protobuf/proto"
@@ -208,12 +207,12 @@ var _ = Describe("EndToEndACL", func() {
208207
By("evaluating " + policyName + " for a permitted subject")
209208
sess, err := network.PeerAdminSession(org1Peer0, chaincodeQuery)
210209
Expect(err).NotTo(HaveOccurred())
211-
Eventually(sess, 30*time.Second).Should(gexec.Exit(0))
210+
Eventually(sess, network.EventuallyTimeout).Should(gexec.Exit(0))
212211

213212
By("evaluating " + policyName + " for a forbidden subject")
214213
sess, err = network.PeerAdminSession(org2Peer0, chaincodeQuery)
215214
Expect(err).NotTo(HaveOccurred())
216-
Eventually(sess, 30*time.Second).Should(gexec.Exit())
215+
Eventually(sess, network.EventuallyTimeout).Should(gexec.Exit())
217216
Expect(sess.Err).To(gbytes.Say(fmt.Sprintf(`access denied for \[%s\]\[%s\](.*)signature set did not satisfy policy`, operation, "testchannel")))
218217
}
219218

integration/e2e/e2e_signal_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,28 +67,28 @@ var _ = Describe("SignalHandling", func() {
6767
It("handles signals", func() {
6868
By("verifying SIGUSR1 to the peer dumps go routines")
6969
peerProcess.Signal(syscall.SIGUSR1)
70-
Eventually(peerRunner.Err()).Should(gbytes.Say("Received signal: "))
71-
Eventually(peerRunner.Err()).Should(gbytes.Say(`Go routines report`))
70+
Eventually(peerRunner.Err(), network.EventuallyTimeout).Should(gbytes.Say("Received signal: "))
71+
Eventually(peerRunner.Err(), network.EventuallyTimeout).Should(gbytes.Say(`Go routines report`))
7272

7373
By("verifying SIGUSR1 to the orderer dumps go routines")
7474
ordererProcess.Signal(syscall.SIGUSR1)
75-
Eventually(ordererRunner.Err()).Should(gbytes.Say("Received signal: "))
76-
Eventually(ordererRunner.Err()).Should(gbytes.Say(`Go routines report`))
75+
Eventually(ordererRunner.Err(), network.EventuallyTimeout).Should(gbytes.Say("Received signal: "))
76+
Eventually(ordererRunner.Err(), network.EventuallyTimeout).Should(gbytes.Say(`Go routines report`))
7777

7878
By("verifying SIGUSR1 does not terminate processes")
7979
Consistently(peerProcess.Wait()).ShouldNot(Receive())
8080
Consistently(ordererProcess.Wait()).ShouldNot(Receive())
8181

8282
By("verifying SIGTERM to the peer stops the process")
8383
peerProcess.Signal(syscall.SIGTERM)
84-
Eventually(peerRunner.Err()).Should(gbytes.Say("Received signal: "))
85-
Eventually(peerProcess.Wait()).Should(Receive())
84+
Eventually(peerRunner.Err(), network.EventuallyTimeout).Should(gbytes.Say("Received signal: "))
85+
Eventually(peerProcess.Wait(), network.EventuallyTimeout).Should(Receive())
8686
peerProcess = nil
8787

8888
By("verifying SIGTERM to the orderer stops the process")
8989
ordererProcess.Signal(syscall.SIGTERM)
90-
Eventually(ordererRunner.Err()).Should(gbytes.Say("Received signal: "))
91-
Eventually(ordererProcess.Wait()).Should(Receive())
90+
Eventually(ordererRunner.Err(), network.EventuallyTimeout).Should(gbytes.Say("Received signal: "))
91+
Eventually(ordererProcess.Wait(), network.EventuallyTimeout).Should(Receive())
9292
ordererProcess = nil
9393
})
9494
})

integration/e2e/e2e_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ func RunRespondWith(n *nwo.Network, orderer *nwo.Orderer, peer *nwo.Peer, channe
322322
WaitForEvent: true,
323323
})
324324
Expect(err).NotTo(HaveOccurred())
325-
Eventually(sess, time.Minute).Should(gexec.Exit(0))
325+
Eventually(sess, n.EventuallyTimeout).Should(gexec.Exit(0))
326326
Expect(sess.Err).To(gbytes.Say("Chaincode invoke successful. result: status:300"))
327327

328328
By("responding with a 400")
@@ -338,7 +338,7 @@ func RunRespondWith(n *nwo.Network, orderer *nwo.Orderer, peer *nwo.Peer, channe
338338
WaitForEvent: true,
339339
})
340340
Expect(err).NotTo(HaveOccurred())
341-
Eventually(sess, time.Minute).Should(gexec.Exit(1))
341+
Eventually(sess, n.EventuallyTimeout).Should(gexec.Exit(1))
342342
Expect(sess.Err).To(gbytes.Say(`Error: endorsement failure during invoke.`))
343343
}
344344

integration/e2e/health_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ var _ = Describe("Health", func() {
8585

8686
peerRunner := network.PeerRunner(peer)
8787
process = ginkgomon.Invoke(peerRunner)
88-
Eventually(process.Ready()).Should(BeClosed())
88+
Eventually(process.Ready(), network.EventuallyTimeout).Should(BeClosed())
8989

9090
authClient, _ = PeerOperationalClients(network, peer)
9191
healthURL = fmt.Sprintf("https://127.0.0.1:%d/healthz", network.PeerPort(peer, nwo.OperationsPort))

integration/gossip/gossip_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
"io/ioutil"
1515
"os"
1616
"syscall"
17-
"time"
1817

1918
docker "github.com/fsouza/go-dockerclient"
2019
"github.com/hyperledger/fabric/integration/nwo"
@@ -114,7 +113,7 @@ var _ = Describe("Gossip Test", func() {
114113
for _, peer := range []*nwo.Peer{peer0Org1, peer1Org1, peer0Org2, peer1Org2} {
115114
Eventually(func() int {
116115
return nwo.GetLedgerHeight(network, peer, channelName)
117-
}).Should(BeNumerically(">=", 2))
116+
}, network.EventuallyTimeout).Should(BeNumerically(">=", 2))
118117
}
119118

120119
By("stop peers except peer0Org1 to make sure they cannot get blocks from orderer")
@@ -159,7 +158,7 @@ var _ = Describe("Gossip Test", func() {
159158
Eventually(proc.Wait(), network.EventuallyTimeout).Should(Receive())
160159

161160
expectedMsg := "Stopped being a leader"
162-
Eventually(peerRunners[id].Err(), time.Minute).Should(gbytes.Say(expectedMsg))
161+
Eventually(peerRunners[id].Err(), network.EventuallyTimeout).Should(gbytes.Say(expectedMsg))
163162

164163
delete(peerProcesses, id)
165164

@@ -215,6 +214,6 @@ func assertPeersLedgerHeight(n *nwo.Network, orderer *nwo.Orderer, peerList []*n
215214
for _, peer := range peerList {
216215
Eventually(func() int {
217216
return nwo.GetLedgerHeight(n, peer, channelID)
218-
}, time.Second*10).Should(Equal(expectedVal))
217+
}, n.EventuallyTimeout).Should(Equal(expectedVal))
219218
}
220219
}

integration/ledger/reset_rollback_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ func (nh *networkHelper) waitUntilEndorserEnabled(peer *nwo.Peer) {
484484
Expect(err).NotTo(HaveOccurred())
485485
Eventually(sess, nh.EventuallyTimeout).Should(gexec.Exit())
486486
return sess.Buffer()
487-
}, "60s", "2s").Should(gbytes.Say("Blockchain info"))
487+
}, nh.EventuallyTimeout).Should(gbytes.Say("Blockchain info"))
488488
}
489489

490490
type testHelper struct {

integration/nwo/deploy.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,7 @@ func CheckCommitReadinessUntilReady(n *Network, channel string, chaincode Chainc
239239
for _, org := range checkOrgs {
240240
keys[org.MSPID] = BeTrue()
241241
}
242-
Eventually(checkCommitReadiness(n, p, channel, chaincode), n.EventuallyTimeout).Should(
243-
MatchKeys(IgnoreExtras, keys),
244-
)
242+
Eventually(checkCommitReadiness(n, p, channel, chaincode), n.EventuallyTimeout).Should(MatchKeys(IgnoreExtras, keys))
245243
}
246244
}
247245

integration/nwo/discover.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func DiscoverPeers(n *Network, p *Peer, user, channelName string) func() []Disco
3636
}
3737
sess, err := n.Discover(peers)
3838
Expect(err).NotTo(HaveOccurred())
39-
Eventually(sess).Should(gexec.Exit(0))
39+
Eventually(sess, n.EventuallyTimeout).Should(gexec.Exit(0))
4040

4141
var discovered []DiscoveredPeer
4242
err = json.Unmarshal(sess.Out.Contents(), &discovered)

integration/pluggable/pluggable_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ var _ = Describe("EndToEnd", func() {
7979

8080
networkRunner := network.NetworkGroupRunner()
8181
process = ifrit.Invoke(networkRunner)
82-
Eventually(process.Ready()).Should(BeClosed())
82+
Eventually(process.Ready(), network.EventuallyTimeout).Should(BeClosed())
8383

8484
chaincode = nwo.Chaincode{
8585
Name: "mycc",
@@ -102,7 +102,7 @@ var _ = Describe("EndToEnd", func() {
102102
AfterEach(func() {
103103
// stop the network
104104
process.Signal(syscall.SIGTERM)
105-
Eventually(process.Wait()).Should(Receive())
105+
Eventually(process.Wait(), network.EventuallyTimeout).Should(Receive())
106106

107107
// cleanup the network artifacts
108108
network.Cleanup()

0 commit comments

Comments
 (0)