Skip to content

Commit 34e255e

Browse files
committed
Pull in script change from #4263.
1 parent 40f3ecc commit 34e255e

1 file changed

Lines changed: 36 additions & 13 deletions

File tree

scripts/travis/install-and-run-mongodb.sh

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,56 @@
11
#!/usr/bin/env bash
22

33
# Script which installs versions of MongoDB specified using an environment variable
4-
5-
if [ ! "${MONGODB}" ]; then
6-
echo "MONGODB environment variable not set"
4+
if [ ! "${MONGODB_VERSION}" ]; then
5+
echo "MONGODB_VERSION environment variable not set."
76
exit 2
87
fi
98

109
# Note: MongoDB 2.4 and 2.6 don't work with ramdisk since they don't work with
1110
# small files and require at least 3 GB of space
12-
if [ ${MONGODB} = '2.4.9' ] || [ ${MONGODB} = '2.6.12' ]; then
11+
if [ "${MONGODB_VERSION}" = '2.4.9' ] || [ "${MONGODB_VERSION}" = '2.6.12' ]; then
1312
DATA_DIR=/tmp/mongodbdata
1413
else
1514
DATA_DIR=/mnt/ramdisk/mongodb
1615
fi
1716

18-
wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-${MONGODB}.tgz -O /tmp/mongodb.tgz
19-
tar -xvf /tmp/mongodb.tgz
17+
DATA_DIR=/tmp/mongodbdata
18+
MONGODB_DIR=/tmp/mongodb
19+
2020
mkdir -p ${DATA_DIR}
21-
echo "Starting MongoDB v${MONGODB}"
22-
${PWD}/mongodb-linux-x86_64-${MONGODB}/bin/mongod --nojournal --journalCommitInterval 500 \
23-
--syncdelay 0 --dbpath ${DATA_DIR} --bind_ip 127.0.0.1 &> /tmp/mongodb.log &
24-
EXIT_CODE=$?
21+
mkdir -p ${MONGODB_DIR}
22+
23+
DOWNLOAD_URL="http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-${MONGODB_VERSION}.tgz"
24+
25+
echo "Downloading MongoDB ${MONGODB_VERSION} from ${DOWNLOAD_URL}"
26+
wget -q ${DOWNLOAD_URL} -O /tmp/mongodb.tgz
27+
tar -xvf /tmp/mongodb.tgz -C ${MONGODB_DIR} --strip=1
28+
29+
echo "Symlinking mongo shell binary to /usr/local/bin"
30+
31+
# Symlink latest mongodb shell
32+
sudo ln -sf ${MONGODB_DIR}/bin/mongo /usr/local/bin/mongo
33+
sudo ln -sf ${MONGODB_DIR}/bin/mongo /usr/bin/mongo
34+
35+
echo "Starting MongoDB v${MONGODB_VERSION}"
36+
# Note: We use --notablescan option to detected missing indexes early. When this
37+
# option is enabled, queries which result in table scan (which usually means a
38+
# missing index or a bad query) are not allowed and result in a failed test.
39+
#--wiredTigerStatisticsLogDelaySecs 0 --noIndexBuildRetry --noscripting --notablescan \
40+
${MONGODB_DIR}/bin/mongod --nojournal --journalCommitInterval 500 --syncdelay 0 \
41+
--wiredTigerStatisticsLogDelaySecs 0 --noIndexBuildRetry --noscripting \
42+
--dbpath ${DATA_DIR} --bind_ip 127.0.0.1 &> /tmp/mongodb.log &
43+
MONGODB_PID=$!
44+
45+
# Give process some time to start up
2546
sleep 5
2647

27-
if [ ${EXIT_CODE} -ne 0 ]; then
48+
if ps -p ${MONGODB_PID} > /dev/null; then
49+
echo "MongoDB successfuly started"
50+
tail -30 /tmp/mongodb.log
51+
exit 0
52+
else
2853
echo "Failed to start MongoDB"
2954
tail -30 /tmp/mongodb.log
3055
exit 1
3156
fi
32-
33-
tail -30 /tmp/mongodb.log

0 commit comments

Comments
 (0)