Skip to content

Commit a94a42b

Browse files
committed
[FAB-1141] Added bootstrap feature.
Refactored golang bdd, clearer modularity. Added new bootstrap feature file to demonstrate orderer network boostrap. Will complete as Peer nears completion. Now creates geneisis block. Waiting to verify with solo orderer. Updated compose files to version 2. Added composition callback mechanism for orderer genesis block distribution. Change-Id: I7d963719b60ebe8db4bb81a470b17a7573d2e199 Signed-off-by: jeffgarratt <[email protected]>
1 parent 0698fc7 commit a94a42b

17 files changed

+1153
-208
lines changed

bddtests/bddtests_test.go

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package bddtests
2+
3+
import "github.com/DATA-DOG/godog"
4+
5+
func FeatureContext(s *godog.Suite) {
6+
bddCtx := &BDDContext{godogSuite: s, users: make(map[string]*UserRegistration), grpcClientPort: 7051}
7+
8+
s.BeforeScenario(bddCtx.beforeScenario)
9+
s.AfterScenario(bddCtx.afterScenarioDecompose)
10+
11+
FeatureContextBootstrap(bddCtx, s)
12+
13+
s.Step(`^we compose "([^"]*)"$`, bddCtx.weCompose)
14+
s.Step(`^requesting "([^"]*)" from "([^"]*)"$`, bddCtx.requestingFrom)
15+
s.Step(`^I should get a JSON response with array "([^"]*)" contains "([^"]*)" elements$`, bddCtx.iShouldGetAJSONResponseWithArrayContainsElements)
16+
s.Step(`^I wait "([^"]*)" seconds$`, bddCtx.iWaitSeconds)
17+
s.Step(`^I register with CA supplying username "([^"]*)" and secret "([^"]*)" on peers:$`, bddCtx.iRegisterWithCASupplyingUsernameAndSecretOnPeers)
18+
s.Step(`^user "([^"]*)" creates a chaincode spec "([^"]*)" of type "([^"]*)" for chaincode "([^"]*)" with args$`, bddCtx.userCreatesAChaincodeSpecOfTypeForChaincodeWithArgs)
19+
20+
s.Step(`^user "([^"]*)" creates a deployment spec "([^"]*)" using chaincode spec "([^"]*)" and devops on peer "([^"]*)"$`, bddCtx.userCreatesADeploymentSpecUsingChaincodeSpecAndDevopsOnPeer)
21+
//s.Step(`^user "([^"]*)" creates a deployment spec "([^"]*)" using chaincode spec "([^"]*)"$`, bddCtx.userCreatesADeploymentSpecUsingChaincodeSpec)
22+
23+
s.Step(`^user "([^"]*)" creates a deployment proposal "([^"]*)" using chaincode deployment spec "([^"]*)"$`, bddCtx.userCreatesADeploymentProposalUsingChaincodeDeploymentSpec)
24+
s.Step(`^user "([^"]*)" sends proposal "([^"]*)" to endorsers with timeout of "([^"]*)" seconds:$`, bddCtx.userSendsProposalToEndorsersWithTimeoutOfSeconds)
25+
s.Step(`^user "([^"]*)" stores their last result as "([^"]*)"$`, bddCtx.userStoresTheirLastResultAs)
26+
s.Step(`^user "([^"]*)" expects proposal responses "([^"]*)" with status "([^"]*)" from endorsers:$`, bddCtx.userExpectsProposalResponsesWithStatusFromEndorsers)
27+
s.Step(`^user "([^"]*)" sets ESCC to "([^"]*)" for chaincode spec "([^"]*)"$`, bddCtx.userSetsESCCToForChaincodeSpec)
28+
s.Step(`^user "([^"]*)" sets VSCC to "([^"]*)" for chaincode spec "([^"]*)"$`, bddCtx.userSetsVSCCToForChaincodeSpec)
29+
}
30+

bddtests/common/common_pb2.py

+42-28
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bddtests/common/configuration_pb2.py

+48-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bddtests/compose-defaults.yml

