Skip to content

Commit

Permalink
[FAB-11120] move legacy world to the last user
Browse files Browse the repository at this point in the history
Attempts to remove the legacy world have not been successful due to
pending work. Relocate the code to the remaining test package and defer
the removal.

Change-Id: I063dcd8c4422cf4dbe0f4f95aaa4e0982b4e2c61
Signed-off-by: Matthew Sykes <sykesmat@us.ibm.com>
  • Loading branch information
sykesm committed Jul 17, 2018
1 parent edfb0b5 commit 0f8446e
Show file tree
Hide file tree
Showing 35 changed files with 89 additions and 2,302 deletions.
2 changes: 1 addition & 1 deletion integration/pvtdata/e2e_suite_test.go
Expand Up @@ -9,7 +9,7 @@ package e2e
import (
"encoding/json"

"github.com/hyperledger/fabric/integration/world"
"github.com/hyperledger/fabric/integration/pvtdata/world"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"

Expand Down
6 changes: 3 additions & 3 deletions integration/pvtdata/e2e_test.go
Expand Up @@ -13,9 +13,9 @@ import (
"path/filepath"
"time"

"github.com/hyperledger/fabric/integration/helpers"
"github.com/hyperledger/fabric/integration/runner"
"github.com/hyperledger/fabric/integration/world"
"github.com/hyperledger/fabric/integration/pvtdata/helpers"
"github.com/hyperledger/fabric/integration/pvtdata/runner"
"github.com/hyperledger/fabric/integration/pvtdata/world"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gbytes"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
41 changes: 41 additions & 0 deletions integration/pvtdata/helpers/images.go
@@ -0,0 +1,41 @@
/*
Copyright IBM Corp All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package helpers

import (
"encoding/base32"
"fmt"
"strings"

"github.com/hyperledger/fabric/common/util"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"

docker "github.com/fsouza/go-dockerclient"
)

func AssertImagesExist(imageNames ...string) {
dockerClient, err := docker.NewClientFromEnv()
Expect(err).NotTo(HaveOccurred())

for _, imageName := range imageNames {
images, err := dockerClient.ListImages(docker.ListImagesOptions{
Filter: imageName,
})
ExpectWithOffset(1, err).NotTo(HaveOccurred())

if len(images) != 1 {
Fail(fmt.Sprintf("missing required image: %s", imageName), 1)
}
}
}

// UniqueName generates base-32 enocded UUIDs for container names.
func UniqueName() string {
name := base32.StdEncoding.WithPadding(base32.NoPadding).EncodeToString(util.GenerateBytesUUID())
return strings.ToLower(name)
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
Expand Up @@ -14,7 +14,7 @@ import (
"os/exec"
"path/filepath"

"github.com/hyperledger/fabric/integration/helpers"
"github.com/hyperledger/fabric/integration/pvtdata/helpers"
"github.com/hyperledger/fabric/protos/discovery"
. "github.com/onsi/gomega"

Expand Down
Expand Up @@ -15,8 +15,8 @@ import (
"time"

"github.com/fsouza/go-dockerclient"
"github.com/hyperledger/fabric/integration/helpers"
"github.com/hyperledger/fabric/integration/runner"
"github.com/hyperledger/fabric/integration/pvtdata/helpers"
"github.com/hyperledger/fabric/integration/pvtdata/runner"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gbytes"
Expand Down
File renamed without changes.
Expand Up @@ -12,7 +12,7 @@ import (
"os/exec"
"time"

"github.com/hyperledger/fabric/integration/helpers"
"github.com/hyperledger/fabric/integration/pvtdata/helpers"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gbytes"
"github.com/onsi/gomega/gexec"
Expand Down
@@ -1,23 +1,27 @@
/*
Copyright IBM Corp All Rights Reserved.
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package world_test

package runner_test

import (
"encoding/json"
"time"

"github.com/hyperledger/fabric/integration/world"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"

"github.com/hyperledger/fabric/integration/pvtdata/world"
"github.com/tedsuo/ifrit"

"testing"
)

func TestWorld(t *testing.T) {
func TestRunner(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "World Suite")
RunSpecs(t, "Private Data Runner Suite")
}

var components *world.Components
Expand All @@ -39,3 +43,11 @@ var _ = SynchronizedAfterSuite(func() {
}, func() {
components.Cleanup()
})

func execute(r ifrit.Runner) error {
var err error
p := ifrit.Invoke(r)
EventuallyWithOffset(1, p.Ready()).Should(BeClosed())
EventuallyWithOffset(1, p.Wait(), 30*time.Second).Should(Receive(&err))
return err
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
Expand Up @@ -13,7 +13,8 @@ import (
"time"

docker "github.com/fsouza/go-dockerclient"
"github.com/hyperledger/fabric/integration/helpers"
"github.com/hyperledger/fabric/integration/pvtdata/helpers"
pvtdatarunner "github.com/hyperledger/fabric/integration/pvtdata/runner"
"github.com/hyperledger/fabric/integration/runner"
"github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
Expand Down Expand Up @@ -42,10 +43,6 @@ func (c *Components) Build(args ...string) {
Expect(err).NotTo(HaveOccurred())
c.Paths["cryptogen"] = cryptogen

idemixgen, err := gexec.Build("github.com/hyperledger/fabric/common/tools/idemixgen", args...)
Expect(err).NotTo(HaveOccurred())
c.Paths["idemixgen"] = idemixgen

configtxgen, err := gexec.Build("github.com/hyperledger/fabric/common/tools/configtxgen", args...)
Expect(err).NotTo(HaveOccurred())
c.Paths["configtxgen"] = configtxgen
Expand All @@ -70,38 +67,32 @@ func (c *Components) Cleanup() {
}
}

func (c *Components) Cryptogen() *runner.Cryptogen {
return &runner.Cryptogen{
func (c *Components) Cryptogen() *pvtdatarunner.Cryptogen {
return &pvtdatarunner.Cryptogen{
Path: c.Paths["cryptogen"],
}
}

func (c *Components) Idemixgen() *runner.Idemixgen {
return &runner.Idemixgen{
Path: c.Paths["idemixgen"],
}
}

func (c *Components) Configtxgen() *runner.Configtxgen {
return &runner.Configtxgen{
func (c *Components) Configtxgen() *pvtdatarunner.Configtxgen {
return &pvtdatarunner.Configtxgen{
Path: c.Paths["configtxgen"],
}
}

func (c *Components) Orderer() *runner.Orderer {
return &runner.Orderer{
func (c *Components) Orderer() *pvtdatarunner.Orderer {
return &pvtdatarunner.Orderer{
Path: c.Paths["orderer"],
}
}

func (c *Components) Peer() *runner.Peer {
return &runner.Peer{
func (c *Components) Peer() *pvtdatarunner.Peer {
return &pvtdatarunner.Peer{
Path: c.Paths["peer"],
}
}

func (c *Components) DiscoveryService() *runner.DiscoveryService {
return &runner.DiscoveryService{
func (c *Components) DiscoveryService() *pvtdatarunner.DiscoveryService {
return &pvtdatarunner.DiscoveryService{
Path: c.Paths["discover"],
}
}
Expand Down
22 changes: 11 additions & 11 deletions integration/world/config.go → integration/pvtdata/world/config.go
Expand Up @@ -20,7 +20,8 @@ import (
"github.com/alecthomas/template"
docker "github.com/fsouza/go-dockerclient"
"github.com/hyperledger/fabric/common/tools/configtxgen/localconfig"
"github.com/hyperledger/fabric/integration/helpers"
"github.com/hyperledger/fabric/integration/pvtdata/helpers"
pvtdatarunner "github.com/hyperledger/fabric/integration/pvtdata/runner"
"github.com/hyperledger/fabric/integration/runner"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
Expand Down Expand Up @@ -64,8 +65,7 @@ type World struct {
OrdererOrgs []OrdererConfig
PeerOrgs []PeerOrgConfig
Profiles map[string]localconfig.Profile
Cryptogen runner.Cryptogen
Idemixgen runner.Idemixgen
Cryptogen pvtdatarunner.Cryptogen
SystemChannel string

DockerClient *docker.Client
Expand Down Expand Up @@ -201,7 +201,7 @@ func GenerateBasicConfig(ordererType string, numPeers, numPeerOrgs int, testDir
)
ExpectWithOffset(1, err).NotTo(HaveOccurred())

crypto := runner.Cryptogen{
crypto := pvtdatarunner.Cryptogen{
Config: filepath.Join(testDir, "crypto.yaml"),
Output: filepath.Join(testDir, "crypto"),
}
Expand Down Expand Up @@ -281,7 +281,7 @@ func (w *World) BootstrapNetwork(channel string) {
r := w.Cryptogen.Generate()
execute(r)

configtxgen := runner.Configtxgen{
configtxgen := pvtdatarunner.Configtxgen{
Path: w.Components.Paths["configtxgen"],
ChannelID: w.SystemChannel,
Profile: w.OrdererProfileName,
Expand All @@ -291,7 +291,7 @@ func (w *World) BootstrapNetwork(channel string) {
r = configtxgen.OutputBlock()
execute(r)

configtxgen = runner.Configtxgen{
configtxgen = pvtdatarunner.Configtxgen{
Path: w.Components.Paths["configtxgen"],
ChannelID: channel,
Profile: w.ChannelProfileName,
Expand All @@ -302,7 +302,7 @@ func (w *World) BootstrapNetwork(channel string) {
execute(r)

for _, peer := range w.PeerOrgs {
configtxgen = runner.Configtxgen{
configtxgen = pvtdatarunner.Configtxgen{
Path: w.Components.Paths["configtxgen"],
ChannelID: channel,
AsOrg: peer.OrganizationName,
Expand All @@ -325,7 +325,7 @@ func (w *World) ordererNetwork() {
zookeepers []string
z *runner.ZooKeeper
kafkas []*runner.Kafka
o *runner.Orderer
o *pvtdatarunner.Orderer
)

o = w.Components.Orderer()
Expand Down Expand Up @@ -379,7 +379,7 @@ func (w *World) ordererNetwork() {
}

func (w *World) peerNetwork() {
var p *runner.Peer
var p *pvtdatarunner.Peer

for _, peerOrg := range w.PeerOrgs {
for peer := 0; peer < peerOrg.PeerCount; peer++ {
Expand All @@ -394,13 +394,13 @@ func (w *World) peerNetwork() {
}

func (w *World) SetupChannel(d Deployment, peers []string) {
var p *runner.Peer
var p *pvtdatarunner.Peer

if len(peers) == 0 {
return
}

setupPeerRunner := func(peerID string) *runner.Peer {
setupPeerRunner := func(peerID string) *pvtdatarunner.Peer {
p = w.Components.Peer()
peerOrg := strings.SplitN(peerID, ".", 2)[1]
p.ConfigDir = filepath.Join(w.Rootpath, peerID)
Expand Down

0 comments on commit 0f8446e

Please sign in to comment.