Skip to content

Commit

Permalink
Build scripts for sonic-mgmt-common (sonic-net#126)
Browse files Browse the repository at this point in the history
1) Added jenkinsfile, build and test scripts for sanity checking of
sonic-mgmt-common PRs. Test stage runs cvl and translib go test cases.
Also added periodic sanity for latest sonic-mgmt-common code.

2) Modified sonic-mgmt-framework PR & sceduled sanities to download and
build latest sonic-mgmt-common fist. Cleaned up build script to include
only sonic-mgmt-framework related stuffs. Translib, cvl specific steps
are moved to sonic-mgmt-common's build script.

3) Introduced a test stage for sonic-mgmt-framework sanity. It runs REST
server go test cases.

4) Modified sonic-telemetry build script to clone and build
sonic-mgmt-common first. Removed dependency on sonic-mgmt-framework.

Signed-off-by: Sachin Holla <sachin.holla@broadcom.com>
  • Loading branch information
sachinholla authored Jun 29, 2020
1 parent 0dd7cf0 commit 5ee7cfa
Show file tree
Hide file tree
Showing 9 changed files with 206 additions and 18 deletions.
34 changes: 34 additions & 0 deletions jenkins/common/sonic-mgmt-common-build-pr/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
pipeline {
agent { node { label 'sonic-slave-buster' } }

stages {
stage('Prepare') {
steps {
dir('sonic-mgmt-common') {
checkout([$class: 'GitSCM',
branches: [[name: '${sha1}']],
userRemoteConfigs: [[url: 'http://github.com/Azure/sonic-mgmt-common',
refspec: '+refs/pull/*:refs/remotes/origin/pr/*']]])
}
copyArtifacts(projectName: 'vs/buildimage-vs-all', filter: '**/*.deb', target: 'buildimage', flatten: false)
}
}

stage('Build') {
steps {
sh './scripts/common/sonic-mgmt-common-build/build.sh'
}
}

stage('Test') {
steps {
sh './scripts/common/sonic-mgmt-common-build/test.sh'
}
}
}
post {
success {
archiveArtifacts(artifacts: 'target/*.deb')
}
}
}
53 changes: 53 additions & 0 deletions jenkins/common/sonic-mgmt-common-build/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
pipeline {
agent { node { label 'sonic-slave-buster' } }

options {
buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '10'))
}

environment {
SONIC_TEAM_WEBHOOK = credentials('public-jenkins-builder')
}

triggers {
pollSCM('H/10 * * * *')
}

stages {
stage('Prepare') {
steps {
dir('sonic-mgmt-common') {
checkout([$class: 'GitSCM',
branches: [[name: 'refs/heads/master']],
userRemoteConfigs: [[url: 'http://github.com/Azure/sonic-mgmt-common']]])
}
copyArtifacts(projectName: '../vs/buildimage-vs-image', filter: '**/*.deb', target: 'buildimage', flatten: false)
}
}

stage('Build') {
steps {
sh './scripts/common/sonic-mgmt-common-build/build.sh'
}
}

stage('Test') {
steps {
sh './scripts/common/sonic-mgmt-common-build/test.sh'
}
}
}
post {
success {
archiveArtifacts(artifacts: 'target/*.deb')
}
fixed {
slackSend(color:'#00FF00', message: "Build job back to normal: ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)")
office365ConnectorSend(webhookUrl: "${env.SONIC_TEAM_WEBHOOK}")
}
regression {
slackSend(color:'#FF0000', message: "Build job Regression: ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)")
office365ConnectorSend(webhookUrl: "${env.SONIC_TEAM_WEBHOOK}")
}
}
}
12 changes: 12 additions & 0 deletions jenkins/common/sonic-mgmt-framework-build-pr/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,27 @@ pipeline {
userRemoteConfigs: [[url: 'http://github.com/Azure/sonic-mgmt-framework',
refspec: '+refs/pull/*:refs/remotes/origin/pr/*']]])
}
dir('sonic-mgmt-common') {
checkout([$class: 'GitSCM',
branches: [[name: 'refs/heads/master']],
userRemoteConfigs: [[url: 'http://github.com/Azure/sonic-mgmt-common']]])
}
copyArtifacts(projectName: 'vs/buildimage-vs-all', filter: '**/*.deb', target: 'buildimage', flatten: false)
}
}

stage('Build') {
steps {
sh './scripts/common/sonic-mgmt-common-build/build.sh'
sh './scripts/common/sonic-mgmt-framework-build/build.sh'
}
}

stage('Test') {
steps {
sh './scripts/common/sonic-mgmt-framework-build/test.sh'
}
}
}
post {
success {
Expand Down
12 changes: 12 additions & 0 deletions jenkins/common/sonic-mgmt-framework-build/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,27 @@ pipeline {
branches: [[name: 'refs/heads/master']],
userRemoteConfigs: [[url: 'http://github.com/Azure/sonic-mgmt-framework']]])
}
dir('sonic-mgmt-common') {
checkout([$class: 'GitSCM',
branches: [[name: 'refs/heads/master']],
userRemoteConfigs: [[url: 'http://github.com/Azure/sonic-mgmt-common']]])
}
copyArtifacts(projectName: '../vs/buildimage-vs-image', filter: '**/*.deb', target: 'buildimage', flatten: false)
}
}

