DAOS-19247 test: Support scripted Test stages#526
Conversation
Add support for scripted fault injection and RPM test stages. Signed-off-by: Phil Henderson <phillip.henderson@hpe.com>
|
Testing new functionality in daos-stack/daos#18597 |
Signed-off-by: Phil Henderson <phillip.henderson@hpe.com>
|
Downstream testing skipped as it will not test the new groovy code. New code verified as part of daos-stack/daos#18597 |
Signed-off-by: Phil Henderson <phillip.henderson@hpe.com>
Signed-off-by: Phil Henderson <phillip.henderson@hpe.com>
Signed-off-by: Phil Henderson <phillip.henderson@hpe.com>
Signed-off-by: Phil Henderson <phillip.henderson@hpe.com>
Signed-off-by: Phil Henderson <phillip.henderson@hpe.com>
Signed-off-by: Phil Henderson <phillip.henderson@hpe.com>
| 'test_script': kwargs.get('testScript', ''), | ||
| 'with_valgrind': kwargs.get('withValgrind', ''), | ||
| 'always_script': kwargs.get('alwaysScript', ''), | ||
| 'test_results': kwargs.get('testResults', 'nlt-junit.xml'), |
There was a problem hiding this comment.
Isn't it the case that unitTest expects testResults instead of test_results?
pipeline-lib/vars/unitTest.groovy
Line 234 in cb6b602
| 'test_results': kwargs.get('testResults', 'nlt-junit.xml'), | |
| 'testResults': kwargs.get('testResults', 'nlt-junit.xml'), |
There was a problem hiding this comment.
Thanks for the suggestion. Fixed in https://github.com/daos-stack/pipeline-lib/pull/526/changes/037d0ddc14145bc96d08751797e10cc4b86a0d2a..0162051eb3f92cb52c3abeabeb3404c1c389b1ed. The arguments for unitTest.groovy are now passed through.
| Map unitTestArgs = [ | ||
| 'timeout_time': kwargs.get('timeoutTime', 60), | ||
| 'inst_repos': kwargs.get('instRepos', daosRepos(distro)), | ||
| 'test_script': kwargs.get('testScript', ''), | ||
| 'with_valgrind': kwargs.get('withValgrind', ''), | ||
| 'always_script': kwargs.get('alwaysScript', ''), | ||
| 'test_results': kwargs.get('testResults', 'nlt-junit.xml'), | ||
| 'unstash_opt': kwargs.get('unstashOpt', true), | ||
| 'unstash_tests': kwargs.get('unstashTests', false), | ||
| 'inst_rpms': kwargs.get('instRpms', unitPackages(target: distro) + ' daos-client-tests'), | ||
| 'image_version': kwargs.get('imageVersion', ''), | ||
| 'prov_env_vars': kwargs.get('provEnvVars', '') | ||
| ] |
There was a problem hiding this comment.
If we have same names here as in unitTest() we can just iterate over kwargs to create the map automatically:
| Map unitTestArgs = [ | |
| 'timeout_time': kwargs.get('timeoutTime', 60), | |
| 'inst_repos': kwargs.get('instRepos', daosRepos(distro)), | |
| 'test_script': kwargs.get('testScript', ''), | |
| 'with_valgrind': kwargs.get('withValgrind', ''), | |
| 'always_script': kwargs.get('alwaysScript', ''), | |
| 'test_results': kwargs.get('testResults', 'nlt-junit.xml'), | |
| 'unstash_opt': kwargs.get('unstashOpt', true), | |
| 'unstash_tests': kwargs.get('unstashTests', false), | |
| 'inst_rpms': kwargs.get('instRpms', unitPackages(target: distro) + ' daos-client-tests'), | |
| 'image_version': kwargs.get('imageVersion', ''), | |
| 'prov_env_vars': kwargs.get('provEnvVars', '') | |
| ] | |
| Set wrapperKeys = [ | |
| 'name', | |
| 'runStage', | |
| 'label', | |
| 'testBranch', | |
| 'jobStatus', | |
| 'distro', | |
| 'unitTestPostArgs', | |
| 'archiveArtifactsArgs' | |
| ] as Set | |
| Map unitTestArgs = new LinkedHashMap(kwargs) | |
| unitTestArgs.keySet().removeAll(wrapperKeys) |
If you want to introduce new names the following structure can be easier to read:
Map keyMap = [
timeoutTime : 'timeout_time',
instRepos : 'inst_repos',
testScript : 'test_script',
withValgrind: 'with_valgrind',
alwaysScript: 'always_script',
testResults : 'test_results',
unstashOpt : 'unstash_opt',
unstashTests: 'unstash_tests',
instRpms : 'inst_rpms',
imageVersion: 'image_version',
provEnvVars : 'prov_env_vars'
]
Map unitTestArgs = [:]
keyMap.each { inKey, outKey ->
if (kwargs.containsKey(inKey)) {
unitTestArgs[outKey] = kwargs[inKey]
}
}
There was a problem hiding this comment.
Thanks, I've just updated the code to pass the unitTest.groovy arguments through in https://github.com/daos-stack/pipeline-lib/pull/526/changes/037d0ddc14145bc96d08751797e10cc4b86a0d2a..0162051eb3f92cb52c3abeabeb3404c1c389b1ed w/o any renaming.
Skip-daos-build-and-test: true Signed-off-by: Phil Henderson <phillip.henderson@hpe.com>
Skip-daos-build-and-test: true Signed-off-by: Phil Henderson <phillip.henderson@hpe.com>
Skip-daos-build-and-test: true Signed-off-by: Phil Henderson <phillip.henderson@hpe.com>
Skip-daos-build-and-test: true Signed-off-by: Phil Henderson <phillip.henderson@hpe.com>
Skip-daos-build-and-test: true Signed-off-by: Phil Henderson <phillip.henderson@hpe.com>
Skip-daos-build-and-test: true Signed-off-by: Phil Henderson <phillip.henderson@hpe.com>
| * unitTestArgs Map of arguments to pass to unitTest; defaults to an empty Map. | ||
| * unitTestPostArgs Map of arguments to pass to unitTestPost() for the stage | ||
| * archiveArtifactsArgs Map of arguments to pass to archiveArtifacts() for the stage |
There was a problem hiding this comment.
| * unitTestArgs Map of arguments to pass to unitTest; defaults to an empty Map. | |
| * unitTestPostArgs Map of arguments to pass to unitTestPost() for the stage | |
| * archiveArtifactsArgs Map of arguments to pass to archiveArtifacts() for the stage | |
| * unitTestArgs Map of arguments to pass to unitTest; defaults to an empty Map. | |
| * unitTestPostArgs Map of arguments to pass to unitTestPost() for the stage; defaults to an empty Map. | |
| * archiveArtifactsArgs Map of arguments to pass to archiveArtifacts() for the stage; defaults to an empty Map. |
| // Add defaults for any missing unitTest() arguments | ||
| if (!unitTestArgs.containsKey('inst_repos')) { | ||
| /* groovylint-disable-next-line DuplicateStringLiteral */ | ||
| unitTestArgs['inst_repos'] = daosRepos(distro) | ||
| } | ||
| if (!unitTestArgs.containsKey('inst_rpms')) { | ||
| /* groovylint-disable-next-line DuplicateStringLiteral */ | ||
| unitTestArgs['inst_rpms'] = unitPackages(target: distro) + ' daos-client-tests' | ||
| } |
There was a problem hiding this comment.
Would it be better to fix unitTest() in unitTest.groovy?
There was a problem hiding this comment.
This PR is a prerequisite for the daos-stack/daos#18597 where the scriptedUnitTestStage() method is being used to run the Fault Injection Testing stage. In this case we want to call the daosRepos() and unitPackages() methods from inside the stage - not when defining arguments for a stage in the Jenkinsfile. As such they have been assigned here as defaults if no inst_repos or inst_rpms arguments are provided.
If in the future we decide to use this for other unit test stages I think we can investigate other options for providing daosRepos() as an input for the unit_test argument for the unitTest() method w/o calling it outside of the stage - which may include passing more arguments to the method and other methods it calls. It is a bit beyond the scope of this change in my opinion.
| // Add defaults for any missing unitTest() arguments | ||
| if (!unitTestArgs.containsKey('inst_repos')) { | ||
| /* groovylint-disable-next-line DuplicateStringLiteral */ | ||
| unitTestArgs['inst_repos'] = daosRepos(distro) | ||
| } | ||
| if (!unitTestArgs.containsKey('inst_rpms')) { | ||
| /* groovylint-disable-next-line DuplicateStringLiteral */ | ||
| unitTestArgs['inst_rpms'] = unitPackages(target: distro) + ' daos-client-tests' | ||
| } |
There was a problem hiding this comment.
Do we have DAOS PR that removes this default from Jenkinsfile?
unitTest(timeout_time: 60,
unstash_opt: true,
// inst_repos: daosRepos(),
// inst_rpms: unitPackages(target: 'el9'),
image_version: 'el9.7',
)
)
There was a problem hiding this comment.
No, the change is for daos-stack/daos#18597 and the Fault Injection Testing stage.
| if (!unitTestArgs.containsKey('inst_rpms')) { | ||
| /* groovylint-disable-next-line DuplicateStringLiteral */ | ||
| unitTestArgs['inst_rpms'] = unitPackages(target: distro) + ' daos-client-tests' | ||
| } |
There was a problem hiding this comment.
Why do we add ' daos-client-test'?
The actual Jenkins file does not require it:
stage('Unit Test') {
...
steps {
job_step_update(
unitTest(timeout_time: 60,
unstash_opt: true,
inst_repos: daosRepos(),
inst_rpms: unitPackages(target: 'el9'),
image_version: 'el9.7',
)
)
}
...
}
| if (!unitTestArgs.containsKey('inst_rpms')) { | |
| /* groovylint-disable-next-line DuplicateStringLiteral */ | |
| unitTestArgs['inst_rpms'] = unitPackages(target: distro) + ' daos-client-tests' | |
| } | |
| if (!unitTestArgs.containsKey('inst_rpms')) { | |
| /* groovylint-disable-next-line DuplicateStringLiteral */ | |
| unitTestArgs['inst_rpms'] = unitPackages(target: distro) | |
| } |
There was a problem hiding this comment.
This is needed for the Fault Injection Testing stage, where scriptedUnitTestStage() is being used.
| // Add defaults for any missing unitTest() arguments | ||
| if (!unitTestArgs.containsKey('inst_repos')) { | ||
| /* groovylint-disable-next-line DuplicateStringLiteral */ | ||
| unitTestArgs['inst_repos'] = daosRepos(distro) |
There was a problem hiding this comment.
Do we have a DAOS PR that removes these defaults from Jenkinsfile?
unitTest(timeout_time: 60,
unstash_opt: true,
// inst_repos: daosRepos(),
// inst_rpms: unitPackages(target: 'el9'),
image_version: 'el9.7',
)
)
There was a problem hiding this comment.
No, the change is for daos-stack/daos#18597 and the Fault Injection Testing stage.
Skip-daos-build-and-test: true Signed-off-by: Phil Henderson <phillip.henderson@hpe.com>
Skip-daos-build-and-test: true Signed-off-by: Phil Henderson <phillip.henderson@hpe.com>
Skip-daos-build-and-test: true Signed-off-by: Phil Henderson <phillip.henderson@hpe.com>
Skip-daos-build-and-test: true Signed-off-by: Phil Henderson <phillip.henderson@hpe.com>
Skip-daos-build-and-test: true Signed-off-by: Phil Henderson <phillip.henderson@hpe.com>
Skip-daos-build-and-test: true Signed-off-by: Phil Henderson <phillip.henderson@hpe.com>
Skip-daos-build-and-test: true Signed-off-by: Phil Henderson <phillip.henderson@hpe.com>
THe env.UNIT_TEST handling was bypassing the ability to check the tags for test matches in the stage. Skip-daos-build-and-test: true Signed-off-by: Phil Henderson <phillip.henderson@hpe.com>
Skip-daos-build-and-test: true Signed-off-by: Phil Henderson <phillip.henderson@hpe.com>
Skip-daos-build-and-test: true Signed-off-by: Phil Henderson <phillip.henderson@hpe.com>
Adding the scriptedTestRpmStage() method to provide a scripted stage definition for the Test RPM
stages and the scriptedUnitTestStage() method to provide a scripted stage definition for the Fault
Injection Testing stage.