Skip to content

Commit 4771a05

Browse files
sykesmmastersingh24
authored andcommitted
UpdateOrdererConfigSession returns without waiting
For consistency with the rest of the *Session functions in the nwo package, UpdateOrdererConfigSession will return the created command session without waiting for it to complete. To prevent the serialized block from getting deleted, the network root directory was used as the parent of the temp directory for the update block and the defer statement to remove the temp dir was removed from the function. Change-Id: I635aac0a0dc1d81df99f0b7a4e27e5a2e250a329 Signed-off-by: Matthew Sykes <sykesmat@us.ibm.com>
1 parent d21e105 commit 4771a05

File tree

3 files changed

+11
-13
lines changed

3 files changed

+11
-13
lines changed

integration/nwo/configblock.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727

2828
// GetConfigBlock retrieves the current config block for a channel
2929
func GetConfigBlock(n *Network, peer *Peer, orderer *Orderer, channel string) *common.Block {
30-
tempDir, err := ioutil.TempDir("", "getConfigBlock")
30+
tempDir, err := ioutil.TempDir(n.RootDir, "getConfigBlock")
3131
Expect(err).NotTo(HaveOccurred())
3232
defer os.RemoveAll(tempDir)
3333

@@ -141,7 +141,7 @@ func UpdateConfig(n *Network, orderer *Orderer, channel string, current, updated
141141
// has completed. If an orderer is not provided, the current config block will
142142
// be fetched from the peer.
143143
func CurrentConfigBlockNumber(n *Network, peer *Peer, orderer *Orderer, channel string) uint64 {
144-
tempDir, err := ioutil.TempDir("", "currentConfigBlock")
144+
tempDir, err := ioutil.TempDir(n.RootDir, "currentConfigBlock")
145145
Expect(err).NotTo(HaveOccurred())
146146
defer os.RemoveAll(tempDir)
147147

@@ -200,7 +200,7 @@ func FetchConfigBlock(n *Network, peer *Peer, orderer *Orderer, channel string,
200200
// UpdateOrdererConfig computes, signs, and submits a configuration update which requires orderers signature and waits
201201
// for the update to complete.
202202
func UpdateOrdererConfig(n *Network, orderer *Orderer, channel string, current, updated *common.Config, submitter *Peer, additionalSigners ...*Orderer) {
203-
tempDir, err := ioutil.TempDir("", "updateConfig")
203+
tempDir, err := ioutil.TempDir(n.RootDir, "updateConfig")
204204
Expect(err).NotTo(HaveOccurred())
205205
updateFile := filepath.Join(tempDir, "update.pb")
206206
defer os.RemoveAll(tempDir)
@@ -230,14 +230,13 @@ func UpdateOrdererConfig(n *Network, orderer *Orderer, channel string, current,
230230
Eventually(ccb, n.EventuallyTimeout).Should(BeNumerically(">", currentBlockNumber))
231231
}
232232

233-
// UpdateOrdererConfigSession computes, signs, and submits a configuration update which requires orderers signature
234-
// and waits for the update to complete. The command session is returned to the caller to enable ExitCode and command
235-
// output assertions.
233+
// UpdateOrdererConfigSession computes, signs, and submits a configuration
234+
// update which requires orderer signatures. The caller should wait on the
235+
// returned seession retrieve the exit code.
236236
func UpdateOrdererConfigSession(n *Network, orderer *Orderer, channel string, current, updated *common.Config, submitter *Peer, additionalSigners ...*Orderer) *gexec.Session {
237-
tempDir, err := ioutil.TempDir("", "updateConfig")
237+
tempDir, err := ioutil.TempDir(n.RootDir, "updateConfig")
238238
Expect(err).NotTo(HaveOccurred())
239239
updateFile := filepath.Join(tempDir, "update.pb")
240-
defer os.RemoveAll(tempDir)
241240

242241
ComputeUpdateOrdererConfig(updateFile, n, channel, current, updated, submitter, additionalSigners...)
243242

@@ -249,7 +248,6 @@ func UpdateOrdererConfigSession(n *Network, orderer *Orderer, channel string, cu
249248
ClientAuth: n.ClientAuthRequired,
250249
})
251250
Expect(err).NotTo(HaveOccurred())
252-
Eventually(sess, n.EventuallyTimeout).Should(gexec.Exit())
253251
return sess
254252
}
255253

integration/raft/config_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ var _ = Describe("EndToEnd reconfiguration and onboarding", func() {
231231
}
232232

233233
sess := nwo.UpdateOrdererConfigSession(network, orderer, channel, config, updatedConfig, peer1org1, orderer)
234-
Expect(sess.ExitCode()).NotTo(Equal(0))
234+
Eventually(sess, network.EventuallyTimeout).Should(gexec.Exit(1))
235235
Expect(sess.Err).To(gbytes.Say(`invalid new config metdadata: ElectionTick \(10\) must be greater than HeartbeatTick \(10\)`))
236236
})
237237
})
@@ -819,7 +819,7 @@ var _ = Describe("EndToEnd reconfiguration and onboarding", func() {
819819
current, updated := nwo.ConsenterRemover(network, peer, o2, network.SystemChannel.Name, certificatesOfOrderers[1].oldCert)
820820
Eventually(func() []byte {
821821
sess := nwo.UpdateOrdererConfigSession(network, o2, network.SystemChannel.Name, current, updated, peer, o2)
822-
Expect(sess.ExitCode()).NotTo(BeZero())
822+
Eventually(sess, network.EventuallyTimeout).Should(gexec.Exit(1))
823823
return sess.Err.Contents()
824824
}, network.EventuallyTimeout).Should(ContainSubstring("2 out of 3 nodes are alive, configuration will result in quorum loss"))
825825

@@ -837,7 +837,7 @@ var _ = Describe("EndToEnd reconfiguration and onboarding", func() {
837837
},
838838
)
839839
sess := nwo.UpdateOrdererConfigSession(network, o2, network.SystemChannel.Name, current, updated, peer, o2)
840-
Expect(sess.ExitCode()).NotTo(BeZero())
840+
Eventually(sess, network.EventuallyTimeout).Should(gexec.Exit(1))
841841
Expect(string(sess.Err.Contents())).To(ContainSubstring("2 out of 3 nodes are alive, configuration will result in quorum loss"))
842842
})
843843
})

integration/raft/migration_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1106,7 +1106,7 @@ func checkPeerDeliverRequest(o *nwo.Orderer, submitter *nwo.Peer, network *nwo.N
11061106

11071107
func updateOrdererConfigFailed(n *nwo.Network, orderer *nwo.Orderer, channel string, current, updated *common.Config, peer *nwo.Peer, additionalSigners ...*nwo.Orderer) {
11081108
sess := nwo.UpdateOrdererConfigSession(n, orderer, channel, current, updated, peer, additionalSigners...)
1109-
Expect(sess.ExitCode()).NotTo(Equal(0))
1109+
Eventually(sess, n.EventuallyTimeout).Should(gexec.Exit(1))
11101110
Expect(sess.Err).NotTo(gbytes.Say("Successfully submitted channel update"))
11111111
}
11121112

0 commit comments

Comments
 (0)