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
5 changes: 5 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ Sleep-seconds: 2'''
}
} // steps
} //stage('env.COMMIT_MESSAGE pragma test')
stage('Unit tests') {
steps{
trustedPipelineUnitTests()
}
} // stage('Unit tests')
stage('DAOS Build and Test') {
when {
beforeAgent true
Expand Down
12 changes: 8 additions & 4 deletions vars/daosLatestVersion.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,16 @@ String distro2repo(String distro) {
String getLatestVersion(String distro, BigDecimal next_version, String type='stable') {
String v = null
String repo = 'daos-stack-daos-' + distro2repo(distro) + '-x86_64-' + type + '-local/'
String artifactory_url = env.ARTIFACTORY_URL
/* For backwards support, add the 'artifactory' path if it is missing from the env */
if (!artifactory_url.endsWith('/artifactory')) {
artifactory_url = "${artifactory_url}/artifactory"
}
try {
v = sh(label: 'Get RPM packages version for: ' + repo + ' with version < ' + next_version.toString(),
script: '$(command -v dnf) --refresh repoquery --repofrompath=daos,' + env.ARTIFACTORY_URL +
'/artifactory/' + repo +
''' --repoid daos --qf %{version}-%{release} --whatprovides 'daos < ''' +
next_version + '''' | rpmdev-sort | tail -1''',
script: '$(command -v dnf) --refresh repoquery --repofrompath=daos,' + artifactory_url + '/' +
repo + ''' --repoid daos --qf "%{version}-%{release}\n" --whatprovides 'daos < ''' +
next_version + '''' | rpmdev-sort | tail -1''',
returnStdout: true).trim()
/* groovylint-disable-next-line CatchException */
} catch (Exception e) {
Expand Down
31 changes: 31 additions & 0 deletions vars/trustedPipelineUnitTests.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* groovylint-disable DuplicateNumberLiteral, ParameterName, VariableName */
// vars/trustedPipelineUnitTests.groovy

/**
* trustedPipelineUnitTests.groovy
*
* Runs trusted-pipeline-lib unit tests
*/

void call() {
// Run unit tests
_run_unit_tests()
}

void _run_unit_tests() {
// Run all the unit tests
println('Test daosLatestVersion()')
_test_daosLatestVersion("master", "el8", /2.7\.\d++.*/)
_test_daosLatestVersion('release/2.6', 'el8', /2.[56]\.\d++.*/)
}

void _test_daosLatestVersion(String distro, String next_version, String expected) {
// Verify the version returned by daosLatestVersion() matches expected
println(" Running daosLatestVersion(distro=${distro}, next_version=${next_version})")
result =daosLatestVersion(distro, next_version)
println(" result: ${result}")
println(" expected: ${expected}")
assert(result.matches(expected))
println(" PASSED")
println("")
}