+23-19
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
1-
vp:
2-
image: hyperledger/fabric-peer
3-
environment:
4-
- CORE_PEER_ADDRESSAUTODETECT=true
5-
- CORE_VM_ENDPOINT=http://172.17.0.1:2375
6-
# TODO: This is currently required due to BUG in variant logic based upon log level.
7-
- CORE_LOGGING_LEVEL=DEBUG
8-
- CORE_PEER_NETWORKID=${CORE_PEER_NETWORKID}
9-
# Script will wait until membersrvc is up (if it exists) before starting
10-
# $$GOPATH (double dollar) required to prevent docker-compose doing its own
11-
# substitution before the value gets to the container
12-
#command: sh -c "exec $$GOPATH/src/github.com/hyperledger/fabric/bddtests/scripts/start-peer.sh"
13-
command: sh -c "sleep 2; peer node start"
1+
version: "2"
142

15-
# Use these options if coverage desired for peers
16-
#image: hyperledger/fabric-peer-coverage
17-
#command: ./peer.test --test.coverprofile=coverage.cov node start
18-
membersrvc:
19-
image: hyperledger/fabric-membersrvc
20-
command: membersrvc
3+
services:
4+
5+
vp:
6+
image: hyperledger/fabric-peer
7+
environment:
8+
- CORE_PEER_ADDRESSAUTODETECT=true
9+
- CORE_VM_ENDPOINT=http://172.17.0.1:2375
10+
# TODO: This is currently required due to BUG in variant logic based upon log level.
11+
- CORE_LOGGING_LEVEL=DEBUG
12+
- CORE_PEER_NETWORKID=${CORE_PEER_NETWORKID}
13+
# Script will wait until membersrvc is up (if it exists) before starting
14+
# $$GOPATH (double dollar) required to prevent docker-compose doing its own
15+
# substitution before the value gets to the container
16+
#command: sh -c "exec $$GOPATH/src/github.com/hyperledger/fabric/bddtests/scripts/start-peer.sh"
17+
command: sh -c "sleep 2; peer node start"
18+
19+
# Use these options if coverage desired for peers
20+
#image: hyperledger/fabric-peer-coverage
21+
#command: ./peer.test --test.coverprofile=coverage.cov node start
22+
membersrvc:
23+
image: hyperledger/fabric-membersrvc
24+
command: membersrvc

bddtests/context.go

+38
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323

2424
"github.com/DATA-DOG/godog"
2525
"github.com/DATA-DOG/godog/gherkin"
26+
"github.com/hyperledger/fabric/core/util"
2627
)
2728

2829
// BDDContext represents the current context for the executing scenario. Commensurate concept of 'context' from behave testing.
@@ -88,3 +89,40 @@ func (b *BDDContext) GetArgsForUser(cells []*gherkin.TableCell, userRegistration
8889
}
8990
return args, nil
9091
}
92+
93+
func (b *BDDContext) weCompose(composeFiles string) error {
94+
if b.composition != nil {
95+
return fmt.Errorf("Already have composition in BDD context (%s)", b.composition.projectName)
96+
}
97+
// Need a unique name, but docker does not allow '-' in names
98+
composeProjectName := strings.Replace(util.GenerateUUID(), "-", "", -1)
99+
newComposition, err := NewComposition(composeProjectName, composeFiles)
100+
if err != nil {
101+
return fmt.Errorf("Error composing system in BDD context: %s", err)
102+
}
103+
b.composition = newComposition
104+
return nil
105+
}
106+
107+
func (b *BDDContext) beforeScenario(scenarioOrScenarioOutline interface{}) {
108+
b.scenarioOrScenarioOutline = scenarioOrScenarioOutline
109+
//switch t := scenarioOrScenarioOutline.(type) {
110+
//case *gherkin.Scenario:
111+
// fmt.Printf("Scenario recieved %v", t)
112+
//case *gherkin.ScenarioOutline:
113+
// fmt.Printf("ScenarioOutline recieved %v", t)
114+
//}
115+
}
116+
117+
func (b *BDDContext) afterScenarioDecompose(interface{}, error) {
118+
if b.hasTag("@doNotDecompose") == true {
119+
fmt.Printf("Not decomposing: %s", b.getScenarioDefinition().Name)
120+
} else {
121+
if b.composition != nil {
122+
b.composition.Decompose()
123+
}
124+
}
125+
// Now clear the users
126+
b.composition = nil
127+
b.users = make(map[string]*UserRegistration)
128+
}

0 commit comments

Comments
 (0)