-
Notifications
You must be signed in to change notification settings - Fork 14
/
pte_driver.sh
executable file
·132 lines (110 loc) · 2.47 KB
/
pte_driver.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/bin/bash
#
# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
#
# usage: ./pte_driver.sh <user input file>
# example: ./pte_driver.sh runCases.txt
#
# runCases.txt:
# sdk=node userInputs/userInput-samplecc-i.json
# sdk=node userInputs/userInput-samplecc-q.json
#
#echo "input vars: $# "
inFile=$1
iPTE=0
tStart=0
# if called from pte_mge.sh, then set vars from inputs
if [ $# -gt 1 ]; then
iPTE=$2
tStart=$3
fi
echo "$0 inFile= $inFile, tStart=$tStart iPTE=$iPTE "
EXENODE=pte-main.js
nInstances=0
PIDS=""
while read line
do
#echo $line
tt=$(echo $line | awk '{print $1}')
#echo " tt $tt"
sdkType=$(echo $tt | awk '{print tolower($tt)}')
#echo "tt $tt sdkType $sdkType"
userinput=$(echo $line | awk '{print $2}')
case $sdkType in
sdk=node)
echo "sdk type supported: $sdkType"
nodeArray[${#nodeArray[@]}]=$userinput
;;
sdk=python)
echo "sdk type unsupported: $sdkType"
pythonArray[${#pythonArray[@]}]=$userinput
;;
sdk=java)
echo "sdk type unsupported: $sdkType"
javaArray[${#javaArray[@]}]=$userinput
;;
*)
echo "sdk type unknown: $sdkType"
;;
esac
done < $1
echo "Node Array: ${nodeArray[@]}"
# node requests
function nodeProc {
nInstances=${#nodeArray[@]}
if [ $tStart -eq 0 ]; then
tWait=$[nInstances*4000+10000]
tCurr=`date +%s%N | cut -b1-13`
tStart=$[tCurr+tWait]
fi
echo "iPTE: $iPTE, nInstances: $nInstances, tStart: $tStart"
BCN=0
for i in ${nodeArray[@]}; do
echo "execution: $i"
node $EXENODE $BCN $i $tStart $iPTE &
PIDS="$PIDS $!"
let BCN+=1
done
}
# python requests
function pythonProc {
echo "python has not supported yet."
}
# java requests
function javaProc {
echo "java has not supported yet."
}
# node
if [ ${#nodeArray[@]} -gt 0 ]; then
echo "executing ${#nodeArray[@]} node requests"
nodeProc
else
echo "no node requests"
fi
# python
if [ ${#pythonArray[@]} -gt 0 ]; then
echo "executing ${#pythonArray[@]} python requests"
pythonProc
else
echo "no python requests"
fi
# java
if [ ${#javaArray[@]} -gt 0 ]; then
echo "executing ${#javaArray[@]} java requests"
javaProc
else
echo "no java requests"
fi
# wait for processes to complete
RET=0
for p in $PIDS; do
wait $p
# return the error code of the process failed last if any
if [ $? -ne 0 ]; then
RET=$?
fi
done
exit $RET