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

journal write concernt a mongo restart test for broker

parent 40007155
No related branches found
No related tags found
No related merge requests found
...@@ -80,6 +80,7 @@ func (db *Mongodb) Connect(address string) (err error) { ...@@ -80,6 +80,7 @@ func (db *Mongodb) Connect(address string) (err error) {
if err != nil { if err != nil {
return err return err
} }
db.session.SetSafe(&mgo.Safe{J: true})
if err := db.updateDatabaseList(); err != nil { if err := db.updateDatabaseList(); err != nil {
return err return err
......
...@@ -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::Debug); producer->SetLogLevel(asapo::LogLevel::Info);
return producer; return producer;
} }
......
...@@ -3,4 +3,5 @@ add_subdirectory(read_config) ...@@ -3,4 +3,5 @@ add_subdirectory(read_config)
if (UNIX) if (UNIX)
add_subdirectory(check_monitoring) add_subdirectory(check_monitoring)
add_subdirectory(check_mongo_restart)
endif() endif()
\ No newline at end of file
set(TARGET_NAME check_broker_mongo_restart)
################################
# Testing
################################
prepare_asapo()
add_script_test("${TARGET_NAME}" "$<TARGET_FILE:dummy-data-producer> $<TARGET_FILE:getnext_broker> $<TARGET_PROPERTY:asapo,EXENAME>" nomem)
#!/usr/bin/env bash
set -e
trap Cleanup EXIT
beamtime_id=asapo_test
token=`$3 token -secret broker_secret.key $beamtime_id`
monitor_database_name=db_test
proxy_address=127.0.0.1:8400
beamline=test
receiver_root_folder=/tmp/asapo/receiver/files
receiver_folder=${receiver_root_folder}/${beamline}/${beamtime_id}
function wait_mongo {
NEXT_WAIT_TIME=0
until mongo --port 27016 --eval "db.version()" | tail -2 | grep version || [ $NEXT_WAIT_TIME -eq 30 ]; do
echo "Wait for mongo"
NEXT_WAIT_TIME=$(( NEXT_WAIT_TIME++ ))
sleep 1
done
if (( NEXT_WAIT_TIME == 30 )); then
echo "Timeout"
exit -1
fi
}
function kill_mongo {
kill -9 `ps xa | grep mongod | grep 27016 | awk '{print $1;}'`
}
function start_mongo {
mongod --dbpath /tmp/mongo --port 27016 --logpath /tmp/mongolog --fork
}
Cleanup() {
echo cleanup
rm -rf ${receiver_root_folder}
nomad stop nginx
nomad stop receiver
nomad stop discovery
nomad stop broker
nomad stop authorizer
# kill $producerid
echo "db.dropDatabase()" | mongo --port 27016 ${beamtime_id}
influx -execute "drop database ${monitor_database_name}"
kill_mongo
}
influx -execute "create database ${monitor_database_name}"
sed -i 's/27017/27016/g' receiver.json.tpl
sed -i 's/"WriteToDisk":true/"WriteToDisk":false/g' receiver.json.tpl
sed -i 's/27017/27016/g' broker.json.tpl
sed -i 's/info/debug/g' broker.json.tpl
start_mongo
wait_mongo
nomad run nginx.nmd
nomad run authorizer.nmd
nomad run receiver.nmd
nomad run discovery.nmd
nomad run broker.nmd
sleep 1
echo "db.${beamtime_id}.insert({dummy:1})" | mongo --port 27016 ${beamtime_id}
#producer
mkdir -p ${receiver_folder}
$1 localhost:8400 ${beamtime_id} 100 1000 4 0 100 &
#producerid=`echo $!`
wait
$2 ${proxy_address} ${beamtime_id} 2 $token &> output.txt &
sleep 2
kill_mongo
sleep 3
start_mongo
wait
cat output.txt
cat output.txt | grep "Processed 1000 file(s)"
rm output.txt
\ No newline at end of file
...@@ -23,6 +23,11 @@ function kill_mongo { ...@@ -23,6 +23,11 @@ function kill_mongo {
} }
function start_mongo {
mongod --dbpath /tmp/mongo --port 27016 --logpath /tmp/mongolog --fork
}
database_name=db_test database_name=db_test
beamtime_id=asapo_test beamtime_id=asapo_test
beamline=test beamline=test
...@@ -37,7 +42,7 @@ Cleanup() { ...@@ -37,7 +42,7 @@ Cleanup() {
kill_mongo kill_mongo
} }
mongod --dbpath /tmp/mongo --port 27016 --logpath /tmp/mongolog --fork start_mongo
wait_mongo wait_mongo
...@@ -63,8 +68,7 @@ sleep 0.5 ...@@ -63,8 +68,7 @@ sleep 0.5
kill_mongo kill_mongo
sleep 3 sleep 3
mongod --dbpath /tmp/mongo --port 27016 --logpath /tmp/mongolog --fork start_mongo
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