Skip to content

Commit

Permalink
Simplify e2e-test for upgrading test env to the latest (hyperledger-l…
Browse files Browse the repository at this point in the history
…abs#268)

Signed-off-by: Atsushi Neki <[email protected]>
  • Loading branch information
nekia authored Dec 20, 2021
1 parent 8c530f4 commit 5853c4b
Show file tree
Hide file tree
Showing 26 changed files with 337 additions and 1,052 deletions.
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
EXPLORER_CONFIG_FILE_PATH=./examples/net1/config.json
EXPLORER_PROFILE_DIR_PATH=./examples/net1/connection-profile
FABRIC_CRYPTO_PATH=/fabric-path/fabric-samples/test-network/organizations
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ app/test/coverage/
venv
.vscode

test/*
test/fabric-samples
tmp/*

logs
Expand Down

This file was deleted.

116 changes: 34 additions & 82 deletions app/platform/fabric/e2e-test/runTestSuite.sh
Original file line number Diff line number Diff line change
@@ -1,98 +1,50 @@
#!/bin/bash

ROOTDIR="$(cd "$(dirname "$0")"/../../../.. && pwd)"
FABRIC_V1_VERSION=1.4.11
FABRIC_CA_V1_VERSION=1.4.9
FABRIC_V2_VERSION=2.3.1
FABRIC_CA_V2_VERSION=1.4.9

echo "#### Downloaded fabric-test repo"

if [ $# -eq 0 ]; then
echo "$0 [-1 | -2]"
exit 1;
fi

while getopts "12" opt; do
case "$opt" in
1)
SDKVER=1.4.11
export FABRIC_VERSION=1
export RELEASE_VERSION=1.4-stable
CHECKOUT_HASH=45799a2ee4eefa49ae705cc57ed415270c35d60a
# export FABRIC_CFG_PATH=$GOPATH/src/github.com/hyperledger/fabric-test/scripts/config
export PATH=$GOPATH/src/github.com/hyperledger/fabric-test/scripts/bin:$PATH
PULL_PEER_IMAGE_VERSION=${FABRIC_V1_VERSION}
PULL_CA_IMAGE_VERSION=${FABRIC_CA_V1_VERSION}
;;
2)
SDKVER=2.0.0-beta.2
export FABRIC_VERSION=2
CHECKOUT_HASH=09680bea5aa0ec464982f7979fd99a777e8c1fed
export FABRIC_CFG_PATH=$GOPATH/src/github.com/hyperledger/fabric-test/config
export PATH=$GOPATH/src/github.com/hyperledger/fabric-test/bin:$PATH
PULL_PEER_IMAGE_VERSION=${FABRIC_V2_VERSION}
PULL_CA_IMAGE_VERSION=${FABRIC_CA_V2_VERSION}
;;
*)
echo "$0 [-1 | -2]"
exit 1;
;;
esac
done

echo "HASH: ${CHECKOUT_HASH}"
echo "SDK : ${SDKVER}"
echo "ROOT: ${ROOTDIR}"

set -e
mkdir $ROOTDIR/test 2>/dev/null

mkdir -p $GOPATH/src/github.com/hyperledger

pushd $GOPATH/src/github.com/hyperledger
sudo rm -rf fabric-test
if [ ! -d fabric-test ]; then
git clone https://github.com/hyperledger/fabric-test.git
fi
cd fabric-test
# git checkout 45799a2ee4eefa49ae705cc57ed415270c35d60a
git checkout ${CHECKOUT_HASH}
make pull-binaries-fabric
echo "#### Updated each sub-module under fabric-test repo"
popd
pushd $ROOTDIR/test

pushd $GOPATH/src/github.com/hyperledger/fabric-test/tools/PTE
npm install fabric-client@${SDKVER}
npm install fabric-ca-client@${SDKVER}
echo "#### Installed required node packages"
popd
curl -sSL https://bit.ly/2ysbOFE | bash -s -- 2.3.3 1.5.2
# curl -sSL https://bit.ly/2ysbOFE | bash -s -- 2.1.1 1.4.7 0.4.20
# curl -sSL https://bit.ly/2ysbOFE | bash -s -- 2.2.4 1.5.2

pushd $ROOTDIR/app/platform/fabric/e2e-test
rm -f PTE
ln -s $GOPATH/src/github.com/hyperledger/fabric-test/tools/PTE ./PTE
popd

pushd $ROOTDIR
rm -rf wallet logs
popd
pushd $ROOTDIR/test/fabric-samples/test-network

curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/master/scripts/bootstrap.sh | bash -s -- ${PULL_PEER_IMAGE_VERSION} ${PULL_CA_IMAGE_VERSION} 0.4.18 -s -b
docker tag hyperledger/fabric-ca:${PULL_CA_IMAGE_VERSION} hyperledger/fabric-ca:${PULL_PEER_IMAGE_VERSION}
git checkout a97e8d1267fafb013aadae6850312c1b07a1ecd8
docker rm -f $(docker ps -qa) 2>/dev/null
docker volume rm $(docker volume ls -q) 2>/dev/null
./network.sh down

pushd $ROOTDIR/app/platform/fabric/e2e-test/specs
set -e

./network.sh up createChannel -ca -c org1channel
./network.sh createChannel -ca -c commonchannel
find organizations/peerOrganizations/ -type f -name "*_sk" | xargs dirname | xargs -I{} bash -c "pushd {} && ln -s *_sk priv_sk && popd"
./network.sh deployCC -c org1channel -ccn basic -ccp ../asset-transfer-basic/chaincode-go -ccl go

export PATH=${PWD}/../bin:$PATH
export FABRIC_CFG_PATH=$PWD/../config/
export CORE_PEER_TLS_ENABLED=true
export CORE_PEER_LOCALMSPID="Org1MSP"
export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org1.example.com/users/[email protected]/msp
export CORE_PEER_ADDRESS=localhost:7051

rm -rf templates
sed -i -e '/github.com\/hyperledger\/fabric-test/d' go.mod
if [ ${FABRIC_VERSION} -eq 2 ]; then
cp -a templates-v2 templates
go get github.com/hyperledger/fabric-test@${CHECKOUT_HASH}
go get github.com/hyperledger/fabric-test/tools/operator@${CHECKOUT_HASH}
go get github.com/hyperledger/fabric-test/chaincodes/samplecc/go@${CHECKOUT_HASH}
else
cp -a templates-v1 templates
go get github.com/hyperledger/fabric-test@${CHECKOUT_HASH}
fi
peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" -C org1channel -n basic --peerAddresses localhost:7051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt" --peerAddresses localhost:9051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt" -c '{"function":"InitLedger","Args":[]}'

sleep 3

peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" -C org1channel -n basic --peerAddresses localhost:7051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt" --peerAddresses localhost:9051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt" -c '{"function":"TransferAsset","Args":["asset6","Christopher"]}'

popd

pushd $ROOTDIR/app/platform/fabric/e2e-test/specs

echo "#### Starting Ginkgo based test suite"
ginkgo -v -stream -failFast

popd
3 changes: 1 addition & 2 deletions app/platform/fabric/e2e-test/specs/apitest_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ func dumpLog() {
fmt.Println("=== Dump Explorer app log ===")
fmt.Println(cwd)
os.Chdir(relativePahtToRoot)
cmd := exec.Command("cat", "logs/console/console.log")
cmd := exec.Command("docker", "logs", "explorer.mynetwork.com")
session, err := gexec.Start(cmd, GinkgoWriter, GinkgoWriter)
Expect(err).ShouldNot(HaveOccurred())
session.Wait()
fmt.Println(session.Out)
}
Loading

0 comments on commit 5853c4b

Please sign in to comment.