Skip to content

Commit 833d1dc

Browse files
committed
added to OSN new handler for update config of channel
Signed-off-by: Fedor Partanskiy <fredprtnsk@gmail.com>
1 parent 4724e76 commit 833d1dc

File tree

3 files changed

+25
-34
lines changed

3 files changed

+25
-34
lines changed

integration/nwo/configblock.go

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ SPDX-License-Identifier: Apache-2.0
77
package nwo
88

99
import (
10+
"net/http"
1011
"os"
1112
"path/filepath"
1213

@@ -155,16 +156,6 @@ func UpdateConfig(n *Network, orderer *Orderer, channel string, current, updated
155156
}()
156157
Eventually(ready, n.EventuallyTimeout).Should(BeClosed())
157158

158-
// sess, err := n.PeerAdminSession(submitter, commands.ChannelUpdate{
159-
// ChannelID: channel,
160-
// Orderer: n.OrdererAddress(orderer, ListenPort),
161-
// File: updateFile,
162-
// ClientAuth: n.ClientAuthRequired,
163-
// })
164-
// Expect(err).NotTo(HaveOccurred())
165-
// Eventually(sess, n.EventuallyTimeout).Should(gexec.Exit(0))
166-
// Expect(sess.Err).To(gbytes.Say("Successfully submitted channel update"))
167-
168159
if getConfigBlockFromOrderer {
169160
ccb := func() uint64 { return CurrentConfigBlockNumber(n, submitter, orderer, channel) }
170161
Eventually(ccb, n.EventuallyTimeout).Should(BeNumerically(">", currentBlockNumber))
@@ -250,25 +241,37 @@ func UpdateOrdererConfig(n *Network, orderer *Orderer, channel string, current,
250241
Eventually(ccb, n.EventuallyTimeout).Should(BeNumerically(">", currentBlockNumber))
251242
}
252243

253-
// UpdateOrdererConfigSession computes, signs, and submits a configuration
244+
// UpdateOrdererConfigFails computes, signs, and submits a configuration
254245
// update which requires orderer signatures. The caller should wait on the
255246
// returned seession retrieve the exit code.
256-
func UpdateOrdererConfigSession(n *Network, orderer *Orderer, channel string, current, updated *common.Config, submitter *Peer, additionalSigners ...*Orderer) *gexec.Session {
247+
func UpdateOrdererConfigFails(n *Network, orderer *Orderer, channel string, current, updated *common.Config, errStr string, submitter *Peer, additionalSigners ...*Orderer) {
257248
tempDir, err := os.MkdirTemp(n.RootDir, "updateConfig")
258249
Expect(err).NotTo(HaveOccurred())
259250
updateFile := filepath.Join(tempDir, "update.pb")
260251

261252
ComputeUpdateOrdererConfig(updateFile, n, channel, current, updated, submitter, additionalSigners...)
262253

263-
// session should not return with a zero exit code nor with a success response
264-
sess, err := n.OrdererAdminSession(orderer, submitter, commands.ChannelUpdate{
265-
ChannelID: channel,
266-
Orderer: n.OrdererAddress(orderer, ListenPort),
254+
sess, err := n.OrdererAdminSession(orderer, submitter, commands.SignConfigTx{
267255
File: updateFile,
268256
ClientAuth: n.ClientAuthRequired,
269257
})
270258
Expect(err).NotTo(HaveOccurred())
271-
return sess
259+
Eventually(sess, n.EventuallyTimeout).Should(gexec.Exit(0))
260+
261+
updateEnvelopeBytes, err := os.ReadFile(updateFile)
262+
Expect(err).NotTo(HaveOccurred())
263+
264+
updateEnvelope := &common.Envelope{}
265+
err = proto.Unmarshal(updateEnvelopeBytes, updateEnvelope)
266+
Expect(err).NotTo(HaveOccurred())
267+
268+
ready := make(chan struct{})
269+
go func() {
270+
defer GinkgoRecover()
271+
UpdateWithStatus(n, orderer, channel, updateEnvelope, http.StatusBadRequest, errStr)
272+
close(ready)
273+
}()
274+
Eventually(ready, n.EventuallyTimeout).Should(BeClosed())
272275
}
273276

274277
func ComputeUpdateOrdererConfig(updateFile string, n *Network, channel string, current, updated *common.Config, submitter *Peer, additionalSigners ...*Orderer) {

integration/raft/config_test.go

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,7 @@ var _ = Describe("EndToEnd reconfiguration and onboarding", func() {
242242
Value: protoutil.MarshalOrPanic(consensusTypeValue),
243243
}
244244

245-
sess := nwo.UpdateOrdererConfigSession(network, orderer, "testchannel", config, updatedConfig, org1Peer0, orderer)
246-
Eventually(sess, network.EventuallyTimeout).Should(gexec.Exit(1))
247-
Expect(sess.Err).To(gbytes.Say(`invalid new config metadata: ElectionTick \(10\) must be greater than HeartbeatTick \(10\)`))
245+
nwo.UpdateOrdererConfigFails(network, orderer, "testchannel", config, updatedConfig, "invalid new config metadata: ElectionTick (10) must be greater than HeartbeatTick (10)", org1Peer0, orderer)
248246
})
249247
})
250248

@@ -455,9 +453,7 @@ var _ = Describe("EndToEnd reconfiguration and onboarding", func() {
455453
Port: newConsenterPort,
456454
},
457455
)
458-
sess = nwo.UpdateOrdererConfigSession(network, orderer, "testchannel", current, updated, peer, orderer)
459-
Eventually(sess, network.EventuallyTimeout).Should(gexec.Exit(1))
460-
Expect(sess.Err).To(gbytes.Say(fmt.Sprintf("BAD_REQUEST -- error applying config update to existing channel 'testchannel': consensus metadata update for channel config update is invalid: invalid new config metadata: consenter %s:%d has invalid certificate: verifying tls client cert with serial number %d: x509: certificate signed by unknown authority", newConsenterHost, newConsenterPort, newConsenterCert.SerialNumber)))
456+
nwo.UpdateOrdererConfigFails(network, orderer, "testchannel", current, updated, fmt.Sprintf("error applying config update to existing channel 'testchannel': consensus metadata update for channel config update is invalid: invalid new config metadata: consenter %s:%d has invalid certificate: verifying tls client cert with serial number %d: x509: certificate signed by unknown authority", newConsenterHost, newConsenterPort, newConsenterCert.SerialNumber), peer, orderer)
461457
})
462458
})
463459

