SEBA-103 polling for tosca loaders to be COMPLETED as opposed to sleep

Change-Id: Ia5c229f084d95e4bba7590f1e2ff833656089efd
diff --git a/jjb/pipeline/all-xos-api-test-helm.groovy b/jjb/pipeline/all-xos-api-test-helm.groovy
index 6cf2fcc..9f1e75a 100644
--- a/jjb/pipeline/all-xos-api-test-helm.groovy
+++ b/jjb/pipeline/all-xos-api-test-helm.groovy
@@ -169,8 +169,6 @@
            set -eu -o pipefail
 
            helm_install_args='-f examples/image-tag-candidate.yaml -f examples/imagePullPolicy-IfNotPresent.yaml -f examples/api-test-values.yaml'
-           basesleep=300
-           extrasleep=60
 
            pushd cord/helm-charts
 
@@ -183,14 +181,12 @@
            if [[ "$GERRIT_PROJECT" =~ ^(rcord|onos-service|fabric|olt-service|vsg-hw|vrouter)\$ ]]; then
              helm dep update xos-profiles/rcord-lite
              helm install \${helm_install_args} xos-profiles/rcord-lite -n rcord-lite
-             extrasleep=300
 
            elif [[ "$GERRIT_PROJECT" =~ ^(vMME|vspgwc|vspgwu|vHSS|hss_db|internetemulator|sdn-controller|epc-service|mcord|progran)\$ ]]; then
              helm dep update xos-profiles/base-openstack
              helm dep update xos-profiles/mcord
              helm install \${helm_install_args} xos-profiles/base-openstack -n base-openstack
              helm install \${helm_install_args} xos-profiles/mcord -n mcord
-             extrasleep=900
 
            elif [[ "$GERRIT_PROJECT" =~ ^(openstack|vtn-service|exampleservice|addressmanager)\$ ]]; then
              # NOTE: onos-service is included in base-openstack, but tested w/rcord-lite chart
@@ -218,9 +214,8 @@
              exit 1
            fi
 
-           # sleep to wait for services to load
-           sleep "\$basesleep"
-           sleep "\$extrasleep"
+           # wait for services to load
+           ./scripts/wait_for_jobs.sh
 
            echo "# Checking helm deployments"
            kubectl get pods
diff --git a/jjb/pipeline/chart-api-test-helm.groovy b/jjb/pipeline/chart-api-test-helm.groovy
index 9ae73a4..8a650ce 100644
--- a/jjb/pipeline/chart-api-test-helm.groovy
+++ b/jjb/pipeline/chart-api-test-helm.groovy
@@ -98,8 +98,6 @@
            set -eu -o pipefail
 
            helm_install_args='-f examples/api-test-values.yaml'
-           basesleep=300
-           extrasleep=60
 
            pushd cord/helm-charts
 
@@ -112,14 +110,12 @@
            if [[ "$GERRIT_PROJECT" =~ ^(rcord|onos-service|fabric|olt-service|vsg-hw|vrouter)\$ ]]; then
              helm dep update xos-profiles/rcord-lite
              helm install \${helm_install_args} xos-profiles/rcord-lite -n rcord-lite
-             extrasleep=300
 
            elif [[ "$GERRIT_PROJECT" =~ ^(vMME|vspgwc|vspgwu|vHSS|hss_db|internetemulator|sdn-controller|epc-service|mcord|progran)\$ ]]; then
              helm dep update xos-profiles/base-openstack
              helm dep update xos-profiles/mcord
              helm install \${helm_install_args} xos-profiles/base-openstack -n base-openstack
              helm install \${helm_install_args} xos-profiles/mcord -n mcord
-             extrasleep=900
 
            elif [[ "$GERRIT_PROJECT" =~ ^(openstack|vtn-service|exampleservice|addressmanager)\$ ]]; then
              # NOTE: onos-service is included in base-openstack, but tested w/rcord-lite chart
@@ -147,9 +143,8 @@
              exit 1
            fi
 
-           # sleep to wait for services to load
-           sleep "\$basesleep"
-           sleep "\$extrasleep"
+           # wait for services to load
+           ./scripts/wait_for_jobs.sh
 
            echo "# Checking helm deployments"
            kubectl get pods
diff --git a/jjb/pipeline/xos-synchronizer-update.groovy b/jjb/pipeline/xos-synchronizer-update.groovy
index bfc89ef..f55d0b0 100644
--- a/jjb/pipeline/xos-synchronizer-update.groovy
+++ b/jjb/pipeline/xos-synchronizer-update.groovy
@@ -214,8 +214,6 @@
            set -eu -o pipefail
 
            helm_install_args='-f examples/image-tag-candidate.yaml -f examples/imagePullPolicy-IfNotPresent.yaml -f examples/api-test-values.yaml'
-           basesleep=300
-           extrasleep=60
 
            pushd cord/helm-charts
 
@@ -228,14 +226,12 @@
            if [[ "$GERRIT_PROJECT" =~ ^(rcord|onos-service|fabric|olt-service|vsg-hw|vrouter)\$ ]]; then
              helm dep update xos-profiles/rcord-lite
              helm install \${helm_install_args} xos-profiles/rcord-lite -n rcord-lite
-             extrasleep=300
 
            elif [[ "$GERRIT_PROJECT" =~ ^(vMME|vspgwc|vspgwu|vHSS|hss_db|internetemulator|sdn-controller|epc-service|mcord|progran)\$ ]]; then
              helm dep update xos-profiles/base-openstack
              helm dep update xos-profiles/mcord
              helm install \${helm_install_args} xos-profiles/base-openstack -n base-openstack
              helm install \${helm_install_args} xos-profiles/mcord -n mcord
-             extrasleep=900
 
            elif [[ "$GERRIT_PROJECT" =~ ^(openstack|vtn-service|exampleservice|addressmanager)\$ ]]; then
              # NOTE: onos-service is included in base-openstack, but tested w/rcord-lite chart
@@ -263,10 +259,9 @@
              exit 1
            fi
 
-           # sleep to wait for services to load
-           sleep "\$basesleep"
-           sleep "\$extrasleep"
-
+           # wait for services to load
+           ./scripts/wait_for_jobs.sh
+ 
            echo "# Checking helm deployments"
            kubectl get pods
            helm list