Skip to content

Commit 946056c

Browse files
Jason Yellicksykesm
authored andcommitted
FAB-16544 IT for orderer endpoint overrides
Adds a simple IT to verify the functionality of the orderer endpoint overrides. The IT is a standalone in the e2e, deploying one Raft orderer and one channel, with one peer in that channel. The test verifies that despite the orderer address in the config pointing to an unreachable location on the network, the overrides allow the peer to still receive an updated config block. Signed-off-by: Jason Yellick <jyellick@us.ibm.com> Change-Id: Ic9380813a93d28d15e307605d4d1813c0db02537
1 parent 5758c93 commit 946056c

File tree

5 files changed

+212
-1
lines changed

5 files changed

+212
-1
lines changed

integration/e2e/e2e_test.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"github.com/hyperledger/fabric-protos-go/orderer/etcdraft"
2727
"github.com/hyperledger/fabric/integration/nwo"
2828
"github.com/hyperledger/fabric/integration/nwo/commands"
29+
"github.com/hyperledger/fabric/integration/nwo/fabricconfig"
2930
. "github.com/onsi/ginkgo"
3031
. "github.com/onsi/gomega"
3132
"github.com/onsi/gomega/gbytes"
@@ -270,6 +271,46 @@ var _ = Describe("EndToEnd", func() {
270271

271272
})
272273
})
274+
275+
Describe("single node etcdraft network with remapped orderer endpoints", func() {
276+
BeforeEach(func() {
277+
network = nwo.New(nwo.MinimalRaft(), testDir, client, StartPort(), components)
278+
network.GenerateConfigTree()
279+
280+
configtxConfig := network.ReadConfigTxConfig()
281+
ordererEndpoints := configtxConfig.Profiles["SampleDevModeEtcdRaft"].Orderer.Organizations[0].OrdererEndpoints
282+
correctOrdererEndpoint := ordererEndpoints[0]
283+
ordererEndpoints[0] = "127.0.0.1:1"
284+
network.WriteConfigTxConfig(configtxConfig)
285+
286+
peer := network.Peer("Org1", "peer0")
287+
peerConfig := network.ReadPeerConfig(peer)
288+
peerConfig.Peer.Deliveryclient.AddressOverrides = []*fabricconfig.AddressOverride{
289+
{
290+
From: "127.0.0.1:1",
291+
To: correctOrdererEndpoint,
292+
CACertsFile: network.CACertsBundlePath(),
293+
},
294+
}
295+
network.WritePeerConfig(peer, peerConfig)
296+
297+
network.Bootstrap()
298+
299+
networkRunner := network.NetworkGroupRunner()
300+
process = ifrit.Invoke(networkRunner)
301+
Eventually(process.Ready(), network.EventuallyTimeout).Should(BeClosed())
302+
})
303+
304+
It("creates and updates channel", func() {
305+
orderer := network.Orderer("orderer")
306+
307+
network.CreateAndJoinChannel(orderer, "testchannel")
308+
309+
// The below call waits for the config update to commit on the peer, so
310+
// it will fail if the orderer addresses are wrong.
311+
nwo.EnableCapabilities(network, "testchannel", "Application", "V2_0", orderer, network.Peer("Org1", "peer0"), network.Peer("Org2", "peer0"))
312+
})
313+
})
273314
})
274315

