github.com/kchristidis/fabric@v1.0.4-0.20171028114726-837acd08cde1/test/tools/PTE/pte_driver.sh (about) 1 #!/bin/bash 2 # 3 # Copyright IBM Corp. All Rights Reserved. 4 # 5 # SPDX-License-Identifier: Apache-2.0 6 # 7 # 8 # usage: ./pte_driver.sh <user input file> 9 # example: ./pte_driver.sh runCases.txt 10 # 11 # runCases.txt: 12 # node userInputs/userInput-samplecc-i.json 13 # node userInputs/userInput-samplecc-q.json 14 # 15 16 inFile=$1 17 EXENODE=pte-main.js 18 nNetwork=0 19 20 while read line 21 do 22 #echo $line 23 tt=$(echo $line | awk '{print $1}') 24 #echo " tt $tt" 25 sdkType=$(echo $tt | awk '{print tolower($tt)}') 26 #echo "tt $tt sdkType $sdkType" 27 userinput=$(echo $line | awk '{print $2}') 28 29 case $sdkType in 30 sdk=node) 31 echo "sdk type spported: $sdkType" 32 nodeArray[${#nodeArray[@]}]=$userinput 33 ;; 34 35 sdk=python) 36 echo "sdk type unspported: $sdkType" 37 pythonArray[${#pythonArray[@]}]=$userinput 38 ;; 39 40 sdk=java) 41 echo "sdk type unspported: $sdkType" 42 javaArray[${#javaArray[@]}]=$userinput 43 ;; 44 45 *) 46 echo "sdk type unknown: $sdkType" 47 ;; 48 49 esac 50 51 done < $1 52 53 echo "Node Array: ${nodeArray[@]}" 54 55 # node requests 56 function nodeProc { 57 nNetwork=${#nodeArray[@]} 58 tWait=$[nNetwork*4000+10000] 59 tCurr=`date +%s%N | cut -b1-13` 60 tStart=$[tCurr+tWait] 61 echo "nNetwork: $nNetwork, tStart: $tStart" 62 63 BCN=0 64 for i in ${nodeArray[@]}; do 65 echo "execution: $i" 66 node $EXENODE $BCN $i $tStart & 67 let BCN+=1 68 done 69 } 70 71 # node requests 72 function pythonProc { 73 echo "python has not supported yet." 74 } 75 76 # node requests 77 function javaProc { 78 echo "java has not supported yet." 79 } 80 81 # node 82 if [ ${#nodeArray[@]} -gt 0 ]; then 83 echo "executing ${#nodeArray[@]} node requests" 84 nodeProc 85 else 86 echo "no node requests" 87 fi 88 89 # python 90 if [ ${#pythonArray[@]} -gt 0 ]; then 91 echo "executing ${#pythonArray[@]} python requests" 92 pythonProc 93 else 94 echo "no python requests" 95 fi 96 97 # java 98 if [ ${#javaArray[@]} -gt 0 ]; then 99 echo "executing ${#javaArray[@]} java requests" 100 javaProc 101 else 102 echo "no java requests" 103 fi 104 105 exit