Skip to content

Commit 94f6f4a

Browse files
committed
[FAB-1141] Add kafka and couchDB to bootstrap
Checking this in to allow Kostas to debug issue on 3 kafka node composition. Solo and 1 kafka node are and couchdb configs are currently succeeding. Added couchdb example. Feel free to choose from any of the examples to configure the environment you want. Commented out for now to not fail CI. Now parameterized orderer references to allow usage of both solo and kafka consensus types to leverage the same scenario. Solo simply reuses orderer0 for all orderer references. Removed comments from couchdb config. Change-Id: Id835abd0112df3a56284ef436c69e0b468c3d2bf Signed-off-by: jeffgarratt <[email protected]>
1 parent 5b59e06 commit 94f6f4a

8 files changed

+129
-34
lines changed
+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
version: '2'
2+
3+
services:
4+
5+
couchdb0:
6+
image: hyperledger/fabric-couchdb
7+
ports:
8+
- "5984:5984"
9+
10+
peer0:
11+
environment:
12+
- CORE_LEDGER_STATE_STATEDATABASE=CouchDB
13+
- CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb0:5984
14+
depends_on:
15+
- couchdb0
16+
17+
couchdb1:
18+
image: hyperledger/fabric-couchdb
19+
ports:
20+
- "6984:5984"
21+
22+
peer1:
23+
environment:
24+
- CORE_LEDGER_STATE_STATEDATABASE=CouchDB
25+
- CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb1:5984
26+
depends_on:
27+
- couchdb1
28+
29+
couchdb2:
30+
image: hyperledger/fabric-couchdb
31+
ports:
32+
- "7984:5984"
33+
34+
peer2:
35+
environment:
36+
- CORE_LEDGER_STATE_STATEDATABASE=CouchDB
37+
- CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb2:5984
38+
depends_on:
39+
- couchdb2
40+
41+
couchdb3:
42+
image: hyperledger/fabric-couchdb
43+
ports:
44+
- "8984:5984"
45+
46+
peer3:
47+
environment:
48+
- CORE_LEDGER_STATE_STATEDATABASE=CouchDB
49+
- CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb3:5984
50+
depends_on:
51+
- couchdb3

bddtests/features/bootstrap.feature

+29-19
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33
#
44
# Tags that can be used and will affect test internals:
55
# @doNotDecompose will NOT decompose the named compose_yaml after scenario ends. Useful for setting up environment and reviewing after scenario.
6-
# @chaincodeImagesUpToDate use this if all scenarios chaincode images are up to date, and do NOT require building. BE SURE!!!
6+
#
7+
# @generateDocs will generate documentation for the scenario that can be used for both verification and comprehension.
8+
#
79

8-
#@chaincodeImagesUpToDate
910
@bootstrap
1011
Feature: Bootstrap
1112
As a blockchain entrepreneur
1213
I want to bootstrap a new blockchain network
1314

14-
@doNotDecompose
15+
#@doNotDecompose
1516
@generateDocs
1617
Scenario Outline: Bootstrap a development network with 4 peers (2 orgs) and 1 orderer (1 org), each having a single independent root of trust (No fabric-ca, just openssl)
1718
#creates 1 self-signed key/cert pair per orderer organization
@@ -22,6 +23,8 @@ Feature: Bootstrap
2223
And user requests role of orderer admin by creating a key and csr for orderer and acquires signed certificate from organization:
2324
| User | Orderer | Organization |
2425
| orderer0Signer | orderer0 | ordererOrg0 |
26+
| orderer1Signer | orderer1 | ordererOrg0 |
27+
| orderer2Signer | orderer2 | ordererOrg0 |
2528

2629

2730
# Rolenames : MspPrincipal.proto
@@ -81,8 +84,11 @@ Feature: Bootstrap
8184

8285
And we compose "<ComposeFile>"
8386

87+
# Sleep as to allow system up time
88+
And I wait "<SystemUpWaitTime>" seconds
89+
8490
# This implicitly incorporates the orderer genesis block info
85-
And the ordererBootstrapAdmin runs the channel template tool to create the orderer configuration template "template1" for application developers using orderer "orderer0"
91+
And the ordererBootstrapAdmin runs the channel template tool to create the orderer configuration template "template1" for application developers using orderer "<orderer0>"
8692
And the ordererBootstrapAdmin distributes orderer configuration template "template1" and chain creation policy name "chainCreatePolicy1"
8793

8894
And the following application developers are defined for peer organizations and each saves their cert as alias
@@ -118,17 +124,17 @@ Feature: Bootstrap
118124

119125
And the user "dev0Org0" creates a ConfigUpdate Tx "configUpdateTx1" using cert alias "dev0Org0App1" using signed ConfigUpdateEnvelope "createChannelConfigUpdate1"
120126

121-
And the user "dev0Org0" using cert alias "dev0Org0App1" broadcasts ConfigUpdate Tx "configUpdateTx1" to orderer "orderer0" to create channel "com.acme.blockchain.jdoe.Channel1"
127+
And the user "dev0Org0" using cert alias "dev0Org0App1" broadcasts ConfigUpdate Tx "configUpdateTx1" to orderer "<orderer0>" to create channel "com.acme.blockchain.jdoe.Channel1"
122128

123129
# Sleep as the deliver takes a bit to have the first block ready
124-
And I wait "2" seconds
130+
And I wait "<BroadcastWaitTime>" seconds
125131

126-
When user "dev0Org0" using cert alias "dev0Org0App1" connects to deliver function on orderer "orderer0"
127-
And user "dev0Org0" sends deliver a seek request on orderer "orderer0" with properties:
132+
When user "dev0Org0" using cert alias "dev0Org0App1" connects to deliver function on orderer "<orderer0>"
133+
And user "dev0Org0" sends deliver a seek request on orderer "<orderer0>" with properties:
128134
| ChainId | Start | End |
129135
| com.acme.blockchain.jdoe.Channel1 | 0 | 0 |
130136

131-
Then user "dev0Org0" should get a delivery "genesisBlockForMyNewChannel" from "orderer0" of "1" blocks with "1" messages within "1" seconds
137+
Then user "dev0Org0" should get a delivery "genesisBlockForMyNewChannel" from "<orderer0>" of "1" blocks with "1" messages within "1" seconds
132138
Given user "dev0Org0" gives "genesisBlockForMyNewChannel" to user "dev0Org1"
133139

134140
# This is entry point for joining an existing channel
@@ -161,7 +167,7 @@ Feature: Bootstrap
161167
# Under the covers, create a deployment spec, etc.
162168
And user "dev0Org0" using cert alias "dev0Org0App1" creates a install proposal "installProposal1" for channel "com.acme.blockchain.jdoe.Channel1" using chaincode spec "cc_spec"
163169

164-
And user "dev0Org0" using cert alias "dev0Org0App1" sends proposal "installProposal1" to endorsers with timeout of "30" seconds with proposal responses "installProposalResponses":
170+
And user "dev0Org0" using cert alias "dev0Org0App1" sends proposal "installProposal1" to endorsers with timeout of "90" seconds with proposal responses "installProposalResponses":
165171
| Endorser |
166172
| peer0 |
167173
| peer2 |
@@ -174,7 +180,7 @@ Feature: Bootstrap
174180
# Under the covers, create a deployment spec, etc.
175181
When user "dev0Org0" using cert alias "dev0Org0App1" creates a instantiate proposal "instantiateProposal1" for channel "com.acme.blockchain.jdoe.Channel1" using chaincode spec "cc_spec"
176182

177-
And user "dev0Org0" using cert alias "dev0Org0App1" sends proposal "instantiateProposal1" to endorsers with timeout of "30" seconds with proposal responses "instantiateProposalResponses":
183+
And user "dev0Org0" using cert alias "dev0Org0App1" sends proposal "instantiateProposal1" to endorsers with timeout of "90" seconds with proposal responses "instantiateProposalResponses":
178184
| Endorser |
179185
| peer0 |
180186
| peer2 |
@@ -192,16 +198,16 @@ Feature: Bootstrap
192198

193199
When the user "dev0Org0" creates transaction "instantiateTx1" from proposal "instantiateProposal1" and proposal responses "instantiateProposalResponses" for channel "com.acme.blockchain.jdoe.Channel1"
194200

