Skip to content

Commit fd477e4

Browse files
committed
FAB-3264: Config Utility for Behave Func Tests
This config utility contains methods that generates configuration artifacts and used in the setup of the fabric network when executing behave functional tests. Change-Id: I372c1bec28a3f7cc5e836fcf928b6bfbe80d9ef5 Signed-off-by: Latitia M Haskins <[email protected]>
1 parent 62aec85 commit fd477e4

File tree

3 files changed

+210
-0
lines changed

3 files changed

+210
-0
lines changed

test/feature/configs/configtx.yaml

+150
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
---
2+
################################################################################
3+
#
4+
# Profile
5+
#
6+
# - Different configuration profiles may be encoded here to be specified
7+
# as parameters to the configtxgen tool.
8+
#
9+
################################################################################
10+
Profiles:
11+
12+
# SampleInsecureSolo defines a configuration which uses the Solo orderer,
13+
# contains no MSP definitions, and allows all transactions and channel
14+
# creation requests.
15+
SampleInsecureSolo:
16+
Orderer:
17+
<<: *OrdererDefaults
18+
Application:
19+
<<: *ApplicationDefaults
20+
21+
# SampleInsecureKafka defines a configuration that differs from the
22+
# SampleInsecureSolo one only in that is uses the Kafka-based orderer.
23+
SampleInsecureKafka:
24+
Orderer:
25+
<<: *OrdererDefaults
26+
OrdererType: kafka
27+
Application:
28+
<<: *ApplicationDefaults
29+
30+
# SampleSingleMSPSolo defines a configuration which uses the Solo orderer,
31+
# and contains a single MSP definition (the MSP sampleconfig).
32+
SampleSingleMSPSolo:
33+
Orderer:
34+
<<: *OrdererDefaults
35+
Organizations:
36+
- *SampleOrg
37+
Application:
38+
<<: *ApplicationDefaults
39+
Organizations:
40+
- *SampleOrg
41+
42+
################################################################################
43+
#
44+
# Section: Organizations
45+
#
46+
# - This section defines the different organizational identities which will
47+
# be referenced later in the configuration.
48+
#
49+
################################################################################
50+
Organizations:
51+
52+
# SampleOrg defines an MSP using the sampleconfig. It should never be used
53+
# in production but may be used as a template for other definitions.
54+
- &SampleOrg
55+
# DefaultOrg defines the organization which is used in the sampleconfig
56+
# of the fabric.git development environment.
57+
Name: SampleOrg
58+
59+
# ID to load the MSP definition as.
60+
ID: DEFAULT
61+
62+
# MSPDir is the filesystem path which contains the MSP configuration.
63+
MSPDir: msp/sampleconfig
64+
65+
# BCCSP: Select which crypto implementation or library to use for the
66+
# blockchain crypto service provider.
67+
BCCSP:
68+
Default: SW
69+
SW:
70+
# TODO: The default Hash and Security level needs refactoring to be
71+
# fully configurable. Changing these defaults requires coordination
72+
# SHA2 is hardcoded in several places, not only BCCSP
73+
Hash: SHA2
74+
Security: 256
75+
# Location of key store. If this is unset, a location will
76+
# be chosen using: 'MSPDir'/keystore
77+
FileKeyStore:
78+
KeyStore:
79+
80+
AnchorPeers:
81+
# AnchorPeers defines the location of peers which can be used
82+
# for cross org gossip communication. Note, this value is only
83+
# encoded in the genesis block in the Application section context.
84+
- Host: 127.0.0.1
85+
Port: 7051
86+
87+
################################################################################
88+
#
89+
# SECTION: Orderer
90+
#
91+
# - This section defines the values to encode into a config transaction or
92+
# genesis block for orderer related parameters.
93+
#
94+
################################################################################
95+
Orderer: &OrdererDefaults
96+
97+
# Orderer Type: The orderer implementation to start.
98+
# Available types are "solo" and "kafka".
99+
OrdererType: solo
100+
101+
Addresses:
102+
- 127.0.0.1:7050
103+
104+
# Batch Timeout: The amount of time to wait before creating a batch.
105+
BatchTimeout: 2s
106+
107+
# Batch Size: Controls the number of messages batched into a block.
108+
BatchSize:
109+
110+
# Max Message Count: The maximum number of messages to permit in a
111+
# batch.
112+
MaxMessageCount: 10
113+
114+
# Absolute Max Bytes: The absolute maximum number of bytes allowed for
115+
# the serialized messages in a batch.
116+
AbsoluteMaxBytes: 99 MB
117+
118+
# Preferred Max Bytes: The preferred maximum number of bytes allowed for
119+
# the serialized messages in a batch. A message larger than the
120+
# preferred max bytes will result in a batch larger than preferred max
121+
# bytes.
122+
PreferredMaxBytes: 512 KB
123+
124+
# Max Channels is the maximum number of channels to allow on the ordering network
125+
# When set to 0, this implies no maximum number of channels
126+
MaxChannels: 0
127+
128+
Kafka:
129+
# Brokers: A list of Kafka brokers to which the orderer connects.
130+
# NOTE: Use IP:port notation
131+
Brokers:
132+
- 127.0.0.1:9092
133+
134+
# Organizations is the list of orgs which are defined as participants on
135+
# the orderer side of the network.
136+
Organizations:
137+
138+
################################################################################
139+
#
140+
# SECTION: Application
141+
#
142+
# - This section defines the values to encode into a config transaction or
143+
# genesis block for application related parameters.
144+
#
145+
################################################################################
146+
Application: &ApplicationDefaults
147+
148+
# Organizations is the list of orgs which are defined as participants on
149+
# the application side of the network.
150+
Organizations:
File renamed without changes.

