Skip to content

Commit

Permalink
[FAB-1141] Added bootstrap feature.
Browse files Browse the repository at this point in the history
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 <garratt.jeff@gmail.com>
  • Loading branch information
jeffgarratt committed Dec 16, 2016
1 parent 0698fc7 commit a94a42b
Show file tree
Hide file tree
Showing 17 changed files with 1,153 additions and 208 deletions.
30 changes: 30 additions & 0 deletions bddtests/bddtests_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package bddtests

import "github.com/DATA-DOG/godog"

func FeatureContext(s *godog.Suite) {
bddCtx := &BDDContext{godogSuite: s, users: make(map[string]*UserRegistration), grpcClientPort: 7051}

s.BeforeScenario(bddCtx.beforeScenario)
s.AfterScenario(bddCtx.afterScenarioDecompose)

FeatureContextBootstrap(bddCtx, s)

s.Step(`^we compose "([^"]*)"$`, bddCtx.weCompose)
s.Step(`^requesting "([^"]*)" from "([^"]*)"$`, bddCtx.requestingFrom)
s.Step(`^I should get a JSON response with array "([^"]*)" contains "([^"]*)" elements$`, bddCtx.iShouldGetAJSONResponseWithArrayContainsElements)
s.Step(`^I wait "([^"]*)" seconds$`, bddCtx.iWaitSeconds)
s.Step(`^I register with CA supplying username "([^"]*)" and secret "([^"]*)" on peers:$`, bddCtx.iRegisterWithCASupplyingUsernameAndSecretOnPeers)
s.Step(`^user "([^"]*)" creates a chaincode spec "([^"]*)" of type "([^"]*)" for chaincode "([^"]*)" with args$`, bddCtx.userCreatesAChaincodeSpecOfTypeForChaincodeWithArgs)

s.Step(`^user "([^"]*)" creates a deployment spec "([^"]*)" using chaincode spec "([^"]*)" and devops on peer "([^"]*)"$`, bddCtx.userCreatesADeploymentSpecUsingChaincodeSpecAndDevopsOnPeer)
//s.Step(`^user "([^"]*)" creates a deployment spec "([^"]*)" using chaincode spec "([^"]*)"$`, bddCtx.userCreatesADeploymentSpecUsingChaincodeSpec)

s.Step(`^user "([^"]*)" creates a deployment proposal "([^"]*)" using chaincode deployment spec "([^"]*)"$`, bddCtx.userCreatesADeploymentProposalUsingChaincodeDeploymentSpec)
s.Step(`^user "([^"]*)" sends proposal "([^"]*)" to endorsers with timeout of "([^"]*)" seconds:$`, bddCtx.userSendsProposalToEndorsersWithTimeoutOfSeconds)
s.Step(`^user "([^"]*)" stores their last result as "([^"]*)"$`, bddCtx.userStoresTheirLastResultAs)
s.Step(`^user "([^"]*)" expects proposal responses "([^"]*)" with status "([^"]*)" from endorsers:$`, bddCtx.userExpectsProposalResponsesWithStatusFromEndorsers)
s.Step(`^user "([^"]*)" sets ESCC to "([^"]*)" for chaincode spec "([^"]*)"$`, bddCtx.userSetsESCCToForChaincodeSpec)
s.Step(`^user "([^"]*)" sets VSCC to "([^"]*)" for chaincode spec "([^"]*)"$`, bddCtx.userSetsVSCCToForChaincodeSpec)
}

70 changes: 42 additions & 28 deletions bddtests/common/common_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 48 additions & 9 deletions bddtests/common/configuration_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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

# Use these options if coverage desired for peers
#image: hyperledger/fabric-peer-coverage
#command: ./peer.test --test.coverprofile=coverage.cov node start
membersrvc:
image: hyperledger/fabric-membersrvc
command: membersrvc
services:

vp:
image: hyperledger/fabric-peer
environment:
- CORE_PEER_ADDRESSAUTODETECT=true
- CORE_VM_ENDPOINT=http://172.17.0.1:2375
# TODO: This is currently required due to BUG in variant logic based upon log level.
- CORE_LOGGING_LEVEL=DEBUG
- CORE_PEER_NETWORKID=${CORE_PEER_NETWORKID}
# Script will wait until membersrvc is up (if it exists) before starting
# $$GOPATH (double dollar) required to prevent docker-compose doing its own
# substitution before the value gets to the container
#command: sh -c "exec $$GOPATH/src/github.com/hyperledger/fabric/bddtests/scripts/start-peer.sh"
command: sh -c "sleep 2; peer node start"

# Use these options if coverage desired for peers
#image: hyperledger/fabric-peer-coverage
#command: ./peer.test --test.coverprofile=coverage.cov node start
membersrvc:
image: hyperledger/fabric-membersrvc
command: membersrvc
38 changes: 38 additions & 0 deletions bddtests/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (

"github.com/DATA-DOG/godog"
"github.com/DATA-DOG/godog/gherkin"
"github.com/hyperledger/fabric/core/util"
)

// BDDContext represents the current context for the executing scenario. Commensurate concept of 'context' from behave testing.
Expand Down Expand Up @@ -88,3 +89,40 @@ func (b *BDDContext) GetArgsForUser(cells []*gherkin.TableCell, userRegistration
}
return args, nil
}

func (b *BDDContext) weCompose(composeFiles string) error {
if b.composition != nil {
return fmt.Errorf("Already have composition in BDD context (%s)", b.composition.projectName)
}
// Need a unique name, but docker does not allow '-' in names
composeProjectName := strings.Replace(util.GenerateUUID(), "-", "", -1)
newComposition, err := NewComposition(composeProjectName, composeFiles)
if err != nil {
return fmt.Errorf("Error composing system in BDD context: %s", err)
}
b.composition = newComposition
return nil
}

func (b *BDDContext) beforeScenario(scenarioOrScenarioOutline interface{}) {
b.scenarioOrScenarioOutline = scenarioOrScenarioOutline
//switch t := scenarioOrScenarioOutline.(type) {
//case *gherkin.Scenario:
// fmt.Printf("Scenario recieved %v", t)
//case *gherkin.ScenarioOutline:
// fmt.Printf("ScenarioOutline recieved %v", t)
//}
}

func (b *BDDContext) afterScenarioDecompose(interface{}, error) {
if b.hasTag("@doNotDecompose") == true {
fmt.Printf("Not decomposing: %s", b.getScenarioDefinition().Name)
} else {
if b.composition != nil {
b.composition.Decompose()
}
}
// Now clear the users
b.composition = nil
b.users = make(map[string]*UserRegistration)
}
Loading

0 comments on commit a94a42b

Please sign in to comment.