Skip to content

Commit

Permalink
FAB-16544 IT for orderer endpoint overrides
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Jason Yellick authored and sykesm committed Nov 11, 2019
1 parent 5758c93 commit 946056c
Show file tree
Hide file tree
Showing 5 changed files with 212 additions and 1 deletion.
41 changes: 41 additions & 0 deletions integration/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/hyperledger/fabric-protos-go/orderer/etcdraft"
"github.com/hyperledger/fabric/integration/nwo"
"github.com/hyperledger/fabric/integration/nwo/commands"
"github.com/hyperledger/fabric/integration/nwo/fabricconfig"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gbytes"
Expand Down Expand Up @@ -270,6 +271,46 @@ var _ = Describe("EndToEnd", func() {

})
})

Describe("single node etcdraft network with remapped orderer endpoints", func() {
BeforeEach(func() {
network = nwo.New(nwo.MinimalRaft(), testDir, client, StartPort(), components)
network.GenerateConfigTree()

configtxConfig := network.ReadConfigTxConfig()
ordererEndpoints := configtxConfig.Profiles["SampleDevModeEtcdRaft"].Orderer.Organizations[0].OrdererEndpoints
correctOrdererEndpoint := ordererEndpoints[0]
ordererEndpoints[0] = "127.0.0.1:1"
network.WriteConfigTxConfig(configtxConfig)

peer := network.Peer("Org1", "peer0")
peerConfig := network.ReadPeerConfig(peer)
peerConfig.Peer.Deliveryclient.AddressOverrides = []*fabricconfig.AddressOverride{
{
From: "127.0.0.1:1",
To: correctOrdererEndpoint,
CACertsFile: network.CACertsBundlePath(),
},
}
network.WritePeerConfig(peer, peerConfig)

network.Bootstrap()

networkRunner := network.NetworkGroupRunner()
process = ifrit.Invoke(networkRunner)
Eventually(process.Ready(), network.EventuallyTimeout).Should(BeClosed())
})

It("creates and updates channel", func() {
orderer := network.Orderer("orderer")

network.CreateAndJoinChannel(orderer, "testchannel")

// The below call waits for the config update to commit on the peer, so
// it will fail if the orderer addresses are wrong.
nwo.EnableCapabilities(network, "testchannel", "Application", "V2_0", orderer, network.Peer("Org1", "peer0"), network.Peer("Org2", "peer0"))
})
})
})

