CI job for fabric.p4
Additionally introduces new defaults
Change-Id: I8d85855931de32b01fac0a436be4f6844919e97c
diff --git a/jjb/defaults.yaml b/jjb/defaults.yaml
index cc1ed78..02ec1fc 100644
--- a/jjb/defaults.yaml
+++ b/jjb/defaults.yaml
@@ -27,6 +27,7 @@
# see other build node types under "Cloud > Amazon EC2" at
# https://jenkins.onosproject.org/configure
build-node: ubuntu16.04-basebuild-1c-1g
+ bigger-build-node: ubuntu16.04-basebuild-8c-15g
# default gerrit server definition
#server-name: 'ONOS Project Gerrit'
@@ -79,3 +80,12 @@
# empty. Also will not vote if no test output exists - good for repos where
# tests or test output generation may not yet exist.
junit-allow-empty-results: false
+
+ # URL of the Docker registry (server running a docker registry) that is the
+ # destination for images to be pushed to after building. If set, must
+ # include trailing slash as a separator before the repo name.
+ # Default is blank, which maps to DockerHub.
+ docker-registry: ''
+
+ # ONF docker credentials for onfbuilder user
+ docker-credentials-id: 'docker-artifact-push-credentials'
diff --git a/jjb/onf-macros.yaml b/jjb/onf-macros.yaml
index 41c85b1..4656c9c 100644
--- a/jjb/onf-macros.yaml
+++ b/jjb/onf-macros.yaml
@@ -1,5 +1,29 @@
# JJB Macros for ONF jobs
+# basic string parameters for onf projects
+# differs from lf-infra-parameters as it allows to speficy a different gerrit project
+- parameter:
+ name: onf-infra-parameters
+ parameters:
+ - string:
+ name: PROJECT
+ default: '{project}'
+ - string:
+ name: STREAM
+ default: '{stream}'
+ - string:
+ name: GERRIT_PROJECT
+ default: '{gerrit_project}'
+ - string:
+ name: GERRIT_BRANCH
+ default: '{stream}'
+ - string:
+ name: GERRIT_REFSPEC
+ default: "refs/heads/{stream}"
+ - string:
+ name: sha1
+ default: "origin/{stream}"
+
# control how long builds and artifact are retained
# differs from lf-infra-properties as it retains artifacts
- property:
@@ -9,6 +33,12 @@
days-to-keep: '{build-days-to-keep}'
artifact-num-to-keep: '{artifact-num-to-keep}'
+- property:
+ name: onf-infra-docker-properties
+ properties:
+ - docker-container:
+ credentials-id: '{docker-credentials-id}'
+ docker-registry-url: '{docker-registry}'
# trigger on gerrit patchsets and actions
# docs: https://docs.openstack.org/infra/jenkins-job-builder/triggers.html#triggers.gerrit
@@ -100,3 +130,18 @@
- file-id: known_hosts
target: '$HOME/.ssh/known_hosts'
+# publisher to clean up the workspace after the build whatever the result
+- publisher:
+ name: onf-infra-wscleanup-publisher
+ publishers:
+ - workspace-cleanup:
+ clean-if:
+ - success: true
+ - unstable: true
+ - failure: true
+ - aborted: true
+ - not-built: true
+ dirmatch: false
+ fail-build: true
+ clean-parent: false
+ disable-deferred-wipeout: false
diff --git a/jjb/repos/fabric-p4.yaml b/jjb/repos/fabric-p4.yaml
new file mode 100644
index 0000000..85c8c6a
--- /dev/null
+++ b/jjb/repos/fabric-p4.yaml
@@ -0,0 +1,40 @@
+---
+# jobs for 'fabric-p4' project
+
+- project:
+ name: fabric-p4
+ project: '{name}'
+ gerrit_project: 'onos'
+
+ # Path in ONOS for fabric.p4 resources
+ resources_path: 'pipelines/fabric/impl/src/main/resources'
+
+ # BF-SDE version supported by fabric.p4
+ sde_ver: '9.0.0'
+
+ # BF_SDE repo
+ sde_repo: 'opennetworking/bf-sde'
+
+ # fabric-tofino project
+ fabric_tofino: 'fabric-tofino'
+ fabric_tofino_repo: 'https://gerrit.opencord.org/{fabric_tofino}'
+
+ # fabric-p4test project
+ fabric_p4test: 'fabric-p4test'
+ fabric_p4test_repo: 'https://github.com/opennetworkinglab/{fabric_p4test}.git'
+
+ # bmv2 run
+ bmv2_run: './run/bmv2/run'
+
+ #tm run
+ tm_run: './run/tm/run'
+
+ jobs:
+ - 'verify-fabric-p4-jobs':
+ branch-regexp: '2.*'
+ stream: 'master'
+
+- job-group:
+ name: 'verify-fabric-p4-jobs'
+ jobs:
+ - 'fabric-p4-verify'
\ No newline at end of file
diff --git a/jjb/shell/fabric-p4/fabric-p4-build-bmv2.sh b/jjb/shell/fabric-p4/fabric-p4-build-bmv2.sh
new file mode 100644
index 0000000..53c5a80
--- /dev/null
+++ b/jjb/shell/fabric-p4/fabric-p4-build-bmv2.sh
@@ -0,0 +1,36 @@
+#!/usr/bin/env bash
+
+#
+# Copyright 2020-present Open Networking Foundation
+#
+# 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.
+#
+
+# Build steps for bmv2
+
+# exit on errors
+set -eu -o pipefail
+
+export ONOS_ROOT=`pwd`
+
+echo "Step 1 - Build fabric.p4 for bmv2"
+cd $ONOS_ROOT/${RESOURCES_PATH}
+make all
+
+echo "Step 2 - Checking bmv2 artifacts"
+if [ -n "$(git status --porcelain)" ]; then
+ echo "The uploaded P4 build artifacts do not correspond to the expected ones. Please run the Makefile locally before pushing a a new change"
+ exit 1
+fi
+
+echo "Build for bmv2 done"
diff --git a/jjb/shell/fabric-p4/fabric-p4-build-tofino.sh b/jjb/shell/fabric-p4/fabric-p4-build-tofino.sh
new file mode 100644
index 0000000..e34082b
--- /dev/null
+++ b/jjb/shell/fabric-p4/fabric-p4-build-tofino.sh
@@ -0,0 +1,33 @@
+#!/usr/bin/env bash
+
+#
+# Copyright 2020-present Open Networking Foundation
+#
+# 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.
+#
+
+# Build steps for fabric-tofino
+
+# exit on errors
+set -eu -o pipefail
+
+export ONOS_ROOT=`pwd`
+
+echo "Step 3 - Clone ${FABRIC_TOFINO}"
+git clone ${FABRIC_TOFINO_REPO}
+cd ${FABRIC_TOFINO}
+
+echo "Step 4 - Build fabric.p4 for tofino"
+make build SDE_DOCKER_IMG=${SDE_REPO}:${SDE_VER}-p4c
+
+echo "Build for tofino done"
diff --git a/jjb/shell/fabric-p4/fabric-p4-p4test.sh b/jjb/shell/fabric-p4/fabric-p4-p4test.sh
new file mode 100644
index 0000000..6c7e665
--- /dev/null
+++ b/jjb/shell/fabric-p4/fabric-p4-p4test.sh
@@ -0,0 +1,28 @@
+#!/usr/bin/env bash
+
+#
+# Copyright 2020-present Open Networking Foundation
+#
+# 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.
+#
+
+# Build fabric-p4test
+
+# exit on errors
+set -eu -o pipefail
+
+echo "Step 5 - Clone ${FABRIC_P4TEST}"
+git clone ${FABRIC_P4TEST_REPO}
+cd ${FABRIC_P4TEST}
+
+echo "Build for ${FABRIC_P4TEST} done"
diff --git a/jjb/shell/fabric-p4/fabric-p4-test-bmv2.sh b/jjb/shell/fabric-p4/fabric-p4-test-bmv2.sh
new file mode 100644
index 0000000..f351296
--- /dev/null
+++ b/jjb/shell/fabric-p4/fabric-p4-test-bmv2.sh
@@ -0,0 +1,30 @@
+#!/usr/bin/env bash
+
+#
+# Copyright 2020-present Open Networking Foundation
+#
+# 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.
+#
+
+# Run tests on bmv2
+
+# exit on errors
+set -eu -o pipefail
+
+export ONOS_ROOT=`pwd`
+
+echo "Step 6 - Run ${FABRIC_P4TEST} on bmv2"
+cd ${FABRIC_P4TEST}
+${BMV2_RUN} all
+
+echo "Tests on bmv2 passed"
diff --git a/jjb/shell/fabric-p4/fabric-p4-test-tofino.sh b/jjb/shell/fabric-p4/fabric-p4-test-tofino.sh
new file mode 100644
index 0000000..c45d918
--- /dev/null
+++ b/jjb/shell/fabric-p4/fabric-p4-test-tofino.sh
@@ -0,0 +1,36 @@
+#!/usr/bin/env bash
+
+#
+# Copyright 2020-present Open Networking Foundation
+#
+# 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.
+#
+
+# Run tests on tm
+
+# exit on errors
+set -eu -o pipefail
+
+SRC_DIR=`pwd`
+export FABRIC_TOFINO=$SRC_DIR/${FABRIC_TOFINO}
+export SDE_DOCKER_IMG=${SDE_REPO}:${SDE_VER}-tm
+
+echo "Step 7 - Run ${FABRIC_P4TEST} on tm"
+cd ${FABRIC_P4TEST}
+${TM_RUN} fabric
+${TM_RUN} fabric-bng
+${TM_RUN} fabric-spgw
+${TM_RUN} fabric-int
+${TM_RUN} fabric-spgw-int
+
+echo "Tests on tm passed"
diff --git a/jjb/templates/fabric-p4-verify.yaml b/jjb/templates/fabric-p4-verify.yaml
new file mode 100644
index 0000000..b14a57e
--- /dev/null
+++ b/jjb/templates/fabric-p4-verify.yaml
@@ -0,0 +1,112 @@
+---
+# Run fabric.p4 test pipeline
+
+- job-template:
+ id: 'fabric-p4-verify'
+ name: 'fabric-p4-verify'
+
+ description: |
+ Created by {id} job-template from ci-management/jjb/templates/fabric-p4-verify.yaml<br/>
+ Runs fabric.p4 test pipeline
+
+ properties:
+ - authorization:
+ JenkinsPowerusers:
+ - credentials-create
+ - credentials-delete
+ - credentials-manage-domains
+ - credentials-update
+ - credentials-view
+ - job-build
+ - job-cancel
+ - job-configure
+ - job-delete
+ - job-discover
+ - job-extended-read
+ - job-move
+ - job-read
+ - job-workspace
+ - run-delete
+ - run-replay
+ - run-update
+ ONFStaff:
+ - job-discover
+ - job-read
+ - onf-infra-properties:
+ build-days-to-keep: '{build-days-to-keep}'
+ artifact-num-to-keep: '-1'
+ - onf-infra-docker-properties:
+ docker-credentials-id: '{docker-credentials-id}'
+ docker-registry: '{docker-registry}'
+
+ parameters:
+ - onf-infra-parameters:
+ project: '{project}'
+ stream: '{stream}'
+ gerrit_project: '{gerrit_project}'
+
+ node: '{bigger-build-node}'
+ project-type: freestyle
+ concurrent: true
+
+ scm:
+ - onf-infra-gerrit-scm:
+ git-url: '$GIT_URL/$GERRIT_PROJECT'
+ refspec: '$GERRIT_REFSPEC'
+ branch: '$GERRIT_BRANCH'
+ submodule-recursive: '{submodule-recursive}'
+ choosing-strategy: gerrit
+ jenkins-ssh-credential: '{jenkins-ssh-credential}'
+ basedir: '{project}'
+
+ triggers:
+ - gerrit:
+ server-name: '{gerrit-server-name}'
+ dependency-jobs: '{dependency-jobs}'
+ trigger-on:
+ - patchset-created-event:
+ exclude-drafts: true
+ exclude-trivial-rebase: false
+ exclude-no-code-change: true
+ - draft-published-event: true
+ - comment-added-contains-event:
+ comment-contains-value: '(?i)^.*recheck$'
+ projects:
+ - project-compare-type: PLAIN
+ project-pattern: 'onos'
+ branches:
+ - branch-compare-type: REG_EXP
+ branch-pattern: '{branch-regexp}'
+ - branch-compare-type: PLAIN
+ branch-pattern: 'master'
+ file-paths:
+ - compare-type: ANT
+ pattern: 'pipelines/fabric/impl/src/main/resources/**'
+ - compare-type: ANT
+ pattern: 'pipelines/fabric/impl/src/main/java/org/onosproject/pipelines/fabric/impl/behaviour/FabricConstants.java'
+
+ wrappers:
+ - lf-infra-wrappers:
+ build-timeout: '30'
+ jenkins-ssh-credential: '{jenkins-ssh-credential}'
+
+ builders:
+ - inject:
+ properties-content: |
+ RESOURCES_PATH={resources_path}
+ SDE_REPO={sde_repo}
+ SDE_VER={sde_ver}
+ FABRIC_TOFINO={fabric_tofino}
+ FABRIC_TOFINO_REPO={fabric_tofino_repo}
+ FABRIC_P4TEST={fabric_p4test}
+ FABRIC_P4TEST_REPO={fabric_p4test_repo}
+ BMV2_RUN={bmv2_run}
+ TM_RUN={tm_run}
+ - shell: !include-raw-escape: ../shell/fabric-p4/fabric-p4-build-bmv2.sh
+ - shell: !include-raw-escape: ../shell/fabric-p4/fabric-p4-build-tofino.sh
+ - shell: !include-raw-escape: ../shell/fabric-p4/fabric-p4-p4test.sh
+ - shell: !include-raw-escape: ../shell/fabric-p4/fabric-p4-test-bmv2.sh
+ - shell: !include-raw-escape: ../shell/fabric-p4/fabric-p4-test-tofino.sh
+
+ publishers:
+ - onf-infra-wscleanup-publisher