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

more test in nomad

parent fefe1d19
No related branches found
No related tags found
No related merge requests found
Showing
with 111 additions and 29 deletions
......@@ -46,6 +46,9 @@ include(astyle)
include(testing_cpp)
include(prepare_asapo)
if(BUILD_WORKER_TOOLS)
set (BUILD_MONGODB_CLIENTLIB ON)
endif()
......
function(prepare_asapo)
get_target_property(RECEIVER_DIR receiver-bin BINARY_DIR)
get_target_property(RECEIVER_NAME receiver-bin OUTPUT_NAME)
get_target_property(DISCOVERY_FULLPATH asapo-discovery EXENAME)
set(WORK_DIR ${CMAKE_CURRENT_BINARY_DIR})
configure_file(${CMAKE_SOURCE_DIR}/config/nomad/receiver.nmd.in receiver.nmd @ONLY)
configure_file(${CMAKE_SOURCE_DIR}/config/nomad/discovery.nmd.in discovery.nmd @ONLY)
configure_file(${CMAKE_SOURCE_DIR}/tests/automatic/settings/receiver.json.tpl receiver.json.tpl COPYONLY)
configure_file(${CMAKE_SOURCE_DIR}/tests/automatic/settings/discovery_settings.json.tpl discovery.json.tpl COPYONLY)
endfunction()
job "discovery" {
datacenters = ["dc1"]
type = "service"
group "group" {
count = 1
task "service" {
driver = "raw_exec"
config {
command = "@DISCOVERY_FULLPATH@",
args = ["-config","${NOMAD_TASK_DIR}/discovery.json"]
}
resources {
cpu = 500 # 500 MHz
memory = 256 # 256MB
network {
port "discovery" {
static = "5006"
}
}
}
service {
name = "discovery"
port = "discovery"
check {
name = "alive"
type = "http"
path = "/receivers"
interval = "10s"
timeout = "2s"
initial_status = "passing"
}
}
template {
source = "@WORK_DIR@/discovery.json.tpl"
destination = "local/discovery.json"
change_mode = "signal"
change_signal = "SIGHUP"
}
}
}
}
......@@ -11,7 +11,7 @@ job "receiver" {
config {
command = "/bin/bash",
args = ["-c", "mkdir files && exec ${RECEIVER_DIR}/${RECEIVER_NAME} receiver.json && rm -rf files"]
args = ["-c", "cd @WORK_DIR@ && exec @RECEIVER_DIR@/@RECEIVER_NAME@ ${NOMAD_TASK_DIR}/receiver.json"]
}
resources {
......@@ -35,8 +35,8 @@ job "receiver" {
}
template {
source = "${CMAKE_CURRENT_BINARY_DIR}/receiver.json.tpl"
destination = "receiver.json"
source = "@WORK_DIR@/receiver.json.tpl"
destination = "local/receiver.json"
change_mode = "signal"
change_signal = "SIGHUP"
}
......
......@@ -6,5 +6,5 @@ database_name=test_run
#just test that it starts, no reciever is running
$@ 0.0.0.0 1 1 2>&1 | grep "Failed to connect"
$@ 0.0.0.0 1 1 1 1 2>&1 | grep "not successfully"
......@@ -29,14 +29,11 @@ Error RequestHandlerTcp::SendHeaderAndData(const Request* request, const std::st
Error io_error;
io__->Send(sd_, &(request->header), sizeof(request->header), &io_error);
if(io_error) {
// todo: add meaningful message to the io_error (here and below)
log__->Debug("cannot send header to " + receiver_address + " - " + io_error->Explain());
return io_error;
}
io__->Send(sd_, request->data, request->header.data_size, &io_error);
if(io_error) {
log__->Debug("cannot send data to " + receiver_address + " - " + io_error->Explain());
return io_error;
}
......@@ -48,7 +45,6 @@ Error RequestHandlerTcp::ReceiveResponse(const std::string& receiver_address) {
SendDataResponse sendDataResponse;
io__->Receive(sd_, &sendDataResponse, sizeof(sendDataResponse), &err);
if(err != nullptr) {
log__->Debug("cannot receive response from " + receiver_address + " - " + err->Explain());
return err;
}
......@@ -69,7 +65,6 @@ Error RequestHandlerTcp::TrySendToReceiver(const Request* request, const std::st
err = ReceiveResponse(receiver_address);
if (err) {
log__->Debug("cannot send data to " + receiver_address + ": " + err->Explain());
return err;
}
......@@ -122,6 +117,7 @@ Error RequestHandlerTcp::ProcessRequestUnlocked(const Request* request) {
if (err != nullptr && err != ProducerErrorTemplates::kFileIdAlreadyInUse) {
io__->CloseSocket(sd_, nullptr);
sd_ = kDisconnectedSocketDescriptor;
log__->Debug("cannot send data to " + receiver_uri + ": " + err->Explain());
log__->Debug("disconnected from " + receiver_uri);
continue;
}
......
......@@ -138,7 +138,13 @@ void RequestHandlerTcpTests::ExpectFailSendHeader(bool only_once) {
Return(-1)
));
EXPECT_CALL(mock_logger, Debug(AllOf(
HasSubstr("cannot send header"),
HasSubstr("disconnected"),
HasSubstr(receivers_list[i])
)
));
EXPECT_CALL(mock_logger, Debug(AllOf(
HasSubstr("cannot send"),
HasSubstr(receivers_list[i])
)
));
......@@ -160,7 +166,13 @@ void RequestHandlerTcpTests::ExpectFailSendData(bool only_once) {
Return(-1)
));
EXPECT_CALL(mock_logger, Debug(AllOf(
HasSubstr("cannot send data"),
HasSubstr("disconnected"),
HasSubstr(receivers_list[i])
)
));
EXPECT_CALL(mock_logger, Debug(AllOf(
HasSubstr("cannot send"),
HasSubstr(receivers_list[i])
)
));
......@@ -183,7 +195,14 @@ void RequestHandlerTcpTests::ExpectFailReceive(bool only_once) {
testing::Return(-1)
));
EXPECT_CALL(mock_logger, Debug(AllOf(
HasSubstr("cannot receive"),
HasSubstr("disconnected"),
HasSubstr(receivers_list[i])
)
));
EXPECT_CALL(mock_logger, Debug(AllOf(
HasSubstr("cannot send"),
HasSubstr(receivers_list[i])
)
));
......
......@@ -3,10 +3,6 @@ set(TARGET_NAME receiver)
################################
# Testing
################################
get_target_property(RECEIVER_DIR receiver-bin BINARY_DIR)
get_target_property(RECEIVER_NAME receiver-bin OUTPUT_NAME)
prepare_asapo()
configure_file(${CMAKE_SOURCE_DIR}/config/nomad/receiver.nmd.in receiver.nmd)
configure_file(${CMAKE_SOURCE_DIR}/tests/automatic/settings/receiver.json.tpl receiver.json.tpl COPYONLY)
configure_file(${CMAKE_SOURCE_DIR}/tests/automatic/settings/discovery_settings.json discovery.json COPYONLY)
add_script_test("${TARGET_NAME}-monitoring" "$<TARGET_FILE:dummy-data-producer> $<TARGET_FILE:receiver-bin> $<TARGET_PROPERTY:asapo-discovery,EXENAME>" nomem)
......@@ -10,19 +10,18 @@ trap Cleanup EXIT
Cleanup() {
echo cleanup
influx -execute "drop database ${database_name}"
# kill $receiverid
nomad stop receiver
kill $discoveryid
nomad stop discovery
echo "db.dropDatabase()" | mongo ${mongo_database_name}
rm -rf files
}
mkdir files
influx -execute "create database ${database_name}"
nomad run receiver.nmd
sleep 0.3
nohup $3 -config discovery.json &>/dev/null &
discoveryid=`echo $!`
nomad run discovery.nmd
sleep 1
......
......@@ -3,5 +3,5 @@ set(TARGET_NAME transfer-single-file)
################################
# Testing
################################
configure_file(${CMAKE_SOURCE_DIR}/tests/automatic/settings/receiver.json receiver.json COPYONLY)
prepare_asapo()
add_script_test("${TARGET_NAME}" "$<TARGET_FILE:dummy-data-producer> $<TARGET_FILE:receiver-bin>" nomem)
......@@ -9,16 +9,17 @@ database_name=test_run
Cleanup() {
echo cleanup
rm -rf files
kill $receiverid
nomad stop receiver
nomad stop discovery
echo "db.dropDatabase()" | mongo ${database_name}
}
nohup $2 receiver.json &>/dev/null &
sleep 0.3
receiverid=`echo $!`
nomad run receiver.nmd
nomad run discovery.nmd
mkdir files
$1 localhost:4200 100 1
$1 localhost:5006 100 1 1 0
ls -ln files/1.bin | awk '{ print $5 }'| grep 102400
{
"MaxConnections": 32,
"Mode": "consul",
"Port": {{ env "NOMAD_PORT_discovery" }},
"LogLevel":"debug"
}
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