test/feature/steps/config_util.py

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Copyright IBM Corp. 2016 All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
16+
17+
import subprocess
18+
import os
19+
import sys
20+
from shutil import copyfile
21+
22+
def generateConfig(context, channelID, profile, ordererBlock="orderer.block"):
23+
# Save all the files to a specific directory for the test
24+
testConfigs = "configs/%s" % context.composition.projectName
25+
if not os.path.isdir(testConfigs):
26+
os.mkdir(testConfigs)
27+
28+
configFile = "configtx.yaml"
29+
if os.path.isfile("configs/%s.yaml" % channelID):
30+
configFile = "%s.yaml" % channelID
31+
copyfile("configs/%s" % configFile, "%s/%s" %(testConfigs, configFile))
32+
33+
# Default location: /opt/gopath/src/github.com/hyperledger/fabric/common/configtx/tool/configtx.yaml
34+
# Workaround until the -path option is added to configtxgen
35+
os.environ['ORDERER_CFG_PATH'] = testConfigs
36+
37+
try:
38+
subprocess.check_call(["configtxgen", "-profile", profile,
39+
#"-path", configFile,
40+
"-outputCreateChannelTx", "%s/%s.tx" % (testConfigs, channelID),
41+
"-outputBlock", "%s/%s" % (testConfigs, ordererBlock),
42+
"-channelID", channelID])
43+
except:
44+
print("Unable to generate channel config data: {0}".format(sys.exc_info()[0]))
45+
46+
47+
def generateCrypto(context, numOrgs=2, numPeersPerOrg=2, numOrderers=1):
48+
# Save all the files to a specific directory for the test
49+
testConfigs = "configs/%s" % context.composition.projectName
50+
if not os.path.isdir(testConfigs):
51+
os.mkdir(testConfigs)
52+
53+
try:
54+
subprocess.check_call(["cryptogen",
55+
"-peerOrgs", numOrgs,
56+
"-ordererNodes", numOrderers,
57+
"-peersPerOrg", numPeersPerOrg,
58+
"-baseDir", testConfigs])
59+
except:
60+
print("Unable to generate crypto material: {0}".format(sys.exc_info()[0]))

0 commit comments

Comments
 (0)