-
Notifications
You must be signed in to change notification settings - Fork 6
/
run_smoke_resmoke_funcs.sh
148 lines (119 loc) · 4.03 KB
/
run_smoke_resmoke_funcs.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
145
146
#!/bin/bash
# these are common functions used in the run_smoke_psmdb_3.0.sh and
# run_resmoke_psmdb_3.2.sh scripts
# constants
ULIMIT_NOFILES_MINIMUM=64000
ULIMIT_UPROCS_MINIMUM=64000
DBPATH="/data" # don't change there are some hard codings
run_system_validations() {
ulimit_nofiles=$(ulimit -n)
[ "${ulimit_nofiles}" -lt "${ULIMIT_NOFILES_MINIMUM}" ] && {
echo "Please increase this number of open files limit before running."
echo "It should be equal to or greater than: ${ULIMIT_NOFILES_MINIMUM}."
echo "The current setting is ${ulimit_nofiles}."
exit 1;
}
ulimit_uprocs=$(ulimit -u)
[ "${ulimit_uprocs}" -lt "${ULIMIT_UPROCS_MINIMUM}" ] && {
echo "Please increase this number of user processes limit before running."
echo "It should be equal to or greater than: ${ULIMIT_UPROCS_MINIMUM}"
echo "The current setting is ${ulimit_uprocs}."
exit 1;
}
# check for needed mongo binaries
for binary in bsondump mongo mongod mongodump mongoexport mongofiles mongoimport mongorestore mongos mongostat; do
if [ ! -x "./${binary}" ]; then
echo "Could not find ./${binary}; make sure you are running this from the root build directory,"
echo "that the MongoDB binaries have been built and the mongo-tools binaries have been copied"
echo "to the build root."
exit 1;
fi
done
# check for keys and set perms
if ! ls jstests/libs/key* > /dev/null 2>&1; then
echo "Run from the root build directory."
exit 1;
fi
chmod 400 jstests/libs/key*
# check for dbpath
if [[ ! -d "${DBPATH}" ]]; then
echo "The smoke test dbpath ${DBPATH} could not be found. Please create this"
echo "data directory before running tests. (a symlink to another location is ok)"
echo "for faster speeds, an SSD target is recommended."
exit 1;
fi
}
load_suite_set() {
local basedir="$1"
local suiteSet="$2"
local file=""
if [ -e "${basedir}/suite_sets/${suiteSet}" ]; then
file="${basedir}/suite_sets/${suiteSet}";
elif [ -e "${basedir}/suite_sets/${suiteSet}.txt" ]; then
file="${basedir}/suite_sets/${suiteSet}.txt";
elif [ -e "${suiteSet}" ]; then
file="${suiteSet}"
fi
if [ -z "${file}" ]; then
exit "Could not open suite set: ${suiteSet} (basedir: ${basedir}"
exit 1
fi
readarray SUITES < "${file}"
}
detectEngines() {
ENGINES=()
DEFAULT_ENGINE=$(./mongod --help | grep storageEngine | perl -ne 'm/\(=([^\)]+)\)/;print $1')
if [ "${DEFAULT_ENGINE}" == "" ]; then
DEFAULT_ENGINE="wiredTiger"
fi
ENGINES+=(${DEFAULT_ENGINE})
for engine in mmapv1 wiredTiger PerconaFT rocksdb inMemory; do
if [ ! "${engine}" == "${DEFAULT_ENGINE}" ]; then
if ./mongod --help | grep -q "${engine}" || [ "${engine}" = "mmapv1" ]; then
ENGINES+=("${engine}")
fi
fi
done
}
hasEngine() {
if [ ${#ENGINES[@]} -eq 0 ]; then
detectEngines
fi
local engine
for engine in "${ENGINES[@]}"; do [[ "$engine" == "$1" ]] && return 0; done
return 1
}
runPreprocessingCommands() {
local logOutputFile=$1
local suiteRawName=$2
local foundCommandSuite=false
for suiteCommand in "${SUITES[@]}"; do
if ! ${foundCommandSuite} && [[ "${suiteCommand}" =~ ^[[:space:]]*\$ ]]; then
continue
fi
if ${foundCommandSuite}; then
if [[ "${suiteCommand}" =~ ^[[:space:]]*\$ ]]; then
# shellcheck disable=SC2001
preprocessingCommand=$(echo "${suiteCommand}" | sed 's/^\s*\$//')
echo "Running: ${preprocessingCommand}" | tee -a "${logOutputFile}"
# if export builtin is piped it will fail
if [[ "${preprocessingCommand}" == *export* ]]; then
eval "${preprocessingCommand}"
else
eval "${preprocessingCommand}" 2>&1 | tee -a "${logOutputFile}"
fi
continue
else
break
fi
fi
IFS='| ' read -r -a suiteDefinition <<< "${suiteCommand}"
suiteName="${suiteDefinition[0]}"
if [ "${suiteName}" = "${suiteRawName}" ]; then
foundCommandSuite=true
continue
else
foundCommandSuite=false
fi
done
}