Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ Void distro_version_test(String branch, String distro, String expected) {
"instead of string starting with '${expected}'")
}
}
return
}

/* groovylint-disable-next-line CompileStatic */
Expand Down Expand Up @@ -594,7 +595,7 @@ pipeline {
'full_regression,foobar,@stages.tag@'],
[tags: [[tag: 'Test-tag', value: 'datamover foobar']],
tag_template: 'datamover,@stages.tag@ foobar,@stages.tag@'],
/* this one doesn't quite work due to the @commits.value@ substituion
/* this one doesn't quite work due to the @commits.value@ substitution
not accounting for the skip-list
[tags: [[tag: 'Test-tag', value: 'datamover'],
[tag: 'Features', value: 'foobar'],
Expand Down
39 changes: 39 additions & 0 deletions vars/Date.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// vars/Date.groovy

/**
* Date.groovy
*
* Jenkins sandbox-compatible replacement for java.util.Date
* Uses System.currentTimeMillis() which is allowed in the sandbox
*/

/**
* Create a new Date object using current time in milliseconds
* Returns the current time in milliseconds since epoch
*
* @return long Current time in milliseconds
*/
long call() {
return System.currentTimeMillis()
}

/**
* Create a Date object from a specific time in milliseconds
*
* @param timeInMillis Time in milliseconds since epoch
* @return long Time in milliseconds
*/
long call(long timeInMillis) {
return timeInMillis
}

/**
* Get time in milliseconds from a Date value
* For compatibility with code expecting .getTime()
*
* @param dateValue The date value (already in milliseconds)
* @return long Time in milliseconds
*/
long getTime(long dateValue) {
return dateValue
}
2 changes: 1 addition & 1 deletion vars/buildRpm.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
*/