195-
And the user "dev0Org0" broadcasts transaction "instantiateTx1" to orderer "orderer0" on channel "com.acme.blockchain.jdoe.Channel1"
201+
And the user "dev0Org0" broadcasts transaction "instantiateTx1" to orderer "<orderer1>" on channel "com.acme.blockchain.jdoe.Channel1"
196202

197203
# Sleep as the deliver takes a bit to have the first block ready
198204
And I wait "2" seconds
199205

200-
And user "dev0Org0" sends deliver a seek request on orderer "orderer0" with properties:
206+
And user "dev0Org0" sends deliver a seek request on orderer "<orderer0>" with properties:
201207
| ChainId | Start | End |
202208
| com.acme.blockchain.jdoe.Channel1 | 1 | 1 |
203209

204-
Then user "dev0Org0" should get a delivery "deliveredInstantiateTx1Block" from "orderer0" of "1" blocks with "1" messages within "1" seconds
210+
Then user "dev0Org0" should get a delivery "deliveredInstantiateTx1Block" from "<orderer0>" of "1" blocks with "1" messages within "1" seconds
205211

206212
# Sleep as the deliver takes a bit to have the first block ready
207213
And I wait "1" seconds
@@ -256,20 +262,24 @@ Feature: Bootstrap
256262

257263
When the user "dev0Org0" creates transaction "invokeTx1" from proposal "invokeProposal1" and proposal responses "invokeProposal1Responses" for channel "com.acme.blockchain.jdoe.Channel1"
258264

259-
And the user "dev0Org0" broadcasts transaction "invokeTx1" to orderer "orderer0" on channel "com.acme.blockchain.jdoe.Channel1"
265+
And the user "dev0Org0" broadcasts transaction "invokeTx1" to orderer "<orderer2>" on channel "com.acme.blockchain.jdoe.Channel1"
260266

261267
# Sleep as the deliver takes a bit to have the first block ready
262268
And I wait "2" seconds
263269

264-
And user "dev0Org0" sends deliver a seek request on orderer "orderer0" with properties:
270+
And user "dev0Org0" sends deliver a seek request on orderer "<orderer0>" with properties:
265271
| ChainId | Start | End |
266272
| com.acme.blockchain.jdoe.Channel1 | 2 | 2 |
267273

268-
Then user "dev0Org0" should get a delivery "deliveredInvokeTx1Block" from "orderer0" of "1" blocks with "1" messages within "1" seconds
274+
Then user "dev0Org0" should get a delivery "deliveredInvokeTx1Block" from "<orderer0>" of "1" blocks with "1" messages within "1" seconds
269275

270276

271277
# TODO: Once events are working, consider listen event listener as well.
272278

273279
Examples: Orderer Options
274-
| ComposeFile | Waittime | PolicyType | ConsensusType |
275-
| docker-compose-next-4.yml | 60 | unanimous | solo |
280+
| ComposeFile | SystemUpWaitTime | ConsensusType | BroadcastWaitTime | orderer0 | orderer1 | orderer2 |Orderer Specific Info|
281+
| docker-compose-next-4.yml | 0 | solo | 2 | orderer0 | orderer0 | orderer0 | |
282+
| docker-compose-next-4.yml ./environments/orderer-1-kafka-1/docker-compose.yml orderer-3-kafka-1.yml | 5 | kafka | 5 | orderer0 | orderer1 | orderer2 | |
283+
| docker-compose-next-4.yml docker-compose-next-4-couchdb.yml | 5 | solo | 2 | orderer0 | orderer0 | orderer0 | |
284+
# | docker-compose-next-4.yml docker-compose-next-4-couchdb.yml ./environments/orderer-1-kafka-1/docker-compose.yml orderer-3-kafka-1.yml | 8 | kafka | 5 | orderer0 | orderer1 | orderer2 | |
285+
# | docker-compose-next-4.yml ./environments/orderer-1-kafka-3/docker-compose.yml | 5 | kafka | 5 | orderer0 | orderer1 | orderer2 | |

bddtests/features/endorser.feature

-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
#
44
# Tags that can be used and will affect test internals:
55
# @doNotDecompose will NOT decompose the named compose_yaml after scenario ends. Useful for setting up environment and reviewing after scenario.
6-
# @chaincodeImagesUpToDate use this if all scenarios chaincode images are up to date, and do NOT require building. BE SURE!!!
76

