jjb/pipeline/voltha/playground/physical-build.groovy
jjb/pipeline/voltha/playground/voltha-tt-physical-functional-tests.groovy
-------------------------------------------------------------------------
o Update to work with the latest iam() vars script.
o Remove stage('IAM') from physical-build.groovy
vars/iam.groovy
---------------
o Updated so caller can pass in more identification parameters.
Change-Id: I2a82320865030b4e75d5df7865af66a16bc10607
diff --git a/jjb/pipeline/voltha/playground/physical-build.groovy b/jjb/pipeline/voltha/playground/physical-build.groovy
index b9677c3..5779ac1 100644
--- a/jjb/pipeline/voltha/playground/physical-build.groovy
+++ b/jjb/pipeline/voltha/playground/physical-build.groovy
@@ -1,4 +1,5 @@
// -*- groovy -*-
+// -----------------------------------------------------------------------
// Copyright 2017-2023 Open Networking Foundation (ONF) and the ONF Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -28,18 +29,21 @@
def volthaNamespace = "voltha"
// -----------------------------------------------------------------------
+// Intent: Visible in jenkins UI, job configure screen
// -----------------------------------------------------------------------
def getIam(String func)
{
// Cannot rely on a stack trace due to jenkins manipulation
String src = [
- 'jjb',
- 'pipeline',
- 'voltha',
- 'playground',
- 'voltha-tt-physical-functional-tests.groovy'
+ 'jjb',
+ 'pipeline',
+ 'voltha',
+ 'playground',
+ 'voltha-tt-physical-functional-tests.groovy'
].join('/')
+
String iam = [src, func].join('::')
+ iam += sprintf('[ver:1.0]')
return iam
}
@@ -56,58 +60,63 @@
/* no label, executor is determined by JJB */
agent
{
- label "${params.buildNode}"
+ label "${params.buildNode}"
}
options
{
- timeout(time: 35, unit: 'MINUTES')
+ timeout(time: 35, unit: 'MINUTES')
}
environment
{
- PATH="$PATH:$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
- KUBECONFIG="$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf"
+ PATH="$PATH:$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
+ KUBECONFIG="$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf"
}
stages
{
- stage('IAM')
- {
- String iam = getIam('main')
- println("** ${iam}: ENTER")
- println("** ${iam}: LEAVE")
- }
+ stage('Download Code')
+ {
+ iam(this)
+ {
+ enter = true
+ label = getIam()
+ }
- stage('Download Code')
- {
- steps {
- getVolthaCode([
- branch: "${branch}",
- volthaSystemTestsChange: "${volthaSystemTestsChange}",
- volthaHelmChartsChange: "${volthaHelmChartsChange}",
- ])
- }
- }
+ steps {
+ getVolthaCode([
+ branch: "${branch}",
+ volthaSystemTestsChange: "${volthaSystemTestsChange}",
+ volthaHelmChartsChange: "${volthaHelmChartsChange}",
+ ])
+ }
- stage ("Parse deployment configuration file") {
- steps {
- sh returnStdout: true, script: "rm -rf ${configBaseDir}"
- sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}"
- script {
- String conf = "${configBaseDir}/${configDeploymentDir}/${configFileName}"
- String flow = params.workFlow
+ iam(this)
+ {
+ leave = true
+ label = getIam()
+ }
+ }
- conf += (flow == 'DT') ? '-DT.yaml'
- : (flow == 'TT') ? '-TT.yaml'
- : '.yaml'
+ stage ("Parse deployment configuration file") {
+ steps {
+ sh returnStdout: true, script: "rm -rf ${configBaseDir}"
+ sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}"
+ script {
+ String conf = "${configBaseDir}/${configDeploymentDir}/${configFileName}"
+ String flow = params.workFlow
- deployment_config = readYaml file: conf
-
- /*
- if ( params.workFlow == "DT" )
- {
- conf += '-DT.yaml'
+ conf += (flow == 'DT') ? '-DT.yaml'
+ : (flow == 'TT') ? '-TT.yaml'
+ : '.yaml'
+
+ deployment_config = readYaml file: conf
+
+ /*
+ if ( params.workFlow == "DT" )
+ {
+ conf += '-DT.yaml'
// deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
}
else if ( params.workFlow == "TT" )
@@ -118,7 +127,7 @@
{
deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml"
}
- */
+ */
}
}
}
diff --git a/jjb/pipeline/voltha/playground/voltha-tt-physical-functional-tests.groovy b/jjb/pipeline/voltha/playground/voltha-tt-physical-functional-tests.groovy
index 569cf1d..f0965ff 100644
--- a/jjb/pipeline/voltha/playground/voltha-tt-physical-functional-tests.groovy
+++ b/jjb/pipeline/voltha/playground/voltha-tt-physical-functional-tests.groovy
@@ -32,13 +32,15 @@
{
// Cannot rely on a stack trace due to jenkins manipulation
String src = [
- 'jjb',
- 'pipeline',
- 'voltha',
- 'playground',
- 'voltha-tt-physical-functional-tests.groovy'
+ 'jjb',
+ 'pipeline',
+ 'voltha',
+ 'playground',
+ 'voltha-tt-physical-functional-tests.groovy'
].join('/')
+
String iam = [src, func].join('::')
+ iam += sprintf('[ver:1.0]')
return iam
}
@@ -50,52 +52,56 @@
/* no label, executor is determined by JJB */
agent
{
- label "${params.buildNode}"
+ label "${params.buildNode}"
}
options
{
- timeout(time: "${timeout}", unit: 'MINUTES')
+ timeout(time: "${timeout}", unit: 'MINUTES')
}
environment
{
- KUBECONFIG="$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf"
- VOLTCONFIG="$HOME/.volt/config-minimal"
- PATH="$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
+ KUBECONFIG="$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf"
+ VOLTCONFIG="$HOME/.volt/config-minimal"
+ PATH="$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
}
stages {
- // -----------------------------------------------------------------------
- // -----------------------------------------------------------------------
- stage('Clone voltha-system-tests')
- {
- steps
- {
- iam(this) { enter = true }
+ // -----------------------------------------------------------------------
+ // -----------------------------------------------------------------------
+ stage('Clone voltha-system-tests')
+ {
+ steps
+ {
+ iam(this)
+ {
+ enter = true
+ label = getIam()
+ }
- step([$class: 'WsCleanup'])
- checkout([
- $class: 'GitSCM',
- userRemoteConfigs: [[
- url: "https://gerrit.opencord.org/voltha-system-tests",
- refspec: "${volthaSystemTestsChange}"
- ]],
- branches: [[ name: "${branch}" ]],
- extensions: [
- [$class: 'WipeWorkspace'],
- [$class: 'RelativeTargetDirectory', relativeTargetDir: "voltha-system-tests"],
- [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
- ],
- ]) // checkout
+ step([$class: 'WsCleanup'])
+ checkout([
+ $class: 'GitSCM',
+ userRemoteConfigs: [[
+ url: "https://gerrit.opencord.org/voltha-system-tests",
+ refspec: "${volthaSystemTestsChange}"
+ ]],
+ branches: [[ name: "${branch}" ]],
+ extensions: [
+ [$class: 'WipeWorkspace'],
+ [$class: 'RelativeTargetDirectory', relativeTargetDir: "voltha-system-tests"],
+ [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
+ ],
+ ]) // checkout
- script
- {
- sh(
- returnStatus: true,
- // returnStdout: true,
- script: """
+ script
+ {
+ sh(
+ returnStatus: true,
+ // returnStdout: true,
+ script: """
if [ '${volthaSystemTestsChange}' != '' ] ; then
cd "$WORKSPACE/voltha-system-tests"
git fetch https://gerrit.opencord.org/voltha-system-tests ${volthaSystemTestsChange}
@@ -104,61 +110,65 @@
fi
""")
- iam(this) { leave = true }
- } // step
- } // steps
- } // stage
+ iam(this)
+ {
+ leave = true
+ label = getIam()
+ }
+ } // step
+ } // steps
+ } // stage
- // -----------------------------------------------------------------------
- // This checkout allows us to show changes in Jenkins
- // we only do this on master as we don't branch all the repos for all the releases
- // (we should compute the difference by tracking the container version, not the code)
- // -----------------------------------------------------------------------
- stage('Download All the VOLTHA repos')
- {
- when {
- expression { return "${branch}" == 'master'; }
+ // -----------------------------------------------------------------------
+ // This checkout allows us to show changes in Jenkins
+ // we only do this on master as we don't branch all the repos for all the releases
+ // (we should compute the difference by tracking the container version, not the code)
+ // -----------------------------------------------------------------------
+ stage('Download All the VOLTHA repos')
+ {
+ when {
+ expression { return "${branch}" == 'master'; }
}
- steps {
- checkout(changelog: true,
- poll: false,
- scm: [$class: 'RepoScm',
- manifestRepositoryUrl: "${params.manifestUrl}",
- manifestBranch: "${params.branch}",
- currentBranch: true,
- destinationDir: 'voltha',
- forceSync: true,
- resetFirst: true,
- quiet: true,
- jobs: 4,
- showAllChanges: true]
- )
- }
- }
+ steps {
+ checkout(changelog: true,
+ poll: false,
+ scm: [$class: 'RepoScm',
+ manifestRepositoryUrl: "${params.manifestUrl}",
+ manifestBranch: "${params.branch}",
+ currentBranch: true,
+ destinationDir: 'voltha',
+ forceSync: true,
+ resetFirst: true,
+ quiet: true,
+ jobs: 4,
+ showAllChanges: true]
+ )
+ }
+ }
- // -----------------------------------------------------------------------
- // -----------------------------------------------------------------------
- stage ('Initialize')
- {
+ // -----------------------------------------------------------------------
+ // -----------------------------------------------------------------------
+ stage ('Initialize')
+ {
steps
- {
- sh(
- returnStatus: true,
- returnStdout: false,
- script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}"
- )
- script
- {
- deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
- }
+ {
+ sh(
+ returnStatus: true,
+ returnStdout: false,
+ script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}"
+ )
+ script
+ {
+ deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
+ }
- installVoltctl("${branch}")
+ installVoltctl("${branch}")
- sh(
- returnStatus: true,
- returnStdout: false,
- script: """
+ sh(
+ returnStatus: true,
+ returnStdout: false,
+ script: """
mkdir -p "$WORKSPACE/bin"
# install kail
@@ -179,22 +189,22 @@
voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/kafka
fi
""")
- } // step
- } // stage
+ } // step
+ } // stage
- // -----------------------------------------------------------------------
- // -----------------------------------------------------------------------
- stage('Functional Tests')
- {
- environment
- {
- ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
- ROBOT_FILE="Voltha_TT_PODTests.robot"
- ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/FunctionalTests"
- }
+ // -----------------------------------------------------------------------
+ // -----------------------------------------------------------------------
+ stage('Functional Tests')
+ {
+ environment
+ {
+ ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
+ ROBOT_FILE="Voltha_TT_PODTests.robot"
+ ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/FunctionalTests"
+ }
- steps {
- sh("""
+ steps {
+ sh("""
mkdir -p $ROBOT_LOGS_DIR
if ( ${powerSwitch} ); then
export ROBOT_MISC_ARGS="--removekeywords wuks -i functionalTT -i PowerSwitch -i sanityTT -i sanityTT-MCAST -e bbsim -e notready -d $ROBOT_LOGS_DIR -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE -v OLT_ADAPTER_APP_LABEL:${oltAdapterAppLabel}"
@@ -208,22 +218,22 @@
make -C $WORKSPACE/voltha-system-tests voltha-tt-test
""")
}
- } // stage
+ } // stage
- // -----------------------------------------------------------------------
- // -----------------------------------------------------------------------
- stage('Failure/Recovery Tests')
- {
- environment
- {
- ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
- ROBOT_FILE="Voltha_TT_FailureScenarios.robot"
- ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/FailureScenarios"
- }
+ // -----------------------------------------------------------------------
+ // -----------------------------------------------------------------------
+ stage('Failure/Recovery Tests')
+ {
+ environment
+ {
+ ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
+ ROBOT_FILE="Voltha_TT_FailureScenarios.robot"
+ ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/FailureScenarios"
+ }
- steps
- {
- sh("""
+ steps
+ {
+ sh("""
mkdir -p $ROBOT_LOGS_DIR
if [ ${params.enableMultiUni} = false ]; then
if ( ${powerSwitch} ); then
@@ -235,24 +245,24 @@
make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true
fi
""")
- }
- } // stage
+ }
+ } // stage
- // -----------------------------------------------------------------------
- // -----------------------------------------------------------------------
- stage('Multi-Tcont Tests')
- {
- environment
- {
- ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
- ROBOT_FILE="Voltha_TT_MultiTcontTests.robot"
- ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/MultiTcontScenarios"
- ROBOT_TEST_INPUT_FILE="$WORKSPACE/voltha-system-tests/tests/data/${configFileName}-TT-multi-tcont-tests-input.yaml"
- }
+ // -----------------------------------------------------------------------
+ // -----------------------------------------------------------------------
+ stage('Multi-Tcont Tests')
+ {
+ environment
+ {
+ ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
+ ROBOT_FILE="Voltha_TT_MultiTcontTests.robot"
+ ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/MultiTcontScenarios"
+ ROBOT_TEST_INPUT_FILE="$WORKSPACE/voltha-system-tests/tests/data/${configFileName}-TT-multi-tcont-tests-input.yaml"
+ }
- steps
- {
- sh("""
+ steps
+ {
+ sh("""
mkdir -p $ROBOT_LOGS_DIR
if [ ${params.enableMultiUni} = false ]; then
if ( ${powerSwitch} ); then
@@ -264,24 +274,24 @@
make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true
fi
""")
- }
- }
-
- // -----------------------------------------------------------------------
- // -----------------------------------------------------------------------
- stage('Multicast Tests')
- {
- environment
- {
- ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
- ROBOT_FILE="Voltha_TT_MulticastTests.robot"
- ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/MulticastTests"
- ROBOT_TEST_INPUT_FILE="$WORKSPACE/voltha-system-tests/tests/data/${configFileName}-TT-multicast-tests-input.yaml"
- }
+ }
+ }
- steps
- {
- sh("""
+ // -----------------------------------------------------------------------
+ // -----------------------------------------------------------------------
+ stage('Multicast Tests')
+ {
+ environment
+ {
+ ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
+ ROBOT_FILE="Voltha_TT_MulticastTests.robot"
+ ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/MulticastTests"
+ ROBOT_TEST_INPUT_FILE="$WORKSPACE/voltha-system-tests/tests/data/${configFileName}-TT-multicast-tests-input.yaml"
+ }
+
+ steps
+ {
+ sh("""
mkdir -p $ROBOT_LOGS_DIR
if [ ${params.enableMultiUni} = true ]; then
if ( ${powerSwitch} ); then
@@ -293,16 +303,16 @@
make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true
fi
""")
- }
- }
+ }
+ }
}
post
{
- always
- {
- getPodsInfo("$WORKSPACE/pods")
- sh(returnStdout: false, script: '''
+ always
+ {
+ getPodsInfo("$WORKSPACE/pods")
+ sh(returnStdout: false, script: '''
set +e
# collect logs collected in the Robot Framework StartLogging keyword
@@ -311,33 +321,33 @@
rm *-combined.log || true
''')
- script {
+ script {
deployment_config.olts.each { olt ->
- if (olt.type == null || olt.type == "" || olt.type == "openolt")
- {
- sh(returnStdout: false, script: """
+ if (olt.type == null || olt.type == "" || olt.type == "openolt")
+ {
+ sh(returnStdout: false, script: """
sshpass -p ${olt.pass} scp ${olt.user}@${olt.sship}:/var/log/openolt.log $WORKSPACE/openolt-${olt.sship}.log || true
sshpass -p ${olt.pass} scp ${olt.user}@${olt.sship}:/var/log/dev_mgmt_daemon.log $WORKSPACE/dev_mgmt_daemon-${olt.sship}.log || true
sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt-${olt.sship}.log # Remove escape sequences
sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/dev_mgmt_daemon-${olt.sship}.log # Remove escape sequences
""")
- }
- }
- }
+ }
+ }
+ }
- step([$class: 'RobotPublisher',
- disableArchiveOutput: false,
- logFileName: '**/log*.html',
- otherFiles: '',
- outputFileName: '**/output*.xml',
- outputPath: 'RobotLogs',
- passThreshold: 100,
- reportFileName: '**/report*.html',
- unstableThreshold: 0,
- onlyCritical: true
+ step([$class: 'RobotPublisher',
+ disableArchiveOutput: false,
+ logFileName: '**/log*.html',
+ otherFiles: '',
+ outputFileName: '**/output*.xml',
+ outputPath: 'RobotLogs',
+ passThreshold: 100,
+ reportFileName: '**/report*.html',
+ unstableThreshold: 0,
+ onlyCritical: true
]);
- archiveArtifacts artifacts: '**/*.log,**/*.gz,**/*.tgz,*.txt,pods/*.txt'
- } // always
+ archiveArtifacts artifacts: '**/*.log,**/*.gz,**/*.tgz,*.txt,pods/*.txt'
+ } // always
} // post
} // pipeline
diff --git a/vars/iam.groovy b/vars/iam.groovy
index 0a340b6..75f204d 100644
--- a/vars/iam.groovy
+++ b/vars/iam.groovy
@@ -19,26 +19,30 @@
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
-String getIam(String func)
+String getIam(Map argv, String func)
{
- // Cannot rely on a stack trace due to jenkins manipulation
- // Report who and where caller came from.
- String src = [
- 'repo:ci-management',
- 'vars',
- 'iam',
- ].join('/')
+ String src = argv.containsKey('label')
+ ? argv.label
+ : [ // Cannot lookup, jenkins alters stack for serialization
+ 'repo:ci-management',
+ 'vars',
+ 'iam',
+ ].join('/')
String iam = [src, func].join('::')
+ if (argv.containsKey('version'))
+ {
+ iam += sprintf("[%s]", argv.version)
+ }
return(iam)
}
// -----------------------------------------------------------------------
// Intent: Display future enhancement list.
// -----------------------------------------------------------------------
-void todo()
+void todo(Map argv)
{
- String iam = getIam('todo')
+ String iam = getIam(argv, 'todo')
println("""
[TODO: $iam]
@@ -54,9 +58,9 @@
// -----------------------------------------------------------------------
// Intent: Placeholder in case future enhancements are needed
// -----------------------------------------------------------------------
-Boolean process(Map config)
+Boolean process(Map argv)
{
- String iam = getIam('process')
+ String iam = getIam(argv, 'process')
Boolean leave = false
@@ -65,13 +69,13 @@
println("** ${iam}: ENTER")
}
else if (config.containsKey('leave')) {
- leave = true
+ leave = true
}
else
{
println("** ${iam}: HELLO")
}
-
+
// Display future enhancement list
if (config.containsKey('todo')) {
todo()
@@ -82,7 +86,7 @@
{
println("** ${iam}: LEAVE")
}
-
+
return(true)
}
@@ -95,6 +99,8 @@
// enter Display "** {iam} ENTER"
// leave Display "** {iam} LEAVE"
// todo Display future enhancement list
+// label path/to/src[ver:1.0]
+// version specify version and label separately
// -----------------------------------------------------------------------
// Usage:
// o called from a jenkins {pipeline,stage,script} block.
@@ -104,11 +110,11 @@
// tans = fans
// }
// -----------------------------------------------------------------------
-Boolean call(def self, Map config)
+Boolean call(def self, Map argv)
{
- String iam = getIam('main')
-
argv = argv ?: [:] // {ternary,elvis} operator
+ String iam = getIam(argv, 'main')
+
println("** ${iam}: argv=${argv}")
Boolean ranToCompletion = false