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
+ }
0 commit comments