8-
#@chaincodeImagesUpToDate
97
@endorser
108
Feature: Endorser
119
As a application developer

bddtests/orderer-3-kafka-1.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
version: '2'
2+
services:
3+
orderer1:
4+
extends:
5+
service: orderer0
6+
image: hyperledger/fabric-testenv-orderer
7+
environment:
8+
- ORDERER_GENERAL_LOCALMSPDIR=${ORDERER1_ORDERER_GENERAL_LOCALMSPDIR}
9+
- ORDERER_GENERAL_LOCALMSPID=${ORDERER1_ORDERER_GENERAL_LOCALMSPID}
10+
- ORDERER_GENERAL_TLS_PRIVATEKEY=${ORDERER1_ORDERER_GENERAL_TLS_PRIVATEKEY}
11+
- ORDERER_GENERAL_TLS_CERTIFICATE=${ORDERER1_ORDERER_GENERAL_TLS_CERTIFICATE}
12+
- ORDERER_GENERAL_TLS_ROOTCAS=${ORDERER1_ORDERER_GENERAL_TLS_ROOTCAS}
13+
depends_on:
14+
- orderer0
15+
- kafka0
16+
17+
orderer2:
18+
extends:
19+
service: orderer0
20+
image: hyperledger/fabric-testenv-orderer
21+
environment:
22+
- ORDERER_GENERAL_LOCALMSPDIR=${ORDERER2_ORDERER_GENERAL_LOCALMSPDIR}
23+
- ORDERER_GENERAL_LOCALMSPID=${ORDERER2_ORDERER_GENERAL_LOCALMSPID}
24+
- ORDERER_GENERAL_TLS_PRIVATEKEY=${ORDERER2_ORDERER_GENERAL_TLS_PRIVATEKEY}
25+
- ORDERER_GENERAL_TLS_CERTIFICATE=${ORDERER2_ORDERER_GENERAL_TLS_CERTIFICATE}
26+
- ORDERER_GENERAL_TLS_ROOTCAS=${ORDERER2_ORDERER_GENERAL_TLS_ROOTCAS}
27+
depends_on:
28+
- orderer0
29+
- kafka0

bddtests/steps/bootstrap_impl.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ def step_impl(context, certAlias, ordererGenesisBlockName, ordererSystemChainIdN
7777
nodeAdminTuple=nodeAdminTuple,
7878
signedConfigItems=configGroups)
7979
ordererBootstrapAdmin.setTagValue(ordererGenesisBlockName, genesisBlock)
80+
ordererBootstrapAdmin.setTagValue("ConsensusType", consensusType)
8081
bootstrap_util.OrdererGensisBlockCompositionCallback(context, genesisBlock)
8182
bootstrap_util.PeerCompositionCallback(context)
8283

@@ -151,7 +152,10 @@ def step_impl(context, userName, createChannelSignedConfigEnvelope):
151152
signedAnchorsConfigItems = user.tags[anchorSignedConfigItemsName]
152153

153154
# Intermediate step until template tool is ready
154-
channel_config_groups = bootstrap_util.createSignedConfigItems(directory, configGroups=signedMspConfigItems + signedAnchorsConfigItems)
155+
consensus_type = ordererBootstrapAdmin.tags["ConsensusType"]
156+
channel_config_groups = bootstrap_util.createSignedConfigItems(directory=directory,
157+
consensus_type=consensus_type,
158+
configGroups=signedMspConfigItems + signedAnchorsConfigItems)
155159

156160
# bootstrap_util.setMetaPolicy(channelId=channelID, channgel_config_groups=channgel_config_groups)
157161

bddtests/steps/bootstrap_util.py

+13-10
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ def SignedBy(cls, index):
392392

393393
class BootstrapHelper:
394394
KEY_CONSENSUS_TYPE = "ConsensusType"
395+
KEY_ORDERER_KAFKA_BROKERS = "KafkaBrokers"
395396
KEY_CHAIN_CREATION_POLICY_NAMES = "ChainCreationPolicyNames"
396397
KEY_ACCEPT_ALL_POLICY = "AcceptAllPolicy"
397398
KEY_HASHING_ALGORITHM = "HashingAlgorithm"
@@ -517,13 +518,6 @@ def encodeBatchTimeout(self):
517518
value=orderer_dot_configuration_pb2.BatchTimeout(timeout=self.batchTimeout).SerializeToString())
518519
return self.signConfigItem(configItem)
519520

