Skip to content

Commit

Permalink
[FAB-3754] System Behave Endorser Util scaffolding
Browse files Browse the repository at this point in the history
This contains updates that are necessary for
completing the endorser utility functionality
for the system behave tests.

Change-Id: I236eee47ce5a502c5954ee6780f194bb0cbf34f2
Signed-off-by: Latitia M Haskins <latitia.haskins@gmail.com>
  • Loading branch information
lhaskins committed Jun 1, 2017
1 parent 506cdda commit 022580d
Show file tree
Hide file tree
Showing 4 changed files with 156 additions and 12 deletions.
8 changes: 4 additions & 4 deletions test/feature/peer.feature
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ Scenario Outline: FAB-3505: Test chaincode example02 deploy, invoke, and query
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.org1.example.com" 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"
Then a user receives expected response is 980
Given "peer1.org1.example.com" comes back up
When a user queries on the chaincode named "mycc" with args ["query", "a"] on "peer1.org1.example.com"
Then a user receives expected response of 980
Examples:
| type |
| solo |
Expand Down
4 changes: 2 additions & 2 deletions test/feature/steps/basic_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ def bootstrapped_impl(context, networkType):
config_util.generateConfig(channelID, profile, projectName)
compose_impl(context, context.composeFile, projectName=projectName)

@given(u'{component} is taken down')
@given(u'"{component}" is taken down')
def step_impl(context, component):
assert component in context.composition.collectServiceNames(), "Unknown component '{0}'".format(component)
context.composition.stop([component])

@given(u'{component} comes back up')
@given(u'"{component}" comes back up')
def step_impl(context, component):
assert component in context.composition.collectServiceNames(), "Unknown component '{0}'".format(component)
context.composition.start([component])
84 changes: 84 additions & 0 deletions test/feature/steps/endorser_util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# 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.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import os
import sys
import subprocess

try:
pbFilePath = "../../bddtests"
sys.path.insert(0, pbFilePath)
from common import common_pb2
from peer import chaincode_pb2
from peer import proposal_pb2
from peer import transaction_pb2
except:
print("ERROR! Unable to import the protobuf libraries from the hyperledger/fabric/bddtests directory: {0}".format(sys.exc_info()[0]))
sys.exit(1)


# The default channel ID
TEST_CHANNEL_ID = "behavesystest"


def get_chaincode_deploy_spec(projectDir, ccType, path, name, args):
pass

def install_chaincode(context, chaincode, containers):
pass

def instantiate_chaincode(context, chaincode, containers):
pass

def create_channel(context, containers, orderers, channelId=TEST_CHANNEL_ID):
pass

def join_channel(context, peers, orderers, channelId=TEST_CHANNEL_ID):
pass

def invoke_chaincode(context, chaincode, orderers, containers, channelId=TEST_CHANNEL_ID):
pass

def query_chaincode(context, chaincode, containers, channelId=TEST_CHANNEL_ID):
pass

def get_orderers(context):
orderers = []
for container in context.composition.collectServiceNames():
if container.startswith("orderer"):
orderers.append(container)
return orderers


def get_peers(context):
peers = []
for container in context.composition.collectServiceNames():
if container.startswith("peer"):
peers.append(container)
return peers


def deploy_chaincode(context, chaincode, containers, channelId=TEST_CHANNEL_ID):
for container in containers:
assert container in context.composition.collectServiceNames(), "Unknown component '{0}'".format(container)

orderers = get_orderers(context)
peers = get_peers(context)
assert orderers != [], "There are no active orderers in this network"

create_channel(context, containers, orderers, channelId)
join_channel(context, peers, orderers, channelId)
install_chaincode(context, chaincode, containers)
instantiate_chaincode(context, chaincode, containers)
72 changes: 66 additions & 6 deletions test/feature/steps/orderer_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,30 @@ def step_impl(context, networkType):
def compose_impl(context, dockerFile):
pass

@given(u'an orderer connected to the kafka cluster')
def step_impl(context):
pass

@given(u'the orderer Batchsize MaxMessageCount is {maxMsgCount}')
def step_impl(context, maxMsgCount):
pass

@given(u'the orderer BatchTimeout is {timeout} {units}')
def step_impl(context, timeout, units):
pass

@given(u'a certificate from {organization} is added to the kafka orderer network')
def step_impl(context, organization):
pass

@given(u'the kafka default replication factor is {factor}')
def step_impl(context, factor):
pass

@given(u'a kafka cluster')
def step_impl(context):
pass

@when(u'a message is broadcasted')
def step_impl(context):
broadcast_impl(context, 1)
Expand All @@ -44,12 +68,36 @@ def step_impl(context):
def broadcast_impl(context, count):
pass

@when(u'the topic partition leader is stopped')
def step_impl(context):
pass

@when(u'a new organization {organization} certificate is added')
def step_impl(context, organization):
pass

@when(u'authorization for {organization} is removed from the kafka cluster')
def step_impl(context, organization):
pass

@when(u'authorization for {organization} is added to the kafka cluster')
def step_impl(context, organization):
pass

@then(u'the broadcasted message is delivered')
def step_impl(context):
verify_deliver_impl(context, 1, 1)

@then(u'all {count} messages are delivered in {numBlocks} block')
def step_impl(context, count, numBlocks):
verify_deliver_impl(context, count, numBlocks)

@then(u'all {count} messages are delivered within {timeout} seconds')
def step_impl(context, count, timeout):
pass
verify_deliver_impl(context, count, None, timeout)

@then(u'all {count} messages are delivered in {numBlocks} within {timeout} seconds')
def step_impl(context, count, numBlocks, timeout):
def verify_deliver_impl(context, count, numBlocks, timeout=60):
pass

@then(u'we get a successful broadcast response')
Expand All @@ -60,11 +108,23 @@ def step_impl(context):
def recv_broadcast_impl(context, count):
pass

@then(u'the broadcasted message is delivered')
@then(u'the {organization} cannot connect to the kafka cluster')
def step_impl(context, organization):
pass

@then(u'the {organization} is able to connect to the kafka cluster')
def step_impl(context, organization):
pass

@then(u'the zookeeper notifies the orderer of the disconnect')
def step_impl(context):
verify_deliver_impl(context, 1, 1)
pass

@then(u'all {count} messages are delivered in {numBlocks} block')
def verify_deliver_impl(context, count, numBlocks):
@then(u'the orderer functions successfully')
def step_impl(context):
# Check the logs for certain key info - be sure there are no errors in the logs
pass

@then(u'the orderer stops sending messages to the cluster')
def step_impl(context):
pass

0 comments on commit 022580d

Please sign in to comment.