-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FAB-3934] Daily Test Runs for Auction App
Client Driver: testAuctionChainCode.py, api_driver.sh. Following transactions are performed on Auction App --Post Users --Get Users --Download Images --Get Items --Post Auction --Open Auction For Bids --Submit Bids --Transfer Item Change-Id: I8c5967588d87f1a4507288a0e6a694c26fc70e99 Signed-off-by: sandp125 <sandeep.pulluru@itpeoplecorp.com>
- Loading branch information
1 parent
897ca82
commit abc81af
Showing
6 changed files
with
718 additions
and
511 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# | ||
# Copyright IBM Corp. All Rights Reserved. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
version: '2' | ||
|
||
services: | ||
|
||
orderer.example.com: | ||
extends: | ||
file: base/docker-compose-base.yaml | ||
service: orderer.example.com | ||
container_name: orderer.example.com | ||
|
||
peer0.org1.example.com: | ||
container_name: peer0.org1.example.com | ||
extends: | ||
file: base/docker-compose-base.yaml | ||
service: peer0.org1.example.com | ||
|
||
peer1.org1.example.com: | ||
container_name: peer1.org1.example.com | ||
extends: | ||
file: base/docker-compose-base.yaml | ||
service: peer1.org1.example.com | ||
|
||
peer0.org2.example.com: | ||
container_name: peer0.org2.example.com | ||
extends: | ||
file: base/docker-compose-base.yaml | ||
service: peer0.org2.example.com | ||
|
||
peer1.org2.example.com: | ||
container_name: peer1.org2.example.com | ||
extends: | ||
file: base/docker-compose-base.yaml | ||
service: peer1.org2.example.com | ||
|
||
cli: | ||
container_name: cli | ||
image: hyperledger/fabric-tools | ||
tty: true | ||
environment: | ||
- GOPATH=/opt/gopath | ||
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock | ||
- CORE_LOGGING_LEVEL=DEBUG | ||
- CORE_PEER_ID=cli | ||
- CORE_PEER_ADDRESS=peer0.org1.example.com:7051 | ||
- CORE_PEER_LOCALMSPID=Org1MSP | ||
- CORE_PEER_TLS_ENABLED=true | ||
- CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt | ||
- CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key | ||
- CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt | ||
- CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp | ||
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer | ||
command: /bin/bash -c 'apt-get update && apt-get install -y jq; sleep 600000000000' | ||
volumes: | ||
- /var/run/:/host/var/run/ | ||
- ../../../../../examples/chaincode/go:/opt/gopath/src/github.com/hyperledger/fabric/examples/chaincode/go | ||
- ./channel-artifacts:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifacts | ||
- ./crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto | ||
- ./logs:/opt/gopath/src/github.com/hyperledger/fabric/test/envsetup/logs | ||
- ../tools:/opt/gopath/src/github.com/hyperledger/fabric/test/tools | ||
- ../chaincodes:/opt/gopath/src/github.com/hyperledger/fabric/test/chaincodes | ||
depends_on: | ||
- orderer.example.com | ||
- peer0.org1.example.com | ||
- peer1.org1.example.com | ||
- peer0.org2.example.com | ||
- peer1.org2.example.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright IBM Corp. All Rights Reserved. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
set -e | ||
|
||
CHANNEL_NAME=$1 | ||
CHANNEL_COUNT=$2 | ||
|
||
: ${CHANNEL_NAME:="mychannel"} | ||
: ${CHANNEL_COUNT:="1"} | ||
|
||
export FABRIC_ROOT=$GOPATH/src/github.com/hyperledger/fabric | ||
export E2E_CLI_PATH=$FABRIC_ROOT/examples/e2e_cli/ | ||
cp $E2E_CLI_PATH/configtx.yaml $PWD | ||
cp $E2E_CLI_PATH/crypto-config.yaml ./crypto-config.yaml | ||
cp -r $E2E_CLI_PATH/base $PWD/ | ||
sed -i 's/e2ecli/envsetup/g' base/peer-base.yaml | ||
export FABRIC_CFG_PATH=$PWD | ||
|
||
ARTIFACTS=./channel-artifacts | ||
OS_ARCH=$(echo "$(uname -s)-$(uname -m | sed 's/x86_64/amd64/g')" | awk '{print tolower($0)}') | ||
|
||
echo "Channel name - "$CHANNEL_NAME | ||
echo "Total channels - "$CHANNEL_COUNT | ||
echo | ||
|
||
CONFIGTXGEN=$(which configtxgen || /bin/true) | ||
|
||
## Generates Org certs using cryptogen tool | ||
function generateCerts() { | ||
CRYPTOGEN=$FABRIC_ROOT/release/$OS_ARCH/bin/cryptogen | ||
|
||
if [ -f "$CRYPTOGEN" ]; then | ||
echo "Using cryptogen -> $CRYPTOGEN" | ||
else | ||
echo "Building cryptogen" | ||
make -C $FABRIC_ROOT release-all | ||
fi | ||
|
||
echo | ||
echo "**** Generate certificates using cryptogen tool ****" | ||
$CRYPTOGEN generate --config=./crypto-config.yaml | ||
echo | ||
} | ||
|
||
## Generate orderer genesis block , channel configuration transaction and anchor peer update transactions | ||
function generateChannelArtifacts() { | ||
|
||
CONFIGTXGEN=$FABRIC_ROOT/release/$OS_ARCH/bin/configtxgen | ||
if [ -f "$CONFIGTXGEN" ]; then | ||
echo "Using configtxgen -> $CONFIGTXGEN" | ||
else | ||
echo "Building configtxgen" | ||
make -C $FABRIC_ROOT release-all | ||
fi | ||
|
||
echo "Generating genesis block" | ||
$CONFIGTXGEN -profile TwoOrgsOrdererGenesis -outputBlock $ARTIFACTS/genesis.block | ||
|
||
for ((i = 0; $i < $CHANNEL_COUNT; i++)); do | ||
echo "Generating channel configuration transaction for channel '$CHANNEL_NAME$i'" | ||
$CONFIGTXGEN -profile TwoOrgsChannel -outputCreateChannelTx $ARTIFACTS/channel$i.tx -channelID $CHANNEL_NAME$i | ||
|
||
echo "Generating anchor peer update for Org1MSP" | ||
$CONFIGTXGEN -profile TwoOrgsChannel -outputAnchorPeersUpdate $ARTIFACTS/Org1MSPanchors$i.tx -channelID $CHANNEL_NAME$i -asOrg Org1MSP | ||
|
||
echo "Generating anchor peer update for Org2MSP" | ||
$CONFIGTXGEN -profile TwoOrgsChannel -outputAnchorPeersUpdate $ARTIFACTS/Org2MSPanchors$i.tx -channelID $CHANNEL_NAME$i -asOrg Org2MSP | ||
done | ||
} | ||
|
||
generateCerts | ||
generateChannelArtifacts | ||
|
||
echo "######################### DONE ######################" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
# | ||
# Copyright IBM Corp. All Rights Reserved. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
|
||
###################################################################### | ||
# To execute: | ||
# Install: sudo apt-get install python python-pytest | ||
# Run on command line: py.test -v --junitxml results_auction_daily.xml testAuctionChaincode.py | ||
|
||
import subprocess | ||
import unittest | ||
from subprocess import check_output | ||
import shutil | ||
|
||
|
||
class ChaincodeAPI(unittest.TestCase): | ||
|
||
@classmethod | ||
def setUpClass(cls): | ||
cls.CHANNEL_NAME = 'channel' | ||
cls.CHANNELS = '2' | ||
cls.CHAINCODES = '1' | ||
cls.ENDORSERS = '4' | ||
cls.RUN_TIME_HOURS = '1' | ||
check_output(['./generateCfgTrx.sh {0} {1}'.format(cls.CHANNEL_NAME, cls.CHANNELS)], cwd='../../envsetup', shell=True) | ||
check_output(['docker-compose -f docker-compose.yaml up -d'], cwd='../../envsetup', shell=True) | ||
|
||
@classmethod | ||
def tearDownClass(cls): | ||
check_output(['docker-compose -f docker-compose.yaml down'], cwd='../../envsetup', shell=True) | ||
delete_this = ['__pycache__', '.cache'] | ||
for item in delete_this: | ||
shutil.rmtree(item) | ||
|
||
################################################################################# | ||
|
||
def runIt(self, command, scriptName): | ||
cmd = \ | ||
'/opt/gopath/src/github.com/hyperledger/fabric/test/tools/AuctionApp/%s %s %s %s %s %s %s' \ | ||
% ( | ||
scriptName, | ||
self.CHANNEL_NAME, | ||
self.CHANNELS, | ||
self.CHAINCODES, | ||
self.ENDORSERS, | ||
self.RUN_TIME_HOURS, | ||
command, | ||
) | ||
output = \ | ||
check_output(['docker exec cli bash -c "{0}"'.format(cmd)], | ||
shell=True) | ||
return output | ||
|
||
def test_FAB3934_1_Create_Channel(self): | ||
''' | ||
Network: 1 Ord, 2 Org, 4 Peers, 2 Chan, 1 CC | ||
Description: This test is used to creates channels | ||
Passing criteria: Creating Channel is successful | ||
''' | ||
output = self.runIt('createChannel', 'api_driver.sh') | ||
self.assertIn('Creating Channel is successful', output) | ||
|
||
|
||
def test_FAB3934_2_Join_Channel(self): | ||
''' | ||
Network: 1 Ord, 2 Org, 4 Peers, 2 Chan, 1 CC | ||
Description: This test is used to join peers on all channels | ||
Passing criteria: Join Channel is successful | ||
''' | ||
output = self.runIt('joinChannel', 'api_driver.sh') | ||
self.assertIn('Join Channel is successful', output) | ||
|
||
|
||
def test_FAB3934_3_Install_Chaincode(self): | ||
''' | ||
Network: 1 Ord, 2 Org, 4 Peers, 2 Chan, 1 CC | ||
Description: This test is used to install all chaincodes on all peers | ||
Passing criteria: Installing chaincode is successful | ||
''' | ||
output = self.runIt('installChaincode', 'api_driver.sh') | ||
self.assertIn('Installing chaincode is successful', output) | ||
|
||
|
||
def test_FAB3934_4_Instantiate_Chaincode(self): | ||
''' | ||
Network: 1 Ord, 2 Org, 4 Peers, 2 Chan, 1 CC | ||
Description: This test is used to instantiate all chaincodes on all channels | ||
Passing criteria: Instantiating chaincode is successful | ||
''' | ||
output = self.runIt('instantiateChaincode', 'api_driver.sh') | ||
self.assertIn('Instantiating chaincode is successful', output) | ||
|
||
|
||
def test_FAB3934_5_Post_Users(self): | ||
''' | ||
Network: 1 Ord, 2 Org, 4 Peers, 2 Chan, 1 CC | ||
Description: This test is used to submit users to the auction application | ||
Passing criteria: Posting Users transaction is successful | ||
''' | ||
output = self.runIt('postUsers', 'api_driver.sh') | ||
self.assertIn('Posting Users transaction is successful', output) | ||
|
||
|
||
def test_FAB3934_6_Get_Users(self): | ||
''' | ||
Network: 1 Ord, 2 Org, 4 Peers, 2 Chan, 1 CC | ||
Description: This test is used to query users submitted to the auction application | ||
Passing criteria: Get Users transaction is successful | ||
''' | ||
output = self.runIt('getUsers', 'api_driver.sh') | ||
self.assertIn('Get Users transaction is successful', output) | ||
|
||
def test_FAB3934_7_Download_Images(self): | ||
''' | ||
Network: 1 Ord, 2 Org, 4 Peers, 2 Chan, 1 CC | ||
Description: This test is used to download auction images on all chaincode containers | ||
Passing criteria: Download Images transaction is successful | ||
''' | ||
output = self.runIt('downloadImages', 'api_driver.sh') | ||
self.assertIn('Download Images transaction is successful', | ||
output) | ||
|
||
|
||
def test_FAB3934_8_Post_Items(self): | ||
''' | ||
Network: 1 Ord, 2 Org, 4 Peers, 2 Chan, 1 CC | ||
Description: This test is used to submit auction items for a user to the auction application | ||
Passing criteria: Post Items transaction is successful | ||
''' | ||
output = self.runIt('postItems', 'api_driver.sh') | ||
self.assertIn('Post Items transaction is successful', output) | ||
|
||
|
||
def test_FAB3934_9_Auction_Invoke(self): | ||
''' | ||
Network: 1 Ord, 2 Org, 4 Peers, 2 Chan, 1 CC | ||
Description: This test runs for 1 Hr. It is used to open auction on the submitted items, | ||
submit bids to the auction, close auction and finally transfer item to a user. | ||
Passing criteria: Open Auction/Submit Bids/Close Auction/Transfer Item transaction(s) are successful | ||
''' | ||
output = self.runIt('auctionInvokes', 'api_driver.sh') | ||
self.assertIn('Open Auction/Submit Bids/Close Auction/Transfer Item transaction(s) are successful' | ||
, output) |
Oops, something went wrong.