Skip to content
Snippets Groups Projects
Commit 40007155 authored by Sergey Yakubov's avatar Sergey Yakubov
Browse files

use mongo without nomad for restart test

parent 980d9712
No related branches found
No related tags found
No related merge requests found
...@@ -11,7 +11,6 @@ function(prepare_asapo) ...@@ -11,7 +11,6 @@ function(prepare_asapo)
configure_file(${CMAKE_SOURCE_DIR}/tests/automatic/settings/receiver.json.tpl.lin receiver.json.tpl COPYONLY) configure_file(${CMAKE_SOURCE_DIR}/tests/automatic/settings/receiver.json.tpl.lin receiver.json.tpl COPYONLY)
endif() endif()
configure_file(${CMAKE_SOURCE_DIR}/config/nomad/receiver.nmd.in receiver.nmd @ONLY) configure_file(${CMAKE_SOURCE_DIR}/config/nomad/receiver.nmd.in receiver.nmd @ONLY)
configure_file(${CMAKE_SOURCE_DIR}/config/nomad/mongo.nmd.in mongo.nmd @ONLY)
configure_file(${CMAKE_SOURCE_DIR}/config/nomad/discovery.nmd.in discovery.nmd @ONLY) configure_file(${CMAKE_SOURCE_DIR}/config/nomad/discovery.nmd.in discovery.nmd @ONLY)
configure_file(${CMAKE_SOURCE_DIR}/config/nomad/authorizer.nmd.in authorizer.nmd @ONLY) configure_file(${CMAKE_SOURCE_DIR}/config/nomad/authorizer.nmd.in authorizer.nmd @ONLY)
configure_file(${CMAKE_SOURCE_DIR}/config/nomad/broker.nmd.in broker.nmd @ONLY) configure_file(${CMAKE_SOURCE_DIR}/config/nomad/broker.nmd.in broker.nmd @ONLY)
......
job "mongo" {
datacenters = ["dc1"]
group "mongo" {
count = 1
restart {
attempts = 2
interval = "3m"
delay = "15s"
mode = "delay"
}
task "mongo" {
driver = "docker"
config {
network_mode = "host"
image = "mongo:4.0.0"
volumes = ["/tmp/mongo:/data/db"]
args = ["--port","27016"]
}
resources {
cpu = 1500
memory = 1256
network {
port "mongo" {
static = 27016
}
}
}
service {
port = "mongo"
name = "mongo"
check {
type = "script"
name = "alive"
command = "mongo"
args = ["--eval","db.version()"]
interval = "10s"
timeout = "5s"
}
check_restart {
limit = 2
grace = "90s"
ignore_warnings = false
}
}
}
}
}
...@@ -94,7 +94,7 @@ std::unique_ptr<asapo::Producer> CreateProducer(const Args& args) { ...@@ -94,7 +94,7 @@ std::unique_ptr<asapo::Producer> CreateProducer(const Args& args) {
} }
producer->EnableLocalLog(true); producer->EnableLocalLog(true);
producer->SetLogLevel(asapo::LogLevel::Info); producer->SetLogLevel(asapo::LogLevel::Debug);
return producer; return producer;
} }
......
...@@ -6,7 +6,7 @@ trap Cleanup EXIT ...@@ -6,7 +6,7 @@ trap Cleanup EXIT
function wait_mongo { function wait_mongo {
NEXT_WAIT_TIME=0 NEXT_WAIT_TIME=0
until mongo --port 27016 --eval "db.version()" | tail -1 | grep 4.0.0 || [ $NEXT_WAIT_TIME -eq 30 ]; do until mongo --port 27016 --eval "db.version()" | tail -2 | grep version || [ $NEXT_WAIT_TIME -eq 30 ]; do
echo "Wait for mongo" echo "Wait for mongo"
NEXT_WAIT_TIME=$(( NEXT_WAIT_TIME++ )) NEXT_WAIT_TIME=$(( NEXT_WAIT_TIME++ ))
sleep 1 sleep 1
...@@ -18,6 +18,11 @@ fi ...@@ -18,6 +18,11 @@ fi
} }
function kill_mongo {
kill -9 `ps xa | grep mongod | grep 27016 | awk '{print $1;}'`
}
database_name=db_test database_name=db_test
beamtime_id=asapo_test beamtime_id=asapo_test
beamline=test beamline=test
...@@ -29,11 +34,13 @@ Cleanup() { ...@@ -29,11 +34,13 @@ Cleanup() {
nomad stop authorizer nomad stop authorizer
nomad stop nginx nomad stop nginx
echo "db.dropDatabase()" | mongo --port 27016 ${beamtime_id} echo "db.dropDatabase()" | mongo --port 27016 ${beamtime_id}
nomad stop mongo kill_mongo
} }
nomad run mongo.nmd mongod --dbpath /tmp/mongo --port 27016 --logpath /tmp/mongolog --fork
wait_mongo wait_mongo
# create db before worker starts reading it. todo: git rid of it # create db before worker starts reading it. todo: git rid of it
echo "db.${beamtime_id}.insert({dummy:1})" | mongo --port 27016 ${beamtime_id} echo "db.${beamtime_id}.insert({dummy:1})" | mongo --port 27016 ${beamtime_id}
...@@ -52,10 +59,12 @@ nfiles=1000 ...@@ -52,10 +59,12 @@ nfiles=1000
$1 localhost:8400 ${beamtime_id} 100 $nfiles 1 0 200 & $1 localhost:8400 ${beamtime_id} 100 $nfiles 1 0 200 &
sleep 0.1 sleep 0.5
kill_mongo
sleep 3
mongod --dbpath /tmp/mongo --port 27016 --logpath /tmp/mongolog --fork
docker rm -f `docker ps | grep mongo | awk '{print $1;}'`
sleep 1
wait wait
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment