Skip to content

Commit 1682ac6

Browse files
Move Functional inline scripts to DAOS project (#153)
Signed-off-by: Brian J. Murrell <brian.murrell@intel.com>
1 parent e0fb7f1 commit 1682ac6

File tree

3 files changed

+144
-71
lines changed

3 files changed

+144
-71
lines changed

vars/runTestFunctional.groovy

Lines changed: 15 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*/
99

10-
def call(Map config = [:]) {
10+
void call(Map config = [:]) {
1111
/**
1212
* runTestFunctional step method
1313
*
@@ -38,79 +38,25 @@ def call(Map config = [:]) {
3838
* Default env.STAGE_NAME.
3939
*/
4040

41-
def test_rpms = 'false'
42-
if (config['test_rpms'] == "true") {
43-
test_rpms = 'true'
41+
if (!fileExists('ci/functional/test_main.sh')) {
42+
return runTestFunctionalV1(config)
4443
}
45-
def functional_test_script = '''test_tag=$(git show -s --format=%%B | sed -ne "/^Test-tag%s:/s/^.*: *//p")
46-
if [ -z "$test_tag" ]; then
47-
test_tag=%s
48-
fi
49-
tnodes=$(echo $NODELIST | cut -d ',' -f 1-%d)
50-
first_node=${NODELIST%%%%,*}
51-
clush -B -S -o '-i ci_key' -l root -w "${first_node}" "set -ex
52-
systemctl start nfs-server.service
53-
mkdir -p /export/share
54-
chown jenkins /export/share
55-
echo \\"/export/share ${NODELIST//,/(rw,no_root_squash) }(rw,no_root_squash)\\" > /etc/exports
56-
exportfs -ra"
57-
clush -B -S -o '-i ci_key' -l root -w "${tnodes}" \
58-
"set -ex
59-
for i in 0 1; do
60-
if [ -e /sys/class/net/ib\\\$i ]; then
61-
if ! ifconfig ib\\\$i | grep \"inet \"; then
62-
{
63-
echo \"Found interface ib\\\$i down after reboot on \\\$HOSTNAME\"
64-
systemctl status
65-
systemctl --failed
66-
journalctl -n 500
67-
ifconfig ib\\\$i
68-
cat /sys/class/net/ib\\\$i/mode
69-
ifup ib\\\$i
70-
} | mail -s \"Interface found down after reboot\" $OPERATIONS_EMAIL
71-
fi
72-
fi
73-
done
74-
if ! grep /mnt/share /proc/mounts; then
75-
mkdir -p /mnt/share
76-
mount $first_node:/export/share /mnt/share
77-
fi
78-
if ''' + test_rpms + '''; then
79-
# remove the install/ dir to be sure we're testing from RPMs
80-
rm -rf install/
81-
fi"
82-
trap 'clush -B -S -o "-i ci_key" -l root -w "${tnodes}" \
83-
"set -x; umount /mnt/share"' EXIT
84-
# set DAOS_TARGET_OVERSUBSCRIBE env here
85-
export DAOS_TARGET_OVERSUBSCRIBE=1
86-
rm -rf install/lib/daos/TESTING/ftest/avocado ./*_results.xml
87-
mkdir -p install/lib/daos/TESTING/ftest/avocado/job-results
88-
ftest_arg="%s"
89-
if ''' + test_rpms + '''; then
90-
ssh -i ci_key -l jenkins "${first_node}" "set -ex
91-
DAOS_TEST_SHARED_DIR=\\$(mktemp -d -p /mnt/share/)
92-
trap \\"rm -rf \\$DAOS_TEST_SHARED_DIR\\" EXIT
93-
export DAOS_TEST_SHARED_DIR
94-
export TEST_RPMS=true
95-
export REMOTE_ACCT=jenkins
96-
/usr/lib/daos/TESTING/ftest/ftest.sh \\"$test_tag\\" \\"$tnodes\\" \\"$ftest_arg\\""
97-
# now collect up the logs and store them like non-RPM test does
98-
mkdir -p install/lib/daos/TESTING/
99-
# scp doesn't copy symlinks, it resolves them
100-
ssh -i ci_key -l jenkins "${first_node}" tar -C /var/tmp/ -czf - ftest | tar -C install/lib/daos/TESTING/ -xzf -
101-
else
102-
./ftest.sh "$test_tag" "$tnodes" "$ftest_arg"
103-
fi'''
10444

105-
config['script'] = String.format(functional_test_script,
106-
config['pragma_suffix'],
107-
config['test_tag'],
108-
config['node_count'],
109-
config['ftest_arg'])
45+
Boolean test_rpms = false
46+
if (config['test_rpms'] == "true") {
47+
test_rpms = true
48+
}
49+
config['script'] = "TEST_TAG=" + config['test_tag'] + ' ' +
50+
"FTEST_ARG=" + config['ftest_arg'] + ' ' +
51+
"PRAGMA_SUFFIX=" + config['pragma_suffix'] + ' ' +
52+
"NODE_COUNT=" + config['node_count'] + ' ' +
53+
"OPERATIONS_EMAIL=" + env.OPERATIONS_EMAIL + ' ' +
54+
"ci/functional/test_main.sh"
55+
11056
config['junit_files'] = "install/lib/daos/TESTING/ftest/avocado/job-results/job-*/*.xml install/lib/daos/TESTING/ftest/*_results.xml"
11157
config['failure_artifacts'] = 'Functional'
11258

113-
if (test_rpms == 'true' && config['stashes']){
59+
if (test_rpms && config['stashes']){
11460
// we don't need (and might not even have) stashes if testing
11561
// from RPMs
11662
config.remove('stashes')

vars/runTestFunctionalV1.groovy

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
// vars/runTestFunctionalV1.groovy
2+
3+
/**
4+
* runTestFunctionalV1.groovy
5+
*
6+
* runTestFunctionalV1 pipeline step
7+
*
8+
*/
9+
10+
def call(Map config = [:]) {
11+
/**
12+
* runTestFunctionalV1 step method
13+
*
14+
* @param config Map of parameters passed
15+
* @return None
16+
*
17+
* config['stashes'] Stashes from the build to unstash
18+
* config['ignore_failure'] Whether a FAILURE result should post a failed step
19+
* config['pragma_suffix'] The Test-tag pragma suffix
20+
* config['test_tag'] The test tags to run
21+
* config['ftest_arg'] An argument to ftest.sh
22+
* config['test_rpms'] Testing using RPMs, true/false
23+
*
24+
* config['context'] Context name for SCM to identify the specific stage to
25+
* update status for.
26+
* Default is 'test/' + env.STAGE_NAME.
27+
*
28+
* Important:
29+
* The SCM status checking for passing may expect a specific name.
30+
*
31+
* Matrix stages must override this setting to include matrix axes
32+
* names to ensure a unique name is generated.
33+
*
34+
* Or the default name has to be changed in a way that is compatible
35+
* with a future Matrix implementation.
36+
*
37+
* config['description'] Description to report for SCM status.
38+
* Default env.STAGE_NAME.
39+
*/
40+
41+
def test_rpms = 'false'
42+
if (config['test_rpms'] == "true") {
43+
test_rpms = 'true'
44+
}
45+
def functional_test_script = '''test_tag=$(git show -s --format=%%B | sed -ne "/^Test-tag%s:/s/^.*: *//p")
46+
if [ -z "$test_tag" ]; then
47+
test_tag=%s
48+
fi
49+
tnodes=$(echo $NODELIST | cut -d ',' -f 1-%d)
50+
first_node=${NODELIST%%%%,*}
51+
clush -B -S -o '-i ci_key' -l root -w "${first_node}" "set -ex
52+
systemctl start nfs-server.service
53+
mkdir -p /export/share
54+
chown jenkins /export/share
55+
echo \\"/export/share ${NODELIST//,/(rw,no_root_squash) }(rw,no_root_squash)\\" > /etc/exports
56+
exportfs -ra"
57+
clush -B -S -o '-i ci_key' -l root -w "${tnodes}" \
58+
"set -ex
59+
for i in 0 1; do
60+
if [ -e /sys/class/net/ib\\\$i ]; then
61+
if ! ifconfig ib\\\$i | grep \"inet \"; then
62+
{
63+
echo \"Found interface ib\\\$i down after reboot on \\\$HOSTNAME\"
64+
systemctl status
65+
systemctl --failed
66+
journalctl -n 500
67+
ifconfig ib\\\$i
68+
cat /sys/class/net/ib\\\$i/mode
69+
ifup ib\\\$i
70+
} | mail -s \"Interface found down after reboot\" $OPERATIONS_EMAIL
71+
fi
72+
fi
73+
done
74+
if ! grep /mnt/share /proc/mounts; then
75+
mkdir -p /mnt/share
76+
mount $first_node:/export/share /mnt/share
77+
fi
78+
if ''' + test_rpms + '''; then
79+
# remove the install/ dir to be sure we're testing from RPMs
80+
rm -rf install/
81+
fi"
82+
trap 'clush -B -S -o "-i ci_key" -l root -w "${tnodes}" \
83+
"set -x; umount /mnt/share"' EXIT
84+
# set DAOS_TARGET_OVERSUBSCRIBE env here
85+
export DAOS_TARGET_OVERSUBSCRIBE=1
86+
rm -rf install/lib/daos/TESTING/ftest/avocado ./*_results.xml
87+
mkdir -p install/lib/daos/TESTING/ftest/avocado/job-results
88+
ftest_arg="%s"
89+
if ''' + test_rpms + '''; then
90+
ssh -i ci_key -l jenkins "${first_node}" "set -ex
91+
DAOS_TEST_SHARED_DIR=\\$(mktemp -d -p /mnt/share/)
92+
trap \\"rm -rf \\$DAOS_TEST_SHARED_DIR\\" EXIT
93+
export DAOS_TEST_SHARED_DIR
94+
export TEST_RPMS=true
95+
export REMOTE_ACCT=jenkins
96+
/usr/lib/daos/TESTING/ftest/ftest.sh \\"$test_tag\\" \\"$tnodes\\" \\"$ftest_arg\\""
97+
# now collect up the logs and store them like non-RPM test does
98+
mkdir -p install/lib/daos/TESTING/
99+
# scp doesn't copy symlinks, it resolves them
100+
ssh -i ci_key -l jenkins "${first_node}" tar -C /var/tmp/ -czf - ftest | tar -C install/lib/daos/TESTING/ -xzf -
101+
else
102+
./ftest.sh "$test_tag" "$tnodes" "$ftest_arg"
103+
fi'''
104+
105+
config['script'] = String.format(functional_test_script,
106+
config['pragma_suffix'],
107+
config['test_tag'],
108+
config['node_count'],
109+
config['ftest_arg'])
110+
config['junit_files'] = "install/lib/daos/TESTING/ftest/avocado/job-results/job-*/*.xml install/lib/daos/TESTING/ftest/*_results.xml"
111+
config['failure_artifacts'] = 'Functional'
112+
113+
if (test_rpms == 'true' && config['stashes']){
114+
// we don't need (and might not even have) stashes if testing
115+
// from RPMs
116+
config.remove('stashes')
117+
}
118+
119+
config.remove('pragma_suffix')
120+
config.remove('test_tag')
121+
config.remove('ftest_arg')
122+
config.remove('node_count')
123+
config.remove('test_rpms')
124+
125+
runTest(config)
126+
127+
}

vars/testRpm.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ def call(Map config = [:]) {
6464
node_count: 1,
6565
profile: config.get('profile', 'daos_ci'),
6666
distro: stage_info['target'],
67-
inst_repos: config['inst_repos'],
68-
inst_rpms: config['inst_rpms']
67+
inst_repos: config.get('inst_repos', ''),
68+
inst_rpms: config.get('inst_rpms', '')
6969

7070
def full_test_script = 'export DAOS_PKG_VERSION=' +
7171
config['daos_pkg_version'] + '\n' +

0 commit comments

Comments
 (0)