-
Notifications
You must be signed in to change notification settings - Fork 311
/
Copy pathftest.sh
executable file
·144 lines (123 loc) · 3.66 KB
/
ftest.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/bin/bash
# /*
# * (C) Copyright 2016-2022 Intel Corporation.
# * (C) Copyright 2025 Hewlett Packard Enterprise Development LP
# *
# * SPDX-License-Identifier: BSD-2-Clause-Patent
# */
set -ex -o pipefail
# shellcheck disable=SC1091
if [ -f .localenv ]; then
# read (i.e. environment, etc.) overrides
. .localenv
fi
TEST_TAG_ARG="${1:-quick}"
TEST_TAG_DIR="$(mktemp -du)"
NFS_SERVER=${NFS_SERVER:-${HOSTNAME%%.*}}
trap 'echo "encountered an unchecked return code, exiting with error"' ERR
IFS=" " read -r -a nodes <<< "${2//,/ }"
TEST_NODES=$(IFS=","; echo "${nodes[*]:1}")
# Optional arguments for launch.py
LAUNCH_OPT_ARGS="${3:-}"
# Add the missing '--nvme' argument identifier for backwards compatibility with
# the 'auto:Optane' optional argument specified without the identifier.
LAUNCH_OPT_ARGS="$(echo "$LAUNCH_OPT_ARGS" | sed -e 's/^/ /' -e 's/ \(auto:-3DNAND\)/--nvme=\1/' -e 's/^ *//')"
# For nodes that are only rebooted between CI nodes left over mounts
# need to be cleaned up.
pre_clean () {
i=5
while [ $i -gt 0 ]; do
if clush "${CLUSH_ARGS[@]}" -B -l "${REMOTE_ACCT:-jenkins}" -R ssh \
-S -w "$(IFS=','; echo "${nodes[*]}")" \
"$(sed -e '1,/^$/d' "$SCRIPT_LOC"/pre_clean_nodes.sh)"; then
break
fi
((i-=1)) || true
done
if [ $i -eq 0 ]; then
echo "All pre clean nodes attempts failed." >&2
return 1
fi
return 0
}
cleanup() {
i=5
while [ $i -gt 0 ]; do
if clush "${CLUSH_ARGS[@]}" -B -l "${REMOTE_ACCT:-jenkins}" -R ssh \
-S -w "$(IFS=','; echo "${nodes[*]}")" \
"DAOS_BASE=$DAOS_BASE
$(sed -e '1,/^$/d' "$SCRIPT_LOC"/cleanup_nodes.sh)"; then
break
fi
((i-=1)) || true
done
if [ $i -eq 0 ]; then
echo "All cleanup attempts failed." >&2
return 1
fi
return 0
}
# shellcheck disable=SC1091
if ${TEST_RPMS:-false}; then
PREFIX=/usr
SL_PREFIX=$PWD
else
TEST_RPMS=false
PREFIX=install
. .build_vars.sh
fi
SCRIPT_LOC="$PREFIX"/lib/daos/TESTING/ftest/scripts
pre_clean
if ${TEARDOWN_ONLY:-false}; then
cleanup
exit 0
fi
trap 'set +e; cleanup' EXIT
# doesn't work: mapfile -t CLUSH_ARGS <<< "$CLUSH_ARGS"
# shellcheck disable=SC2206
CLUSH_ARGS=($CLUSH_ARGS)
DAOS_BASE=${SL_SRC_DIR}
if ! clush "${CLUSH_ARGS[@]}" -B -l "${REMOTE_ACCT:-jenkins}" -R ssh -S \
-w "$(IFS=','; echo "${nodes[*]}")" \
"FIRST_NODE=${nodes[0]}
TEST_RPMS=$TEST_RPMS
DAOS_BASE=$DAOS_BASE
SL_PREFIX=$SL_PREFIX
TEST_TAG_DIR=$TEST_TAG_DIR
JENKINS_URL=$JENKINS_URL
NFS_SERVER=$NFS_SERVER
$(sed -e '1,/^$/d' "$SCRIPT_LOC"/setup_nodes.sh)"; then
echo "Cluster setup (i.e. provisioning) failed"
exit 1
fi
args="${1:-quick}"
shift || true
args+=" $*"
# shellcheck disable=SC2029
# shellcheck disable=SC2086
if ! ssh -A $SSH_KEY_ARGS ${REMOTE_ACCT:-jenkins}@"${nodes[0]}" \
"FIRST_NODE=\"${nodes[0]}\"
TEST_RPMS=\"$TEST_RPMS\"
DAOS_TEST_SHARED_DIR=\"${DAOS_TEST_SHARED_DIR:-$PWD/install/tmp}\"
DAOS_BASE=\"$DAOS_BASE\"
TEST_TAG_DIR=\"$TEST_TAG_DIR\"
PREFIX=\"$PREFIX\"
SETUP_ONLY=\"${SETUP_ONLY:-false}\"
TEST_TAG_ARG=\"$TEST_TAG_ARG\"
TEST_NODES=\"$TEST_NODES\"
LAUNCH_OPT_ARGS=\"$LAUNCH_OPT_ARGS\"
WITH_VALGRIND=\"$WITH_VALGRIND\"
STAGE_NAME=\"$STAGE_NAME\"
$(sed -e '1,/^$/d' "$SCRIPT_LOC"/main.sh)"; then
rc=${PIPESTATUS[0]}
if ${SETUP_ONLY:-false}; then
exit "$rc"
fi
else
if ${SETUP_ONLY:-false}; then
trap '' EXIT
exit 0
fi
rc=0
fi
exit "$rc"