Skip to content
This repository was archived by the owner on Mar 31, 2025. It is now read-only.

Commit 5853c4b

Browse files
authored
Simplify e2e-test for upgrading test env to the latest (#268)
Signed-off-by: Atsushi Neki <[email protected]>
1 parent 8c530f4 commit 5853c4b

26 files changed

+337
-1052
lines changed

.env

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
EXPLORER_CONFIG_FILE_PATH=./examples/net1/config.json
2+
EXPLORER_PROFILE_DIR_PATH=./examples/net1/connection-profile
3+
FABRIC_CRYPTO_PATH=/fabric-path/fabric-samples/test-network/organizations

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ app/test/coverage/
1313
venv
1414
.vscode
1515

16-
test/*
16+
test/fabric-samples
1717
tmp/*
1818

1919
logs

app/platform/fabric/e2e-test/configs/connection-profile/org1-network-pem.json

-61
This file was deleted.
+34-82
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,50 @@
11
#!/bin/bash
22

33
ROOTDIR="$(cd "$(dirname "$0")"/../../../.. && pwd)"
4-
FABRIC_V1_VERSION=1.4.11
5-
FABRIC_CA_V1_VERSION=1.4.9
6-
FABRIC_V2_VERSION=2.3.1
7-
FABRIC_CA_V2_VERSION=1.4.9
8-
9-
echo "#### Downloaded fabric-test repo"
10-
11-
if [ $# -eq 0 ]; then
12-
echo "$0 [-1 | -2]"
13-
exit 1;
14-
fi
15-
16-
while getopts "12" opt; do
17-
case "$opt" in
18-
1)
19-
SDKVER=1.4.11
20-
export FABRIC_VERSION=1
21-
export RELEASE_VERSION=1.4-stable
22-
CHECKOUT_HASH=45799a2ee4eefa49ae705cc57ed415270c35d60a
23-
# export FABRIC_CFG_PATH=$GOPATH/src/github.com/hyperledger/fabric-test/scripts/config
24-
export PATH=$GOPATH/src/github.com/hyperledger/fabric-test/scripts/bin:$PATH
25-
PULL_PEER_IMAGE_VERSION=${FABRIC_V1_VERSION}
26-
PULL_CA_IMAGE_VERSION=${FABRIC_CA_V1_VERSION}
27-
;;
28-
2)
29-
SDKVER=2.0.0-beta.2
30-
export FABRIC_VERSION=2
31-
CHECKOUT_HASH=09680bea5aa0ec464982f7979fd99a777e8c1fed
32-
export FABRIC_CFG_PATH=$GOPATH/src/github.com/hyperledger/fabric-test/config
33-
export PATH=$GOPATH/src/github.com/hyperledger/fabric-test/bin:$PATH
34-
PULL_PEER_IMAGE_VERSION=${FABRIC_V2_VERSION}
35-
PULL_CA_IMAGE_VERSION=${FABRIC_CA_V2_VERSION}
36-
;;
37-
*)
38-
echo "$0 [-1 | -2]"
39-
exit 1;
40-
;;
41-
esac
42-
done
43-
44-
echo "HASH: ${CHECKOUT_HASH}"
45-
echo "SDK : ${SDKVER}"
46-
echo "ROOT: ${ROOTDIR}"
474

48-
set -e
5+
mkdir $ROOTDIR/test 2>/dev/null
496

50-
mkdir -p $GOPATH/src/github.com/hyperledger
51-
52-
pushd $GOPATH/src/github.com/hyperledger
53-
sudo rm -rf fabric-test
54-
if [ ! -d fabric-test ]; then
55-
git clone https://github.com/hyperledger/fabric-test.git
56-
fi
57-
cd fabric-test
58-
# git checkout 45799a2ee4eefa49ae705cc57ed415270c35d60a
59-
git checkout ${CHECKOUT_HASH}
60-
make pull-binaries-fabric
61-
echo "#### Updated each sub-module under fabric-test repo"
62-
popd
7+
pushd $ROOTDIR/test
638

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

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

75-
pushd $ROOTDIR
76-
rm -rf wallet logs
77-
popd
15+
pushd $ROOTDIR/test/fabric-samples/test-network
7816

79-
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
80-
docker tag hyperledger/fabric-ca:${PULL_CA_IMAGE_VERSION} hyperledger/fabric-ca:${PULL_PEER_IMAGE_VERSION}
17+
git checkout a97e8d1267fafb013aadae6850312c1b07a1ecd8
18+
docker rm -f $(docker ps -qa) 2>/dev/null
19+
docker volume rm $(docker volume ls -q) 2>/dev/null
20+
./network.sh down
8121

82-
pushd $ROOTDIR/app/platform/fabric/e2e-test/specs
22+
set -e
23+
24+
./network.sh up createChannel -ca -c org1channel
25+
./network.sh createChannel -ca -c commonchannel
26+
find organizations/peerOrganizations/ -type f -name "*_sk" | xargs dirname | xargs -I{} bash -c "pushd {} && ln -s *_sk priv_sk && popd"
27+
./network.sh deployCC -c org1channel -ccn basic -ccp ../asset-transfer-basic/chaincode-go -ccl go
28+
29+
export PATH=${PWD}/../bin:$PATH
30+
export FABRIC_CFG_PATH=$PWD/../config/
31+
export CORE_PEER_TLS_ENABLED=true
32+
export CORE_PEER_LOCALMSPID="Org1MSP"
33+
export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
34+
export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org1.example.com/users/[email protected]/msp
35+
export CORE_PEER_ADDRESS=localhost:7051
8336

84-
rm -rf templates
85-
sed -i -e '/github.com\/hyperledger\/fabric-test/d' go.mod
86-
if [ ${FABRIC_VERSION} -eq 2 ]; then
87-
cp -a templates-v2 templates
88-
go get github.com/hyperledger/fabric-test@${CHECKOUT_HASH}
89-
go get github.com/hyperledger/fabric-test/tools/operator@${CHECKOUT_HASH}
90-
go get github.com/hyperledger/fabric-test/chaincodes/samplecc/go@${CHECKOUT_HASH}
91-
else
92-
cp -a templates-v1 templates
93-
go get github.com/hyperledger/fabric-test@${CHECKOUT_HASH}
94-
fi
37+
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":[]}'
38+
39+
sleep 3
40+
41+
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"]}'
42+
43+
popd
44+
45+
pushd $ROOTDIR/app/platform/fabric/e2e-test/specs
9546

9647
echo "#### Starting Ginkgo based test suite"
9748
ginkgo -v -stream -failFast
49+
9850
popd

app/platform/fabric/e2e-test/specs/apitest_suite_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@ func dumpLog() {
4141
fmt.Println("=== Dump Explorer app log ===")
4242
fmt.Println(cwd)
4343
os.Chdir(relativePahtToRoot)
44-
cmd := exec.Command("cat", "logs/console/console.log")
44+
cmd := exec.Command("docker", "logs", "explorer.mynetwork.com")
4545
session, err := gexec.Start(cmd, GinkgoWriter, GinkgoWriter)
4646
Expect(err).ShouldNot(HaveOccurred())
4747
session.Wait()
48-
fmt.Println(session.Out)
4948
}

0 commit comments

Comments
 (0)