Merge "[SEBA-497] Fix how xos containers are built/tested"
diff --git a/jjb/pipeline/xos-core.groovy b/jjb/pipeline/xos-core.groovy
index dca5f16..f7bc99e 100644
--- a/jjb/pipeline/xos-core.groovy
+++ b/jjb/pipeline/xos-core.groovy
@@ -96,11 +96,13 @@
 
            export DOCKER_REPOSITORY=xosproject/
            export DOCKER_TAG=\$(cat $WORKSPACE/cord/orchestration/xos/VERSION)
+           export DOCKER_BUILD_ARGS=--no-cache
 
-           cd $WORKSPACE/cord/orchestration/xos/containers/xos
-           make build
+           cd $WORKSPACE/cord/orchestration/xos
+           make docker-build
+
            cd $WORKSPACE/cord/orchestration/xos/testservice
-           make DOCKER_BUILD_ARGS=--no-cache docker-build
+           make docker-build
            """
       }
     }
@@ -147,6 +149,7 @@
            set -eu -o pipefail
            pushd cord/test/cord-tester/src/test/cord-api/
            source setup_venv.sh
+
            cd Tests/xos-test-service
            robot -e notready test-service.robot || true
            popd
diff --git a/jjb/shell/xos-unit.sh b/jjb/shell/xos-unit.sh
index 53af6b6..26b28a2 100644
--- a/jjb/shell/xos-unit.sh
+++ b/jjb/shell/xos-unit.sh
@@ -21,20 +21,22 @@
 WORKSPACE=${WORKSPACE:-.}
 GERRIT_PROJECT=${GERRIT_PROJECT:-xos}
 
-# create python virtual env
-export XOS_DIR=${WORKSPACE}/cord/orchestration/xos
-$XOS_DIR/scripts/setup_venv.sh
-source venv-xos/bin/activate
-
 # find the path to the project that is checked out
 PROJECT_PATH=$(xmllint --xpath "string(//project[@name=\"$GERRIT_PROJECT\"]/@path)" cord/.repo/manifest.xml)
 
 if [ -f "$WORKSPACE/cord/$PROJECT_PATH/Makefile" ]; then
+  # assume newer testing method which uses Makefile
   pushd "$WORKSPACE/cord/$PROJECT_PATH"
   make test
+
 else
+  # assume older branch, so set up the venv the old way
   echo "No Makefile present"
 
+  export XOS_DIR=${WORKSPACE}/cord/orchestration/xos
+  "$XOS_DIR/scripts/setup_venv.sh"
+  source "$XOS_DIR/venv-xos/bin/activate"
+
   if [ "$GERRIT_PROJECT" = 'xos' ] ; then
     pushd "$WORKSPACE/cord/$PROJECT_PATH"
   else
@@ -43,9 +45,9 @@
 
   echo "Checking Migrations"
   if [ "$GERRIT_PROJECT" = 'xos' ] ; then
-    xos-migrate -r $WORKSPACE/cord -s core --check
+    xos-migrate -r "$WORKSPACE/cord" -s core --check
   else
-    xos-migrate -r $WORKSPACE/cord -s $GERRIT_PROJECT --check
+    xos-migrate -r "$WORKSPACE/cord" -s "$GERRIT_PROJECT" --check
   fi
 
   echo "Performing nose2 tests"
diff --git a/jjb/verify/chameleon.yaml b/jjb/verify/chameleon.yaml
index 02bb32c..f5fc3ae 100644
--- a/jjb/verify/chameleon.yaml
+++ b/jjb/verify/chameleon.yaml
@@ -18,7 +18,9 @@
       - 'tag-collision-reject':
           dependency-jobs: 'verify_chameleon_licensed'
       - 'python-unit-test':
-          dependency-jobs: 'verify_chameleon_sonarqube'
+          dependency-jobs: 'verify_chameleon_tag-collision'
+      - 'xos-auth':
+          dependency-jobs: 'verify_chameleon_unit-test'
 
 - job-group:
     name: 'publish-chameleon-jobs'
diff --git a/jjb/verify/xos-tosca.yaml b/jjb/verify/xos-tosca.yaml
index 1eaeeab..bdcca9f 100644
--- a/jjb/verify/xos-tosca.yaml
+++ b/jjb/verify/xos-tosca.yaml
@@ -15,12 +15,8 @@
       - 'verify-licensed'
       - 'tag-collision-reject':
           dependency-jobs: 'verify_xos-tosca_licensed'
-      - 'verify-sonarqube':
+      - 'python-unit-test':
           dependency-jobs: 'verify_xos-tosca_tag-collision'
       - 'api-test':
-          dependency-jobs: 'verify_xos-tosca_sonarqube'
           pipeline_script: 'all-xos-api-test-helm.groovy'
-      - 'xos-tosca-unit-test':
-          dependency-jobs: 'verify_xos-tosca_sonarqube'
-      - 'xos-tosca-e2e-test':
-          dependency-jobs: 'verify_xos-tosca_sonarqube'
+          dependency-jobs: 'verify_xos-tosca_unit-test'
diff --git a/jjb/verify/xos.yaml b/jjb/verify/xos.yaml
index 0faaf33..d1aa840 100644
--- a/jjb/verify/xos.yaml
+++ b/jjb/verify/xos.yaml
@@ -29,12 +29,9 @@
 - job-group:
     name: 'verify-xos-jobs-code'
     jobs:
-#     - 'verify-sonarqube':
-#         build-timeout: 45
       - 'python-unit-test':
           build-timeout: 45
           build-node: 'ubuntu16.04-basebuild-2c-4g'
-#     - 'synchronizer-update'
       - 'api-test':
           pipeline_script: 'xos-core.groovy'
 
diff --git a/jjb/xos-auth.yaml b/jjb/xos-auth.yaml
new file mode 100644
index 0000000..6b035f9
--- /dev/null
+++ b/jjb/xos-auth.yaml
@@ -0,0 +1,85 @@
+---
+# xos auth test
+
+- job-template:
+    id: 'xos-auth-test'
+    name: 'verify_{project}_auth-test'
+
+    description: |
+      Created by {id} job-template from ci-management/jjb/xos-auth.yaml
+
+    triggers:
+      - cord-infra-gerrit-trigger-patchset:
+          gerrit-server-name: '{gerrit-server-name}'
+          project-regexp: '^{project}$'
+          branch-regexp: '{branch-regexp}'
+          dependency-jobs: '{dependency-jobs}'
+          file-include-regexp: '{all-files-regexp}'
+
+    properties:
+      - cord-infra-properties:
+          build-days-to-keep: '{build-days-to-keep}'
+          artifact-num-to-keep: '{artifact-num-to-keep}'
+
+    wrappers:
+      - lf-infra-wrappers:
+          build-timeout: '20'
+          jenkins-ssh-credential: '{jenkins-ssh-credential}'
+
+    scm:
+      - cord-infra-gerrit-repo-scm:
+          manifest-url: '{gerrit-server-url}/{cord-repo-manifest}'
+          branch: '$GERRIT_BRANCH'
+          destination-dir: 'cord'
+
+    node: 'ubuntu16.04-basebuild-4c-8g'
+    project-type: freestyle
+    concurrent: true
+
+    builders:
+      - cord-infra-gerrit-repo-patch:
+          destination-dir: 'cord'
+          project: '$GERRIT_PROJECT'
+          change-number: '$GERRIT_CHANGE_NUMBER'
+          patchset-number: '$GERRIT_PATCHSET_NUMBER'
+      - shell: |
+          #!/usr/bin/env bash
+          set -ex -o pipefail
+
+          export XOS_DIR=$WORKSPACE/cord/orchestration/xos
+          export CHAMELEON_DIR=$WORKSPACE/cord/component/chameleon
+
+          #install minikube+helm
+          export MINIKUBE_WANTUPDATENOTIFICATION=false
+          export MINIKUBE_WANTREPORTERRORPROMPT=false
+          export CHANGE_MINIKUBE_NONE_USER=true
+          export MINIKUBE_HOME=$HOME
+          mkdir -p $HOME/.kube || true
+          touch $HOME/.kube/config
+          export KUBECONFIG=$HOME/.kube/config
+          sudo -E /usr/bin/minikube start --vm-driver=none
+          sleep 300
+
+          helm init
+          sleep 60
+          helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/
+
+          # build chameleon container
+          cd $CHAMELEON_DIR
+          make DOCKER_REPOSITORY=xosproject/ docker-build
+
+          #deploy xos core
+          cd $WORKSPACE/cord/helm-charts
+          helm dep update xos-core
+          helm install --set images.xos_chameleon.tag=candidate -f examples/imagePullPolicy-IfNotPresent.yaml -n xos-core xos-core
+
+          #wait for xos-core and models to be loaded
+          timeout 300 bash -c "until http -a admin@opencord.org:letmein GET http://127.0.0.1:30001/xosapi/v1/core/sites |jq '.items[0].name'|grep -q mysite; do echo 'Waiting for API To be up'; sleep 10; done"
+
+          #test apis
+          curl -Is -u admin@opencord.org:letmein GET http://127.0.0.1:30001/xosapi/v1/core/sites | grep -q '200 OK'
+          curl -Is -u wronguser@opencord.org:wrongpass GET http://127.0.0.1:30001/xosapi/v1/core/sites | grep '403 Forbidden'
+          curl -Is -u admin@opencord.org:letmein GET http://127.0.0.1:30001/xosapi/v1/utility/auth_noop | grep '405 Method Not Allowed'
+          curl -Is -u wronguser@opencord.org:wrongpass GET http://127.0.0.1:30001/xosapi/v1/utility/auth_noop | grep '405 Method Not Allowed'
+          curl -Is -u wronguser@opencord.org:wrongpass GET http://127.0.0.1:30001/xosapi/v1/utility/noop | grep '405 Method Not Allowed'
+          curl -Is GET http://127.0.0.1:30001/xosapi/v1/utility/noop | grep '405 Method Not Allowed'
diff --git a/jjb/xos-tosca-e2e.yaml b/jjb/xos-tosca-e2e.yaml
deleted file mode 100644
index dff9bea..0000000
--- a/jjb/xos-tosca-e2e.yaml
+++ /dev/null
@@ -1,85 +0,0 @@
----
-# xos tosca e2e test
-
-- job-template:
-    id: 'xos-tosca-e2e-test'
-    name: 'verify_{project}_e2e-test'
-
-    description: |
-      Created by {id} job-template from ci-management/jjb/xos-tosca-e2e.yaml
-
-    triggers:
-      - cord-infra-gerrit-trigger-patchset:
-          gerrit-server-name: '{gerrit-server-name}'
-          project-regexp: '^{project}$'
-          branch-regexp: '{branch-regexp}'
-          dependency-jobs: '{dependency-jobs}'
-          file-include-regexp: '{all-files-regexp}'
-
-    properties:
-      - cord-infra-properties:
-          build-days-to-keep: '{build-days-to-keep}'
-          artifact-num-to-keep: '{artifact-num-to-keep}'
-
-    wrappers:
-      - lf-infra-wrappers:
-          build-timeout: '20'
-          jenkins-ssh-credential: '{jenkins-ssh-credential}'
-
-    scm:
-      - cord-infra-gerrit-repo-scm:
-          manifest-url: '{gerrit-server-url}/{cord-repo-manifest}'
-          branch: '$GERRIT_BRANCH'
-          destination-dir: 'cord'
-
-    node: 'ubuntu16.04-basebuild-4c-8g'
-    project-type: freestyle
-    concurrent: true
-
-    builders:
-      - cord-infra-gerrit-repo-patch:
-          destination-dir: 'cord'
-          project: '$GERRIT_PROJECT'
-          change-number: '$GERRIT_CHANGE_NUMBER'
-          patchset-number: '$GERRIT_PATCHSET_NUMBER'
-      - shell: |
-          #!/usr/bin/env bash
-          set -ex -o pipefail
-
-          export XOS_DIR=$WORKSPACE/cord/orchestration/xos
-          export TOSCA_DIR=$WORKSPACE/cord/orchestration/xos-tosca
-
-           #install minikube+helm
-           export MINIKUBE_WANTUPDATENOTIFICATION=false
-           export MINIKUBE_WANTREPORTERRORPROMPT=false
-           export CHANGE_MINIKUBE_NONE_USER=true
-           export MINIKUBE_HOME=$HOME
-           mkdir -p $HOME/.kube || true
-           touch $HOME/.kube/config
-           export KUBECONFIG=$HOME/.kube/config
-           sudo -E /usr/bin/minikube start --vm-driver=none
-           sleep 300
-
-           helm init
-           sleep 60
-           helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/
-
-           # build tosca container
-           cd $TOSCA_DIR
-           make build
-
-           #deploy xos core
-           cd $WORKSPACE/cord/helm-charts
-           helm dep update xos-core
-           helm install --set images.xos_tosca.tag=candidate -f examples/imagePullPolicy-IfNotPresent.yaml -n xos-core xos-core
-
-           #wait for xos-core and models to be loaded
-           timeout 300 bash -c "until http -a admin@opencord.org:letmein GET http://127.0.0.1:30001/xosapi/v1/core/sites |jq '.items[0].name'|grep -q mysite; do echo 'Waiting for API To be up'; sleep 10; done"
-
-           #test apis
-           curl -Is -u admin@opencord.org:letmein GET http://127.0.0.1:30001/xosapi/v1/core/sites | grep -q '200 OK'
-           curl -Is -u wronguser@opencord.org:wrongpass GET http://127.0.0.1:30001/xosapi/v1/core/sites | grep '403 Forbidden'
-           curl -Is -u admin@opencord.org:letmein GET http://127.0.0.1:30001/xosapi/v1/utility/auth_noop | grep '405 Method Not Allowed'
-           curl -Is -u wronguser@opencord.org:wrongpass GET http://127.0.0.1:30001/xosapi/v1/utility/auth_noop | grep '405 Method Not Allowed'
-           curl -Is -u wronguser@opencord.org:wrongpass GET http://127.0.0.1:30001/xosapi/v1/utility/noop | grep '405 Method Not Allowed'
-           curl -Is GET http://127.0.0.1:30001/xosapi/v1/utility/noop | grep '405 Method Not Allowed'
diff --git a/jjb/xos-tosca-unit.yaml b/jjb/xos-tosca-unit.yaml
deleted file mode 100644
index 2259350..0000000
--- a/jjb/xos-tosca-unit.yaml
+++ /dev/null
@@ -1,76 +0,0 @@
----
-# xos tosca unit test
-
-- job-template:
-    id: 'xos-tosca-unit-test'
-    name: 'verify_{project}_unit-test'
-
-    description: |
-      Created by {id} job-template from ci-management/jjb/xos-tosca-unit.yaml
-
-    triggers:
-      - cord-infra-gerrit-trigger-patchset:
-          gerrit-server-name: '{gerrit-server-name}'
-          project-regexp: '^{project}$'
-          branch-regexp: '{branch-regexp}'
-          dependency-jobs: '{dependency-jobs}'
-          file-include-regexp: '{all-files-regexp}'
-
-    properties:
-      - cord-infra-properties:
-          build-days-to-keep: '{build-days-to-keep}'
-          artifact-num-to-keep: '{artifact-num-to-keep}'
-
-    wrappers:
-      - lf-infra-wrappers:
-          build-timeout: '{build-timeout}'
-          jenkins-ssh-credential: '{jenkins-ssh-credential}'
-
-    scm:
-      - cord-infra-gerrit-repo-scm:
-          manifest-url: '{gerrit-server-url}/{cord-repo-manifest}'
-          branch: '$GERRIT_BRANCH'
-          destination-dir: 'cord'
-
-    node: '{build-node}'
-    project-type: freestyle
-    concurrent: true
-
-    builders:
-      - cord-infra-gerrit-repo-patch:
-          destination-dir: 'cord'
-          project: '$GERRIT_PROJECT'
-          change-number: '$GERRIT_CHANGE_NUMBER'
-          patchset-number: '$GERRIT_PATCHSET_NUMBER'
-      - shell: |
-          #!/usr/bin/env bash
-          set -ex -o pipefail
-
-          export XOS_DIR=$WORKSPACE/cord/orchestration/xos
-          export TOSCA_DIR=$WORKSPACE/cord/orchestration/xos-tosca
-
-          # setup virtual env
-          $XOS_DIR/scripts/setup_venv.sh
-          source "$WORKSPACE/venv-xos/bin/activate"
-          set -u
-
-          # Run the tests
-          pushd "$WORKSPACE/cord/orchestration/xos-tosca"
-          make tests
-          popd
-
-    publishers:
-      - junit:
-          results: "**/nose2-junit.xml"
-      - cobertura:
-          report-file: "**/coverage.xml"
-          targets:
-            - files:
-                healthy: 80
-                unhealthy: 0
-                failing: 0
-            - method:
-                healthy: 50
-                unhealthy: 0
-                failing: 0
-