func RunQueryInvokeQuery(n *nwo.Network, orderer *nwo.Orderer, peer *nwo.Peer, channel string) {
Expand Down
132 changes: 132 additions & 0 deletions integration/nwo/fabricconfig/configtx.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package fabricconfig

import "time"

type ConfigTx struct {
Organizations []*Organization `yaml:"Organizations,omitempty"`
Capabilities *Capabilities `yaml:"Capabilities,omitempty"`
Application *Application `yaml:"Application,omitempty"`
Orderer *ConfigTxOrderer `yaml:"Orderer,omitempty"`
Channel *Channel `yaml:"Channel,omitempty"`
Profiles map[string]*Channel `yaml:"Profiles,omitempty"`

ExtraProperties map[string]interface{} `yaml:",inline,omitempty"`
}

type Organization struct {
Name string `yaml:"Name,omitempty"`
SkipAsForeign bool `yaml:"SkipAsForeign,omitempty"`
ID string `yaml:"ID,omitempty"`
MSPDir string `yaml:"MSPDir,omitempty"`
Policies map[string]*Policy `yaml:"Policies,omitempty"`
OrdererEndpoints []string `yaml:"OrdererEndpoints,omitempty"`
AnchorPeers []*AnchorPeer `yaml:"AnchorPeers,omitempty"`

ExtraProperties map[string]interface{} `yaml:",inline,omitempty"`
}

type Policy struct {
Type string `yaml:"Type,omitempty"`
Rule string `yaml:"Rule,omitempty"`

ExtraProperties map[string]interface{} `yaml:",inline,omitempty"`
}

type Capabilities struct {
Channel map[string]bool `yaml:"Channel,omitempty"`
Orderer map[string]bool `yaml:"Orderer,omitempty"`
Application map[string]bool `yaml:"Application,omitempty"`

ExtraProperties map[string]interface{} `yaml:",inline,omitempty"`
}

type AnchorPeer struct {
Host string `yaml:"Host,omitempty"`
Port int `yaml:"Port,omitempty"`

ExtraProperties map[string]interface{} `yaml:",inline,omitempty"`
}

type Application struct {
ACLs map[string]string `yaml:"ACLs,omitempty"`
Organizations []*Organization `yaml:"Organizations,omitempty"`
Policies map[string]*Policy `yaml:"Policies,omitempty"`
Capabilities map[string]bool `yaml:"Capabilities,omitempty"`

ExtraProperties map[string]interface{} `yaml:",inline,omitempty"`
}

type ConfigTxOrderer struct {
OrdererType string `yaml:"OrdererType,omitempty"`
BatchTimeout time.Duration `yaml:"BatchTimeout,omitempty"`
BatchSize *BatchSize `yaml:"BatchSize,omitempty"`
Kafka *ConfigTxKafka `yaml:"Kafka,omitempty"`
EtcdRaft *ConfigTxEtcdRaft `yaml:"EtcdRaft,omitempty"`
Organizations []*Organization `yaml:"Organizations,omitempty"`
Policies map[string]*Policy `yaml:"Policies,omitempty"`
Capabilities map[string]bool `yaml:"Capabilities,omitempty"`

ExtraProperties map[string]interface{} `yaml:",inline,omitempty"`
}

type BatchSize struct {
MaxMessageCount string `yaml:"MaxMessageCount,omitempty"`
AbsoluteMaxBytes string `yaml:"AbsoluteMaxBytes,omitempty"`
PreferredMaxBytes string `yaml:"PreferredMaxBytes,omitempty"`

ExtraProperties map[string]interface{} `yaml:",inline,omitempty"`
}

type ConfigTxKafka struct {
Brokers []string `yaml:"Brokers,omitempty"`

ExtraProperties map[string]interface{} `yaml:",inline,omitempty"`
}

type ConfigTxEtcdRaft struct {
Consenters []*Consenter `yaml:"Consenters,omitempty"`
Options *EtcdRaftOptions `yaml:"EtcdRaftOptions,omitempty"`

ExtraProperties map[string]interface{} `yaml:",inline,omitempty"`
}

type Consenter struct {
Host string `yaml:"Host,omitempty"`
Port int `yaml:"Port,omitempty"`
ClientTLSCert string `yaml:"ClientTLSCert,omitempty"`
ServerTLSCert string `yaml:"ServerTLSCert,omitempty"`

ExtraProperties map[string]interface{} `yaml:",inline,omitempty"`
}

type EtcdRaftOptions struct {
TickInterval string `yaml:"TickInterval,omitempty"`
ElectionTick string `yaml:"ElectionTick,omitempty"`
HeartbeatTick string `yaml:"HeartbeatTick,omitempty"`
MaxInflightBlocks string `yaml:"MaxInflightBlocks,omitempty"`
SnapshotIntervalSize string `yaml:"SnapshotIntervalSize,omitempty"`

ExtraProperties map[string]interface{} `yaml:",inline,omitempty"`
}

type Channel struct {
Orderer *ConfigTxOrderer `yaml:"Orderer,omitempty"`
Application *Application `yaml:"Application,omitempty"`
Policies map[string]*Policy `yaml:"Policies,omitempty"`
Capabilities map[string]bool `yaml:"Capabilities,omitempty"`
Consortiums map[string]*Consortium `yaml:"Consortiums,omitempty"`

ExtraProperties map[string]interface{} `yaml:",inline,omitempty"`
}

type Consortium struct {
Organizations []*Organization `yaml:"Organizations,omitempty"`

ExtraProperties map[string]interface{} `yaml:",inline,omitempty"`
}
9 changes: 8 additions & 1 deletion integration/nwo/fabricconfig/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,14 @@ type SoftwareProvider struct {
}

type DeliveryClient struct {
ReconnectTotalTimeThreshold time.Duration `yaml:"reconnectTotalTimeThreshold,omitempty"`
ReconnectTotalTimeThreshold time.Duration `yaml:"reconnectTotalTimeThreshold,omitempty"`
AddressOverrides []*AddressOverride `yaml:"addressOverrides,omitempty"`
}

type AddressOverride struct {
From string `yaml:"from"`
To string `yaml:"to"`
CACertsFile string `yaml:"caCertsFile"`
}

type Service struct {
Expand Down
22 changes: 22 additions & 0 deletions integration/nwo/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,28 @@ func (n *Network) WriteOrdererConfig(o *Orderer, config *fabricconfig.Orderer) {
Expect(err).NotTo(HaveOccurred())
}

// ReadConfigTxConfig unmarshals the configtx.yaml and returns an
// object approximating its contents.
func (n *Network) ReadConfigTxConfig() *fabricconfig.ConfigTx {
var configtx fabricconfig.ConfigTx
configtxBytes, err := ioutil.ReadFile(n.ConfigTxConfigPath())
Expect(err).NotTo(HaveOccurred())

err = yaml.Unmarshal(configtxBytes, &configtx)
Expect(err).NotTo(HaveOccurred())

return &configtx
}

// WriteConfigTxConfig serializes the provided configuration to configtx.yaml.
func (n *Network) WriteConfigTxConfig(config *fabricconfig.ConfigTx) {
configtxBytes, err := yaml.Marshal(config)
Expect(err).NotTo(HaveOccurred())

err = ioutil.WriteFile(n.ConfigTxConfigPath(), configtxBytes, 0644)
Expect(err).NotTo(HaveOccurred())
}

// PeerDir returns the path to the configuration directory for the specified
// Peer.
func (n *Network) PeerDir(p *Peer) string {
Expand Down
9 changes: 9 additions & 0 deletions integration/nwo/standard_networks.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,15 @@ func BasicEtcdRaft() *Config {
return config
}

func MinimalRaft() *Config {
config := BasicEtcdRaft()
config.Peers[1].Channels = nil
config.Peers[2].Channels = nil
config.Peers[3].Channels = nil
config.Profiles[1].Organizations = []string{"Org1"}
return config
}

func MultiChannelEtcdRaft() *Config {
config := MultiChannelBasicSolo()

Expand Down

0 comments on commit 946056c

Please sign in to comment.