Skip to content

Commit

Permalink
[FAB-1017] Fix due to code changes
Browse files Browse the repository at this point in the history
This updates some files with more scaffolding and
config changes for moving forward with the behave
system and functional tests. There is also some
cleanup to a feature file.

Change-Id: I06705387bacb23772b4c25fde8dcca040cd1055d
Signed-off-by: Latitia M Haskins <latitia.haskins@gmail.com>
  • Loading branch information
lhaskins committed May 18, 2017
1 parent e7d70a8 commit ba7c1cd
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 47 deletions.
69 changes: 54 additions & 15 deletions test/feature/configs/configtx.yaml
@@ -1,22 +1,28 @@
---
################################################################################
#
# Profile
# Profiles
#
# - Different configuration profiles may be encoded here to be specified
# as parameters to the configtxgen tool.
# as parameters to the configtxgen tool. The profiles which specify consortiums
# are to be used for generating the orderer genesis block. With the correct
# consortium members defined in the orderer genesis block, channel creation
# requests may be generated with only the org member names and a consortium name
#
################################################################################
Profiles:

# SampleInsecureSolo defines a configuration which uses the Solo orderer,
# contains no MSP definitions, and allows all transactions and channel
# creation requests.
# creation requests for the consortium SampleConsortium.
SampleInsecureSolo:
Orderer:
<<: *OrdererDefaults
Application:
<<: *ApplicationDefaults
Consortiums:
SampleConsortium:
Organizations:

# SampleInsecureKafka defines a configuration that differs from the
# SampleInsecureSolo one only in that is uses the Kafka-based orderer.
Expand All @@ -26,9 +32,13 @@ Profiles:
OrdererType: kafka
Application:
<<: *ApplicationDefaults
Consortiums:
SampleConsortium:
Organizations:

# SampleSingleMSPSolo defines a configuration which uses the Solo orderer,
# and contains a single MSP definition (the MSP sampleconfig).
# The Consortium SampleConsortium has only a single member, SampleOrg
SampleSingleMSPSolo:
Orderer:
<<: *OrdererDefaults
Expand All @@ -38,6 +48,26 @@ Profiles:
<<: *ApplicationDefaults
Organizations:
- *SampleOrg
Consortiums:
SampleConsortium:
Organizations:
- *SampleOrg

# SampleEmptyInsecureChannel defines a channel with no members
# and therefore no access control
SampleEmptyInsecureChannel:
Consortium: SampleConsortium
Application:
Organizations:

# SampleSingleMSPChannel defines a channel with only the sample org as a
# member. It is designed to be used in conjunction with SampleSingleMSPSolo
# and SampleSingleMSPKafka orderer profiles
SampleSingleMSPChannel:
Consortium: SampleConsortium
Application:
Organizations:
- *SampleOrg

################################################################################
#
Expand All @@ -60,27 +90,34 @@ Organizations:
ID: DEFAULT

# MSPDir is the filesystem path which contains the MSP configuration.
MSPDir: msp/sampleconfig
MSPDir: msp

# AdminPrincipal dictates the type of principal used for an
# organization's Admins policy. Today, only the values of Role.ADMIN and
# Role.MEMBER are accepted, which indicates a principal of role type
# ADMIN and role type MEMBER respectively.
AdminPrincipal: Role.ADMIN

# BCCSP: Select which crypto implementation or library to use for the
# blockchain crypto service provider.
BCCSP:
Default: SW
SW:
# TODO: The default Hash and Security level needs refactoring to be
# fully configurable. Changing these defaults requires coordination
# SHA2 is hardcoded in several places, not only BCCSP
# TODO: The default Hash and Security level needs refactoring to
# be fully configurable. Changing these defaults requires
# coordination SHA2 is hardcoded in several places, not only
# BCCSP.
Hash: SHA2
Security: 256
# Location of key store. If this is unset, a location will
# be chosen using: 'MSPDir'/keystore
# Location of key store. If this is unset, a location will be
# chosen using: 'MSPDir'/keystore
FileKeyStore:
KeyStore:

