Add tests for the abstract-olt project
Change-Id: I02dd3b4ea3d8c0f35d9b3f5de3387200f738c012
diff --git a/jjb/cord-macros.yaml b/jjb/cord-macros.yaml
index 1cca914..c6a71db 100644
--- a/jjb/cord-macros.yaml
+++ b/jjb/cord-macros.yaml
@@ -22,6 +22,27 @@
reset-first: true
depth: 1
+# same as lf-infra-gerrit-scm, but allows checkouts to a subdir of $WORKSPACE
+# with the `basedir` option
+#
+# `basedir` serves the same function as `destination-dir` in the repo scm
+# macros, seems strange that they're named differently.
+- scm:
+ name: cord-infra-gerrit-scm
+ scm:
+ - git:
+ credentials-id: '{jenkins-ssh-credential}'
+ url: '{git-url}'
+ refspec: '{refspec}'
+ branches:
+ - 'refs/heads/{branch}'
+ skip-tag: true
+ wipe-workspace: true
+ submodule:
+ recursive: '{submodule-recursive}'
+ choosing-strategy: '{choosing-strategy}'
+ basedir: '{basedir}'
+
# download a specific patchset after checking out entire source tree with repo
# docs: https://docs.openstack.org/infra/jenkins-job-builder/builders.html#builders.inject
- builder:
diff --git a/jjb/defaults.yaml b/jjb/defaults.yaml
index d4b4232..3ab54c1 100644
--- a/jjb/defaults.yaml
+++ b/jjb/defaults.yaml
@@ -14,6 +14,10 @@
# by default, don't depend on other jobs
dependency-jobs: ''
+ # SCM checkout locations within Jenkins Workspace
+ destination-dir: ''
+ basedir: ''
+
# used to rename jobs if version/branch forking is required
name-extension: ''
diff --git a/jjb/verify/abstract-olt.yaml b/jjb/verify/abstract-olt.yaml
index b84aa7c..6240946 100644
--- a/jjb/verify/abstract-olt.yaml
+++ b/jjb/verify/abstract-olt.yaml
@@ -15,3 +15,93 @@
- 'verify-licensed'
- 'verify-sonarqube':
dependency-jobs: 'verify_abstract-olt_licensed'
+ - 'abstract-olt-tests':
+ dependency-jobs: 'verify_abstract-olt_sonarqube'
+
+- job-template:
+ id: 'abstract-olt-tests'
+ name: 'verify_{project}_tests'
+
+ description: |
+ Created by {id} job-template from ci-management/jjb/verify/abstract-olt.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-scm:
+ git-url: '$GIT_URL/$GERRIT_PROJECT'
+ refspec: ''
+ branch: '$GERRIT_BRANCH'
+ submodule-recursive: 'false'
+ choosing-strategy: default
+ jenkins-ssh-credential: '{jenkins-ssh-credential}'
+ basedir: '{project}'
+
+ node: 'ubuntu16.04-basebuild-1c-2g'
+ 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 -eux -o pipefail
+
+ export GOPATH=~/go
+ export PATH=$PATH:/usr/lib/go-1.10/bin:~/go/bin
+
+ # move code the proper location
+ mkdir -p $GOPATH/src/gerrit.opencord.org
+ mv abstract-olt $GOPATH/src/gerrit.opencord.org/abstract-olt
+
+ # get prereqs
+ go get -v github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
+ go get -v github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger
+ go get -v github.com/golang/protobuf/protoc-gen-go
+
+ pushd $GOPATH/src/gerrit.opencord.org/abstract-olt
+
+ make test
+
+ go test -v ./... 2>&1 | go-junit-report > $WORKSPACE/junit-report.xml
+
+ go test -coverprofile=coverage.txt -covermode=count ./...
+ gocover-cobertura < coverage.txt > $WORKSPACE/coverage.xml
+
+ popd
+
+
+ publishers:
+ - junit:
+ results: "junit-report.xml"
+ - cobertura:
+ report-file: "coverage.xml"
+ targets:
+ - files:
+ healthy: 80
+ unhealthy: 0
+ failing: 0
+ - method:
+ healthy: 50
+ unhealthy: 0
+ failing: 0