stage('Build') {
steps {
sh './scripts/common/sonic-mgmt-common-build/build.sh'
sh './scripts/common/sonic-mgmt-framework-build/build.sh'
}
}

stage('Test') {
steps {
sh './scripts/common/sonic-mgmt-framework-build/test.sh'
}
}
}
post {
success {
Expand Down
27 changes: 27 additions & 0 deletions scripts/common/sonic-mgmt-common-build/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash -ex

# Build script for sonic-mgmt-common.
# Installs all dependencies required for compiling and testing
# CVL and translib.

[[ ! -z ${DISTRO} ]] || DISTRO=buster

# REDIS
sudo apt-get install -y redis-server
sudo sed -ri 's/^# unixsocket/unixsocket/' /etc/redis/redis.conf
sudo sed -ri 's/^unixsocketperm .../unixsocketperm 777/' /etc/redis/redis.conf
sudo sed -ri 's/redis-server.sock/redis.sock/' /etc/redis/redis.conf
sudo service redis-server start

# LIBYANG
sudo dpkg -i buildimage/target/debs/${DISTRO}/libyang*.deb


pushd sonic-mgmt-common

dpkg-buildpackage -rfakeroot -b -us -uc

popd

mkdir -p target
cp sonic-mgmt-common*.deb target/
33 changes: 33 additions & 0 deletions scripts/common/sonic-mgmt-common-build/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash -ex

# Run sanity tests for sonic-mgmt-common.
# Assumes sonic-mgmt-common is already compiled and all dependencies
# are installed.


STATUS=0
DEBDIR=$(realpath sonic-mgmt-common/debian/sonic-mgmt-common)

# Run CVL tests

pushd sonic-mgmt-common/build/tests/cvl

CVL_SCHEMA_PATH=testdata/schema \
./cvl.test -test.v -logtostderr || STATUS=1

popd

# Run translib tests

pushd sonic-mgmt-common/build/tests/translib

export CVL_SCHEMA_PATH=${DEBDIR}/usr/sbin/schema
export YANG_MODELS_PATH=${DEBDIR}/usr/models/yang

./db.test -test.v -logtostderr || STATUS=1

./translib.test -test.v -logtostderr || STATUS=1

popd

exit ${STATUS}
21 changes: 5 additions & 16 deletions scripts/common/sonic-mgmt-framework-build/build.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
#!/bin/bash -ex

DISTRO=buster

# Install HIREDIS
sudo dpkg -i buildimage/target/debs/${DISTRO}/libhiredis*.deb

# Install REDIS
sudo apt-get install -y redis-server
sudo sed -ri 's/^# unixsocket/unixsocket/' /etc/redis/redis.conf
sudo sed -ri 's/^unixsocketperm .../unixsocketperm 777/' /etc/redis/redis.conf
sudo sed -ri 's/redis-server.sock/redis.sock/' /etc/redis/redis.conf
sudo service redis-server start

#Install libyang
sudo dpkg -i buildimage/target/debs/${DISTRO}/libyang*.deb
# Build script for sonic-mgmt-framework.
# Assumes sonic-mgmt-common is already cloned & built.
# Dependencies of sonic-mgmt-common would have been installed already.
# Only sonic-mgmt-framework dependencies will have to be installed here.

pushd sonic-mgmt-framework

Expand All @@ -22,5 +12,4 @@ dpkg-buildpackage -rfakeroot -b -us -uc
popd

mkdir -p target
cp *.deb target/

cp sonic-mgmt-framework*.deb target/
18 changes: 18 additions & 0 deletions scripts/common/sonic-mgmt-framework-build/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash -ex

# Run sanity tests for sonic-mgmt-framework.
# Assumes both sonic-mgmt-common and sonic-mgmt-framework repos
# are already compiled.

STATUS=0
DEBDIR=$(realpath sonic-mgmt-common/debian/sonic-mgmt-common)

pushd sonic-mgmt-framework/build/tests/rest

export CVL_SCHEMA_PATH=${DEBDIR}/usr/sbin/schema

./server.test -test.v -logtostderr || STATUS=1

popd

exit ${STATUS}
14 changes: 12 additions & 2 deletions scripts/common/sonic-telemetry-build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,18 @@ sudo service redis-server start
# Install libyang
sudo dpkg -i buildimage/target/debs/stretch/libyang*.deb

# Clone sonic-mgmt-framework repository
git clone https://github.com/Azure/sonic-mgmt-framework
# Clone sonic-mgmt-common repository
git clone https://github.com/Azure/sonic-mgmt-common.git

# Build sonic-mgmt-common first

pushd sonic-mgmt-common

dpkg-buildpackage -rfakeroot -b -us -uc

popd

# Build sonic-telemetry

pushd sonic-telemetry

Expand Down

0 comments on commit 5ee7cfa

Please sign in to comment.