diff --git a/jjb/onf-make-unit-test.yaml b/jjb/onf-make-unit-test.yaml new file mode 100644 index 000000000..801914a95 --- /dev/null +++ b/jjb/onf-make-unit-test.yaml @@ -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
+ 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 tag +# with a 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.xml + true + false + True + true + + + + 1 + + 3000 + + + - cobertura: + report-file: "**/*coverage.xml" + targets: + - files: + healthy: 80 + unhealthy: 0 + failing: 0 + - method: + healthy: 50 + unhealthy: 0 + failing: 0 + +# [EOF] diff --git a/jjb/onf-make/onf-make.yaml b/jjb/onf-make/onf-make.yaml new file mode 100644 index 000000000..8888a83de --- /dev/null +++ b/jjb/onf-make/onf-make.yaml @@ -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] diff --git a/jjb/shell/get-onf-make-patch.sh b/jjb/shell/get-onf-make-patch.sh new file mode 100755 index 000000000..ab360bbd7 --- /dev/null +++ b/jjb/shell/get-onf-make-patch.sh @@ -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 diff --git a/jjb/shell/make-unit.sh b/jjb/shell/make-unit.sh index 9a69b6083..03f98ef17 100755 --- a/jjb/shell/make-unit.sh +++ b/jjb/shell/make-unit.sh @@ -20,13 +20,13 @@ 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:-} @@ -34,10 +34,10 @@ 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 diff --git a/jjb/voltha-e2e.yaml b/jjb/voltha-e2e.yaml index 7ca459faf..ad40e75cb 100755 --- a/jjb/voltha-e2e.yaml +++ b/jjb/voltha-e2e.yaml @@ -1999,6 +1999,182 @@ - compare-type: REG_EXP pattern: '{all-files-regexp}' +- job-template: + id: 'voltha-make-test' + name: '{name}' + #build-node: 'ubuntu18.04-basebuild-4c-8g' + build-node: 'ubuntu18.04-basebuild-8c-15g' + pipeline-script: 'voltha/bbsim-tests.groovy' + pipeline-branch: 'master' + override-branch: '$GERRIT_BRANCH' + sandbox: true + build-timeout: 20 + timeout: 50 + olts: 1 + registry: mirror.registry.opennetworking.org + logLevel: 'INFO' + test-project: 'voltha-go' + volthaSystemTestsChange: '' + volthaHelmChartsChange: '' + extraHelmFlags: '' + enableMacLearning: false + withMonitoring: false + robot-args: '' + branch-regexp: '{all-branches-regexp}' + testTargets: | + - target: sanity-kind-att + workflow: att + flags: "" + teardown: true + logging: true + - target: sanity-kind-dt + workflow: dt + flags: "" + teardown: true + logging: true + - target: sanity-kind-tt + workflow: tt + flags: "" + teardown: true + logging: true + + description: | + + Created by {id} job-template from ci-management/jjb/voltha-e2e.yaml

