summaryrefslogtreecommitdiff
path: root/databases/mongodb60/files/make.test.sh
blob: c42bb1973e6bc071502dea4d7fdd64c7675116f9 (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
#! /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

# 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"