AnchorPeers:
# AnchorPeers defines the location of peers which can be used
# for cross org gossip communication. Note, this value is only
# encoded in the genesis block in the Application section context.
# AnchorPeers defines the location of peers which can be used for
# cross-org gossip communication. Note, this value is only encoded
# in the genesis block in the Application section context.
- Host: 127.0.0.1
Port: 7051

Expand Down Expand Up @@ -112,7 +149,9 @@ Orderer: &OrdererDefaults
MaxMessageCount: 10

# Absolute Max Bytes: The absolute maximum number of bytes allowed for
# the serialized messages in a batch.
# the serialized messages in a batch. If the "kafka" OrdererType is
# selected, set 'message.max.bytes' and 'replica.fetch.max.bytes' on the
# Kafka brokers to a value that is equal to or larger than this one.
AbsoluteMaxBytes: 99 MB

# Preferred Max Bytes: The preferred maximum number of bytes allowed for
Expand All @@ -121,8 +160,8 @@ Orderer: &OrdererDefaults
# bytes.
PreferredMaxBytes: 512 KB

# Max Channels is the maximum number of channels to allow on the ordering network
# When set to 0, this implies no maximum number of channels
# Max Channels is the maximum number of channels to allow on the ordering
# network. When set to 0, this implies no maximum number of channels.
MaxChannels: 0

Kafka:
Expand Down
12 changes: 6 additions & 6 deletions test/feature/peer.feature
Expand Up @@ -22,16 +22,16 @@ Scenario Outline: FAB-3505: Test chaincode example02 deploy, invoke, and query
When a user deploys chaincode at path "github.com/hyperledger/fabric/chaincode_example02" with ["init", "a", "1000" , "b", "2000"] with name "mycc"
Then the chaincode is deployed
When a user queries on the chaincode named "mycc" with args ["query", "a"]
Then a user receives expected response is 1000
Then a user receives expected response of 1000
When a user invokes on the chaincode named "mycc" with args ["txId1", "invoke", "a", 10]
When a user queries on the chaincode named "mycc" with args ["query", "a"]
Then a user receives expected response is 990
And a user queries on the chaincode named "mycc" with args ["query", "a"]
Then a user receives expected response of 990

Given "Peer1" is taken down
Given "peer1" is taken down
When a user invokes on the chaincode named "mycc" with args ["txId1", "invoke", "a", 10]
And I wait "15" seconds
And "Peer1" comes back up
When a user queries on the chaincode named "mycc" with args ["query", "a"] on "Peer1"
And "peer1" comes back up
When a user queries on the chaincode named "mycc" with args ["query", "a"] on "peer1"
Then a user receives expected response is 980
Examples:
| type |
Expand Down
30 changes: 26 additions & 4 deletions test/feature/steps/basic_impl.py
@@ -1,4 +1,4 @@
# Copyright IBM Corp. 2016 All Rights Reserved.
# Copyright IBM Corp. 2017 All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -16,16 +16,38 @@
from behave import *
import time


ORDERER_TYPES = ["solo",
"kafka",
"solo-msp"]

PROFILE_TYPES = {"solo": "SampleInsecureSolo",
"kafka": "SampleInsecureKafka",
"solo-msp": "SampleSingleMSPSolo"}


@given(u'I wait "{seconds}" seconds')
@when(u'I wait "{seconds}" seconds')
@then(u'I wait "{seconds}" seconds')
def step_impl(context, seconds):
time.sleep(float(seconds))

@given(u'I have a bootstrapped fabric network of')
@given(u'we compose "{composeYamlFile}"')
def compose_impl(context, composeYamlFile):
pass

@given(u'I have a bootstrapped fabric network')
def step_impl(context):
bootstrapped_impl(context, "solo")

@given(u'I have a bootstrapped fabric network of type {type}')
def bootstrapped_impl(context, type):
@given(u'I have a bootstrapped fabric network of type {networkType}')
def bootstrapped_impl(context, networkType):
pass