520-
def encodeConsensusType(self):
521-
configItem = self.getConfigItem(
522-
commonConfigType=common_dot_configtx_pb2.ConfigItem.ConfigType.Value("ORDERER"),
523-
key=BootstrapHelper.KEY_CONSENSUS_TYPE,
524-
value=orderer_dot_configuration_pb2.ConsensusType(type=self.consensusType).SerializeToString())
525-
return self.signConfigItem(configItem)
526-
527521
def encodeChainCreators(self, ciValue=orderer_dot_configuration_pb2.ChainCreationPolicyNames(
528522
names=DEFAULT_CHAIN_CREATORS).SerializeToString()):
529523
configItem = self.getConfigItem(
@@ -655,9 +649,11 @@ def getMspConfigItemsForPolicyNames(context, policyNames):
655649
return getSignedMSPConfigItems(context=context, orgNames=orgNamesReferenced)
656650

657651

658-
def createSignedConfigItems(directory, configGroups=[]):
652+
def createSignedConfigItems(directory, consensus_type, configGroups=[]):
659653

660-
channelConfig = createChannelConfigGroup(directory)
654+
channelConfig = createChannelConfigGroup(directory=directory, consensusType=consensus_type)
655+
#TODO: Once jyellicks latest updates come through, will NOT need base orderer config
656+
# channelConfig = common_dot_configtx_pb2.ConfigGroup()
661657
for configGroup in configGroups:
662658
mergeConfigGroups(channelConfig, configGroup)
663659
return channelConfig
@@ -727,6 +723,13 @@ def createChannelConfigGroup(directory, hashingAlgoName="SHA256", consensusType=
727723
channel.groups[OrdererGroup].groups[ordererOrg.name].values[BootstrapHelper.KEY_MSP_INFO].value = toValue(
728724
ordererOrg.getMSPConfig())
729725

726+
# #Kafka specific
727+
# matchingNATs = [nat for nat in directory.getNamedCtxTuples() if (("orderer" in nat.user) and ("Signer" in nat.user) and ((compose_service in nat.nodeName)))]
728+
# for broker in [org for org in directory.getOrganizations().values() if Network.Orderer in org.networks]:
729+
# channel.groups[OrdererGroup].groups[ordererOrg.name].values[BootstrapHelper.KEY_MSP_INFO].value = toValue(
730+
# ordererOrg.getMSPConfig())
731+
channel.groups[OrdererGroup].values[BootstrapHelper.KEY_ORDERER_KAFKA_BROKERS].value = toValue(orderer_dot_configuration_pb2.KafkaBrokers(brokers=["kafka0:9092"]))
732+
730733

731734

732735
# Now set policies for each org group (Both peer and orderer)
@@ -820,7 +823,7 @@ def createGenesisBlock(context, chainId, consensusType, nodeAdminTuple, signedCo
820823
directory = getDirectory(context)
821824
assert len(directory.ordererAdminTuples) > 0, "No orderer admin tuples defined!!!"
822825

823-
channelConfig = createChannelConfigGroup(directory)
826+
channelConfig = createChannelConfigGroup(directory=directory, consensusType=consensusType)
824827
for configGroup in signedConfigItems:
825828
mergeConfigGroups(channelConfig, configGroup)
826829

bddtests/steps/docgen.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def compositionCallCLIAdvice(self, joinpoint):
8080
return result
8181

8282
def _getNetworkGroup(self, serviceName):
83-
groups = {"peer" : 1, "orderer" : 2}
83+
groups = {"peer" : 1, "orderer" : 2, "kafka" : 7, "zookeeper" : 8, "couchdb" : 9}
8484
groupId = 0
8585
for group, id in groups.iteritems():
8686
if serviceName.lower().startswith(group):

bddtests/templates/html/graph.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
</style>
1414
<div>
15-
<svg width="860" height="600"></svg>
15+
<svg width="860" height="700"></svg>
1616
</div>
1717
<script src="https://d3js.org/d3.v4.min.js"></script>
1818
<script>

0 commit comments

Comments
 (0)