Skip to content

Commit 022580d

Browse files
committed
[FAB-3754] System Behave Endorser Util scaffolding
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 <[email protected]>
1 parent 506cdda commit 022580d

File tree

4 files changed

+156
-12
lines changed

4 files changed

+156
-12
lines changed

test/feature/peer.feature

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ Scenario Outline: FAB-3505: Test chaincode example02 deploy, invoke, and query
2727
And a user queries on the chaincode named "mycc" with args ["query", "a"]
2828
Then a user receives expected response of 990
2929

30-
Given "peer1" is taken down
30+
Given "peer1.org1.example.com" is taken down
3131
When a user invokes on the chaincode named "mycc" with args ["txId1", "invoke", "a", 10]
3232
And I wait "15" seconds
33-
And "peer1" comes back up
34-
When a user queries on the chaincode named "mycc" with args ["query", "a"] on "peer1"
35-
Then a user receives expected response is 980
33+
Given "peer1.org1.example.com" comes back up
34+
When a user queries on the chaincode named "mycc" with args ["query", "a"] on "peer1.org1.example.com"
35+
Then a user receives expected response of 980
3636
Examples:
3737
| type |
3838
| solo |

test/feature/steps/basic_impl.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ def bootstrapped_impl(context, networkType):
6262
config_util.generateConfig(channelID, profile, projectName)
6363
compose_impl(context, context.composeFile, projectName=projectName)
6464

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

70-
@given(u'{component} comes back up')
70+
@given(u'"{component}" comes back up')
7171
def step_impl(context, component):
7272
assert component in context.composition.collectServiceNames(), "Unknown component '{0}'".format(component)
7373
context.composition.start([component])

test/feature/steps/endorser_util.py

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Copyright IBM Corp. 2017 All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
16+
import os
17+
import sys
18+
import subprocess
19+
20+
try:
21+
pbFilePath = "../../bddtests"
22+
sys.path.insert(0, pbFilePath)
23+
from common import common_pb2
24+
from peer import chaincode_pb2
25+
from peer import proposal_pb2
26+
from peer import transaction_pb2
27+
except:
28+
print("ERROR! Unable to import the protobuf libraries from the hyperledger/fabric/bddtests directory: {0}".format(sys.exc_info()[0]))
29+
sys.exit(1)
30+
31+
32+
# The default channel ID
33+
TEST_CHANNEL_ID = "behavesystest"
34+
35+
36+
def get_chaincode_deploy_spec(projectDir, ccType, path, name, args):
37+
pass
38+
39+
def install_chaincode(context, chaincode, containers):
40+
pass
41+
42+
def instantiate_chaincode(context, chaincode, containers):
43+
pass
44+
45+
def create_channel(context, containers, orderers, channelId=TEST_CHANNEL_ID):
46+
pass
47+
48+
def join_channel(context, peers, orderers, channelId=TEST_CHANNEL_ID):
49+
pass
50+
51+
def invoke_chaincode(context, chaincode, orderers, containers, channelId=TEST_CHANNEL_ID):
52+
pass
53+
54+
def query_chaincode(context, chaincode, containers, channelId=TEST_CHANNEL_ID):
55+
pass
56+
57+
def get_orderers(context):
58+
orderers = []
59+
for container in context.composition.collectServiceNames():
60+
if container.startswith("orderer"):
61+
orderers.append(container)
62+
return orderers
63+
64+
65+
def get_peers(context):
66+
peers = []
67+
for container in context.composition.collectServiceNames():
68+
if container.startswith("peer"):
69+
peers.append(container)
70+
return peers
71+
72+
73+
def deploy_chaincode(context, chaincode, containers, channelId=TEST_CHANNEL_ID):
74+
for container in containers:
75+
assert container in context.composition.collectServiceNames(), "Unknown component '{0}'".format(container)
76+
77+
orderers = get_orderers(context)
78+
peers = get_peers(context)
79+
assert orderers != [], "There are no active orderers in this network"
80+
81+
create_channel(context, containers, orderers, channelId)
82+
join_channel(context, peers, orderers, channelId)
83+
install_chaincode(context, chaincode, containers)
84+
instantiate_chaincode(context, chaincode, containers)

test/feature/steps/orderer_impl.py

+66-6
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,30 @@ def step_impl(context, networkType):
3636
def compose_impl(context, dockerFile):
3737
pass
3838

39+
@given(u'an orderer connected to the kafka cluster')
40+
def step_impl(context):
41+
pass
42+
43+
@given(u'the orderer Batchsize MaxMessageCount is {maxMsgCount}')
44+
def step_impl(context, maxMsgCount):
45+
pass
46+
47+
@given(u'the orderer BatchTimeout is {timeout} {units}')
48+
def step_impl(context, timeout, units):
49+
pass
50+
51+
@given(u'a certificate from {organization} is added to the kafka orderer network')
52+
def step_impl(context, organization):
53+
pass
54+
55+
@given(u'the kafka default replication factor is {factor}')
56+
def step_impl(context, factor):
57+
pass
58+
59+
@given(u'a kafka cluster')
60+
def step_impl(context):
61+
pass
62+
3963
@when(u'a message is broadcasted')
4064
def step_impl(context):
4165
broadcast_impl(context, 1)
@@ -44,12 +68,36 @@ def step_impl(context):
4468
def broadcast_impl(context, count):
4569
pass
4670

71+
@when(u'the topic partition leader is stopped')
72+
def step_impl(context):
73+
pass
74+
75+
@when(u'a new organization {organization} certificate is added')
76+
def step_impl(context, organization):
77+
pass
78+
79+
@when(u'authorization for {organization} is removed from the kafka cluster')
80+
def step_impl(context, organization):
81+
pass
82+
83+
@when(u'authorization for {organization} is added to the kafka cluster')
84+
def step_impl(context, organization):
85+
pass
86+
87+
@then(u'the broadcasted message is delivered')
88+
def step_impl(context):
89+
verify_deliver_impl(context, 1, 1)
90+
91+
@then(u'all {count} messages are delivered in {numBlocks} block')
92+
def step_impl(context, count, numBlocks):
93+
verify_deliver_impl(context, count, numBlocks)
94+
4795
@then(u'all {count} messages are delivered within {timeout} seconds')
4896
def step_impl(context, count, timeout):
49-
pass
97+
verify_deliver_impl(context, count, None, timeout)
5098

5199
@then(u'all {count} messages are delivered in {numBlocks} within {timeout} seconds')
52-
def step_impl(context, count, numBlocks, timeout):
100+
def verify_deliver_impl(context, count, numBlocks, timeout=60):
53101
pass
54102

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

63-
@then(u'the broadcasted message is delivered')
111+
@then(u'the {organization} cannot connect to the kafka cluster')
112+
def step_impl(context, organization):
113+
pass
114+
115+
@then(u'the {organization} is able to connect to the kafka cluster')
116+
def step_impl(context, organization):
117+
pass
118+
119+
@then(u'the zookeeper notifies the orderer of the disconnect')
64120
def step_impl(context):
65-
verify_deliver_impl(context, 1, 1)
121+
pass
66122

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

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

0 commit comments

Comments
 (0)