Map call(Map config = [:]) {
Date startDate = new Date()
long startDate = System.currentTimeMillis()
String context = config.get('context', 'build/' + env.STAGE_NAME)
String description = config.get('description', env.STAGE_NAME)
String build_script = config.get('build_script', 'ci/rpm/build.sh')
Expand Down
12 changes: 8 additions & 4 deletions vars/cloverReportPublish.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* clover Report Publish step method
*
* Consolidiate clover data for publising.
* Consolidate clover data for publishing.
*
* @param config Map of parameters passed
*
Expand All @@ -31,11 +31,11 @@

Map call(Map config = [:]) {
// If we don't have a BULLSEYE environment variable set
// there are no Bullsye reports to process.
// there are no Bullseye reports to process.
if (!env.BULLSEYE) {
return ['result': 'SUCCESS', 'cloverreportpublish_time': 0]
}
Date startDate = new Date()
long startDate = System.currentTimeMillis()
Map stage_info = parseStageInfo(config)

String coverage_website = config.get('coverage_website',
Expand All @@ -61,7 +61,11 @@ Map call(Map config = [:]) {
target_stash += '-' + stage_info['build_type']
}

unstash config.get('stash', "${target_stash}-build-vars")
try {
unstash config.get('stash', "${target_stash}-build-vars")
} catch (hudson.AbortException ex) {
println("Unstash failed: ${ex}")
}

int stash_cnt = 0
stashes.each { name ->
Expand Down
10 changes: 4 additions & 6 deletions vars/daosPackagesVersion.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,8 @@ String call(String distro, String next_version) {
String version_file = normalized_distro
try {
unstash normalized_distro + '-rpm-version'
/* groovylint-disable-next-line CatchException */
} catch (Exception e1) {
// backward compatibilty
} catch (hudson.AbortException e1) {
// backward compatibility
try {
// ugly backwards compatibility hack due to hardware distro
// being el8 now
Expand All @@ -107,9 +106,8 @@ String call(String distro, String next_version) {
}
unstash _distro + '-rpm-version'
version_file = _distro
/* groovylint-disable-next-line CatchException */
} catch (Exception e2) {
print('Ingoring missing but deprecated ' + _distro + '-rpm-version' + ' stash')
} catch (hudson.AbortException e2) {
print('Ignoring missing but deprecated ' + _distro + '-rpm-version' + ' stash')
return ''
}
}
Expand Down
29 changes: 24 additions & 5 deletions vars/durationSeconds.groovy
Original file line number Diff line number Diff line change
@@ -1,17 +1,36 @@
/* groovylint-disable DuplicateNumberLiteral, UnnecessaryGetter */
// vars/durationSeconds.groovy

/**
* durationSeconds step method
*
* @param startTime, long value with start time in milliseconds.
* @param endTime, long value with end time in milliseconds, default current time.
* returns: Duration time in seconds.
*/

int call(long startTime, long endTime=0) {
long actualEndTime
if (endTime == 0) {
actualEndTime = System.currentTimeMillis()
} else {
actualEndTime = endTime
}
int delta = (actualEndTime - startTime) / 1000
return delta
}

/**
* durationSeconds step method (Date overload)
*
* @param startDate, Date object with start time.
* @param endDate, Date object with end time, default current date time.
* @param endDate, Date object with end time, default current time.
* returns: Duration time in seconds.
*/

int call(Date startDate, Date endDate=null) {
if (endDate == null) {
endDate = new Date()
}
int delta = (endDate.getTime() - startDate.getTime())/1000
long startTime = startDate.getTime()
long endTime = endDate ? endDate.getTime() : System.currentTimeMillis()
int delta = (endTime - startTime) / 1000
return delta
}
42 changes: 4 additions & 38 deletions vars/functionalTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* config['description'] Description to report for SCM status.
* Default env.STAGE_NAME.
*
* config['failure_artifacts'] Failure aritfifacts to return.
* config['failure_artifacts'] Failure artifacts to return.
* Default env.STAGE_NAME.
*
* config['ignore_failure'] Ignore test failures. Default false.
Expand All @@ -41,10 +41,10 @@
*
* config['node_count'] Count of nodes that will actually be used
* the test. Default will be based on the
* enviroment variables for the stage.
* environment variables for the stage.
*
* config['stashes'] List of stashes to use. Default will be
* baed on the environment variables for the
* based on the environment variables for the
* stage.
*
* config['target'] Target distribution, such as 'centos7',
Expand All @@ -62,7 +62,7 @@
*/

Map call(Map config = [:]) {
Date startDate = new Date()
long startDate = System.currentTimeMillis()
String nodelist = config.get('NODELIST', env.NODELIST)
String context = config.get('context', 'test/' + env.STAGE_NAME)
String description = config.get('description', env.STAGE_NAME)
Expand Down Expand Up @@ -114,40 +114,6 @@ Map call(Map config = [:]) {
run_test_config['context'] = context
run_test_config['description'] = description

String script = 'if ! pip3 install'
script += ''' --upgrade --upgrade-strategy only-if-needed launchable; then
set +e
echo "Failed to install launchable"
id
pip3 list --user || true
find ~/.local/lib -type d
hostname
pip3 --version
pip3 index versions launchable
pip3 install --user launchable==
exit 1
fi
pip3 list --user || true
'''
sh label: 'Install Launchable',
script: script

try {
withCredentials([string(credentialsId: 'launchable-test', variable: 'LAUNCHABLE_TOKEN')]) {
sh label: 'Send build data',
/* groovylint-disable-next-line GStringExpressionWithinString */
script: '''export PATH=$PATH:$HOME/.local/bin
launchable record build --name ${BUILD_TAG//%2F/-} --source src=.
launchable subset --time 60m --build ${BUILD_TAG//%2F/-} ''' +
'--get-tests-from-previous-sessions --rest=rest.txt raw > subset.txt'
}
/* groovylint-disable-next-line CatchException */
} catch (Exception error) {
println(
"Ignoring failure to record " + env.STAGE_NAME + " tests with launchable: " +
error.getMessage())
}

Map runtestData = [:]
if (config.get('test_function', 'runTestFunctional') ==
'runTestFunctionalV2') {
Expand Down
43 changes: 8 additions & 35 deletions vars/functionalTestPostV2.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,13 @@ void call(Map config = [:]) {

// Need to unstash the script result from runTest
String results_map = 'results_map_' + sanitizedStageName()
unstash name: results_map
Map results = readYaml file: results_map
Map results = [:]
try {
unstash name: results_map
results = readYaml file: results_map
} catch (hudson.AbortException e) {
println("Failed to unstash ${results_map}: ${e.message}")
}
String prev_result = currentBuild.result

junit(testResults: junit_results)
Expand Down Expand Up @@ -88,39 +93,7 @@ void call(Map config = [:]) {
config.get('artifacts', env.STAGE_NAME + '/**')
archiveArtifacts(artifacts: artifacts)

// Analyze test failures
String jobName = env.JOB_NAME.replace('/', '_')
jobName += '_' + env.BUILD_NUMBER
String fileName = env.DAOS_STACK_JOB_STATUS_DIR + '/' + jobName

if (fileExists('ci/functional/launchable_analysis')) {
sh(label: 'Analyze failed tests vs. Launchable subset',
script: 'ci/functional/launchable_analysis "' + fileName + '"')
}

String script = 'pip3 install'
script += ' --user --upgrade launchable~=1.0'

sh(label: 'Install Launchable',
script: script)

try {
withCredentials([string(credentialsId: 'launchable-test', variable: 'LAUNCHABLE_TOKEN')]) {
sh(label: 'Submit test results to Launchable',
/* groovylint-disable-next-line GStringExpressionWithinString */
script: 'if ls -l "' + env.STAGE_NAME + '''"/*/*/xunit1_results.xml 2>/dev/null; then
export PATH=$PATH:$HOME/.local/bin
launchable record tests --build ${BUILD_TAG//%2F/-} pytest ''' +
'"' + env.STAGE_NAME + '''"/*/*/xunit1_results.xml
fi''')
}
/* groovylint-disable-next-line CatchException */
} catch (Exception error) {
println(
"Ignoring failure to record " + env.STAGE_NAME + " tests with launchable: " +
error.getMessage())
}
if (!ignore_failure && results['result'] == 'FAILURE') {
unstable "Failure detected with test harness or hardware."
unstable 'Failure detected with test harness or hardware.'
}
}
9 changes: 5 additions & 4 deletions vars/hwDistroTarget.groovy
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* groovylint-disable DuplicateNumberLiteral */
// vars/hwDistroTarget.groovy

/**
Expand All @@ -11,11 +12,11 @@
*/

String call(String size) {
(name, version) = hwDistroTarget2(size)
return name + version
List result = hwDistroTarget2(size)
return result[0] + result[1]
}

String call() {
(name, version) = hwDistroTarget2()
return name + version
List result = hwDistroTarget2()
return result[0] + result[1]
}
8 changes: 6 additions & 2 deletions vars/hwDistroTarget2.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
* Method to return the distro target and version (as a list) for a given stage
*/

String targetRegex() {
return '([a-z]+)(.*)'
}

// I'd love to use a more explicit
// String, String hw_distro(String size) here but it chokes Jenkins (at
// least)
Expand All @@ -28,13 +32,13 @@ List call(String size) {
}
distro = cachedCommitPragma('Func-hw-test-' + size + '-distro',
cachedCommitPragma('Func-hw-test-distro', distro))
return (distro =~ /([a-z]+)(.*)/)[0][1..2]
return (distro =~ targetRegex())[0][1..2]
}

List call() {
if (env.STAGE_NAME.contains('Hardware')) {
return hwDistroTarget2(env.STAGE_NAME[env.STAGE_NAME.lastIndexOf(' ')
+ 1..-1].toLowerCase())
}
return (parseStageInfo()['target'] =~ /([a-z]+)(.*)/)[0][1..2]
return (parseStageInfo()['target'] =~ targetRegex())[0][1..2]
}
2 changes: 1 addition & 1 deletion vars/junitSimpleReport.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
void call(Map config = [:]) {
int zero = 0
int one = 1
simple = 'simple'
String simple = 'simple'
String jclass = config.get('class', simple)
String jname = config.get('name', simple)
String jsuite = config.get('suite', sanitizedStageName())
Expand Down
11 changes: 5 additions & 6 deletions vars/notifyBrokenBranch.groovy
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* groovylint-disable DuplicateStringLiteral */
// vars/notifyBrokenBranch.groovy
/* groovylint-disable VariableName */

Expand All @@ -8,16 +9,14 @@
*
* config['branches'] List of branches to notify for. Default "master"
* config['onPR'] Send e-mail when called from a PR. Default false
*
*/

def call(Map config = [:]) {

void call(Map config = [:]) {
String branches
if (config['branches']) {
branches = config['branches'].split()
} else {
branches = ["master"]
branches = ['master']
}

// Needed this as a work around that env['GIT_BRANCH'] is blacklisted
Expand All @@ -40,15 +39,15 @@ def call(Map config = [:]) {
subject: 'Build broken on ' + git_branch,
onPR: config['onPR']

String branch = git_branch.toUpperCase().replaceAll("-", "_")
String branch = git_branch.toUpperCase().replaceAll('-', '_')
// This will need to be implemented in trusted-pipe-line lib eventually
// as checking if environment variables exist is blacklisted in the
// groovy sandbox.
// for now we only have DAOS_STACK_MASTER_WATCHER
// def watchers = env["DAOS_STACK_${branch}_WATCHER"]
if (branch == 'MASTER') {
String watchers = env.DAOS_STACK_MASTER_WATCHER
if (watchers != "null") {
if (watchers != 'null') {
emailextDaos body: git_branch + ' is broken.\n\n' +
'See ' + env.BUILD_URL + ' for more details.',
to: watchers,
Expand Down
Loading