add ability to time steps
diff --git a/README.md b/README.md
index c05acd6..28feeee 100644
--- a/README.md
+++ b/README.md
@@ -62,6 +62,7 @@
| OPTION | DEFAULT | DESCRIPTION |
| ------------------------------- | ---------------------------- | ----------------------------------------------------------------------------------- |
| `TYPE` | minimal | `minimal` or `full` and determines number of cluster nodes and etcd cluster members |
+| `WITH_TIMINGS` | no | Outputs duration of various steps of the install |
| `WITH_BBSIM` | no | Should the BBSIM POD be deployed? |
| `WITH_RADIUS` | no | Should `freeradius` service be deployed? |
| `WITH_ONOS` | yes | Should `ONOS` service be deployed? |
diff --git a/voltha b/voltha
index ac8730c..f5adc4d 100755
--- a/voltha
+++ b/voltha
@@ -66,6 +66,7 @@
TYPE=${TYPE:-minimal}
NAME=${NAME:-$TYPE}
+WITH_TIMINGS=${WITH_TIMINGS:-no}
WITH_BBSIM=${WITH_BBSIM:-no}
WITH_RADIUS=${WITH_RADIUS:-no}
WITH_ONOS=${WITH_ONOS:-yes}
@@ -207,6 +208,18 @@
INSTALL_HELM=no
fi
+# Verify WITH_TIMINGS settting and convert uniform value of yes or no
+if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$WITH_TIMINGS:") -eq 0 ]; then
+ >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$WITH_TIMINGS value of '$WITH_TIMINGS'. Should be 'yes' or 'no'${NORMAL}"
+ exit 1
+fi
+
+if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_TIMINGS:") -eq 1 ]; then
+ WITH_TIMINGS=yes
+else
+ WITH_TIMINGS=no
+fi
+
mkdir -p .voltha
touch .voltha/ports
HAVE=$(grep $NAME .voltha/ports)
@@ -279,6 +292,7 @@
}
IDX=1
+CLOCK="TIME:"
SPIN_PARTS=
NOT_VERIFIED=
VERIFIED=
@@ -308,6 +322,7 @@
\xe2\xa2\x8c\xe2\xa1\xb1 \
\xe2\xa2\x86\xe2\xa1\xb1 \
"
+ CLOCK="\xe2\x8f\xb1"
NOT_VERIFIED="\xe2\x9c\x97\x20"
VERIFIED="\xe2\x9c\x93\x20"
HELM="\xE2\x8E\x88"
@@ -326,6 +341,27 @@
LOCK="\xf0\x9f\x94\x92"
fi
+timeout() {
+ local INDENT=
+ if [ "$1" == "-" ]; then
+ INDENT=" "
+ shift
+ fi
+ local h=$(expr $1 / 3600)
+ local m=$(expr $1 % 3600 / 60)
+ local s=$(expr $1 % 60)
+ local t=""
+
+ if [ $h -gt 0 ]; then
+ t="$t${h}h"
+ fi
+ if [ $m -gt 0 ]; then
+ t="$t${m}m"
+ fi
+ t="$t${s}s"
+ echo -e "$INDENT $CLOCK $t"
+}
+
bspin() {
IDX=1
local INDENT=
@@ -511,7 +547,7 @@
# Output install options to log
echo "OPTIONS" >> $LOG
-ALL_OPTIONS="NAME TYPE WITH_BBSIM WITH_RADIUS WITH_ONOS WITH_TP JUST_K8S DEPLOY_K8S \
+ALL_OPTIONS="NAME TYPE WITH_TIMINGS WITH_BBSIM WITH_RADIUS WITH_ONOS WITH_TP JUST_K8S DEPLOY_K8S \
SKIP_RESTART_API INSTALL_KUBECTL INSTALL_HELM USE_GO VOLTHA_LOG_LEVEL \
VOLTHA_CHART VOLTHA_ADAPTER_SIM_CHART VOLTHA_ADAPTER_OPEN_OLT_CHART \
VOLTHA_ADAPTER_OPEN_ONU_CHART SADIS_VER OLT_VER AAA_VER DHCP_VER \
@@ -616,6 +652,7 @@
mkdir -p $GOPATH/bin
espin $VERIFIED
+STIME=$(date +%s)
if [ "$INSTALL_KUBECTL" == "no" ]; then
bspin "Skip kubectl install"
espin $NO_ENTRY
@@ -631,7 +668,11 @@
espin - $VERIFIED
fi
fi
+if [ "$WITH_TIMINGS" == "yes" ]; then
+ timeout $(expr $(date +%s) - $STIME)
+fi
+STIME=$(date +%s)
if [ "$DEPLOY_K8S" == "no" ]; then
bspin "Skip Kubernetes/Kind Deployment"
espin $NO_ENTRY
@@ -648,6 +689,11 @@
fi
fi
+if [ "$WITH_TIMINGS" == "yes" ]; then
+ timeout $(expr $(date +%s) - $STIME)
+fi
+
+STIME=$(date +%s)
if [ "$INSTALL_HELM" == "no" ]; then
bspin "Skip Helm Install"
espin $NO_ENTRY
@@ -662,7 +708,11 @@
espin - $VERIFIED
fi
fi
+if [ "$WITH_TIMINGS" == "yes" ]; then
+ timeout $(expr $(date +%s) - $STIME)
+fi
+STIME=$(date +%s)
bspin "Verify voltctl $HIGH_VOLTAGE"
if [ -x $GOPATH/bin/voltctl ]; then
espin $VERIFIED
@@ -673,11 +723,15 @@
(set -x; chmod 755 $GOPATH/bin/voltctl >>$LOG 2>&1) >>$LOG 2>&1
espin - $VERIFIED
fi
+if [ "$WITH_TIMINGS" == "yes" ]; then
+ timeout $(expr $(date +%s) - $STIME)
+fi
bspin "Verify command PATH"
export PATH=$GOPATH/bin:$PATH
espin $VERIFIED
+STIME=$(date +%s)
if [ "$DEPLOY_K8S" == "yes" ]; then
HAVE=$(kind get clusters | grep -c voltha-$NAME)
bspin "Verify Kubernetes/Kind Cluster"
@@ -710,7 +764,11 @@
EXPECT=$(test "$TYPE" == "minimal" && echo "12" || echo "14")
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)
+fi
+STIME=$(date +%s)
COUNT=$(count_pods "kube-system" "tiller-deploy-.*")
bspin "Verify Helm"
if [ $COUNT -ne 1 ]; then
@@ -765,7 +823,11 @@
espin $VERIFIED
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)
+fi
+STIME=$(date +%s)
bspin "Verify Helm values file: $NAME-values.yaml"
if [ ! -r "./$NAME-values.yaml" ]; then
espin $NOT_VERIFIED
@@ -775,6 +837,9 @@
else
espin $VERIFIED
fi
+if [ "$WITH_TIMINGS" == "yes" ]; then
+ timeout $(expr $(date +%s) - $STIME)
+fi
if [ "$JUST_K8S" == "yes" ]; then
echo "Environment deployed, not deploying VOLTHA artifacts as requested. Good bye."
@@ -794,6 +859,7 @@
exit 0
fi
+STIME=$(date +%s)
bspin "Verify ETCD Operator $OLD_KEY"
if [ $(helm list --deployed --short --namespace voltha "^etcd-operator\$" | wc -l) -ne 1 ]; then
espin $NOT_VERIFIED
@@ -803,7 +869,11 @@
fi
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)
+fi
+STIME=$(date +%s)
if [ $WITH_ONOS == "yes" ]; then
bspin "Verify ONOS installed $BIRD"
if [ $(helm list --deployed --short --namespace default "^onos\$" | wc -l) -ne 1 ]; then
@@ -842,7 +912,11 @@
(set -x; ./onos-files/install-onos-applications.sh >>$LOG 2>&1) >>$LOG 2>&1
espin - $VERIFIED
fi
+if [ "$WITH_TIMINGS" == "yes" ]; then
+ timeout $(expr $(date +%s) - $STIME)
+fi
+STIME=$(date +%s)
bspin "Verify VOLTHA installed $HIGH_VOLTAGE"
if [ $(helm list --deployed --short --namespace voltha "^voltha\$" | wc -l) -ne 1 ]; then
espin $NOT_VERIFIED
@@ -861,7 +935,11 @@
voltha-zookeeper-.*"
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)
+fi
+STIME=$(date +%s)
echo -e "Verify Adapters $PLUG"
bspin - "Verify Simulated Adapters installed"
if [ $(helm list --deployed --short --namespace voltha "^sim\$" | wc -l) -ne 1 ]; then
@@ -888,8 +966,12 @@
ADAPTERS="adapter-.*"
wait_for_pods - "voltha" 4 -1 "Waiting for adapters to start" $ADAPTERS
+if [ "$WITH_TIMINGS" == "yes" ]; then
+ timeout $(expr $(date +%s) - $STIME)
+fi
if [ $WITH_BBSIM == "yes" ]; then
+ STIME=$(date +%s)
echo -e "Verify BBSIM $PLUG"
bspin - "Verify BBSIM Installed"
if [ $(helm list --deployed --short --namespace voltha "^bbsim\$" | wc -l) -ne 1 ]; then
@@ -899,9 +981,13 @@
espin - $VERIFIED
fi
wait_for_pods - "voltha" 1 -1 "Waiting for BBSIM to start" "bbsim-.*"
+ if [ "$WITH_TIMINGS" == "yes" ]; then
+ timeout $(expr $(date +%s) - $STIME)
+ fi
fi
if [ $WITH_RADIUS == "yes" ]; then
+ STIME=$(date +%s)
echo -e "Verify RADIUS $LOCK"
bspin - "Verify RADIUS Installed"
if [ $(helm list --deployed --short --namespace voltha "^radius\$" | wc -l) -ne 1 ]; then
@@ -911,8 +997,12 @@
espin - $VERIFIED
fi
wait_for_pods - "voltha" 1 -1 "Waiting for RADIUS to start" "radius-.*"
+ if [ "$WITH_TIMINGS" == "yes" ]; then
+ timeout $(expr $(date +%s) - $STIME)
+ fi
fi
+STIME=$(date +%s)
if [ $SKIP_RESTART_API == "no" ]; then
echo -e "Restart VOLTHA API $RESTART"
API="voltha-api-server-.* ofagent-.*"
@@ -943,6 +1033,9 @@
done
(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)
+fi
if [ $WITH_ONOS == "yes" -a $WITH_RADIUS == "yes" ]; then
bspin "Configure ONOS RADIUS Connection $GEAR"