@@ -1092,11 +1088,7 @@ var _ = Describe("EndToEnd reconfiguration and onboarding", func() {
10921088
By("Removing alive node from 2/3 cluster")
10931089
peer := network.Peer("Org1", "peer0")
10941090
current, updated := consenterRemover(network, peer, o2, "testchannel", certificatesOfOrderers[1].oldCert)
1095-
Eventually(func() []byte {
1096-
sess := nwo.UpdateOrdererConfigSession(network, o2, "testchannel", current, updated, peer, o2)
1097-
Eventually(sess, network.EventuallyTimeout).Should(gexec.Exit(1))
1098-
return sess.Err.Contents()
1099-
}, network.EventuallyTimeout).Should(ContainSubstring("2 out of 3 nodes are alive, configuration will result in quorum loss"))
1091+
nwo.UpdateOrdererConfigFails(network, o2, "testchannel", current, updated, "2 out of 3 nodes are alive, configuration will result in quorum loss", peer, o2)
11001092

11011093
By("Adding node to 2/3 cluster")
11021094
current, updated = consenterAdder(
@@ -1111,9 +1103,7 @@ var _ = Describe("EndToEnd reconfiguration and onboarding", func() {
11111103
Port: uint32(network.OrdererPort(o1, nwo.ListenPort)),
11121104
},
11131105
)
1114-
sess := nwo.UpdateOrdererConfigSession(network, o2, "testchannel", current, updated, peer, o2)
1115-
Eventually(sess, network.EventuallyTimeout).Should(gexec.Exit(1))
1116-
Expect(string(sess.Err.Contents())).To(ContainSubstring("2 out of 3 nodes are alive, configuration will result in quorum loss"))
1106+
nwo.UpdateOrdererConfigFails(network, o2, "testchannel", current, updated, "2 out of 3 nodes are alive, configuration will result in quorum loss", peer, o2)
11171107
})
11181108
})
11191109

integration/raft/migration_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -622,9 +622,7 @@ func checkPeerDeliverRequest(o *nwo.Orderer, submitter *nwo.Peer, network *nwo.N
622622
}
623623

624624
func updateOrdererConfigFailed(n *nwo.Network, orderer *nwo.Orderer, channel string, current, updated *common.Config, peer *nwo.Peer, additionalSigners ...*nwo.Orderer) {
625-
sess := nwo.UpdateOrdererConfigSession(n, orderer, channel, current, updated, peer, additionalSigners...)
626-
Eventually(sess, n.EventuallyTimeout).Should(gexec.Exit(1))
627-
Expect(sess.Err).NotTo(gbytes.Say("Successfully submitted channel update"))
625+
nwo.UpdateOrdererConfigFails(n, orderer, channel, current, updated, "", peer, additionalSigners...)
628626
}
629627

630628
func updateOrdererEndpointsConfigFails(n *nwo.Network, orderer *nwo.Orderer, channel string, current, updated *common.Config, peer *nwo.Peer, additionalSigners ...*nwo.Peer) {

0 commit comments

Comments
 (0)