Add µONOS category and setup steps in Jenkins Pipelines
Change-Id: I08850a3461aa4e84cb453f9c52be86f5edcd0e14
diff --git a/TestON/JenkinsFile/MOJenkinsFile.groovy b/TestON/JenkinsFile/MOJenkinsFile.groovy
new file mode 100644
index 0000000..d7add2d
--- /dev/null
+++ b/TestON/JenkinsFile/MOJenkinsFile.groovy
@@ -0,0 +1,123 @@
+#!groovy
+// Copyright 2019 Open Networking Foundation (ONF)
+//
+// Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
+// the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
+// or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg>
+//
+// TestON is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 2 of the License, or
+// (at your option) any later version.
+//
+// TestON is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with TestON. If not, see <http://www.gnu.org/licenses/>.
+
+test_list = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsTestONTests.groovy' )
+fileRelated = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsPathAndFiles.groovy' )
+
+category = null
+prop = null
+testsToRun = null
+testsToRunStrList = null
+branch = null
+branchWithPrefix = null
+nodeLabel = null
+testStation = null
+testsOverride = null
+pipelineTimeout = null
+
+testsFromList = [:]
+pipeline = [:]
+
+def main(){
+ pipelineTimeout = params.TimeOut.toInteger() // integer minutes until the entire pipeline times out. Usually passed from upstream master-trigger job.
+ timeout( time: pipelineTimeout, unit: "MINUTES" ){
+ init()
+ runTests()
+ }
+}
+
+main()
+
+def init(){
+ fileRelated.init()
+ test_list.init()
+ readParams()
+
+ if ( branch == "manually" ){
+ echo '''Warning: entered branch was: "manually". Defaulting to master branch.'''
+ branch = "master"
+ branchWithPrefix = test_list.addPrefixToBranch( branch )
+ }
+ prop = getProperties()
+
+ // get the list of the tests from category
+ testsFromList = test_list.getTestsFromCategory( category )
+
+ tokenizeTokens = "\n;, "
+
+ if ( testsOverride == "" || testsOverride == null ){
+ testsToRunStrList = prop[ "Tests" ].tokenize( tokenizeTokens )
+ } else {
+ testsToRunStrList = testsOverride.tokenize( tokenizeTokens )
+ }
+ testsToRun = test_list.getTestsFromStringList( testsToRunStrList )
+}
+
+def getProperties(){
+ // get the properties of the test by reading the TestONOS.property
+
+ filePath = '''/var/jenkins/TestONOS-''' + category + '''-''' + branchWithPrefix + '''.property'''
+
+ node( testStation ) {
+ return readProperties( file: filePath )
+ }
+}
+
+def readParams(){
+ category = params.Category // "MO", etc.
+ branch = params.Branch // "1.15", "2.1", "master", etc.
+ branchWithPrefix = test_list.addPrefixToBranch( branch )
+ testStation = params.TestStation // "TestStation-BMs", etc.
+ nodeLabel = params.NodeLabel // "BM", "VM", "Fabric-1.x", etc.
+ testsOverride = params.TestsOverride // "FUNCflow, FUNCintent, [...]", overrides property file
+}
+
+def runTests(){
+ // run the test sequentially and save the function into the dictionary.
+ for ( String test : testsFromList.keySet() ){
+ toBeRun = testsToRun.keySet().contains( test )
+ stepName = ( toBeRun ? "" : "Not " ) + "Running $test"
+ pipeline[ stepName ] = runMOtest( test,
+ toBeRun )
+ }
+
+ // run the tests sequentially.
+ for ( test in pipeline.keySet() ){
+ pipeline[ test ].call()
+ }
+}
+
+def runMOtest( test, toBeRun ){
+ return {
+ catchError {
+ stage( test ){
+ if ( toBeRun ){
+ node( testStation ) {
+ sh script: '''. ~/.profile
+ cd ~/onos-test
+ make clean
+ make integration
+ ''', label: "make integration"
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/TestON/JenkinsFile/MasterTrigger.groovy b/TestON/JenkinsFile/MasterTrigger.groovy
index 82b5802..5df3d4a 100644
--- a/TestON/JenkinsFile/MasterTrigger.groovy
+++ b/TestON/JenkinsFile/MasterTrigger.groovy
@@ -239,56 +239,82 @@
return result
}
-def preSetup( onos_branch, test_branch, onos_tag, isManual ){
+def preSetup( onos_branch, test_branch, onos_tag, isManual, category ){
// pre setup part which will clean up and checkout to corresponding branch.
result = ""
if ( !isManual ){
- result = '''echo -e "\n##### Set TestON Branch #####"
- echo "TestON Branch is set on: ''' + test_branch + '''"
- cd ~/OnosSystemTest/
- git checkout HEAD~1 # Make sure you aren't pn a branch
- git branch | grep -v "detached from" | xargs git branch -d # delete all local branches merged with remote
- git branch -D ''' + test_branch + ''' # just in case there are local changes. This will normally result in a branch not found error
- git clean -df # clean any local files
- git fetch --all # update all caches from remotes
- git reset --hard origin/''' + test_branch + ''' # force local index to match remote branch
- git clean -df # clean any local files
- git checkout ''' + test_branch + ''' #create new local branch
- git branch
- git log -1 --decorate
- echo -e "\n##### Set ONOS Branch #####"
- echo "ONOS Branch is set on: ''' + onos_branch + '''"
- echo -e "\n #### check karaf version ######"
- env |grep karaf
- cd ~/onos
- git checkout HEAD~1 # Make sure you aren't pn a branch
- git branch | grep -v "detached from" | xargs git branch -d # delete all local branches merged with remote
- git branch -D ''' + onos_branch + ''' # just incase there are local changes. This will normally result in a branch not found error
- git clean -df # clean any local files
- git fetch --all # update all caches from remotes
- git reset --hard origin/''' + onos_branch + ''' # force local index to match remote branch
- git clean -df # clean any local files
- rm -rf buck-out
- rm -rf bazel-*
- ''' + tagCheck( onos_tag, onos_branch ) + '''
- git branch
- git log -1 --decorate
- echo -e "\n##### set jvm heap size to 8G #####"
- echo ${ONOSJAVAOPTS}
- inserted_line="export JAVA_OPTS=\"\${ONOSJAVAOPTS}\""
- sed -i "s/bash/bash\\n$inserted_line/" ~/onos/tools/package/bin/onos-service
- echo "##### Check onos-service setting..... #####"
- cat ~/onos/tools/package/bin/onos-service
- export JAVA_HOME=/usr/lib/jvm/java-8-oracle'''
+ if ( category == "MO" ){
+ result = '''echo -e "\n##### Set onos-config branch"
+ cd ~/onos-test/
+ git checkout HEAD~1 # Make sure you aren't on a branch
+ git branch | grep -v "detached from" | xargs git branch -d # delete all local branches merged with remote
+ git branch -D ''' + test_branch + ''' # just in case there are local changes. This will normally result in a branch not found error
+ git reset --hard origin/''' + test_branch + ''' # force local index to match remote branch
+ git clean -df # clean any local files
+ git fetch --all # update all caches from remotes
+ git reset --hard origin/''' + onos_branch + ''' # force local index to match remote branch
+ git clean -df
+ git branch
+ git log -1 --decorate
+ '''
+ } else {
+ result = '''echo -e "\n##### Set TestON Branch #####"
+ echo "TestON Branch is set on: ''' + test_branch + '''"
+ cd ~/OnosSystemTest/
+ git checkout HEAD~1 # Make sure you aren't pn a branch
+ git branch | grep -v "detached from" | xargs git branch -d # delete all local branches merged with remote
+ git branch -D ''' + test_branch + ''' # just in case there are local changes. This will normally result in a branch not found error
+ git clean -df # clean any local files
+ git fetch --all # update all caches from remotes
+ git reset --hard origin/''' + test_branch + ''' # force local index to match remote branch
+ git clean -df # clean any local files
+ git checkout ''' + test_branch + ''' #create new local branch
+ git branch
+ git log -1 --decorate
+ echo -e "\n##### Set ONOS Branch #####"
+ echo "ONOS Branch is set on: ''' + onos_branch + '''"
+ echo -e "\n #### check karaf version ######"
+ env |grep karaf
+ cd ~/onos
+ git checkout HEAD~1 # Make sure you aren't pn a branch
+ git branch | grep -v "detached from" | xargs git branch -d # delete all local branches merged with remote
+ git branch -D ''' + onos_branch + ''' # just incase there are local changes. This will normally result in a branch not found error
+ git clean -df # clean any local files
+ git fetch --all # update all caches from remotes
+ git reset --hard origin/''' + onos_branch + ''' # force local index to match remote branch
+ git clean -df # clean any local files
+ rm -rf buck-out
+ rm -rf bazel-*
+ ''' + tagCheck( onos_tag, onos_branch ) + '''
+ git branch
+ git log -1 --decorate
+ echo -e "\n##### set jvm heap size to 8G #####"
+ echo ${ONOSJAVAOPTS}
+ inserted_line="export JAVA_OPTS=\"\${ONOSJAVAOPTS}\""
+ sed -i "s/bash/bash\\n$inserted_line/" ~/onos/tools/package/bin/onos-service
+ echo "##### Check onos-service setting..... #####"
+ cat ~/onos/tools/package/bin/onos-service
+ export JAVA_HOME=/usr/lib/jvm/java-8-oracle'''
+ }
+
} else {
- result = '''echo "Since this is a manual run, we'll use the current ONOS and TestON branch:"
- echo "ONOS branch:"
- cd ~/OnosSystemTest/
- git branch
- echo "TestON branch:"
- cd ~/TestON/
- git branch'''
+ if ( category == "MO" ) {
+ result = '''echo "Since this is a manual run, we'll use the current onos-test branch:"
+ echo "onos-test branch:"
+ cd ~/onos-test
+ git branch
+ '''
+ } else {
+ result = '''echo "Since this is a manual run, we'll use the current ONOS and TestON branch:"
+ echo "ONOS branch:"
+ cd ~/OnosSystemTest/
+ git branch
+ echo "TestON branch:"
+ cd ~/TestON/
+ git branch'''
+ }
+
}
return result
}
@@ -338,9 +364,11 @@
set +e
. ~/.bashrc
env
- ''' + preSetup( onos_branch, test_branch, onos_tag, manuallyRun ), label: "Repo Setup", returnStdout: false
- sh script: postSetup( onos_branch, test_branch, onos_tag, manuallyRun ), label: "Install Bazel", returnStdout: false
- generateKey()
+ ''' + preSetup( onos_branch, test_branch, onos_tag, manuallyRun, category ), label: "Repo Setup", returnStdout: false
+ if ( category != "MO" ){
+ sh script: postSetup( onos_branch, test_branch, onos_tag, manuallyRun ), label: "Install Bazel", returnStdout: false
+ generateKey()
+ }
}
}
@@ -420,7 +448,7 @@
}
}
- echo "=========================================="
+ echo "========================================="
echo "BRANCH: " + branch
echo "CATEGORY: " + category
echo "TESTS: " + filteredList
diff --git a/TestON/JenkinsFile/dependencies/schedule.json b/TestON/JenkinsFile/dependencies/schedule.json
index 8bae191..c70fe45 100644
--- a/TestON/JenkinsFile/dependencies/schedule.json
+++ b/TestON/JenkinsFile/dependencies/schedule.json
@@ -16,5 +16,6 @@
"onos-1.x_schedule": [ "sat" ],
"onos-2.x_schedule": [ "sun" ],
"USECASE_master": [ "tue" ],
- "SR_schedule": [ "sun", "mon", "tue", "wed", "thu", "sat" ]
+ "SR_schedule": [ "sun", "mon", "tue", "wed", "thu", "sat" ],
+ "none": []
}
diff --git a/TestON/JenkinsFile/dependencies/tests.json b/TestON/JenkinsFile/dependencies/tests.json
index 9d0a132..4609386 100644
--- a/TestON/JenkinsFile/dependencies/tests.json
+++ b/TestON/JenkinsFile/dependencies/tests.json
@@ -1452,6 +1452,11 @@
"MOmakeIntegration": {
"wikiName": "Micro ONOS Integration Tests",
"schedules" : [
+ {
+ "branch": "master",
+ "day": "none",
+ "nodeLabel": "micro-onos"
+ }
],
"category": "MO",
"supportedBranches": [ "all" ]