275316
func RunQueryInvokeQuery(n *nwo.Network, orderer *nwo.Orderer, peer *nwo.Peer, channel string) {
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
/*
2+
Copyright IBM Corp. All Rights Reserved.
3+
4+
SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
package fabricconfig
8+
9+
import "time"
10+
11+
type ConfigTx struct {
12+
Organizations []*Organization `yaml:"Organizations,omitempty"`
13+
Capabilities *Capabilities `yaml:"Capabilities,omitempty"`
14+
Application *Application `yaml:"Application,omitempty"`
15+
Orderer *ConfigTxOrderer `yaml:"Orderer,omitempty"`
16+
Channel *Channel `yaml:"Channel,omitempty"`
17+
Profiles map[string]*Channel `yaml:"Profiles,omitempty"`
18+
19+
ExtraProperties map[string]interface{} `yaml:",inline,omitempty"`
20+
}
21+
22+
type Organization struct {
23+
Name string `yaml:"Name,omitempty"`
24+
SkipAsForeign bool `yaml:"SkipAsForeign,omitempty"`
25+
ID string `yaml:"ID,omitempty"`
26+
MSPDir string `yaml:"MSPDir,omitempty"`
27+
Policies map[string]*Policy `yaml:"Policies,omitempty"`
28+
OrdererEndpoints []string `yaml:"OrdererEndpoints,omitempty"`
29+
AnchorPeers []*AnchorPeer `yaml:"AnchorPeers,omitempty"`
30+
31+
ExtraProperties map[string]interface{} `yaml:",inline,omitempty"`
32+
}
33+
34+
type Policy struct {
35+
Type string `yaml:"Type,omitempty"`
36+
Rule string `yaml:"Rule,omitempty"`
37+
38+
ExtraProperties map[string]interface{} `yaml:",inline,omitempty"`
39+
}
40+
41+
type Capabilities struct {
42+
Channel map[string]bool `yaml:"Channel,omitempty"`
43+
Orderer map[string]bool `yaml:"Orderer,omitempty"`
44+
Application map[string]bool `yaml:"Application,omitempty"`
45+
46+
ExtraProperties map[string]interface{} `yaml:",inline,omitempty"`
47+
}
48+
49+
type AnchorPeer struct {
50+
Host string `yaml:"Host,omitempty"`
51+
Port int `yaml:"Port,omitempty"`
52+
53+
ExtraProperties map[string]interface{} `yaml:",inline,omitempty"`
54+
}
55+
56+
type Application struct {
57+
ACLs map[string]string `yaml:"ACLs,omitempty"`
58+
Organizations []*Organization `yaml:"Organizations,omitempty"`
59+
Policies map[string]*Policy `yaml:"Policies,omitempty"`
60+
Capabilities map[string]bool `yaml:"Capabilities,omitempty"`
61+
62+
ExtraProperties map[string]interface{} `yaml:",inline,omitempty"`
63+
}
64+
65+
type ConfigTxOrderer struct {
66+
OrdererType string `yaml:"OrdererType,omitempty"`
67+
BatchTimeout time.Duration `yaml:"BatchTimeout,omitempty"`
68+
BatchSize *BatchSize `yaml:"BatchSize,omitempty"`
69+
Kafka *ConfigTxKafka `yaml:"Kafka,omitempty"`
70+
EtcdRaft *ConfigTxEtcdRaft `yaml:"EtcdRaft,omitempty"`
71+
Organizations []*Organization `yaml:"Organizations,omitempty"`
72+
Policies map[string]*Policy `yaml:"Policies,omitempty"`
73+
Capabilities map[string]bool `yaml:"Capabilities,omitempty"`
74+
75+
ExtraProperties map[string]interface{} `yaml:",inline,omitempty"`
76+
}
77+
78+
type BatchSize struct {
79+
MaxMessageCount string `yaml:"MaxMessageCount,omitempty"`
80+
AbsoluteMaxBytes string `yaml:"AbsoluteMaxBytes,omitempty"`
81+
PreferredMaxBytes string `yaml:"PreferredMaxBytes,omitempty"`
82+
83+
ExtraProperties map[string]interface{} `yaml:",inline,omitempty"`
84+
}
85+
86+
type ConfigTxKafka struct {
87+
Brokers []string `yaml:"Brokers,omitempty"`
88+
89+
ExtraProperties map[string]interface{} `yaml:",inline,omitempty"`
90+
}
91+
92+
type ConfigTxEtcdRaft struct {
93+
Consenters []*Consenter `yaml:"Consenters,omitempty"`
94+
Options *EtcdRaftOptions `yaml:"EtcdRaftOptions,omitempty"`
95+
96+
ExtraProperties map[string]interface{} `yaml:",inline,omitempty"`
97+
}
98+
99+
type Consenter struct {
100+
Host string `yaml:"Host,omitempty"`
101+
Port int `yaml:"Port,omitempty"`
102+
ClientTLSCert string `yaml:"ClientTLSCert,omitempty"`
103+
ServerTLSCert string `yaml:"ServerTLSCert,omitempty"`
104+
105+
ExtraProperties map[string]interface{} `yaml:",inline,omitempty"`
106+
}
107+
108+
type EtcdRaftOptions struct {
109+
TickInterval string `yaml:"TickInterval,omitempty"`
110+
ElectionTick string `yaml:"ElectionTick,omitempty"`
111+
HeartbeatTick string `yaml:"HeartbeatTick,omitempty"`
112+
MaxInflightBlocks string `yaml:"MaxInflightBlocks,omitempty"`
113+
SnapshotIntervalSize string `yaml:"SnapshotIntervalSize,omitempty"`
114+
115+
ExtraProperties map[string]interface{} `yaml:",inline,omitempty"`
116+
}
117+
118+
type Channel struct {
119+
Orderer *ConfigTxOrderer `yaml:"Orderer,omitempty"`
120+
Application *Application `yaml:"Application,omitempty"`
121+
Policies map[string]*Policy `yaml:"Policies,omitempty"`
122+
Capabilities map[string]bool `yaml:"Capabilities,omitempty"`
123+
Consortiums map[string]*Consortium `yaml:"Consortiums,omitempty"`
124+
125+
ExtraProperties map[string]interface{} `yaml:",inline,omitempty"`
126+
}
127+
128+
type Consortium struct {
129+
Organizations []*Organization `yaml:"Organizations,omitempty"`
130+
131+
ExtraProperties map[string]interface{} `yaml:",inline,omitempty"`
132+
}

integration/nwo/fabricconfig/core.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,14 @@ type SoftwareProvider struct {
168168
}
169169

170170
type DeliveryClient struct {
171-
ReconnectTotalTimeThreshold time.Duration `yaml:"reconnectTotalTimeThreshold,omitempty"`
171+
ReconnectTotalTimeThreshold time.Duration `yaml:"reconnectTotalTimeThreshold,omitempty"`
172+
AddressOverrides []*AddressOverride `yaml:"addressOverrides,omitempty"`
173+
}
174+
175+
type AddressOverride struct {
176+
From string `yaml:"from"`
177+
To string `yaml:"to"`
178+
CACertsFile string `yaml:"caCertsFile"`
172179
}
173180

174181
type Service struct {

integration/nwo/network.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,28 @@ func (n *Network) WriteOrdererConfig(o *Orderer, config *fabricconfig.Orderer) {
305305
Expect(err).NotTo(HaveOccurred())
306306
}
307307

308+
// ReadConfigTxConfig unmarshals the configtx.yaml and returns an
309+
// object approximating its contents.
310+
func (n *Network) ReadConfigTxConfig() *fabricconfig.ConfigTx {
311+
var configtx fabricconfig.ConfigTx
312+
configtxBytes, err := ioutil.ReadFile(n.ConfigTxConfigPath())
313+
Expect(err).NotTo(HaveOccurred())
314+
315+
err = yaml.Unmarshal(configtxBytes, &configtx)
316+
Expect(err).NotTo(HaveOccurred())
317+
318+
return &configtx
319+
}
320+
321+
// WriteConfigTxConfig serializes the provided configuration to configtx.yaml.
322+
func (n *Network) WriteConfigTxConfig(config *fabricconfig.ConfigTx) {
323+
configtxBytes, err := yaml.Marshal(config)
324+
Expect(err).NotTo(HaveOccurred())
325+
326+
err = ioutil.WriteFile(n.ConfigTxConfigPath(), configtxBytes, 0644)
327+
Expect(err).NotTo(HaveOccurred())
328+
}
329+
308330
// PeerDir returns the path to the configuration directory for the specified
309331
// Peer.
310332
func (n *Network) PeerDir(p *Peer) string {

integration/nwo/standard_networks.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,15 @@ func BasicEtcdRaft() *Config {
146146
return config
147147
}
148148

149+
func MinimalRaft() *Config {
150+
config := BasicEtcdRaft()
151+
config.Peers[1].Channels = nil
152+
config.Peers[2].Channels = nil
153+
config.Peers[3].Channels = nil
154+
config.Profiles[1].Organizations = []string{"Org1"}
155+
return config
156+
}
157+
149158
func MultiChannelEtcdRaft() *Config {
150159
config := MultiChannelBasicSolo()
151160

0 commit comments

Comments
 (0)