Skip to content

Commit

Permalink
peer delivery client policy integration tests (#4907)
Browse files Browse the repository at this point in the history
Signed-off-by: Emil Elizarov <emil.elizarov@ibm.com>
Co-authored-by: Emil Elizarov <emil.elizarov@ibm.com>
  • Loading branch information
semil and Emil Elizarov authored Jul 2, 2024
1 parent c27d12a commit 649c877
Show file tree
Hide file tree
Showing 3 changed files with 150 additions and 5 deletions.
12 changes: 7 additions & 5 deletions integration/nwo/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ type Network struct {
TLSEnabled bool
GatewayEnabled bool
OrdererReplicationPolicy string
PeerDeliveryClientPolicy string

PortsByOrdererID map[string]Ports
PortsByPeerID map[string]Ports
Expand All @@ -186,11 +187,12 @@ func New(c *Config, rootDir string, dockerClient *docker.Client, startPort int,
Components: components,
DockerClient: dockerClient,

NetworkID: runner.UniqueName(),
EventuallyTimeout: time.Minute,
MetricsProvider: "prometheus",
PortsByOrdererID: map[string]Ports{},
PortsByPeerID: map[string]Ports{},
NetworkID: runner.UniqueName(),
EventuallyTimeout: time.Minute,
MetricsProvider: "prometheus",
PortsByOrdererID: map[string]Ports{},
PortsByPeerID: map[string]Ports{},
PeerDeliveryClientPolicy: "",

Organizations: c.Organizations,
Consensus: c.Consensus,
Expand Down
1 change: 1 addition & 0 deletions integration/nwo/template/core_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ peer:
localMspId: {{ (.Organization Peer.Organization).MSPID }}
deliveryclient:
reconnectTotalTimeThreshold: 3600s
policy: {{ .PeerDeliveryClientPolicy }}
localMspType: bccsp
profile:
enabled: false
Expand Down
142 changes: 142 additions & 0 deletions integration/smartbft/smartbft_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2028,6 +2028,148 @@ var _ = Describe("EndToEnd Smart BFT configuration test", func() {
Eventually(ordererRunners[2].Err(), network.EventuallyTimeout, time.Second).Should(gbytes.Say("deleteRequest"))
Eventually(ordererRunners[3].Err(), network.EventuallyTimeout, time.Second).Should(gbytes.Say("deleteRequest"))
})

It("default delivery client is cluster", func() {
channel := "testchannel1"
By("Create network")
networkConfig := nwo.MultiNodeSmartBFT()
networkConfig.Channels = nil
network = nwo.New(networkConfig, testDir, client, StartPort(), components)
Expect(network.PeerDeliveryClientPolicy).To(Equal(""))
network.GenerateConfigTree()
network.Bootstrap()

By("Start orderers")
var ordererRunners []*ginkgomon.Runner
for _, orderer := range network.Orderers {
runner := network.OrdererRunner(orderer, "FABRIC_LOGGING_SPEC=debug")
ordererRunners = append(ordererRunners, runner)
proc := ifrit.Invoke(runner)
ordererProcesses = append(ordererProcesses, proc)
Eventually(proc.Ready(), network.EventuallyTimeout).Should(BeClosed())
}

By("Start peer")
peerGroupRunner, peerRunners := peerGroupRunners(network)
peerProcesses = ifrit.Invoke(peerGroupRunner)
Eventually(peerProcesses.Ready(), network.EventuallyTimeout).Should(BeClosed())
peer := network.Peer("Org1", "peer0")

By("Join network to channel")
joinChannel(network, channel)

By("Waiting for followers to see the leader")
Eventually(ordererRunners[1].Err(), network.EventuallyTimeout, time.Second).Should(gbytes.Say("Message from 1"))
Eventually(ordererRunners[2].Err(), network.EventuallyTimeout, time.Second).Should(gbytes.Say("Message from 1"))
Eventually(ordererRunners[3].Err(), network.EventuallyTimeout, time.Second).Should(gbytes.Say("Message from 1"))

By("Joining peers to channel")
network.JoinChannel(channel, network.Orderers[0], network.PeersWithChannel(channel)...)

By("Validating BlockDeliverer type")
Eventually(peerRunners[0].Err(), network.EventuallyTimeout).Should(gbytes.Say("Creating a BFT \\(byzantine fault tolerant\\) BlockDeliverer"))

By("Deploying chaincode")
deployChaincode(network, channel, testDir)
assertBlockReception(map[string]int{channel: 4}, network.Orderers, peer, network)

By("Transacting on channel")
invokeQuery(network, peer, network.Orderers[0], channel, 90)
invokeQuery(network, peer, network.Orderers[0], channel, 80)
assertBlockReception(map[string]int{channel: 6}, network.Orderers, peer, network)
})

It("cluster delivery client is creating a BFT delivery client", func() {
channel := "testchannel1"
By("Create network")
networkConfig := nwo.MultiNodeSmartBFT()
networkConfig.Channels = nil
network = nwo.New(networkConfig, testDir, client, StartPort(), components)
network.PeerDeliveryClientPolicy = "cluster"
network.GenerateConfigTree()
network.Bootstrap()

By("Start orderers")
var ordererRunners []*ginkgomon.Runner
for _, orderer := range network.Orderers {
runner := network.OrdererRunner(orderer, "FABRIC_LOGGING_SPEC=debug")
ordererRunners = append(ordererRunners, runner)
proc := ifrit.Invoke(runner)
ordererProcesses = append(ordererProcesses, proc)
Eventually(proc.Ready(), network.EventuallyTimeout).Should(BeClosed())
}

By("Start peer")
peer := network.Peers[0]
peerRunner := network.PeerRunner(peer)
peerRunner.Command.Env = append(peerRunner.Command.Env, "FABRIC_LOGGING_SPEC=debug")
peerProcesses = ifrit.Invoke(peerRunner)
Eventually(peerProcesses.Ready(), network.EventuallyTimeout).Should(BeClosed())

By("Join network to channel")
joinChannel(network, channel)

By("Waiting for followers to see the leader")
Eventually(ordererRunners[1].Err(), network.EventuallyTimeout, time.Second).Should(gbytes.Say("Message from 1"))
Eventually(ordererRunners[2].Err(), network.EventuallyTimeout, time.Second).Should(gbytes.Say("Message from 1"))
Eventually(ordererRunners[3].Err(), network.EventuallyTimeout, time.Second).Should(gbytes.Say("Message from 1"))

By("Joining peer to channel")
network.JoinChannel(channel, network.Orderers[0], peer)

By("Validating BlockDeliverer type")
Eventually(peerRunner.Err(), network.EventuallyTimeout).Should(gbytes.Say("Creating a BFT \\(byzantine fault tolerant\\) BlockDeliverer"))
})

It("simple delivery client is creating a CFT delivery client", func() {
channel := "testchannel1"
By("Create network")
networkConfig := nwo.MultiNodeSmartBFT()
networkConfig.Channels = nil
network = nwo.New(networkConfig, testDir, client, StartPort(), components)
network.PeerDeliveryClientPolicy = "simple"
network.GenerateConfigTree()
network.Bootstrap()

By("Start orderers")
var ordererRunners []*ginkgomon.Runner
for _, orderer := range network.Orderers {
runner := network.OrdererRunner(orderer, "FABRIC_LOGGING_SPEC=debug")
ordererRunners = append(ordererRunners, runner)
proc := ifrit.Invoke(runner)
ordererProcesses = append(ordererProcesses, proc)
Eventually(proc.Ready(), network.EventuallyTimeout).Should(BeClosed())
}

By("Start peer")
peerGroupRunner, peerRunners := peerGroupRunners(network)
peerProcesses = ifrit.Invoke(peerGroupRunner)
Eventually(peerProcesses.Ready(), network.EventuallyTimeout).Should(BeClosed())
peer := network.Peer("Org1", "peer0")

By("Join network to channel")
joinChannel(network, channel)

By("Waiting for followers to see the leader")
Eventually(ordererRunners[1].Err(), network.EventuallyTimeout, time.Second).Should(gbytes.Say("Message from 1"))
Eventually(ordererRunners[2].Err(), network.EventuallyTimeout, time.Second).Should(gbytes.Say("Message from 1"))
Eventually(ordererRunners[3].Err(), network.EventuallyTimeout, time.Second).Should(gbytes.Say("Message from 1"))

By("Joining peers to channel")
network.JoinChannel(channel, network.Orderers[0], network.PeersWithChannel(channel)...)

By("Validating BlockDeliverer type")
Eventually(peerRunners[0].Err(), network.EventuallyTimeout).Should(gbytes.Say("Creating a CFT \\(crash fault tolerant\\) BlockDeliverer"))

By("Deploying chaincode")
deployChaincode(network, channel, testDir)
assertBlockReception(map[string]int{channel: 4}, network.Orderers, peer, network)

By("Transacting on channel")
invokeQuery(network, peer, network.Orderers[0], channel, 90)
invokeQuery(network, peer, network.Orderers[0], channel, 80)
assertBlockReception(map[string]int{channel: 6}, network.Orderers, peer, network)
})
})
})

Expand Down

0 comments on commit 649c877

Please sign in to comment.