[VOL-5100] - periodic-voltha-test-bbsim
jjb/pipeline/voltha/master/bbsim-tests.groovy
---------------------------------------------
o misc npm-groovy-lint cleanups:
- indentation, quotes, typed vars, etc.
- convert tabs to space (expand -i -t 8)
o Stage('Install Kind')
- wrap install_kind call in a script{} block for evaluation.
- no primitives available like sh() to provide needed script{} context.
o Re-enable IAM method now that branch_name is fixed.
makefiles/lint/include.mk
makefiles/lint/groovy/include.mk
makefiles/lint/groovy/install.mk
--------------------------------
o (WIP) Add skeleton targets for lint-groovy able to install
npm-groovy-lint on demand for local use.
Change-Id: Ifbf72ae9cb021d28c15a783454278ac2c680e45e
diff --git a/jjb/pipeline/voltha/master/bbsim-tests.groovy b/jjb/pipeline/voltha/master/bbsim-tests.groovy
index c056614..8ff8e6b 100644
--- a/jjb/pipeline/voltha/master/bbsim-tests.groovy
+++ b/jjb/pipeline/voltha/master/bbsim-tests.groovy
@@ -25,7 +25,7 @@
//------------------//
//---] GLOBAL [---//
//------------------//
-def clusterName = "kind-ci"
+def clusterName = 'kind-ci'
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
@@ -38,15 +38,14 @@
// Intent: Due to lack of a reliable stack trace, construct a literal.
// Jenkins will re-write the call stack for serialization.
// -----------------------------------------------------------------------
-def getIam(String func)
-{
+String getIam(String func) {
String branch_name = getBranchName()
String src = [
'ci-management',
'jjb',
'pipeline',
'voltha',
- branch_name,
+ branch_name,
'bbsim-tests.groovy'
].join('/')
@@ -86,20 +85,20 @@
println("** ${iam}: ENTER")
try
{
- println("** ${iam} Running installKind(name): ENTER")
- installKind(name)
- println("** ${iam} Running installKind(name): LEAVE")
- ans = True // iff
+ println("** ${iam} Running installKind(name): ENTER")
+ installKind(name)
+ println("** ${iam} Running installKind(name): LEAVE")
+ ans = True // iff
}
catch (Exception err)
{
- ans = False
- println("** ${iam}: EXCEPTION ${err}")
- throw err
+ ans = False
+ println("** ${iam}: EXCEPTION ${err}")
+ throw err
}
finally
{
- println("** ${iam}: ENTER")
+ println("** ${iam}: ENTER")
}
return(ans)
@@ -114,18 +113,16 @@
def volthaNamespace = "voltha"
def logsDir = "$WORKSPACE/${testTarget}"
- /*
stage('IAM')
{
script
{
- // Announce ourselves for log usability
- String iam = getIam('execute_test')
- println("${iam}: ENTER")
- println("${iam}: LEAVE")
+ // Announce ourselves for log usability
+ String iam = getIam('execute_test')
+ println("${iam}: ENTER")
+ println("${iam}: LEAVE")
}
}
- */
stage('Cleanup')
{
@@ -156,16 +153,7 @@
println(" ** Running: ${cmd}:\n")
sh("${cmd}")
// if (! my_install_kail())
- // throw new Exception('installKail() failed')
- }
-
- stage ('Install Kind')
- {
- steps
- {
- String branch_name = getBranchName()
- install_kind(branch_name)
- }
+ // throw new Exception('installKail() failed')
}
stage('Deploy common infrastructure')
@@ -183,12 +171,12 @@
stage('Deploy Voltha')
{
- if (teardown)
- {
- timeout(10)
- {
- script
- {
+ if (teardown)
+ {
+ timeout(10)
+ {
+ script
+ {
sh """
mkdir -p ${logsDir}
_TAG=kail-startup kail -n ${infraNamespace} -n ${volthaNamespace} > ${logsDir}/onos-voltha-startup-combined.log &
@@ -198,28 +186,28 @@
def localCharts = false
if (volthaHelmChartsChange != ""
- || gerritProject == "voltha-helm-charts"
- || isReleaseBranch(branch) // branch != 'master'
+ || gerritProject == "voltha-helm-charts"
+ || isReleaseBranch(branch) // branch != 'master'
) {
localCharts = true
}
- String branch_name = getBranchName()
+ String branch_name = getBranchName()
Boolean is_release = isReleaseBranch(branch)
- println([
- " ** localCharts=${localCharts}",
- "branch_name=${branch_name}",
- "branch=${branch}",
- "branch=isReleaseBranch=${is_release}",
- ].join(', '))
+ println([
+ " ** localCharts=${localCharts}",
+ "branch_name=${branch_name}",
+ "branch=${branch}",
+ "branch=isReleaseBranch=${is_release}",
+ ].join(', '))
// NOTE temporary workaround expose ONOS node ports
- def localHelmFlags = extraHelmFlags.trim()
- + " --set global.log_level=${logLevel.toUpperCase()} "
- + " --set onos-classic.onosSshPort=30115 "
- + " --set onos-classic.onosApiPort=30120 "
- + " --set onos-classic.onosOfPort=31653 "
- + " --set onos-classic.individualOpenFlowNodePorts=true "
- + testSpecificHelmFlags
+ def localHelmFlags = extraHelmFlags.trim()
+ + " --set global.log_level=${logLevel.toUpperCase()} "
+ + " --set onos-classic.onosSshPort=30115 "
+ + " --set onos-classic.onosApiPort=30120 "
+ + " --set onos-classic.onosOfPort=31653 "
+ + " --set onos-classic.individualOpenFlowNodePorts=true "
+ + testSpecificHelmFlags
if (gerritProject != "") {
localHelmFlags = "${localHelmFlags} " + getVolthaImageFlags("${gerritProject}")
@@ -237,22 +225,22 @@
])
}
- // -----------------------------------------------------------------------
- // Intent: Replacing P_IDS with pgrep/pkill is a step forward.
- // Why not simply use a pid file, capture _TAG=kail-startup above
- // Grep runs the risk of terminating stray commands (??-good <=> bad-??)
- // -----------------------------------------------------------------------
- println('Try out the pgrep/pkill commands')
- def stream = sh(
+ // -----------------------------------------------------------------------
+ // Intent: Replacing P_IDS with pgrep/pkill is a step forward.
+ // Why not simply use a pid file, capture _TAG=kail-startup above
+ // Grep runs the risk of terminating stray commands (??-good <=> bad-??)
+ // -----------------------------------------------------------------------
+ echo 'Try out pgrep/pkill commands'
+ def stream = sh(
returnStatus:false,
returnStdout:true,
- script: '''pgrep --list-full kail-startup || true'''
- )
- println("** pgrep output: ${stream}")
+ script: '''pgrep --list-full kail-startup || true'''
+ )
+ println("** pgrep output: ${stream}")
- // -----------------------------------------------------------------------
- // stop logging
- // -----------------------------------------------------------------------
+ // -----------------------------------------------------------------------
+ // stop logging
+ // -----------------------------------------------------------------------
sh """
P_IDS="\$(ps e -ww -A | grep "_TAG=kail-startup" | grep -v grep | awk '{print \$1}')"
if [ -n "\$P_IDS" ]; then
@@ -349,17 +337,28 @@
// -----------------------------------------------------------------------
def collectArtifacts(exitStatus)
{
+ echo '''
+
+** -----------------------------------------------------------------------
+** collectArtifacts
+** -----------------------------------------------------------------------
+'''
+
getPodsInfo("$WORKSPACE/${exitStatus}")
+
sh """
kubectl logs -n voltha -l app.kubernetes.io/part-of=voltha > $WORKSPACE/${exitStatus}/voltha.log
"""
+
archiveArtifacts artifacts: '**/*.log,**/*.gz,**/*.txt,**/*.html,**/voltha-pods-mem-consumption-att/*,**/voltha-pods-mem-consumption-dt/*,**/voltha-pods-mem-consumption-tt/*'
+
sh '''
sync
[[ $(pgrep --count kail) -gt 0 ]] && pkill --echo kail
which voltctl
md5sum $(which voltctl)
'''
+
step([$class: 'RobotPublisher',
disableArchiveOutput: false,
logFileName: "**/*/log*.html",
@@ -412,21 +411,39 @@
}
}
- steps
- {
- // NOTE that the correct patch has already been checked out
- // during the getVolthaCode step
- buildVolthaComponent("${gerritProject}")
+ steps
+ {
+ // NOTE that the correct patch has already been checked out
+ // during the getVolthaCode step
+ buildVolthaComponent("${gerritProject}")
}
}
+ // -----------------------------------------------------------------------
+ // Intent: Install early so stage('Create K8s Cluster') will not
+ // fail on bogus "script.sh: line 1: kind: command not found".
+ // -----------------------------------------------------------------------
+ stage ('Install Kind')
+ {
+ steps
+ {
+ script
+ {
+ String branch_name = getBranchName()
+ install_kind(branch_name)
+ } // script
+ } // steps
+ } // stage
+
+ // -----------------------------------------------------------------------
+ // -----------------------------------------------------------------------
stage('Create K8s Cluster')
{
steps
{
script
{
- def clusterExists = sh(
+ def clusterExists = sh(
returnStdout: true,
script: """kind get clusters | grep "${clusterName}" | wc -l""")
@@ -438,38 +455,44 @@
} // steps
} // stage('Create K8s Cluster')
- stage('Replace voltctl')
- {
- // if the project is voltctl, override the downloaded one with the built one
- when {
- expression {
- return gerritProject == "voltctl"
- }
- }
-
- // Hmmmm(?) where did the voltctl download happen ?
- // Likely Makefile but would be helpful to document here.
- steps
- {
- println("${iam} Running: installVoltctl($branch)")
- installVoltctl("$branch")
- } // steps
- } // stage
-
- stage('Load image in kind nodes')
- {
- when {
- expression {
- return !gerritProject.isEmpty()
- }
- }
- steps {
- loadToKind()
+ // -----------------------------------------------------------------------
+ // -----------------------------------------------------------------------
+ stage('Replace voltctl')
+ {
+ // if the project is voltctl, override the downloaded one with the built one
+ when {
+ expression {
+ return gerritProject == "voltctl"
}
}
- stage('Parse and execute tests')
+ // Hmmmm(?) where did the voltctl download happen ?
+ // Likely Makefile but would be helpful to document here.
+ steps
{
+ println("${iam} Running: installVoltctl($branch)")
+ installVoltctl("$branch")
+ } // steps
+ } // stage
+
+ // -----------------------------------------------------------------------
+ // -----------------------------------------------------------------------
+ stage('Load image in kind nodes')
+ {
+ when {
+ expression {
+ return !gerritProject.isEmpty()
+ }
+ }
+ steps {
+ loadToKind()
+ } // steps
+ } // stage
+
+ // -----------------------------------------------------------------------
+ // -----------------------------------------------------------------------
+ stage('Parse and execute tests')
+ {
steps {
script {
def tests = readYaml text: testTargets
diff --git a/makefiles/lint/groovy.mk b/makefiles/lint/groovy/include.mk
similarity index 100%
rename from makefiles/lint/groovy.mk
rename to makefiles/lint/groovy/include.mk
diff --git a/makefiles/lint/groovy/install.mk b/makefiles/lint/groovy/install.mk
index 7843e8f..fcfa8d6 100644
--- a/makefiles/lint/groovy/install.mk
+++ b/makefiles/lint/groovy/install.mk
@@ -1,4 +1,49 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2022-2023 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.
+# -----------------------------------------------------------------------
-# curl -O -L https://npmjs.org/install.sh
-# sh install
-# curl -L https://npmjs.org/install.sh | sh
+##-------------------##
+##---] GLOBALS [---##
+##-------------------##
+lint-groovy-cmds += $(shell which npm-groovy-lint)
+lint-groovy-cmds += $(HOME)/.npm/bin/npm-groovy-lint
+lint-groovy-cmds += /usr/bin/npm-groovy-lint
+# lint-groovy-cmds += /dev/null# # force existence
+
+lint-groovy-cmd = $(firstword $(wildcard $(lint-groovy-cmds)))
+
+##-------------------##
+##---] TARGETS [---##
+##-------------------##
+ifndef NO-LINT-GROOVY
+
+ lint : lint-groovy
+endif
+
+## -----------------------------------------------------------------------
+## Intent: Install npm-groovy-lint
+## -----------------------------------------------------------------------
+$(lint-groovy-cmd) : lint-groovy-install
+lint-groovy-install:
+
+## -----------------------------------------------------------------------
+## Intent: Display command help
+## -----------------------------------------------------------------------
+help-summary ::
+ @echo ' lint-groovy-install Syntax check groovy sources'
+
+# [EOF]
+
diff --git a/makefiles/lint/groovy/urls b/makefiles/lint/groovy/urls
index aa5c5eb..4d9ba27 100644
--- a/makefiles/lint/groovy/urls
+++ b/makefiles/lint/groovy/urls
@@ -5,4 +5,7 @@
https://github.com/nvuillam/npm-groovy-lint
+# Homepage
+installhttps://nvuillam.github.io/npm-groovy-lint/
+
# [EOF]
diff --git a/makefiles/lint/include.mk b/makefiles/lint/include.mk
index 7cfed79..e928fc3 100644
--- a/makefiles/lint/include.mk
+++ b/makefiles/lint/include.mk
@@ -28,7 +28,7 @@
@echo "[LINT]"
include $(ONF_MAKEDIR)/lint/doc8/include.mk
-include $(ONF_MAKEDIR)/lint/groovy.mk
+include $(ONF_MAKEDIR)/lint/groovy/include.mk
include $(ONF_MAKEDIR)/lint/jjb.mk
include $(ONF_MAKEDIR)/lint/json.mk
include $(ONF_MAKEDIR)/lint/license/include.mk
diff --git a/vars/showCommands.groovy b/vars/showCommands.groovy
index 58108ea..9e83ab9 100644
--- a/vars/showCommands.groovy
+++ b/vars/showCommands.groovy
@@ -27,7 +27,7 @@
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
void run_cmd(String command) {
- String buffer [
+ String buffer = [
"Running command: $command",
]