mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-17 15:35:09 +00:00
* Addresses Issue #548 by providing a simple guide for running Java chaincode as a service with a local debugger. Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com> * missed a couple of bash syntax errors Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com> * Add metadata and activate examples to the CC README Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com> * move ccpackage/ contents into network script Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com> * Fix CI test - Azure mounts git checkout at a different folder root path Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com> * Update test-network-k8s README with updated cc deploy commands Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com> * Run basic-asset transfer CI tests with Java + golang CC in Azure Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com> * remove (obsolete) test-net chaincode/ folder Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com> * Address some PR review feedback points - README reorg Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com> * Use the SDKs contract router Main, not a local entrypoint Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com> * bump the build - remove trailing newlines from a README Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
115 lines
3.7 KiB
Bash
Executable file
115 lines
3.7 KiB
Bash
Executable file
#!/bin/bash -e
|
|
#
|
|
# Copyright IBM Corp All Rights Reserved
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
set -euo pipefail
|
|
|
|
# Test matrix parameters
|
|
export CONTAINER_CLI=${CONTAINER_CLI:-docker}
|
|
export CLIENT_LANGUAGE=${CLIENT_LANGUAGE:-typescript}
|
|
export CHAINCODE_LANGUAGE=${CHAINCODE_LANGUAGE:-java}
|
|
|
|
# Fabric version and Docker registry source: use the latest stable tag image from JFrog
|
|
export FABRIC_VERSION=${FABRIC_VERSION:-2.4}
|
|
export TEST_NETWORK_FABRIC_CONTAINER_REGISTRY=hyperledger-fabric.jfrog.io
|
|
export TEST_NETWORK_FABRIC_VERSION=amd64-${FABRIC_VERSION}-stable
|
|
export TEST_NETWORK_FABRIC_CA_VERSION=amd64-${FABRIC_VERSION}-stable
|
|
|
|
# test-network-k8s parameters
|
|
export TEST_TAG=$(git describe)
|
|
export TEST_NETWORK_KIND_CLUSTER_NAME=${TEST_NETWORK_KIND_CLUSTER_NAME:-kind}
|
|
|
|
# asset-transfer-basic chaincode target
|
|
export TEST_NETWORK_CHAINCODE_NAME=${TEST_NETWORK_CHAINCODE_NAME:-asset-transfer-basic}
|
|
export TEST_NETWORK_CHAINCODE_PATH=${TEST_NETWORK_CHAINCODE_PATH:-$PWD/../asset-transfer-basic/chaincode-${CHAINCODE_LANGUAGE}}
|
|
export TEST_NETWORK_CHAINCODE_IMAGE=${TEST_NETWORK_CHAINCODE_IMAGE:-fabric-samples/asset-transfer-basic/chaincode-${CHAINCODE_LANGUAGE}}
|
|
|
|
# gateway client application parameters
|
|
export GATEWAY_CLIENT_APPLICATION_PATH=${GATEWAY_CLIENT_APPLICATION_PATH:-../asset-transfer-basic/application-gateway-${CLIENT_LANGUAGE}}
|
|
export CHANNEL_NAME=${TEST_NETWORK_CHANNEL_NAME:-mychannel}
|
|
export CHAINCODE_NAME=${TEST_NETWORK_CHAINCODE_NAME:-asset-transfer-basic}
|
|
export MSP_ID=${MSP_ID:-Org1MSP}
|
|
export CRYPTO_PATH=${CRYPTO_PATH:-../../test-network-k8s/build/channel-msp/peerOrganizations/org1}
|
|
export KEY_DIRECTORY_PATH=${KEY_DIRECTORY_PATH:-../../test-network-k8s/build/enrollments/org1/users/org1admin/msp/keystore}
|
|
export CERT_PATH=${CERT_PATH:-../../test-network-k8s/build/enrollments/org1/users/org1admin/msp/signcerts/cert.pem}
|
|
export TLS_CERT_PATH=${TLS_CERT_PATH:-../../test-network-k8s/build/channel-msp/peerOrganizations/org1/msp/tlscacerts/tlsca-signcert.pem}
|
|
export PEER_ENDPOINT=${PEER_ENDPOINT:-org1-peer1.vcap.me:443}
|
|
export PEER_HOST_ALIAS=${PEER_HOST_ALIAS:-org1-peer1.vcap.me}
|
|
|
|
function print() {
|
|
GREEN='\033[0;32m'
|
|
NC='\033[0m'
|
|
echo
|
|
echo -e "${GREEN}${1}${NC}"
|
|
}
|
|
|
|
function touteSuite() {
|
|
createCluster
|
|
}
|
|
|
|
function quitterLaScene() {
|
|
destroyCluster
|
|
}
|
|
|
|
function createCluster() {
|
|
print "Initializing KIND Kubernetes cluster"
|
|
./network kind
|
|
}
|
|
|
|
function destroyCluster() {
|
|
print "Destroying KIND Kubernetes cluster"
|
|
./network unkind
|
|
}
|
|
|
|
function createNetwork() {
|
|
print "Launching network"
|
|
./network up
|
|
./network channel create
|
|
|
|
print "Deploying chaincode"
|
|
./network chaincode deploy asset-transfer-basic basic_1.0 $TEST_NETWORK_CHAINCODE_PATH
|
|
}
|
|
|
|
function stopNetwork() {
|
|
print "Stopping network"
|
|
./network down
|
|
}
|
|
|
|
# Set up the suite with a KIND cluster
|
|
touteSuite
|
|
trap "quitterLaScene" EXIT
|
|
|
|
createNetwork
|
|
|
|
print "Inserting and querying assets"
|
|
( ./network chaincode metadata $CHAINCODE_NAME \
|
|
&& ./network chaincode invoke $CHAINCODE_NAME '{"Args":["InitLedger"]}' \
|
|
&& sleep 5 \
|
|
&& ./network chaincode query $CHAINCODE_NAME '{"Args":["ReadAsset","asset1"]}' )
|
|
print "OK"
|
|
|
|
print "Running rest-easy test"
|
|
( ./network rest-easy \
|
|
&& sleep 5 \
|
|
&& export SAMPLE_APIKEY='97834158-3224-4CE7-95F9-A148C886653E' \
|
|
&& curl -s --header "X-Api-Key: ${SAMPLE_APIKEY}" "http://fabric-rest-sample.vcap.me/api/assets/asset1" | jq )
|
|
print "OK"
|
|
|
|
stopNetwork
|
|
|
|
# Run the basic-asset-transfer basic application
|
|
createNetwork
|
|
print "Running Gateway client application"
|
|
( pushd ${GATEWAY_CLIENT_APPLICATION_PATH} \
|
|
&& npm install \
|
|
&& npm start )
|
|
print "OK"
|
|
stopNetwork
|
|
|
|
# Run additional test ...
|
|
# Run additional test ...
|
|
# Run additional test ...
|
|
|
|
# destroyCluster will be invoked on EXIT trap handler at the end of this suite.
|