Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Orderer v3: Remove system channel usage from integration tests: ledger #3930

Merged
merged 5 commits into from
Jan 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 25 additions & 13 deletions integration/ledger/couchdb_indexes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"syscall"

docker "github.com/fsouza/go-dockerclient"
"github.com/hyperledger/fabric/integration/channelparticipation"
"github.com/hyperledger/fabric/integration/nwo"
"github.com/hyperledger/fabric/integration/nwo/commands"
"github.com/hyperledger/fabric/integration/nwo/fabricconfig"
Expand All @@ -23,6 +24,7 @@ import (
"github.com/onsi/gomega/gbytes"
"github.com/onsi/gomega/gexec"
"github.com/tedsuo/ifrit"
ginkgomon "github.com/tedsuo/ifrit/ginkgomon_v2"
)

const (
Expand All @@ -44,11 +46,12 @@ var (

var _ = Describe("CouchDB indexes", func() {
var (
testDir string
client *docker.Client
network *nwo.Network
orderer *nwo.Orderer
process ifrit.Process
testDir string
client *docker.Client
network *nwo.Network
orderer *nwo.Orderer
ordererRunner *ginkgomon.Runner
ordererProcess, peerProcess ifrit.Process

couchAddr string
couchDB *runner.CouchDB
Expand All @@ -65,7 +68,7 @@ var _ = Describe("CouchDB indexes", func() {
client, err = docker.NewClientFromEnv()
Expect(err).NotTo(HaveOccurred())

network = nwo.New(nwo.FullEtcdRaft(), testDir, client, StartPort(), components)
network = nwo.New(nwo.FullEtcdRaftNoSysChan(), testDir, client, StartPort(), components)

cwd, err := os.Getwd()
Expect(err).NotTo(HaveOccurred())
Expand Down Expand Up @@ -94,12 +97,13 @@ var _ = Describe("CouchDB indexes", func() {

// start the network
network.Bootstrap()
networkRunner := network.NetworkGroupRunner()
process = ifrit.Invoke(networkRunner)
Eventually(process.Ready(), network.EventuallyTimeout).Should(BeClosed())

// Start all the fabric processes
ordererRunner, ordererProcess, peerProcess = network.StartSingleOrdererNetwork("orderer")

By("setting up the channel")
orderer = network.Orderer("orderer")
network.CreateAndJoinChannel(orderer, "testchannel")
network.UpdateChannelAnchors(orderer, "testchannel")
channelparticipation.JoinOrdererJoinPeersAppChannel(network, "testchannel", orderer, ordererRunner)
network.VerifyMembership(network.PeersWithChannel("testchannel"), "testchannel")

legacyChaincode = nwo.Chaincode{
Expand All @@ -125,8 +129,16 @@ var _ = Describe("CouchDB indexes", func() {
})

AfterEach(func() {
process.Signal(syscall.SIGTERM)
Eventually(process.Wait(), network.EventuallyTimeout).Should(Receive())
if ordererProcess != nil {
ordererProcess.Signal(syscall.SIGTERM)
Eventually(ordererProcess.Wait(), network.EventuallyTimeout).Should(Receive())
}

if peerProcess != nil {
peerProcess.Signal(syscall.SIGTERM)
Eventually(peerProcess.Wait(), network.EventuallyTimeout).Should(Receive())
}

couchProcess.Signal(syscall.SIGTERM)
Eventually(couchProcess.Wait(), network.EventuallyTimeout).Should(Receive())
network.Cleanup()
Expand Down
3 changes: 1 addition & 2 deletions integration/ledger/ledger_generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ import (
"fmt"
"path/filepath"

. "github.com/onsi/ginkgo/v2"

"github.com/hyperledger/fabric/integration/nwo"
. "github.com/onsi/ginkgo/v2"
)

// This test generate sample ledger data that can be used to verify rebuild ledger function and upgrade function (in a future release).
Expand Down
34 changes: 22 additions & 12 deletions integration/ledger/reset_rollback_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@ import (
"strings"
"syscall"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

docker "github.com/fsouza/go-dockerclient"
"github.com/hyperledger/fabric-protos-go/common"
"github.com/hyperledger/fabric/integration/channelparticipation"
"github.com/hyperledger/fabric/integration/nwo"
"github.com/hyperledger/fabric/integration/nwo/commands"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gbytes"
"github.com/onsi/gomega/gexec"
"github.com/tedsuo/ifrit"
ginkgomon "github.com/tedsuo/ifrit/ginkgomon_v2"
)

var _ = Describe("rollback, reset, pause, resume, and unjoin peer node commands", func() {
Expand Down Expand Up @@ -263,6 +264,7 @@ type setup struct {
peerProcess []ifrit.Process
orderer *nwo.Orderer
ordererProcess ifrit.Process
ordererRunner *ginkgomon.Runner
}

func initThreeOrgsSetup() *setup {
Expand All @@ -273,7 +275,14 @@ func initThreeOrgsSetup() *setup {
client, err := docker.NewClientFromEnv()
Expect(err).NotTo(HaveOccurred())

n := nwo.New(nwo.ThreeOrgEtcdRaft(), testDir, client, StartPort(), components)
config := nwo.ThreeOrgEtcdRaftNoSysChan()
// disable all anchor peers
for _, p := range config.Peers {
for _, pc := range p.Channels {
pc.Anchor = false
}
}
n := nwo.New(config, testDir, client, StartPort(), components)
n.GenerateConfigTree()
n.Bootstrap()

Expand All @@ -288,6 +297,7 @@ func initThreeOrgsSetup() *setup {
network: n,
peers: peers,
channelID: "testchannel",
orderer: n.Orderer("orderer"),
}

setup.startOrderer()
Expand All @@ -296,10 +306,10 @@ func initThreeOrgsSetup() *setup {
setup.startPeer(peers[1])
setup.startPeer(peers[2])

orderer := n.Orderer("orderer")
n.CreateAndJoinChannel(orderer, "testchannel")
n.UpdateChannelAnchors(orderer, "testchannel")
setup.orderer = orderer
channelparticipation.JoinOrdererJoinPeersAppChannel(n, "testchannel", setup.orderer, setup.ordererRunner)
n.UpdateOrgAnchorPeers(setup.orderer, testchannelID, "Org1", n.PeersInOrg("Org1"))
n.UpdateOrgAnchorPeers(setup.orderer, testchannelID, "Org2", n.PeersInOrg("Org2"))
n.UpdateOrgAnchorPeers(setup.orderer, testchannelID, "Org3", n.PeersInOrg("Org3"))

By("verifying membership")
setup.network.VerifyMembership(setup.peers, setup.channelID)
Expand All @@ -317,6 +327,7 @@ func (s *setup) terminateAllProcess() {
s.ordererProcess.Signal(syscall.SIGTERM)
Eventually(s.ordererProcess.Wait(), s.network.EventuallyTimeout).Should(Receive())
s.ordererProcess = nil
s.ordererRunner = nil

for _, p := range s.peerProcess {
p.Signal(syscall.SIGTERM)
Expand Down Expand Up @@ -347,10 +358,9 @@ func (s *setup) startPeer(peer *nwo.Peer) {
}

func (s *setup) startOrderer() {
ordererRunner := s.network.OrdererGroupRunner()
ordererProcess := ifrit.Invoke(ordererRunner)
Eventually(ordererProcess.Ready(), s.network.EventuallyTimeout).Should(BeClosed())
s.ordererProcess = ordererProcess
s.ordererRunner = s.network.OrdererRunner(s.orderer)
s.ordererProcess = ifrit.Invoke(s.ordererRunner)
Eventually(s.ordererProcess.Ready(), s.network.EventuallyTimeout).Should(BeClosed())
}

type networkHelper struct {
Expand Down
21 changes: 6 additions & 15 deletions integration/ledger/snapshot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
pb "github.com/hyperledger/fabric-protos-go/peer"
"github.com/hyperledger/fabric/core/ledger/util"
"github.com/hyperledger/fabric/integration/chaincode/kvexecutor"
"github.com/hyperledger/fabric/integration/channelparticipation"
"github.com/hyperledger/fabric/integration/nwo"
"github.com/hyperledger/fabric/integration/nwo/commands"
"github.com/hyperledger/fabric/integration/nwo/runner"
Expand Down Expand Up @@ -180,7 +181,6 @@ var _ = Describe("Snapshot Generation and Bootstrap", func() {
{IsDelete: "false", Value: newMarble(testKey, "blue", 35, "newowner2")},
}
helper.assertGetHistoryForMarble(legacyChaincode.Name, org3peer0, expectedHistory, testKey)

verifyQSCC(setup.network, org3peer0, testchannelID, blockNum, txidBeforeSnapshot)

// verify DUPLICATE_TXID error when resubmitting old tx on a peer bootstrapped from snapshot (v1_4 capability)
Expand Down Expand Up @@ -522,11 +522,7 @@ func initAndStartFourOrgsNetwork() *setup {
client, err := docker.NewClientFromEnv()
Expect(err).NotTo(HaveOccurred())

config := nwo.BasicEtcdRaft()

config.Channels = []*nwo.Channel{
{Name: testchannelID, Profile: "TwoOrgsChannel"},
}
config := nwo.BasicEtcdRaftNoSysChan()

for _, peer := range config.Peers {
peer.Channels = []*nwo.PeerChannel{
Expand Down Expand Up @@ -568,8 +564,7 @@ func initAndStartFourOrgsNetwork() *setup {
Users: 2,
CA: &nwo.CA{Hostname: "ca"},
})
config.Consortiums[0].Organizations = append(config.Consortiums[0].Organizations, "Org3")
config.Profiles[1].Organizations = append(config.Profiles[1].Organizations, "Org3")
config.Profiles[0].Organizations = append(config.Profiles[0].Organizations, "Org3")
config.Peers = append(config.Peers, &nwo.Peer{
Name: "peer0",
Organization: "Org3",
Expand All @@ -587,8 +582,7 @@ func initAndStartFourOrgsNetwork() *setup {
Users: 2,
CA: &nwo.CA{Hostname: "ca"},
})
config.Consortiums[0].Organizations = append(config.Consortiums[0].Organizations, "Org4")
config.Profiles[1].Organizations = append(config.Profiles[1].Organizations, "Org4")
config.Profiles[0].Organizations = append(config.Profiles[0].Organizations, "Org4")
config.Peers = append(config.Peers, &nwo.Peer{
Name: "peer0",
Organization: "Org4",
Expand Down Expand Up @@ -633,6 +627,7 @@ func initAndStartFourOrgsNetwork() *setup {
network: n,
peers: peers,
channelID: testchannelID,
orderer: n.Orderer("orderer"),
}
Expect(setup.testDir).To(Equal(setup.network.RootDir))

Expand All @@ -642,12 +637,8 @@ func initAndStartFourOrgsNetwork() *setup {
By("starting peers")
setup.startPeers()

orderer := n.Orderer("orderer")
setup.orderer = orderer

By("creating and joining testchannel")
n.CreateAndJoinChannel(orderer, testchannelID)
n.UpdateChannelAnchors(orderer, testchannelID)
channelparticipation.JoinOrdererJoinPeersAppChannel(setup.network, "testchannel", setup.orderer, setup.ordererRunner)

By("verifying membership for testchannel")
n.VerifyMembership(n.PeersWithChannel(testchannelID), testchannelID)
Expand Down
31 changes: 20 additions & 11 deletions integration/lifecycle/ccenv14_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,21 @@ import (
"syscall"

docker "github.com/fsouza/go-dockerclient"
"github.com/hyperledger/fabric/integration/channelparticipation"
"github.com/hyperledger/fabric/integration/nwo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/tedsuo/ifrit"
ginkgomon "github.com/tedsuo/ifrit/ginkgomon_v2"
)

var _ = Describe("etcdraft network using ccenv-1.4", func() {
var (
client *docker.Client
testDir string
network *nwo.Network
process ifrit.Process
client *docker.Client
testDir string
network *nwo.Network
ordererRunner *ginkgomon.Runner
ordererProcess, peerProcess ifrit.Process
)

BeforeEach(func() {
Expand All @@ -39,7 +42,7 @@ var _ = Describe("etcdraft network using ccenv-1.4", func() {
client, err = docker.NewClientFromEnv()
Expect(err).NotTo(HaveOccurred())

network = nwo.New(nwo.BasicEtcdRaft(), testDir, client, StartPort(), components)
network = nwo.New(nwo.BasicEtcdRaftNoSysChan(), testDir, client, StartPort(), components)
network.GenerateConfigTree()
for _, peer := range network.PeersWithChannel("testchannel") {
core := network.ReadPeerConfig(peer)
Expand All @@ -48,15 +51,21 @@ var _ = Describe("etcdraft network using ccenv-1.4", func() {
}
network.Bootstrap()

networkRunner := network.NetworkGroupRunner()
process = ifrit.Invoke(networkRunner)
Eventually(process.Ready(), network.EventuallyTimeout).Should(BeClosed())
// Start all the fabric processes
ordererRunner, ordererProcess, peerProcess = network.StartSingleOrdererNetwork("orderer")
})

AfterEach(func() {
// Shutdown processes and cleanup
process.Signal(syscall.SIGTERM)
Eventually(process.Wait(), network.EventuallyTimeout).Should(Receive())
if ordererProcess != nil {
ordererProcess.Signal(syscall.SIGTERM)
Eventually(ordererProcess.Wait(), network.EventuallyTimeout).Should(Receive())
}

if peerProcess != nil {
peerProcess.Signal(syscall.SIGTERM)
Eventually(peerProcess.Wait(), network.EventuallyTimeout).Should(Receive())
}
network.Cleanup()

os.RemoveAll(testDir)
Expand Down Expand Up @@ -88,7 +97,7 @@ var _ = Describe("etcdraft network using ccenv-1.4", func() {
Policy: `AND ('Org1MSP.member','Org2MSP.member')`,
}

network.CreateAndJoinChannels(orderer)
channelparticipation.JoinOrdererJoinPeersAppChannel(network, "testchannel", orderer, ordererRunner)
nwo.DeployChaincodeLegacy(network, "testchannel", orderer, chaincode)
RunQueryInvokeQuery(network, orderer, "mycc", 100, endorsers...)
})
Expand Down