github.com/IBM-Blockchain/fabric-operator@v1.0.4/sample-network/scripts/run-e2e-test.sh (about)

     1  #!/bin/bash
     2  #
     3  # Copyright contributors to the Hyperledger Fabric Operator project
     4  #
     5  # SPDX-License-Identifier: Apache-2.0
     6  #
     7  # Licensed under the Apache License, Version 2.0 (the "License");
     8  # you may not use this file except in compliance with the License.
     9  # You may obtain a copy of the License at:
    10  #
    11  # 	  http://www.apache.org/licenses/LICENSE-2.0
    12  #
    13  # Unless required by applicable law or agreed to in writing, software
    14  # distributed under the License is distributed on an "AS IS" BASIS,
    15  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    16  # See the License for the specific language governing permissions and
    17  # limitations under the License.
    18  #
    19  set -o errexit
    20  
    21  cd "$(dirname "$0")/.."
    22  
    23  # Dump out the error log if we are exiting with a nonzero error code
    24  function exit_fn() {
    25    rc=$?
    26    set +x
    27  
    28    if [ "0" -ne $rc ]; then
    29      cat network-debug.log
    30    fi
    31  }
    32  
    33  # Call the exit handler when we exit.
    34  trap "exit_fn" EXIT
    35  
    36  export PATH=$PWD:$PWD/bin:$PATH
    37  export TEST_NETWORK_INGRESS_DOMAIN=localho.st
    38  
    39  echo "Starting E2E Test.  Environment:"
    40  printenv | sort
    41  
    42  # Set up a cluster
    43  network kind
    44  
    45  # Set up ngress and CRDs
    46  network cluster init
    47  
    48  # Set up a Fabric Network
    49  network up
    50  
    51  kubectl -n test-network get all
    52  
    53  
    54  # Chaincode: general
    55  
    56  export FABRIC_CFG_PATH=${PWD}/temp/config
    57  export CORE_PEER_LOCALMSPID=Org1MSP
    58  export CORE_PEER_ADDRESS=test-network-org1-peer1-peer.${TEST_NETWORK_INGRESS_DOMAIN}:443
    59  export CORE_PEER_TLS_ENABLED=true
    60  export CORE_PEER_MSPCONFIGPATH=${PWD}/temp/enrollments/org1/users/org1admin/msp
    61  export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/temp/channel-msp/peerOrganizations/org1/msp/tlscacerts/tlsca-signcert.pem
    62  
    63  
    64  ## ccaas
    65  
    66  rm -rf /tmp/fabric-samples || true
    67  git clone https://github.com/hyperledger/fabric-samples.git /tmp/fabric-samples
    68  
    69  network channel create
    70  
    71  network cc deploy   asset-transfer-basic basic_1.0 /tmp/fabric-samples/asset-transfer-basic/chaincode-java
    72  
    73  network cc metadata asset-transfer-basic
    74  network cc invoke   asset-transfer-basic '{"Args":["InitLedger"]}'
    75  network cc query    asset-transfer-basic '{"Args":["ReadAsset","asset1"]}' | jq
    76  
    77  peer chaincode query -n asset-transfer-basic -C mychannel -c '{"Args":["org.hyperledger.fabric:GetMetadata"]}'
    78  
    79  
    80  ## k8s-builder
    81  
    82  network down
    83  
    84  export TEST_NETWORK_PEER_IMAGE=ghcr.io/hyperledger-labs/k8s-fabric-peer
    85  export TEST_NETWORK_PEER_IMAGE_LABEL=v0.7.2
    86  
    87  network up
    88  network channel create
    89  
    90  curl -fsSL https://github.com/hyperledgendary/conga-nft-contract/releases/download/v0.1.1/conga-nft-contract-v0.1.1.tgz -o conga-nft-contract-v0.1.1.tgz
    91  
    92  peer lifecycle chaincode install conga-nft-contract-v0.1.1.tgz
    93  
    94  export PACKAGE_ID=$(peer lifecycle chaincode calculatepackageid conga-nft-contract-v0.1.1.tgz) && echo $PACKAGE_ID
    95  
    96  peer lifecycle \
    97    chaincode approveformyorg \
    98    --channelID     mychannel \
    99    --name          conga-nft-contract \
   100    --version       1 \
   101    --package-id    ${PACKAGE_ID} \
   102    --sequence      1 \
   103    --orderer       test-network-org0-orderersnode1-orderer.${TEST_NETWORK_INGRESS_DOMAIN}:443 \
   104    --tls --cafile  $PWD/temp/channel-msp/ordererOrganizations/org0/orderers/org0-orderersnode1/tls/signcerts/tls-cert.pem \
   105    --connTimeout   15s
   106  
   107  peer lifecycle \
   108    chaincode commit \
   109    --channelID     mychannel \
   110    --name          conga-nft-contract \
   111    --version       1 \
   112    --sequence      1 \
   113    --orderer       test-network-org0-orderersnode1-orderer.${TEST_NETWORK_INGRESS_DOMAIN}:443 \
   114    --tls --cafile  $PWD/temp/channel-msp/ordererOrganizations/org0/orderers/org0-orderersnode1/tls/signcerts/tls-cert.pem \
   115    --connTimeout   15s
   116  
   117  kubectl -n test-network describe pods -l app.kubernetes.io/created-by=fabric-builder-k8s
   118  
   119  peer chaincode query -n conga-nft-contract -C mychannel -c '{"Args":["org.hyperledger.fabric:GetMetadata"]}'
   120  
   121  network down