+ E2E Validation for Voltha 2.X + + properties: + - onf-infra-volthadevs-permissions + - 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}' + + parameters: + - string: + name: buildNode + default: '{build-node}' + description: 'Name of the Jenkins node to run the job on' + + - string: + name: gerritProject + default: '{test-project}' + description: 'Name of the Gerrit project' + + - string: + name: gerritRefspec + default: 'refs/heads/master' + description: 'PatchSet REFSPEC in Gerrit, example value: "refs/changes/79/18779/13"' + + - string: + name: extraHelmFlags + default: '{extraHelmFlags}' + description: 'Helm flags to pass to every helm command' + + # applicable for voltha-2.9 (excluding) onwards + - bool: + name: enableMacLearning + default: '{enableMacLearning}' + description: "Deploy and test with ONOS Mac-Learning app" + + - string: + name: extraRobotArgs + default: '{robot-args}' + description: 'Arguments to pass to robot' + + - string: + name: volthaSystemTestsChange + default: '{volthaSystemTestsChange}' + description: 'Download a change for gerrit in the voltha-system-tests repo, example value: "refs/changes/79/18779/13"' + + - string: + name: volthaHelmChartsChange + default: '{volthaHelmChartsChange}' + description: 'Download a change for gerrit in the voltha-helm-charts repo, example value: "refs/changes/79/18779/13"' + + - string: + name: branch + default: '{override-branch}' + description: 'Name of the branch to use' + + # test configuration + # this is a parameter to drive the test execution, VOLTHA is redeployed each time with + # the provided configuration and then the make target is invoked, + # example value (has to be valid YAML): + # testTargets: | + # - target: 1t1gem-openonu-go-adapter-test + # workflow: att + # flags: "" + # teardown: true + # logging: true + - text: + name: testTargets + default: '{testTargets}' + description: 'Test configuration, see the ci-management job definition for more info' + + - string: + name: timeout + default: '{timeout}' + description: 'Timeout of pipeline job [minutes]' + + - string: + name: olts + default: '{olts}' + description: 'How many BBSim instances to run' + + - string: + name: registry + default: '{registry}' + description: 'Which registry to use (amazon vs menlo)' + + - bool: + name: withMonitoring + default: '{withMonitoring}' + description: 'Option to install Prometheus' + + - string: + name: logLevel + default: '{logLevel}' + description: 'Log level for all the components' + + project-type: pipeline + concurrent: true + + pipeline-scm: + scm: + - git: + url: https://gerrit.opencord.org/ci-management + branches: + - origin/{pipeline-branch} + script-path: jjb/pipeline/{pipeline-script} + + triggers: + - gerrit: + server-name: '{gerrit-server-name}' + dependency-jobs: '{dependency-jobs}' + silent-start: true + trigger-on: + - patchset-created-event: + exclude-drafts: true + exclude-trivial-rebase: false + exclude-no-code-change: true + - draft-published-event + - comment-added-contains-event: + comment-contains-value: '(?i)^.*recheck$' + projects: + - project-compare-type: REG_EXP + project-pattern: '^{project}$' + branches: + - branch-compare-type: REG_EXP + branch-pattern: '{branch-regexp}' + file-paths: + - compare-type: REG_EXP + pattern: '{all-files-regexp}' + # POD Per Patchset Pipeline Jobs # to use these parameters in a job: `<<: *voltha-physical-patchset-parameters` - _voltha-physical-patchset-parameters: &voltha-physical-patchset-parameters diff --git a/vars/getVolthaCode.groovy b/vars/getVolthaCode.groovy index aecb30dee..4230b9e60 100644 --- a/vars/getVolthaCode.groovy +++ b/vars/getVolthaCode.groovy @@ -76,8 +76,8 @@ def wrapped(Map config) 'voltha-helm-charts', ] - // We are always downloading those repos, if the patch under test is in one of those - // just checkout the patch, no need to clone it again + // We are always downloading those repos, if the patch under test is in + // one of those just checkout the patch, no need to clone it again if (cfg.gerritProject == '') { // Revisit: @@ -88,6 +88,36 @@ def wrapped(Map config) // checkout during an error condition. // Case: when cfg= is invalid due to a jenkins hiccup. } + else if (params.GERRIT_PROJECT == "onf-make") + { + // When testing onf-make, the tests are kicked off from the onf-make + // repo, so the GERRIT_PROJECT and GERRIT_PATCHSET_REVISION params + // will carry the data of what we want the submodule to be. + // However, the gerritProject is overridden, so that we can pull + // in another repo and run the tests to make sure that they work + // with the code changes to onf-make. + repo_project = "https://gerrit.opencord.org/${cfg.gerritProject}" + + checkout([ + $class: 'GitSCM', + userRemoteConfigs: [[ url:repo_project ]], + branches: [[ name: "${cfg.branch}", ]], + extensions: [ + [$class: 'WipeWorkspace'], + [$class: 'RelativeTargetDirectory', relativeTargetDir: "${cfg.gerritProject}"], + [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false], + submodule(recursiveSubmodules: true, reference: "${params.GERRIT_PATCHSET_REVISION}"), + ], + ]) + + sh("""pushd $WORKSPACE/${cfg.gerritProject} + git fetch "$repo_project" ${cfg.gerritRefspec} && git checkout FETCH_HEAD + + echo "Currently on commit: \n" + git log -1 --oneline + popd + """) + } else if (!(cfg.gerritProject in frequent_repos)) { repo_project = "https://gerrit.opencord.org/${cfg.gerritProject}" @@ -103,14 +133,13 @@ def wrapped(Map config) ], ]) - sh(""" - pushd $WORKSPACE/${cfg.gerritProject} - git fetch "$repo_project" ${cfg.gerritRefspec} && git checkout FETCH_HEAD + sh("""pushd $WORKSPACE/${cfg.gerritProject} + git fetch "$repo_project" ${cfg.gerritRefspec} && git checkout FETCH_HEAD - echo "Currently on commit: \n" - git log -1 --oneline - popd - """) + echo "Currently on commit: \n" + git log -1 --oneline + popd + """) } }