Skip to content

Commit

Permalink
Orderer v3: Remove system channel usage from integration tests: ledger (
Browse files Browse the repository at this point in the history
#3930)

* Orderer v3: Remove system channel usage from integration tests: lifecycle

Signed-off-by: Yoav Tock <tock@il.ibm.com>
Change-Id: Ifd8cdbc4a31146408333f9c110e94d1984b0fea9

* Orderer v3: Remove system channel usage from integration tests: msp

Signed-off-by: Yoav Tock <tock@il.ibm.com>
Change-Id: Ic6f4f589a06aeacbdbcd23381bd47eff56fe413b

* Orderer v3: Remove system channel usage from integration tests: pkcs11

Signed-off-by: Yoav Tock <tock@il.ibm.com>
Change-Id: I386625f8f36f94d2e2b3cf19b067f363d9fc53e4

* Orderer v3: Remove system channel usage from integration tests: pluggable, sbe

Signed-off-by: Yoav Tock <tock@il.ibm.com>
Change-Id: I8d9b0b94952c652d45b115c58bcc0a92733344fb

* Orderer v3: Remove system channel usage from integration tests: ledger

Signed-off-by: Yoav Tock <tock@il.ibm.com>
Change-Id: I05c7b4d6d38d1e82f1f0c5d00387dc4ab1f8fbf1

Signed-off-by: Yoav Tock <tock@il.ibm.com>
  • Loading branch information
tock-ibm committed Jan 23, 2023
1 parent 9183098 commit e414d3f
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 42 deletions.
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

0 comments on commit e414d3f

Please sign in to comment.