SEBA-102 adding stage to wait for xos core to have loaded core models

Change-Id: I5daddd2331ea33710391871968a3544db228e674
diff --git a/jjb/pipeline/all-xos-api-test-helm.groovy b/jjb/pipeline/all-xos-api-test-helm.groovy
index 3ef3249..a137b46 100644
--- a/jjb/pipeline/all-xos-api-test-helm.groovy
+++ b/jjb/pipeline/all-xos-api-test-helm.groovy
@@ -208,8 +208,6 @@
 
            elif [[ "$GERRIT_PROJECT" =~ ^(xos|xos-tosca|cord-tester|helm-charts)\$ ]]; then
              echo "No additional charts to install for testing $GERRIT_PROJECT"
-	     # ADDING TEMP SLEEP UNIL SEBA-102 resolves
-	     sleep 300
 
            else
              echo "Couldn't find a chart to test project: $GERRIT_PROJECT!"
@@ -233,6 +231,30 @@
            """
       }
     }
+    stage('wait for core') {
+      steps {
+        timeout(time:5) {
+          waitUntil {
+            script {
+              try {
+                sh """
+                CORE_POD=\$(kubectl get pods | grep xos-core | awk '{print \$1}')
+                CHAM_POD=\$(kubectl get pods | grep chameleon | awk '{print \$1}')
+                CHAM_CONTAINER=\$(docker ps | grep k8s_xos-chameleon | awk '{print \$1}')
+                XOS_CHAMELEON=\$(docker exec \$CHAM_CONTAINER ip a | grep -oE "([0-9]{1,3}\\.){3}[0-9]{1,3}\\b" | grep 172)
+                kubectl logs \$CORE_POD | grep "XOS core entering wait loop"
+                kubectl logs \$CHAM_POD | grep reconnected | wc -l | grep 2
+                curl -I -u admin@opencord.org:letmein http://\$XOS_CHAMELEON:9101/xosapi/v1/core/users | grep "200 OK"
+                """
+                return true
+              } catch (exception) {
+              return false
+              }
+            }
+          }
+        }
+      }
+    }
 
     stage('setup') {
       steps {
diff --git a/jjb/pipeline/chart-api-test-helm.groovy b/jjb/pipeline/chart-api-test-helm.groovy
index a9463f4..2b1fa42 100644
--- a/jjb/pipeline/chart-api-test-helm.groovy
+++ b/jjb/pipeline/chart-api-test-helm.groovy
@@ -162,6 +162,30 @@
            """
       }
     }
+    stage('wait for core') {
+      steps {
+        timeout(time:5) {
+          waitUntil {
+            script {
+              try {
+                sh """
+                CORE_POD=\$(kubectl get pods | grep xos-core | awk '{print \$1}')
+                CHAM_POD=\$(kubectl get pods | grep chameleon | awk '{print \$1}')
+                CHAM_CONTAINER=\$(docker ps | grep k8s_xos-chameleon | awk '{print \$1}')
+                XOS_CHAMELEON=\$(docker exec \$CHAM_CONTAINER ip a | grep -oE "([0-9]{1,3}\\.){3}[0-9]{1,3}\\b" | grep 172)
+                kubectl logs \$CORE_POD | grep "XOS core entering wait loop"
+                kubectl logs \$CHAM_POD | grep reconnected | wc -l | grep 2
+                curl -I -u admin@opencord.org:letmein http://\$XOS_CHAMELEON:9101/xosapi/v1/core/users | grep "200 OK"
+                """
+                return true
+              } catch (exception) {
+              return false
+              }
+            }
+          }
+        }
+      }
+    }
 
     stage('setup') {
       steps {
diff --git a/jjb/pipeline/xos-synchronizer-update.groovy b/jjb/pipeline/xos-synchronizer-update.groovy
index 5a08c96..9f38652 100644
--- a/jjb/pipeline/xos-synchronizer-update.groovy
+++ b/jjb/pipeline/xos-synchronizer-update.groovy
@@ -263,7 +263,7 @@
 
            # wait for services to load
            ./scripts/wait_for_jobs.sh
- 
+
            echo "# Checking helm deployments"
            kubectl get pods
            helm list
@@ -279,6 +279,31 @@
       }
     }
 
+    stage('wait for core') {
+      steps {
+        timeout(time:5) {
+          waitUntil {
+            script {
+              try {
+                sh """
+                CORE_POD=\$(kubectl get pods | grep xos-core | awk '{print \$1}')
+                CHAM_POD=\$(kubectl get pods | grep chameleon | awk '{print \$1}')
+                CHAM_CONTAINER=\$(docker ps | grep k8s_xos-chameleon | awk '{print \$1}')
+                XOS_CHAMELEON=\$(docker exec \$CHAM_CONTAINER ip a | grep -oE "([0-9]{1,3}\\.){3}[0-9]{1,3}\\b" | grep 172)
+                kubectl logs \$CORE_POD | grep "XOS core entering wait loop"
+                kubectl logs \$CHAM_POD | grep reconnected | wc -l | grep 2
+                curl -I -u admin@opencord.org:letmein http://\$XOS_CHAMELEON:9101/xosapi/v1/core/users | grep "200 OK"
+                """
+                return true
+              } catch (exception) {
+              return false
+              }
+            }
+          }
+        }
+      }
+    }
+
     stage('setup') {
       steps {
         sh """