add a total time capability
diff --git a/voltha b/voltha
index 2a45b2a..c316a2c 100755
--- a/voltha
+++ b/voltha
@@ -12,6 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+TOTAL_START_TIME=$(date +%s)
FANCY=${FANCY:-1}
if [ "$TERM X" == " X" ]; then
@@ -347,12 +348,7 @@
LOCK="\xf0\x9f\x94\x92"
fi
-timeout() {
- local INDENT=
- if [ "$1" == "-" ]; then
- INDENT=" "
- shift
- fi
+duration() {
local h=$(expr $1 / 3600)
local m=$(expr $1 % 3600 / 60)
local s=$(expr $1 % 60)
@@ -364,8 +360,16 @@
if [ $m -gt 0 ]; then
t="$t${m}m"
fi
- t="$t${s}s"
- echo -e "$INDENT $CLOCK $t"
+ echo "$t${s}s"
+}
+
+printtime() {
+ local INDENT=
+ if [ "$1" == "-" ]; then
+ INDENT=" "
+ shift
+ fi
+ echo -e "$INDENT $CLOCK $(duration $1)"
}
bspin() {
@@ -707,7 +711,7 @@
fi
fi
if [ "$WITH_TIMINGS" == "yes" ]; then
- timeout $(expr $(date +%s) - $STIME)
+ printtime $(expr $(date +%s) - $STIME)
fi
STIME=$(date +%s)
@@ -728,7 +732,7 @@
fi
if [ "$WITH_TIMINGS" == "yes" ]; then
- timeout $(expr $(date +%s) - $STIME)
+ printtime $(expr $(date +%s) - $STIME)
fi
STIME=$(date +%s)
@@ -747,7 +751,7 @@
fi
fi
if [ "$WITH_TIMINGS" == "yes" ]; then
- timeout $(expr $(date +%s) - $STIME)
+ printtime $(expr $(date +%s) - $STIME)
fi
STIME=$(date +%s)
@@ -762,7 +766,7 @@
espin - $VERIFIED
fi
if [ "$WITH_TIMINGS" == "yes" ]; then
- timeout $(expr $(date +%s) - $STIME)
+ printtime $(expr $(date +%s) - $STIME)
fi
bspin "Verify command PATH"
@@ -803,7 +807,7 @@
wait_for_pods - "kube-system" $EXPECT -1 "Waiting for system PODs to start" $P
fi
if [ "$WITH_TIMINGS" == "yes" ]; then
- timeout $(expr $(date +%s) - $STIME)
+ printtime $(expr $(date +%s) - $STIME)
fi
STIME=$(date +%s)
@@ -862,7 +866,7 @@
fi
wait_for_pods - "kube-system" 1 -1 "Waiting for Tiller POD to start" "tiller-deploy-.*"
if [ "$WITH_TIMINGS" == "yes" ]; then
- timeout $(expr $(date +%s) - $STIME)
+ printtime $(expr $(date +%s) - $STIME)
fi
STIME=$(date +%s)
@@ -876,7 +880,7 @@
espin $VERIFIED
fi
if [ "$WITH_TIMINGS" == "yes" ]; then
- timeout $(expr $(date +%s) - $STIME)
+ printtime $(expr $(date +%s) - $STIME)
fi
if [ "$JUST_K8S" == "yes" ]; then
@@ -908,7 +912,7 @@
EXPECT=$(test "$TYPE" == "minimal" && echo "1" || echo "3")
wait_for_pods - "voltha" $EXPECT -1 "Waiting for ETCD Operator to start" "etcd-operator-.*"
if [ "$WITH_TIMINGS" == "yes" ]; then
- timeout $(expr $(date +%s) - $STIME)
+ printtime $(expr $(date +%s) - $STIME)
fi
STIME=$(date +%s)
@@ -965,7 +969,7 @@
push_onos_config "Enabling extraneous rules for ONOS" "configuration/org.onosproject.net.flow.impl.FlowRuleManager" "onos-files/olt-onos-enableExtraneousRules.json"
fi
if [ "$WITH_TIMINGS" == "yes" ]; then
- timeout $(expr $(date +%s) - $STIME)
+ printtime $(expr $(date +%s) - $STIME)
fi
STIME=$(date +%s)
@@ -988,7 +992,7 @@
EXPECT=$(test "$TYPE" == "minimal" && echo "9" || echo "11")
wait_for_pods - "voltha" $EXPECT -1 "Waiting for VOLTHA Core to start" $VOLTHA
if [ "$WITH_TIMINGS" == "yes" ]; then
- timeout $(expr $(date +%s) - $STIME)
+ printtime $(expr $(date +%s) - $STIME)
fi
STIME=$(date +%s)
@@ -1019,7 +1023,7 @@
ADAPTERS="adapter-.*"
wait_for_pods - "voltha" 4 -1 "Waiting for adapters to start" $ADAPTERS
if [ "$WITH_TIMINGS" == "yes" ]; then
- timeout $(expr $(date +%s) - $STIME)
+ printtime $(expr $(date +%s) - $STIME)
fi
if [ $WITH_BBSIM == "yes" ]; then
@@ -1034,7 +1038,7 @@
fi
wait_for_pods - "voltha" 1 -1 "Waiting for BBSIM to start" "bbsim-.*"
if [ "$WITH_TIMINGS" == "yes" ]; then
- timeout $(expr $(date +%s) - $STIME)
+ printtime $(expr $(date +%s) - $STIME)
fi
fi
@@ -1050,7 +1054,7 @@
fi
wait_for_pods - "voltha" 1 -1 "Waiting for RADIUS to start" "radius-.*"
if [ "$WITH_TIMINGS" == "yes" ]; then
- timeout $(expr $(date +%s) - $STIME)
+ printtime $(expr $(date +%s) - $STIME)
fi
fi
@@ -1086,7 +1090,7 @@
(set -x; screen -dmS voltha-etcd-$NAME bash -c "while true; do kubectl port-forward -n voltha service/voltha-etcd-cluster-client $VOLTHA_ETCD_PORT:2379; done" >>$LOG 2>&1) >>$LOG 2>&1
espin - $VERIFIED
if [ "$WITH_TIMINGS" == "yes" ]; then
- timeout $(expr $(date +%s) - $STIME)
+ printtime $(expr $(date +%s) - $STIME)
fi
if [ $WITH_ONOS == "yes" -a $WITH_RADIUS == "yes" ]; then
@@ -1141,3 +1145,7 @@
echo "" | tee -a $LOG
echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG
+if [ "$WITH_TIMINGS" == "yes" ]; then
+ echo -e "$CLOCK TOTAL: $(duration $(expr $(date +%s) - $TOTAL_START_TIME))"
+fi
+