You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is less a question, but instead sharing a hacky wrapper for starting the memory server inside docker when on a host that doesn't have any recent mongo builds (e.g. alpine edge). You may have to increase your timeouts if using a testing suite as the startup time is slower. The container will auto-kill itself after 60 seconds in case the scripts exits from some signal I didn't trap.
mongod
#!/bin/bash
PORT=27107
BIND_IP="127.0.0.1"
args=()
while(( "$#" ));docase"$1"in
--dbpath) # strip since running in own containerif [ -n"$2" ] && [ ${2:0:1}!="-" ];thenshift 2
elseecho"Error: Argument for $1 is missing">&2exit 1
fi
;;
--bind_ip) # strip to use as part of docker runif [ -n"$2" ] && [ ${2:0:1}!="-" ];then
BIND_IP=$2shift 2
elseecho"Error: Argument for $1 is missing">&2exit 1
fi
;;
--port) # extract but don't strip to setup proper port forwardingif [ -n"$2" ] && [ ${2:0:1}!="-" ];then
PORT=$2
args+=($1$2)
shift 2
elseecho"Error: Argument for $1 is missing">&2exit 1
fi
;;
*)
args+=($1)
shift
;;
esacdonetrap term SIGTERM INT
functionterm() {
kill"$child"exit 0
}
docker run --rm -p $BIND_IP:$PORT:$PORT mongo:latest timeout 60s mongod --bind_ip 0.0.0.0 ${args[@]}& child=$!wait"$child"
In the test script, I use something like the following to use the bash script:
Versions
package: mongo-memory-server
What is your question?
This is less a question, but instead sharing a hacky wrapper for starting the memory server inside docker when on a host that doesn't have any recent mongo builds (e.g. alpine edge). You may have to increase your timeouts if using a testing suite as the startup time is slower. The container will auto-kill itself after 60 seconds in case the scripts exits from some signal I didn't trap.
mongod
In the test script, I use something like the following to use the bash script:
You can then switch to using the dockerized memory server by running tests like so:
DOCKERIZED_MONGOMS=1 yarn test
The text was updated successfully, but these errors were encountered: