Skip to content

Commit

Permalink
[FAB-6747]configtxgen unable to read V1.1 sample profs
Browse files Browse the repository at this point in the history
configtxgen is unable to read in the sample V1.1 profiles due to the
period in the profile name as defined in sampleconfig/configtx.yaml
(e.g. SampleSingleMSPChannelV1.1). This CR updates the profile names
to use underscores instead so Viper is able to locate and load them
as expected.

Change-Id: Ic7bf03199c20eca466519c406c702221b071602c
Signed-off-by: Will Lahti <wtlahti@us.ibm.com>
  • Loading branch information
wlahti committed Oct 25, 2017
1 parent 43d3e63 commit 3fea60e
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 11 deletions.
8 changes: 5 additions & 3 deletions common/tools/configtxgen/localconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,21 @@ const (
// SampleSingleMSPSoloProfile references the sample profile which includes only the sample MSP and uses solo for ordering.
SampleSingleMSPSoloProfile = "SampleSingleMSPSolo"
// SampleSingleMSPSoloV11Profile references the sample profile which includes only the sample MSP with v1.1 capabilities defined and uses solo for ordering.
SampleSingleMSPSoloV11Profile = "SampleSingleMSPSoloV1.1"
SampleSingleMSPSoloV11Profile = "SampleSingleMSPSoloV1_1"

// SampleInsecureKafkaProfile references the sample profile which does not include any MSPs and uses Kafka for ordering.
SampleInsecureKafkaProfile = "SampleInsecureKafka"
// SampleDevModeKafkaProfile references the sample profile which requires only basic membership for admin privileges and uses Kafka for ordering.
SampleDevModeKafkaProfile = "SampleDevModeKafka"
// SampleSingleMSPKafkaProfile references the sample profile which includes only the sample MSP and uses Kafka for ordering.
SampleSingleMSPKafkaProfile = "SampleSingleMSPKafka"
// SampleSingleMSPKafkaV11Profile references the sample profile which includes only the sample MSPwith v1.1 capabilities defined and uses Kafka for ordering.
SampleSingleMSPKafkaV11Profile = "SampleSingleMSPKafkaV1.1"
// SampleSingleMSPKafkaV11Profile references the sample profile which includes only the sample MSP with v1.1 capabilities defined and uses Kafka for ordering.
SampleSingleMSPKafkaV11Profile = "SampleSingleMSPKafkaV1_1"

// SampleSingleMSPChannelProfile references the sample profile which includes only the sample MSP and is used to create a channel
SampleSingleMSPChannelProfile = "SampleSingleMSPChannel"
// SampleSingleMSPChannelV11Profile references the sample profile which includes only the sample MSP with v1.1 capabilities and is used to create a channel
SampleSingleMSPChannelV11Profile = "SampleSingleMSPChannelV1_1"

// SampleConsortiumName is the sample consortium from the sample configtx.yaml
SampleConsortiumName = "SampleConsortium"
Expand Down
48 changes: 48 additions & 0 deletions common/tools/configtxgen/localconfig/config_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
Copyright IBM Corp. 2017 All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package localconfig

import (
"testing"

"github.com/hyperledger/fabric/common/flogging"
"github.com/stretchr/testify/assert"
)

func init() {
flogging.SetModuleLevel(pkgLogID, "DEBUG")
}

func TestLoadProfile(t *testing.T) {
pNames := []string{
SampleDevModeKafkaProfile,
SampleDevModeSoloProfile,
SampleInsecureKafkaProfile,
SampleInsecureSoloProfile,
SampleSingleMSPChannelProfile,
SampleSingleMSPChannelV11Profile,
SampleSingleMSPKafkaProfile,
SampleSingleMSPKafkaV11Profile,
SampleSingleMSPSoloProfile,
SampleSingleMSPSoloV11Profile,
}
for _, pName := range pNames {
t.Run(pName, func(t *testing.T) {
p := Load(pName)
assert.NotNil(t, p, "profile should not be nil")
})
}
}

func TestLoadTopLevel(t *testing.T) {
topLevel := LoadTopLevel()
assert.NotNil(t, topLevel.Application, "application should not be nil")
assert.NotNil(t, topLevel.Capabilities, "capabilities should not be nil")
assert.NotNil(t, topLevel.Orderer, "orderer should not be nil")
assert.NotNil(t, topLevel.Organizations, "organizations should not be nil")
assert.NotNil(t, topLevel.Profiles, "profiles should not be nil")
}
16 changes: 8 additions & 8 deletions sampleconfig/configtx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ Profiles:
Organizations:
- *SampleOrg

# SampleSingleMSPSoloV1.1 mimics the SampleSingleMSPSolo definition but
# SampleSingleMSPSoloV1_1 mimics the SampleSingleMSPSolo definition but
# additionally defines the v1.1 only capabilities which do not allow a
# mixed v1.0.x v1.1.x network.
SampleSingleMSPSoloV1.1:
SampleSingleMSPSoloV1_1:
Capabilities:
<<: *GlobalCapabilities
Orderer:
Expand All @@ -135,9 +135,9 @@ Profiles:
Organizations:
- *SampleOrg

# SampleSingleMSPKafkaV1.1 defines a configuration that differs from the
# SampleSingleMSPSoloV1.1 one only in that it uses the Kafka-based orderer.
SampleSingleMSPKafkaV1.1:
# SampleSingleMSPKafkaV1_1 defines a configuration that differs from the
# SampleSingleMSPSoloV1_1 one only in that it uses the Kafka-based orderer.
SampleSingleMSPKafkaV1_1:
Capabilities:
<<: *GlobalCapabilities
Orderer:
Expand Down Expand Up @@ -175,10 +175,10 @@ Profiles:
Organizations:
- *SampleOrg

# SampleSingleMSPChannelV1.1 defines a channel just as SampleSingleMSPChannel
# SampleSingleMSPChannelV1_1 defines a channel just as SampleSingleMSPChannel
# However, it also defines the capabilities map which makes this channel
# incompatible with v1.0.x peers.
SampleSingleMSPChannelV1.1:
SampleSingleMSPChannelV1_1:
Consortium: SampleConsortium
Application:
Organizations:
Expand Down Expand Up @@ -296,7 +296,7 @@ Application: &ApplicationDefaults
#
# SECTION: Capabilities
#
# - This section defines the capabilities of fabric network. This is a new
# - This section defines the capabilities of fabric network. This is a new
# concept as of v1.1.0 and should not be utilized in mixed networks with
# v1.0.x peers and orderers. Capabilities define features which must be
# present in a fabric binary for that binary to safely participate in the
Expand Down

0 comments on commit 3fea60e

Please sign in to comment.