From d69c246782d3630e2555804f2bfa36e205e3da53 Mon Sep 17 00:00:00 2001
From: George Sedov <george.sedov@desy.de>
Date: Wed, 12 Jan 2022 20:33:03 +0100
Subject: [PATCH] Remove windows test for kafka, update kafka message for full
 path

---
 .../request_handler_kafka_notify.cpp          |  9 +++++-
 .../CMakeLists.txt                            | 26 +++++++++--------
 .../check_linux.sh                            |  2 +-
 .../check_windows.bat                         | 28 -------------------
 4 files changed, 23 insertions(+), 42 deletions(-)
 delete mode 100644 tests/automatic/producer_receiver/transfer_single_file_with_kafka/check_windows.bat

diff --git a/receiver/src/request_handler/request_handler_kafka_notify.cpp b/receiver/src/request_handler/request_handler_kafka_notify.cpp
index 558f74d3f..c94cce9a4 100644
--- a/receiver/src/request_handler/request_handler_kafka_notify.cpp
+++ b/receiver/src/request_handler/request_handler_kafka_notify.cpp
@@ -1,5 +1,6 @@
 #include "request_handler_kafka_notify.h"
 #include "../request.h"
+#include "file_processors/file_processor.h"
 
 namespace asapo {
 
@@ -9,9 +10,15 @@ Error RequestHandlerKafkaNotify::ProcessRequest(Request* request) const {
         return nullptr;
     }
 
+    std::string root_folder;
+
+    if (auto err = GetRootFolder(request, &root_folder)){
+        return err;
+    }
+
     std::string message = "{"
             "\"event\":\"IN_CLOSE_WRITE\","
-            "\"path\":\"" + request->GetFileName() + "\""
+            "\"path\":\"" + root_folder + kPathSeparator + request->GetFileName() + "\""
     "}";
 
     return kafka_client_->Send(message, "asapo");
diff --git a/tests/automatic/producer_receiver/transfer_single_file_with_kafka/CMakeLists.txt b/tests/automatic/producer_receiver/transfer_single_file_with_kafka/CMakeLists.txt
index f3dd1eb04..3f97480dd 100644
--- a/tests/automatic/producer_receiver/transfer_single_file_with_kafka/CMakeLists.txt
+++ b/tests/automatic/producer_receiver/transfer_single_file_with_kafka/CMakeLists.txt
@@ -1,17 +1,19 @@
 set(TARGET_NAME transfer-single-file_kafka)
-set(SOURCE_FILES kafka_mock.cpp)
+if (NOT WIN32)
+    set(SOURCE_FILES kafka_mock.cpp)
 
-add_executable(${TARGET_NAME} ${SOURCE_FILES})
-target_link_libraries(${TARGET_NAME} rdkafka)
+    add_executable(${TARGET_NAME} ${SOURCE_FILES})
+    target_link_libraries(${TARGET_NAME} rdkafka)
 
-#use expression generator to get rid of VS adding Debug/Release folders
-set_target_properties(${TARGET_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY
-        ${CMAKE_CURRENT_BINARY_DIR}$<$<CONFIG:Debug>:>
-        )
+    #use expression generator to get rid of VS adding Debug/Release folders
+    set_target_properties(${TARGET_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY
+            ${CMAKE_CURRENT_BINARY_DIR}$<$<CONFIG:Debug>:>
+            )
 
-################################
-# Testing
-################################
-prepare_asapo()
+    ################################
+    # Testing
+    ################################
+    prepare_asapo()
 
-add_script_test("${TARGET_NAME}" "$<TARGET_FILE:dummy-data-producer>" nomem)
+    add_script_test("${TARGET_NAME}" "$<TARGET_FILE:dummy-data-producer>" nomem)
+endif()
\ No newline at end of file
diff --git a/tests/automatic/producer_receiver/transfer_single_file_with_kafka/check_linux.sh b/tests/automatic/producer_receiver/transfer_single_file_with_kafka/check_linux.sh
index 51a93d0ba..4aaa80ddc 100644
--- a/tests/automatic/producer_receiver/transfer_single_file_with_kafka/check_linux.sh
+++ b/tests/automatic/producer_receiver/transfer_single_file_with_kafka/check_linux.sh
@@ -32,7 +32,7 @@ Cleanup() {
 
 rm -f bootstrap
 
-./transfer-single-file_kafka processed/1 & KAFKA_PID=$!
+./transfer-single-file_kafka ${receiver_folder}/processed/1 & KAFKA_PID=$!
 
 echo "Started the kafka listener"
 
diff --git a/tests/automatic/producer_receiver/transfer_single_file_with_kafka/check_windows.bat b/tests/automatic/producer_receiver/transfer_single_file_with_kafka/check_windows.bat
deleted file mode 100644
index afcbb8dd8..000000000
--- a/tests/automatic/producer_receiver/transfer_single_file_with_kafka/check_windows.bat
+++ /dev/null
@@ -1,28 +0,0 @@
-SET mongo_exe="c:\Program Files\MongoDB\Server\4.2\bin\mongo.exe"
-SET beamtime_id=asapo_test
-SET beamline=test
-SET receiver_root_folder=c:\tmp\asapo\receiver\files
-SET receiver_folder="%receiver_root_folder%\test_facility\gpfs\%beamline%\2019\data\%beamtime_id%"
-
-mkdir %receiver_folder%
-
-"%1" 127.0.0.1:8400 %beamtime_id% 100 1 1 0 30
-
-ping 192.0.2.1 -n 1 -w 1000 > nul
-
-FOR /F "usebackq" %%A IN ('%receiver_folder%\processed\1') DO set size=%%~zA
-if %size% NEQ 100000 goto :error
-
-"%1" 127.0.0.1:8400 wrong_id 100 1 1 0 2 2>1 | findstr /c:"authorization"  || goto :error
-
-goto :clean
-
-:error
-call :clean
-exit /b 1
-
-:clean
-rmdir /S /Q %receiver_root_folder%
-echo db.dropDatabase() | %mongo_exe% %beamtime_id%_detector
-
-
-- 
GitLab