summaryrefslogtreecommitdiff
path: root/databases/mongodb50/files/make.test.sh
blob: d479bd7df1326fe4c3bf8bca06e5d8d563971ed4 (plain) (blame)
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
#! /bin/sh

set -e

usage() {
	echo "Usage: $0 <path>"
	echo "<path>    path to the executables"
}

test "$#" -eq 1 || ( usage && exit 1 )

set -x

PATH="$1:$PATH"

DBDIR=$( mktemp -d -t tmp.mongodb )

trap 'rm -rf "$DBDIR"' EXIT

# Trivial check if the binaries execute at all.
mongod --version
mongos --version
mongo --version

# Check if an empty database can be created.
mkdir "$DBDIR/db"
tail -F "$DBDIR/log" | ( grep -qFe "Waiting for connections" && kill $(cat "$DBDIR/pid") ) &
script -eF "$DBDIR/log" \
	timeout -s TERM -k 30s 60s \
	mongod --dbpath "$DBDIR/db" --pidfilepath "$DBDIR/pid"

echo "Test successful"