From ba7c1cd8bdefc3b47dc8f57d274d71943c79d337 Mon Sep 17 00:00:00 2001 From: Latitia M Haskins Date: Mon, 1 May 2017 17:14:17 -0400 Subject: [PATCH] [FAB-1017] Fix due to code changes 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 --- test/feature/configs/configtx.yaml | 69 +++++++++++++++---- test/feature/peer.feature | 12 ++-- test/feature/steps/basic_impl.py | 30 ++++++-- test/feature/steps/compose_util.py | 2 +- test/feature/steps/endorser_impl.py | 23 +++++-- .../orderer_impl.py} | 12 +--- test/feature/{ft => }/steps/orderer_util.py | 8 +-- 7 files changed, 109 insertions(+), 47 deletions(-) rename test/feature/{ft/steps/orderer_at_impl.py => steps/orderer_impl.py} (86%) rename test/feature/{ft => }/steps/orderer_util.py (83%) diff --git a/test/feature/configs/configtx.yaml b/test/feature/configs/configtx.yaml index 6e612b1865c..a965b0d734a 100644 --- a/test/feature/configs/configtx.yaml +++ b/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. @@ -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 @@ -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 ################################################################################ # @@ -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 @@ -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 @@ -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: diff --git a/test/feature/peer.feature b/test/feature/peer.feature index b6b78cb2642..7cd0054d8e7 100644 --- a/test/feature/peer.feature +++ b/test/feature/peer.feature @@ -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 | diff --git a/test/feature/steps/basic_impl.py b/test/feature/steps/basic_impl.py index d32f80d0125..67a45b699a7 100644 --- a/test/feature/steps/basic_impl.py +++ b/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. @@ -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 diff --git a/test/feature/steps/compose_util.py b/test/feature/steps/compose_util.py index a1b8381c656..1a05478a43e 100644 --- a/test/feature/steps/compose_util.py +++ b/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. diff --git a/test/feature/steps/endorser_impl.py b/test/feature/steps/endorser_impl.py index 3120bbc4615..03bb206ce36 100644 --- a/test/feature/steps/endorser_impl.py +++ b/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. @@ -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): @@ -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) diff --git a/test/feature/ft/steps/orderer_at_impl.py b/test/feature/steps/orderer_impl.py similarity index 86% rename from test/feature/ft/steps/orderer_at_impl.py rename to test/feature/steps/orderer_impl.py index 23290b58570..ed51dc691b9 100644 --- a/test/feature/ft/steps/orderer_at_impl.py +++ b/test/feature/steps/orderer_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. @@ -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): diff --git a/test/feature/ft/steps/orderer_util.py b/test/feature/steps/orderer_util.py similarity index 83% rename from test/feature/ft/steps/orderer_util.py rename to test/feature/steps/orderer_util.py index ccfbd9fde19..5658e417a2e 100644 --- a/test/feature/ft/steps/orderer_util.py +++ b/test/feature/steps/orderer_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. @@ -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) @@ -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