@given(u'{component} is taken down')
def step_impl(context, component):
pass

@given(u'{component} comes back up')
def step_impl(context, component):
pass
2 changes: 1 addition & 1 deletion test/feature/steps/compose_util.py
@@ -1,4 +1,4 @@
# Copyright IBM Corp. 2016 All Rights Reserved.
# Copyright IBM Corp. 2017 All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
23 changes: 17 additions & 6 deletions test/feature/steps/endorser_impl.py
@@ -1,4 +1,4 @@
# Copyright IBM Corp. 2016 All Rights Reserved.
# Copyright IBM Corp. 2017 All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -32,13 +32,21 @@ def step_impl(context):
["init", "a", "100" , "b", "200"],
"mycc")

@when(u'a user queries on the chaincode named {name}')
def query_impl(context, name):
@when(u'a user queries on the chaincode named {name} with args {args} on {component}')
def query_impl(context, name, args, component):
pass

@when(u'a user queries on the chaincode named {name} with args {args}')
def step_impl(context, name, args):
query_impl(context, name, json.loads(args), "peer0")

@when(u'a user queries on the chaincode named {name}')
def step_impl(context, name):
query_impl(context, name, ["query", "a"], "peer0")

@when(u'a user queries on the chaincode')
def step_impl(context):
query_impl(context, "mycc")
query_impl(context, "mycc", ["query", "a"], "peer0")

@when(u'a user invokes {count} times on the chaincode named {name} with args {args}')
def invokes_impl(context, count, name, args):
Expand All @@ -64,7 +72,10 @@ def step_impl(context):
def step_impl(context):
pass

@then(u'a user receives expected response')
def step_impl(context):
@then(u'a user receives expected response of {response}')
def expected_impl(context, response):
pass

@then(u'a user receives expected response')
def step_impl(context):
expected_impl(context, 1000)
@@ -1,4 +1,4 @@
# Copyright IBM Corp. 2016 All Rights Reserved.
# Copyright IBM Corp. 2017 All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -27,16 +27,6 @@
"kafka": "SampleInsecureKafka",
"solo-msp": "SampleSingleMSPSolo"}

@given(u'I wait "{seconds}" seconds')
@when(u'I wait "{seconds}" seconds')
@then(u'I wait "{seconds}" seconds')
def step_impl(context, seconds):
time.sleep(float(seconds))


@given(u'we compose "{composeYamlFile}"')
def step_impl(context, composeYamlFile):
pass

@given(u'a bootstrapped orderer network of type {networkType}')
def step_impl(context, networkType):
Expand Down
@@ -1,4 +1,4 @@
# Copyright IBM Corp. 2016 All Rights Reserved.
# Copyright IBM Corp. 2017 All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -18,11 +18,11 @@
import datetime

try:
pbFilePath = os.environ['GOPATH'] + "/src/github.com/hyperledger/fabric/bddtests"
pbFilePath = "../../bddtests"
sys.path.insert(0, pbFilePath)
from common import common_pb2
except:
print "ERROR! Unable to import the protobuf libraries from the hyperledger/fabric/bddtests directory: {0}".format(sys.exc_info()[0])
print("ERROR! Unable to import the protobuf libraries from the hyperledger/fabric/bddtests directory: {0}".format(sys.exc_info()[0]))
sys.exit(1)


Expand All @@ -36,7 +36,7 @@ def _testAccessPBMethods():
header = common_pb2.Header(channel_header=channel_header.SerializeToString(),
signature_header=common_pb2.SignatureHeader().SerializeToString())
payload = common_pb2.Payload(header=header,
data="Functional test: {0}".format(datetime.datetime.utcnow()))
data=str.encode("Functional test: {0}".format(datetime.datetime.utcnow())) )
envelope = common_pb2.Envelope(payload=payload.SerializeToString())
return envelope

Expand Down

0 comments on commit ba7c1cd

Please sign in to comment.