mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-26 03:25:09 +00:00
proper tear down
Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
This commit is contained in:
parent
632383900a
commit
5939d19820
3 changed files with 146 additions and 173 deletions
|
|
@ -15,182 +15,24 @@ variables:
|
||||||
PATH: $(Build.Repository.LocalPath)/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin
|
PATH: $(Build.Repository.LocalPath)/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
- job: CommercialPaper_Go
|
|
||||||
displayName: Commercial Paper (Go)
|
|
||||||
pool:
|
|
||||||
vmImage: ubuntu-20.04
|
|
||||||
steps:
|
|
||||||
- template: templates/install-deps.yml
|
|
||||||
- template: templates/commercial-paper/azure-pipelines-go.yml
|
|
||||||
|
|
||||||
- job: CommercialPaper_Java
|
- job: KubeTestNetworkBasic
|
||||||
displayName: Commercial Paper (Java)
|
displayName: Kube Test Network Basic
|
||||||
pool:
|
|
||||||
vmImage: ubuntu-20.04
|
|
||||||
steps:
|
|
||||||
- template: templates/install-deps.yml
|
|
||||||
- template: templates/commercial-paper/azure-pipelines-java.yml
|
|
||||||
|
|
||||||
- job: CommercialPaper_JavaScript
|
|
||||||
displayName: Commercial Paper (JavaScript)
|
|
||||||
pool:
|
|
||||||
vmImage: ubuntu-20.04
|
|
||||||
steps:
|
|
||||||
- template: templates/install-deps.yml
|
|
||||||
- template: templates/commercial-paper/azure-pipelines-javascript.yml
|
|
||||||
|
|
||||||
- job: FabCar_Go
|
|
||||||
displayName: FabCar (Go)
|
|
||||||
pool:
|
|
||||||
vmImage: ubuntu-20.04
|
|
||||||
steps:
|
|
||||||
- template: templates/install-deps.yml
|
|
||||||
- template: templates/fabcar/azure-pipelines-go.yml
|
|
||||||
|
|
||||||
- job: FabCar_Java
|
|
||||||
displayName: FabCar (Java)
|
|
||||||
pool:
|
|
||||||
vmImage: ubuntu-20.04
|
|
||||||
steps:
|
|
||||||
- template: templates/install-deps.yml
|
|
||||||
- template: templates/fabcar/azure-pipelines-java.yml
|
|
||||||
|
|
||||||
- job: FabCar_JavaScript
|
|
||||||
displayName: FabCar (JavaScript)
|
|
||||||
pool:
|
|
||||||
vmImage: ubuntu-20.04
|
|
||||||
steps:
|
|
||||||
- template: templates/install-deps.yml
|
|
||||||
- template: templates/fabcar/azure-pipelines-javascript.yml
|
|
||||||
|
|
||||||
- job: Fabcar_TypeScript
|
|
||||||
displayName: FabCar (TypeScript)
|
|
||||||
pool:
|
|
||||||
vmImage: ubuntu-20.04
|
|
||||||
steps:
|
|
||||||
- template: templates/install-deps.yml
|
|
||||||
- template: templates/fabcar/azure-pipelines-typescript.yml
|
|
||||||
|
|
||||||
- job: Lint
|
|
||||||
displayName: Lint
|
|
||||||
pool:
|
|
||||||
vmImage: ubuntu-20.04
|
|
||||||
steps:
|
|
||||||
- task: GoTool@0
|
|
||||||
inputs:
|
|
||||||
goBin: $(GO_BIN)
|
|
||||||
version: $(GO_VER)
|
|
||||||
displayName: Install GoLang
|
|
||||||
- task: NodeTool@0
|
|
||||||
inputs:
|
|
||||||
versionSpec: $(NODE_VER)
|
|
||||||
displayName: Install Node.js
|
|
||||||
- script: ./ci/scripts/lint.sh
|
|
||||||
displayName: Lint Code
|
|
||||||
|
|
||||||
- job: TestNetworkBasic
|
|
||||||
displayName: Test Network
|
|
||||||
pool:
|
pool:
|
||||||
vmImage: ubuntu-20.04
|
vmImage: ubuntu-20.04
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
Basic-Go:
|
Docker-Typescript:
|
||||||
CHAINCODE_NAME: basic
|
CONTAINER_CLI: docker
|
||||||
CHAINCODE_LANGUAGE: go
|
CLIENT_LANGUAGE: typescript
|
||||||
Basic-Java:
|
# Podman-Typescript:
|
||||||
CHAINCODE_NAME: basic
|
# CONTAINER_CLI: podman
|
||||||
CHAINCODE_LANGUAGE: java
|
# CLIENT_LANGUAGE: typescript
|
||||||
Basic-Javascript:
|
# Nerdctl-Typescript:
|
||||||
CHAINCODE_NAME: basic
|
# CONTAINER_CLI: nerdctl
|
||||||
CHAINCODE_LANGUAGE: javascript
|
# CLIENT_LANGUAGE: typescript
|
||||||
Basic-Typescript:
|
|
||||||
CHAINCODE_NAME: basic
|
|
||||||
CHAINCODE_LANGUAGE: typescript
|
|
||||||
steps:
|
steps:
|
||||||
- template: templates/install-deps.yml
|
- template: templates/install-k8s-deps.yml
|
||||||
- script: sudo apt-get install softhsm2
|
- script: ../ci/scripts/run-k8s-test-network-basic.sh
|
||||||
displayName: Install SoftHSM
|
workingDirectory: test-network-k8s
|
||||||
- script: ../ci/scripts/run-test-network-basic.sh
|
displayName: Run Kubernetes Test Network Basic Asset Transfer
|
||||||
workingDirectory: test-network
|
|
||||||
displayName: Run Test Network Basic Chaincode
|
|
||||||
|
|
||||||
- job: TestNetworkLedger
|
|
||||||
displayName: Test Network
|
|
||||||
pool:
|
|
||||||
vmImage: ubuntu-20.04
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
Ledger-Go:
|
|
||||||
CHAINCODE_NAME: ledger
|
|
||||||
CHAINCODE_LANGUAGE: go
|
|
||||||
Ledger-Javascript:
|
|
||||||
CHAINCODE_NAME: ledger
|
|
||||||
CHAINCODE_LANGUAGE: javascript
|
|
||||||
steps:
|
|
||||||
- template: templates/install-deps.yml
|
|
||||||
- script: ../ci/scripts/run-test-network-ledger.sh
|
|
||||||
workingDirectory: test-network
|
|
||||||
displayName: Run Test Network Ledger Chaincode
|
|
||||||
|
|
||||||
- job: TestNetworkPrivate
|
|
||||||
displayName: Test Network
|
|
||||||
pool:
|
|
||||||
vmImage: ubuntu-20.04
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
Private-Go:
|
|
||||||
CHAINCODE_NAME: private
|
|
||||||
CHAINCODE_LANGUAGE: go
|
|
||||||
steps:
|
|
||||||
- template: templates/install-deps.yml
|
|
||||||
- script: ../ci/scripts/run-test-network-private.sh
|
|
||||||
workingDirectory: test-network
|
|
||||||
displayName: Run Test Network Private Chaincode
|
|
||||||
|
|
||||||
- job: TestNetworkSBE
|
|
||||||
displayName: Test Network
|
|
||||||
pool:
|
|
||||||
vmImage: ubuntu-20.04
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
SBE-Typescript:
|
|
||||||
CHAINCODE_NAME: sbe
|
|
||||||
CHAINCODE_LANGUAGE: typescript
|
|
||||||
SBE-Java:
|
|
||||||
CHAINCODE_NAME: sbe
|
|
||||||
CHAINCODE_LANGUAGE: java
|
|
||||||
steps:
|
|
||||||
- template: templates/install-deps.yml
|
|
||||||
- script: ../ci/scripts/run-test-network-sbe.sh
|
|
||||||
workingDirectory: test-network
|
|
||||||
displayName: Run Test Network SBE Chaincode
|
|
||||||
|
|
||||||
- job: TestNetworkSecured
|
|
||||||
displayName: Test Network
|
|
||||||
pool:
|
|
||||||
vmImage: ubuntu-20.04
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
Secured-Go:
|
|
||||||
CHAINCODE_NAME: secured
|
|
||||||
CHAINCODE_LANGUAGE: go
|
|
||||||
steps:
|
|
||||||
- template: templates/install-deps.yml
|
|
||||||
- script: ../ci/scripts/run-test-network-secured.sh
|
|
||||||
workingDirectory: test-network
|
|
||||||
displayName: Run Test Network Secured Chaincode
|
|
||||||
|
|
||||||
- job: TestNetworkEvents
|
|
||||||
displayName: Test Network
|
|
||||||
pool:
|
|
||||||
vmImage: ubuntu-20.04
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
Events-Javascript:
|
|
||||||
CHAINCODE_NAME: events
|
|
||||||
CHAINCODE_LANGUAGE: javascript
|
|
||||||
steps:
|
|
||||||
- template: templates/install-deps.yml
|
|
||||||
- script: ../ci/scripts/run-test-network-events.sh
|
|
||||||
workingDirectory: test-network
|
|
||||||
displayName: Run Test Network Events Chaincode
|
|
||||||
|
|
|
||||||
122
ci/scripts/run-k8s-test-network-basic.sh
Executable file
122
ci/scripts/run-k8s-test-network-basic.sh
Executable file
|
|
@ -0,0 +1,122 @@
|
||||||
|
#!/bin/bash -e
|
||||||
|
#
|
||||||
|
# Copyright IBM Corp All Rights Reserved
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Test matrix parameters
|
||||||
|
# todo: compatibility with podman, k3s/rancher, docker, KIND, etc.
|
||||||
|
export CONTAINER_CLI=${CONTAINER_CLI:-docker}
|
||||||
|
export CLIENT_LANGUAGE=${CLIENT_LANGUAGE:-typescript}
|
||||||
|
|
||||||
|
# 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}
|
||||||
|
export TEST_NETWORK_CHAINCODE_NAME=${TEST_NETWORK_CHAINCODE_NAME:-asset-transfer-basic}
|
||||||
|
export TEST_NETWORK_CHAINCODE_IMAGE=${TEST_NETWORK_CHAINCODE_NAME}:${TEST_TAG}
|
||||||
|
export TEST_NETWORK_CHAINCODE_PATH=${TEST_NETWORK_CHAINCODE_PATH:-../asset-transfer-basic/chaincode-external}
|
||||||
|
|
||||||
|
# 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:-basic-asset-transfer}
|
||||||
|
export MSP_ID=${MSP_ID:-Org1MSP}
|
||||||
|
export CRYPTO_PATH=${CRYPTO_PATH:-../../test-network-k8s/build/organizations/peerOrganizations/org1.example.com}
|
||||||
|
export KEY_DIRECTORY_PATH=${KEY_DIRECTORY_PATH:-../../test-network-k8s/build/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore}
|
||||||
|
export CERT_PATH=${CERT_PATH:-../../test-network-k8s/build/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts/cert.pem}
|
||||||
|
export TLS_CERT_PATH=${TLS_CERT_PATH:-../../test-network-k8s/build/organizations/peerOrganizations/org1.example.com/peers/org1-peer1.org1.example.com/tls/cacerts/org1-tls-ca.pem}
|
||||||
|
export PEER_ENDPOINT=${PEER_ENDPOINT:-localhost:7051}
|
||||||
|
export PEER_HOST_ALIAS=${PEER_HOST_ALIAS:-org1-peer1}
|
||||||
|
|
||||||
|
function print() {
|
||||||
|
GREEN='\033[0;32m'
|
||||||
|
NC='\033[0m'
|
||||||
|
echo
|
||||||
|
echo -e "${GREEN}${1}${NC}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function touteSuite() {
|
||||||
|
createCluster
|
||||||
|
buildChaincodeImage
|
||||||
|
}
|
||||||
|
|
||||||
|
function quitterLaScene() {
|
||||||
|
destroyCluster
|
||||||
|
scrubCCImages
|
||||||
|
}
|
||||||
|
|
||||||
|
function createCluster() {
|
||||||
|
print "Initializing KIND Kubernetes cluster"
|
||||||
|
./network kind
|
||||||
|
}
|
||||||
|
|
||||||
|
function destroyCluster() {
|
||||||
|
print "Destroying KIND Kubernetes cluster"
|
||||||
|
./network unkind
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildChaincodeImage() {
|
||||||
|
print "Building chaincode image $TEST_NETWORK_CHAINCODE_IMAGE"
|
||||||
|
${CONTAINER_CLI} build -t $TEST_NETWORK_CHAINCODE_IMAGE $TEST_NETWORK_CHAINCODE_PATH
|
||||||
|
|
||||||
|
# todo: work with local reg, or k3s, or KIND, or ...
|
||||||
|
kind load docker-image $TEST_NETWORK_CHAINCODE_IMAGE
|
||||||
|
}
|
||||||
|
|
||||||
|
function scrubCCImages() {
|
||||||
|
print "Scrubbing chaincode images"
|
||||||
|
${CONTAINER_CLI} rmi $TEST_NETWORK_CHAINCODE_IMAGE
|
||||||
|
}
|
||||||
|
|
||||||
|
function createNetwork() {
|
||||||
|
print "Launching network"
|
||||||
|
./network up
|
||||||
|
./network channel create
|
||||||
|
|
||||||
|
print "Opening gateway port-forward to 'localhost:7051'"
|
||||||
|
kubectl -n test-network port-forward svc/org1-peer1 7051:7051 &
|
||||||
|
|
||||||
|
print "Deploying chaincode"
|
||||||
|
./network chaincode deploy
|
||||||
|
|
||||||
|
print "Extracting certificates"
|
||||||
|
kubectl \
|
||||||
|
-n test-network \
|
||||||
|
exec deploy/org1-peer1 \
|
||||||
|
-c main \
|
||||||
|
-- tar zcvf - -C /var/hyperledger/fabric organizations/peerOrganizations/org1.example.com \
|
||||||
|
| tar zxvf - -C ../test-network-k8s/build/
|
||||||
|
}
|
||||||
|
|
||||||
|
function stopNetwork() {
|
||||||
|
pkill -f "port-forward"
|
||||||
|
|
||||||
|
print "Stopping network"
|
||||||
|
./network down
|
||||||
|
}
|
||||||
|
|
||||||
|
# Set up the suite with a KIND cluster
|
||||||
|
touteSuite
|
||||||
|
trap "quitterLaScene" EXIT
|
||||||
|
|
||||||
|
# Run the basic-asset-transfer basic application
|
||||||
|
createNetwork
|
||||||
|
print "Running Gateway client application"
|
||||||
|
( pushd ${GATEWAY_CLIENT_APPLICATION_PATH} \
|
||||||
|
&& npm install \
|
||||||
|
&& npm start )
|
||||||
|
stopNetwork
|
||||||
|
|
||||||
|
# Run additional test ...
|
||||||
|
# Run additional test ...
|
||||||
|
# Run additional test ...
|
||||||
|
|
||||||
|
# destroyCluster will be invoked on EXIT trap handler at the end of this suite.
|
||||||
9
ci/templates/install-k8s-deps.yml
Normal file
9
ci/templates/install-k8s-deps.yml
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- task: NodeTool@0
|
||||||
|
inputs:
|
||||||
|
versionSpec: $(NODE_VER)
|
||||||
|
displayName: Install Node.js
|
||||||
Loading…
Reference in a new issue