Skip to content

Commit

Permalink
Merge "CI: Add tests for onf-make"
Browse files Browse the repository at this point in the history
  • Loading branch information
eb-oss authored and Gerrit Code Review committed Oct 14, 2024
2 parents 59d88fc + 3f0cec3 commit 43254c1
Show file tree
Hide file tree
Showing 6 changed files with 432 additions and 14 deletions.
106 changes: 106 additions & 0 deletions jjb/onf-make-unit-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
---
# Makefile based unit test

- job-template:
id: 'onf-make-unit-test'
name: 'onf-make-unit-test-{test-repo}'
test-repo: '{test-repo}'

description: |
Created by {id} job-template from ci-management/jjb/onf-make-unit-test.yaml<br/>
Runs make with the following unit tests targets - '{unit-test-targets}'
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-scm:
git-url: '$GIT_URL/$GERRIT_PROJECT'
refspec: '$GERRIT_REFSPEC'
branch: '$GERRIT_BRANCH'
submodule-recursive: 'false'
choosing-strategy: gerrit
jenkins-ssh-credential: '{jenkins-ssh-credential}'
basedir: '{project}'

node: '{build-node}'
project-type: freestyle
concurrent: true

builders:
- inject:
properties-content: |
DEST_GOPATH={dest-gopath}
UNIT_TEST_TARGETS={unit-test-targets}
UNIT_TEST_KEEP_GOING={unit-test-keep-going}
GOPROXY=https://proxy.golang.org
TEST_PROJECT={test-repo}
- shell: !include-raw-verbatim: shell/get-onf-make-patch.sh
- shell: !include-raw-verbatim: shell/make-unit.sh

publishers:
- junit:
results: "**/*results.xml,**/*report.xml"
allow-empty-results: '{junit-allow-empty-results}'
# NOTE: circa 2020-04-11, the Jenkins xUnit plugin version 3.x.x changed the
# config XML to not be JJB compatible, replacing the previous XML <types> tag
# with a <tools> tag.
#
# Temporarily switch to using raw XML to configure xUnit.
#
# The following xunit and XML should be equivalent, except that the variable
# `xunit-skip-if-no-test-files` is assumed to always be true.
#
# - xunit:
# types:
# - gtest:
# pattern: "**/*xunit.xml"
# deleteoutput: false
# skip-if-no-test-files: '{xunit-skip-if-no-test-files}'
#
- raw:
xml: |
<xunit plugin="xunit">
<tools>
<GoogleTestType>
<pattern>**/*xunit.xml</pattern>
<failIfNotNew>true</failIfNotNew>
<deleteOutputFiles>false</deleteOutputFiles>
<skipNoTestFiles>True</skipNoTestFiles>
<stopProcessingIfError>true</stopProcessingIfError>
</GoogleTestType>
</tools>
<thresholds/>
<thresholdMode>1</thresholdMode>
<extraConfiguration>
<testTimeMargin>3000</testTimeMargin>
</extraConfiguration>
</xunit>
- cobertura:
report-file: "**/*coverage.xml"
targets:
- files:
healthy: 80
unhealthy: 0
failing: 0
- method:
healthy: 50
unhealthy: 0
failing: 0

# [EOF]
74 changes: 74 additions & 0 deletions jjb/onf-make/onf-make.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---

- project:
name: onf-make-tests

project-name: '{name}'
project: 'onf-make'
manualBranch: ''
olts: 1
onus: 1
pons: 1
withAlarms: true
make-target-failtest: bbsim-failurescenarios
make-target-errortest: bbsim-errorscenarios
make-target-alarmtest: bbsim-alarms-kind
make-target-multipleolt: bbsim-multiolt-kind
make-target-1t4gemtest: 1t4gem-openonu-go-adapter-test
make-target-1t8gemtest: 1t8gem-openonu-go-adapter-test
make-target-reconciletest: reconcile-openonu-go-adapter-test-att
make-target-reconciledttest: reconcile-openonu-go-adapter-test-dt
make-target-reconciletttest: reconcile-openonu-go-adapter-test-tt

