Skip to content

Commit

Permalink
FAB-16544 Fix IT UpdateChannel to match doc
Browse files Browse the repository at this point in the history
The documentation in UpdateChannel function says that it waits for the
config to commit at all of the peers, but this isn't actually the case.
Instead, it waits for the config to commit at the orderer it's already
committed at.  This change already existed in master, but was apparently
not backported to release-1.4.

Signed-off-by: Jason Yellick <jyellick@us.ibm.com>
Change-Id: I83a9f78bba37181b45dd5b3ed4e9af23f3556661
  • Loading branch information
Jason Yellick committed Nov 6, 2019
1 parent 1ac3f05 commit 63e1563
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion integration/discovery/discovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ var _ = Describe("DiscoveryService", func() {
currentConfig := nwo.GetConfig(network, network.Peer("org3", "peer0"), orderer, "testchannel")
updatedConfig := proto.Clone(currentConfig).(*common.Config)
updatedConfig.ChannelGroup.Groups["Application"].Groups["org3"].Policies["Writers"].Policy.Value = utils.MarshalOrPanic(cauthdsl.SignedByMspAdmin("Org3MSP"))
nwo.UpdateConfig(network, orderer, "testchannel", currentConfig, updatedConfig, network.Peer("org3", "peer0"))
nwo.UpdateConfig(network, orderer, "testchannel", currentConfig, updatedConfig, true, network.Peer("org3", "peer0"))

By("trying to discover peers as an org 3 member")
endorsers = commands.Endorsers{
Expand Down
2 changes: 1 addition & 1 deletion integration/e2e/acl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ func SetACLPolicy(network *nwo.Network, channel, policyName, policy string, orde
}),
}

nwo.UpdateConfig(network, orderer, channel, config, updatedConfig, submitter, signer)
nwo.UpdateConfig(network, orderer, channel, config, updatedConfig, true, submitter, signer)
}

// GetTxIDFromBlock gets a transaction id from a block that has been
Expand Down
17 changes: 14 additions & 3 deletions integration/nwo/configblock.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func GetConfig(n *Network, peer *Peer, orderer *Orderer, channel string) *common

// UpdateConfig computes, signs, and submits a configuration update and waits
// for the update to complete.
func UpdateConfig(n *Network, orderer *Orderer, channel string, current, updated *common.Config, submitter *Peer, additionalSigners ...*Peer) {
func UpdateConfig(n *Network, orderer *Orderer, channel string, current, updated *common.Config, getConfigBlockFromOrderer bool, submitter *Peer, additionalSigners ...*Peer) {
tempDir, err := ioutil.TempDir("", "updateConfig")
Expect(err).NotTo(HaveOccurred())
defer os.RemoveAll(tempDir)
Expand Down Expand Up @@ -103,8 +103,13 @@ func UpdateConfig(n *Network, orderer *Orderer, channel string, current, updated
Eventually(sess, n.EventuallyTimeout).Should(gexec.Exit(0))
}

var currentBlockNumber uint64
// get current configuration block number
currentBlockNumber := CurrentConfigBlockNumber(n, submitter, orderer, channel)
if getConfigBlockFromOrderer {
currentBlockNumber = CurrentConfigBlockNumber(n, submitter, orderer, channel)
} else {
currentBlockNumber = CurrentConfigBlockNumber(n, submitter, nil, channel)
}

sess, err := n.PeerAdminSession(submitter, commands.ChannelUpdate{
ChannelID: channel,
Expand All @@ -115,10 +120,16 @@ func UpdateConfig(n *Network, orderer *Orderer, channel string, current, updated
Eventually(sess, n.EventuallyTimeout).Should(gexec.Exit(0))
Expect(sess.Err).To(gbytes.Say("Successfully submitted channel update"))

if getConfigBlockFromOrderer {
ccb := func() uint64 { return CurrentConfigBlockNumber(n, submitter, orderer, channel) }
Eventually(ccb, n.EventuallyTimeout).Should(BeNumerically(">", currentBlockNumber))
return
}

// wait for the block to be committed to all peers that
// have joined the channel
for _, peer := range n.PeersWithChannel(channel) {
ccb := func() uint64 { return CurrentConfigBlockNumber(n, peer, orderer, channel) }
ccb := func() uint64 { return CurrentConfigBlockNumber(n, peer, nil, channel) }
Eventually(ccb, n.EventuallyTimeout).Should(BeNumerically(">", currentBlockNumber))
}
}
Expand Down
2 changes: 1 addition & 1 deletion integration/nwo/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func EnableCapabilities(network *Network, channel, capabilitiesGroup, capabiliti
),
}

UpdateConfig(network, orderer, channel, config, updatedConfig, peers[0], peers...)
UpdateConfig(network, orderer, channel, config, updatedConfig, false, peers[0], peers...)
}

// EnableCapabilitiesOrdererAdmin enables a specific capabilities flag for a running network,
Expand Down

0 comments on commit 63e1563

Please sign in to comment.