systest jenkins pipeline

Change-Id: I496980ad1dcad1be691587caec41d7d86259a55f
Signed-off-by: Mike Marchetti <mmarchetti@sandvine.com>
diff --git a/systest/Dockerfile b/systest/Dockerfile
new file mode 100644
index 0000000..ec30486
--- /dev/null
+++ b/systest/Dockerfile
@@ -0,0 +1,6 @@
+FROM ubuntu:16.04
+
+RUN apt-get update && apt-get -y install python \
+    libcurl4-gnutls-dev libgnutls-dev \
+    python-setuptools python-pip git python-pytest \
+    charm-tools
diff --git a/systest/Jenkinsfile b/systest/Jenkinsfile
new file mode 100644
index 0000000..8e290e8
--- /dev/null
+++ b/systest/Jenkinsfile
@@ -0,0 +1,59 @@
+// input parameters:
+//   string:  UPSTREAM_PROJECT
+//   string:  NODE
+//
+//   OpenStack VIM Credentials
+//   string:  OS_AUTH_URL
+//   string:  OS_USERNAME
+//   string:  OS_PASSWORD
+//   string:  OS_PROJECT_NAME
+
+node("${params.NODE}") {
+
+    // grab the upstream artifact name
+    step ([$class: 'CopyArtifact',
+          projectName: params.UPSTREAM_PROJECT])
+
+    container_name = sh(returnStdout: true, script: 'cat build_version.txt').trim()
+
+    stage("get osm") {
+        // get the IP of the osm container
+        OSM_IP = sh(returnStdout: true, script: "lxc list ${container_name} -c 4|grep eth0 |awk '{print \$2}'").trim()
+    }
+
+    stage("checkout") {
+        checkout scm
+    }
+
+    // build the pytest container
+    stage("build-docker") {
+        sh 'docker build -t osmclient systest/.'
+    }
+
+    os_credentials = "OS_AUTH_URL=${params.OS_AUTH_URL} OS_USERNAME=${params.OS_USERNAME} OS_PASSWORD=${params.OS_PASSWORD} OS_PROJECT_NAME=${params.OS_PROJECT_NAME}"
+
+    // now run the built container.
+    withDockerContainer('osmclient') {
+
+        // install the osmclient
+        stage("install-osmclient") {
+            sh 'pip install git+https://osm.etsi.org/gerrit/osm/osmclient'
+        }
+
+        stage("build-descriptors") {
+            sh "make -C systest descriptors"
+        }
+
+        stage("smoke-test") {
+            sh "make -C systest OSM_HOSTNAME=${OSM_IP} smoke"
+            junit 'systest/reports/pytest-smoke.xml'
+        }
+
+        stage("cirros-test") {
+            sh """
+               make -C systest OSM_HOSTNAME=${OSM_IP} ${os_credentials} cirros
+               """
+            junit 'systest/reports/pytest-cirros.xml'
+        }
+    }
+}
diff --git a/systest/Makefile b/systest/Makefile
index fb296cc..fe75754 100644
--- a/systest/Makefile
+++ b/systest/Makefile
@@ -18,18 +18,18 @@
 # the make invocation.
 # eg. 
 #    export OSM_HOSTNAME=1.2.3.4:8008
-#    export OS_URL=https://<keystoneserver>:5000/v2.0
+#    export OS_AUTH_URL=https://<keystoneserver>:5000/v2.0
 #    export OS_USERNAME=admin
 #    export OS_PASSWORD=admin
 #    export OS_PROJECT_NAME=admin
 OSM_HOSTNAME ?=
-OS_URL ?=
+OS_AUTH_URL ?=
 OS_USERNAME ?=
 OS_PASSWORD_NAME ?=
 OS_PROJECT_NAME ?=
 
-ifdef OS_URL
-    OPTION_OS_URL=--os-url $(OS_URL)
+ifdef OS_AUTH_URL
+    OPTION_OS_AUTH_URL=--os-url $(OS_AUTH_URL)
 endif
 ifdef OS_USERNAME
     OPTION_OS_USERNAME=--os-username $(OS_USERNAME)
@@ -48,8 +48,9 @@
     OPTION_TEST_NSD_DESCRIPTORS=--osm-nsd-descriptor-packages $(TEST_NSD_DESCRIPTORS)
 endif
 
-DESCRIPTOR_REPO_NAME=descriptor-packages
-DESCRIPTOR_BUILD_DIR := $(shell pwd)/$(DESCRIPTOR_REPO_NAME)/build
+DESCRIPTOR_REPO_NAME = descriptor-packages
+DESCRIPTOR_REPO_DIR ?= $(shell pwd)/descriptor-packages
+DESCRIPTOR_BUILD_DIR := $(DESCRIPTOR_REPO_DIR)/build
 OPTION_DESCRIPTOR_BUILD_DIR=--osm-descriptor-packages $(DESCRIPTOR_BUILD_DIR)
 
 TEST_OSM_NS_NAME_PREFIX=pytest-$(shell date +%D-%T)-
@@ -79,24 +80,24 @@
 	$(call check_env_var,OSM_HOSTNAME)
 
 check_openstack_env:
-	$(call check_env_var,OS_URL)
+	$(call check_env_var,OS_AUTH_URL)
 	$(call check_env_var,OS_USERNAME)
 	$(call check_env_var,OS_PASSWORD)
 	$(call check_env_var,OS_PROJECT_NAME)
 
 .PHONY: check_openstack_env check_OSM_HOSTNAME
 
-$(DESCRIPTOR_REPO_NAME):
-	@test -e $(DESCRIPTOR_REPO_NAME) || git clone $(DESCRIPTOR_REPO)
-	make -C $(DESCRIPTOR_REPO_NAME)
+descriptors:
+	test -e $(DESCRIPTOR_REPO_NAME) || git clone $(DESCRIPTOR_REPO)
+	$(MAKE) -C $(DESCRIPTOR_REPO_NAME)
 
 report_dir:
 	@mkdir -p reports
 
-_run_test: $(DESCRIPTOR_REPO_NAME) report_dir
+_run_test: report_dir
 	$(Q)py.test \
         --osmhost $(OSM_HOSTNAME) \
-        $(OPTION_OS_URL) \
+        $(OPTION_OS_AUTH_URL) \
         $(OPTION_OS_USERNAME) \
         $(OPTION_OS_PASSWORD) \
         $(OPTION_OS_PROJECT_NAME) \