jobs:
- 'voltha-make-test':
name: 'onf-make-voltha-dt-fttb-test-bbsim-master'
code-branch: 'master'
extraHelmFlags: '--set global.image_tag=master --set onos-classic.image.tag=master --set voltha-adapter-openonu.adapter_open_onu.uni_port_mask=0x00FF --set onu=2'
testTargets: |
- target: sanity-kind-dt-fttb
workflow: dt-fttb
flags: ""
teardown: true
logging: true
- 'voltha-make-test':
name: 'onf-make-voltha-sanity-test-multi-runs'
code-branch: 'master'
extraHelmFlags: '--set global.image_tag=master --set onos-classic.image.tag=master --set onu=2,pon=2'
testTargets: |
- target: sanity-kind
workflow: att
flags: ""
teardown: true
logging: true
- target: sanity-kind
workflow: att
flags: ""
teardown: false
logging: true
- target: sanity-kind
workflow: att
flags: ""
teardown: false
logging: true
- target: sanity-kind
workflow: att
flags: ""
teardown: false
logging: true
- target: sanity-kind
workflow: att
flags: ""
teardown: false
logging: true
- 'onf-make-unit-test':
test-repo: 'bbsim'
build-node: 'ubuntu18.04-basebuild-4c-8g'
branch-regexp: '^master$'
dest-gopath: "github.com/opencord"
unit-test-targets: 'lint sca test'
unit-test-keep-going: 'false'

# [EOF]
33 changes: 33 additions & 0 deletions jjb/shell/get-onf-make-patch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash

# Copyright 2017-2024 Open Networking Foundation (ONF) and the ONF Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# get-onf-make-patch.sh - Pull the patch of onf-make that triggered the job
# for testing

ONF_MAKE_SUBDIR="lf/onf-make"
PROJECT="${TEST_PROJECT:-}"
REPO="https://gerrit.opencord.org/$PROJECT"

cd $WORKSPACE
git clone "$REPO" "$PROJECT"
cd "$PROJECT"
git submodule update --init

REPO="https://gerrit.opencord.org/onf-make"

pushd "$ONF_MAKE_SUBDIR"
git fetch "$REPO" "$GERRIT_REFSPEC" && git checkout FETCH_HEAD
popd
10 changes: 5 additions & 5 deletions jjb/shell/make-unit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,24 @@ set -eu -o pipefail
# when not running under Jenkins, use current dir as workspace, a blank project
# name
WORKSPACE=${WORKSPACE:-.}
GERRIT_PROJECT=${GERRIT_PROJECT:-}
TEST_PROJECT="${TEST_PROJECT:-}"

# Fixes to for golang projects to support GOPATH
# If $DEST_GOPATH is not an empty string:
# - create GOPATH within WORKSPACE, and destination directory within
# - set PATH to include $GOPATH/bin and the system go binaries
# - move project from $WORKSPACE/$GERRIT_PROJECT to new location in $GOPATH
# - move project from $WORKSPACE/$TEST_PROJECT to new location in $GOPATH
# - start tests within that directory

DEST_GOPATH=${DEST_GOPATH:-}
if [ ! -z "$DEST_GOPATH" ]; then
export GOPATH=${GOPATH:-$WORKSPACE/go}
mkdir -p "$GOPATH/src/$DEST_GOPATH"
export PATH=$PATH:/usr/lib/go-1.12/bin:/usr/local/go/bin:$GOPATH/bin
test_path="$GOPATH/src/$DEST_GOPATH/$GERRIT_PROJECT"
mv "$WORKSPACE/$GERRIT_PROJECT" "$test_path"
test_path="$GOPATH/src/$DEST_GOPATH/$TEST_PROJECT"
mv "$WORKSPACE/$TEST_PROJECT" "$test_path"
else
test_path="$WORKSPACE/$GERRIT_PROJECT"
test_path="$WORKSPACE/$TEST_PROJECT"
fi

# Use "test" as the default target, can be a space separated list
Expand Down
Loading

0 comments on commit 43254c1

Please sign in to comment.