Commit 4150a698 authored by Matthew Sykes's avatar Matthew Sykes
Browse files

[FAB-10662] eventually timeout added to nwo



Change-Id: Icc8d1ee55b4d0a00a6084a081faf59a8fa7e52a2
Signed-off-by: default avatarMatthew Sykes <sykesmat@us.ibm.com>
parent 5df24f08
......@@ -10,7 +10,6 @@ import (
"io/ioutil"
"os"
"path/filepath"
"time"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gbytes"
......@@ -39,7 +38,7 @@ func GetConfigBlock(n *Network, peer *Peer, orderer *Orderer, channel string) *c
OutputFile: output,
})
Expect(err).NotTo(HaveOccurred())
Eventually(sess, time.Minute).Should(gexec.Exit(0))
Eventually(sess, n.EventuallyTimeout).Should(gexec.Exit(0))
Expect(sess.Err).To(gbytes.Say("Received block: "))
// unmarshal the config block bytes
......@@ -91,7 +90,7 @@ func UpdateConfig(n *Network, signer, submitter *Peer, orderer *Orderer, channel
sess, err := n.PeerAdminSession(signer, commands.SignConfigTx{File: updateFile})
Expect(err).NotTo(HaveOccurred())
Eventually(sess, time.Minute).Should(gexec.Exit(0))
Eventually(sess, n.EventuallyTimeout).Should(gexec.Exit(0))
// get current configuration block number
currentBlockNumber := CurrentConfigBlockNumber(n, submitter, orderer, channel)
......@@ -102,11 +101,12 @@ func UpdateConfig(n *Network, signer, submitter *Peer, orderer *Orderer, channel
File: updateFile,
})
Expect(err).NotTo(HaveOccurred())
Eventually(sess, time.Minute).Should(gexec.Exit(0))
Eventually(sess, n.EventuallyTimeout).Should(gexec.Exit(0))
Expect(sess.Err).To(gbytes.Say("Successfully submitted channel update"))
// wait for the block to be committed
Eventually(func() uint64 { return CurrentConfigBlockNumber(n, submitter, orderer, channel) }).Should(BeNumerically(">", currentBlockNumber))
ccb := func() uint64 { return CurrentConfigBlockNumber(n, submitter, orderer, channel) }
Eventually(ccb, n.EventuallyTimeout).Should(BeNumerically(">", currentBlockNumber))
}
// CurrentConfigBlockNumber retrieves the block number from the header of the
......@@ -126,7 +126,7 @@ func CurrentConfigBlockNumber(n *Network, peer *Peer, orderer *Orderer, channel
OutputFile: output,
})
Expect(err).NotTo(HaveOccurred())
Eventually(sess, time.Minute).Should(gexec.Exit(0))
Eventually(sess, n.EventuallyTimeout).Should(gexec.Exit(0))
Expect(sess.Err).To(gbytes.Say("Received block: "))
// unmarshal the config block bytes
......
......@@ -8,7 +8,6 @@ package nwo
import (
"fmt"
"time"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gbytes"
......@@ -52,11 +51,11 @@ func InstallChaincode(n *Network, chaincode Chaincode, peers ...*Peer) {
Path: chaincode.Path,
})
Expect(err).NotTo(HaveOccurred())
Eventually(sess, time.Minute).Should(gexec.Exit(0))
Eventually(sess, n.EventuallyTimeout).Should(gexec.Exit(0))
sess, err = n.PeerAdminSession(p, commands.ChaincodeListInstalled{})
Expect(err).NotTo(HaveOccurred())
Eventually(sess, time.Minute).Should(gexec.Exit(0))
Eventually(sess, n.EventuallyTimeout).Should(gexec.Exit(0))
Expect(sess).To(gbytes.Say(fmt.Sprintf("Name: %s, Version: %s,", chaincode.Name, chaincode.Version)))
}
}
......@@ -72,14 +71,14 @@ func InstantiateChaincode(n *Network, channel string, orderer *Orderer, chaincod
CollectionsConfig: chaincode.CollectionsConfig,
})
Expect(err).NotTo(HaveOccurred())
Eventually(sess, time.Minute).Should(gexec.Exit(0))
Eventually(sess, n.EventuallyTimeout).Should(gexec.Exit(0))
EnsureInstantiated(n, channel, chaincode.Name, chaincode.Version, checkPeers...)
}
func EnsureInstantiated(n *Network, channel, name, version string, peers ...*Peer) {
for _, p := range peers {
Eventually(listInstantiated(n, p, channel), time.Minute).Should(
Eventually(listInstantiated(n, p, channel), n.EventuallyTimeout).Should(
gbytes.Say(fmt.Sprintf("Name: %s, Version: %s,", name, version)),
)
}
......@@ -107,7 +106,7 @@ func UpgradeChaincode(n *Network, channel string, orderer *Orderer, chaincode Ch
CollectionsConfig: chaincode.CollectionsConfig,
})
Expect(err).NotTo(HaveOccurred())
Eventually(sess, time.Minute).Should(gexec.Exit(0))
Eventually(sess, n.EventuallyTimeout).Should(gexec.Exit(0))
EnsureInstantiated(n, channel, chaincode.Name, chaincode.Version, peers...)
}
......@@ -118,7 +117,7 @@ func listInstantiated(n *Network, peer *Peer, channel string) func() *gbytes.Buf
ChannelID: channel,
})
Expect(err).NotTo(HaveOccurred())
Eventually(sess, 10*time.Second).Should(gexec.Exit(0))
Eventually(sess, n.EventuallyTimeout).Should(gexec.Exit(0))
return sess.Buffer()
}
}
......@@ -127,11 +127,12 @@ type Profile struct {
// Network holds information about a fabric network.
type Network struct {
RootDir string
StartPort uint16
NetworkID string
Components *Components
DockerClient *docker.Client
RootDir string
StartPort uint16
Components *Components
DockerClient *docker.Client
NetworkID string
EventuallyTimeout time.Duration
PortsByBrokerID map[string]Ports
PortsByOrdererID map[string]Ports
......@@ -159,10 +160,11 @@ func New(c *Config, rootDir string, client *docker.Client, startPort int, compon
Components: components,
DockerClient: client,
NetworkID: helpers.UniqueName(),
PortsByBrokerID: map[string]Ports{},
PortsByOrdererID: map[string]Ports{},
PortsByPeerID: map[string]Ports{},
NetworkID: helpers.UniqueName(),
EventuallyTimeout: time.Minute,
PortsByBrokerID: map[string]Ports{},
PortsByOrdererID: map[string]Ports{},
PortsByPeerID: map[string]Ports{},
Organizations: c.Organizations,
Consensus: c.Consensus,
......@@ -489,7 +491,7 @@ func (n *Network) Bootstrap() {
Output: n.CryptoPath(),
})
Expect(err).NotTo(HaveOccurred())
Eventually(sess).Should(gexec.Exit(0))
Eventually(sess, n.EventuallyTimeout).Should(gexec.Exit(0))
sess, err = n.ConfigTxGen(commands.OutputBlock{
ChannelID: n.SystemChannel.Name,
......@@ -498,7 +500,7 @@ func (n *Network) Bootstrap() {
OutputBlock: n.OutputBlockPath(n.SystemChannel.Name),
})
Expect(err).NotTo(HaveOccurred())
Eventually(sess).Should(gexec.Exit(0))
Eventually(sess, n.EventuallyTimeout).Should(gexec.Exit(0))
for _, c := range n.Channels {
sess, err := n.ConfigTxGen(commands.CreateChannelTx{
......@@ -508,7 +510,7 @@ func (n *Network) Bootstrap() {
OutputCreateChannelTx: n.CreateChannelTxPath(c.Name),
})
Expect(err).NotTo(HaveOccurred())
Eventually(sess).Should(gexec.Exit(0))
Eventually(sess, n.EventuallyTimeout).Should(gexec.Exit(0))
}
}
......@@ -580,14 +582,14 @@ func (n *Network) CreateAndJoinChannel(o *Orderer, channelName string) {
OutputBlock: tempFile.Name(),
})
Expect(err).NotTo(HaveOccurred())
Eventually(sess, time.Minute).Should(gexec.Exit(0))
Eventually(sess, n.EventuallyTimeout).Should(gexec.Exit(0))
for _, p := range peers {
sess, err := n.PeerAdminSession(p, commands.ChannelJoin{
BlockPath: tempFile.Name(),
})
Expect(err).NotTo(HaveOccurred())
Eventually(sess).Should(gexec.Exit(0))
Eventually(sess, n.EventuallyTimeout).Should(gexec.Exit(0))
}
}
......@@ -615,7 +617,7 @@ func (n *Network) UpdateChannelAnchors(o *Orderer, channelName string) {
}
sess, err := n.ConfigTxGen(anchorUpdate)
Expect(err).NotTo(HaveOccurred())
Eventually(sess).Should(gexec.Exit(0))
Eventually(sess, n.EventuallyTimeout).Should(gexec.Exit(0))
sess, err = n.PeerAdminSession(p, commands.ChannelUpdate{
ChannelID: channelName,
......@@ -623,7 +625,7 @@ func (n *Network) UpdateChannelAnchors(o *Orderer, channelName string) {
File: tempFile.Name(),
})
Expect(err).NotTo(HaveOccurred())
Eventually(sess).Should(gexec.Exit(0))
Eventually(sess, n.EventuallyTimeout).Should(gexec.Exit(0))
}
}
......@@ -640,7 +642,7 @@ func (n *Network) CreateChannel(name string, o *Orderer, p *Peer) {
OutputBlock: "/dev/null",
})
Expect(err).NotTo(HaveOccurred())
Eventually(sess).Should(gexec.Exit(0))
Eventually(sess, n.EventuallyTimeout).Should(gexec.Exit(0))
}
// JoinChannel will join peers to the specified channel. The orderer is used to
......@@ -664,14 +666,14 @@ func (n *Network) JoinChannel(name string, o *Orderer, peers ...*Peer) {
OutputFile: tempFile.Name(),
})
Expect(err).NotTo(HaveOccurred())
Eventually(sess).Should(gexec.Exit(0))
Eventually(sess, n.EventuallyTimeout).Should(gexec.Exit(0))
for _, p := range peers {
sess, err := n.PeerAdminSession(p, commands.ChannelJoin{
BlockPath: tempFile.Name(),
})
Expect(err).NotTo(HaveOccurred())
Eventually(sess).Should(gexec.Exit(0))
Eventually(sess, n.EventuallyTimeout).Should(gexec.Exit(0))
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment