From 6d997cf100b9896ec0ab4783219e0258d4accf24 Mon Sep 17 00:00:00 2001 From: Sergey Yakubov <sergey.yakubov@desy.de> Date: Fri, 18 Sep 2020 12:47:42 +0200 Subject: [PATCH] add test for raw source --- tests/automatic/full_chain/CMakeLists.txt | 1 + .../simple_chain_raw/CMakeLists.txt | 7 +++ .../simple_chain_raw/check_linux.sh | 55 +++++++++++++++++++ .../simple_chain_raw/check_windows.bat | 40 ++++++++++++++ .../settings/authorizer_settings.json.tpl.lin | 3 +- .../settings/authorizer_settings.json.tpl.win | 3 +- 6 files changed, 107 insertions(+), 2 deletions(-) create mode 100644 tests/automatic/full_chain/simple_chain_raw/CMakeLists.txt create mode 100644 tests/automatic/full_chain/simple_chain_raw/check_linux.sh create mode 100644 tests/automatic/full_chain/simple_chain_raw/check_windows.bat diff --git a/tests/automatic/full_chain/CMakeLists.txt b/tests/automatic/full_chain/CMakeLists.txt index 6110eb7f0..958cfce30 100644 --- a/tests/automatic/full_chain/CMakeLists.txt +++ b/tests/automatic/full_chain/CMakeLists.txt @@ -7,6 +7,7 @@ add_subdirectory(simple_chain_metadata) add_subdirectory(two_beamlines) add_subdirectory(two_streams) add_subdirectory(simple_chain_filegen) +add_subdirectory(simple_chain_raw) add_subdirectory(simple_chain_filegen_batches) add_subdirectory(simple_chain_filegen_multisource) add_subdirectory(simple_chain_filegen_readdata_cache) diff --git a/tests/automatic/full_chain/simple_chain_raw/CMakeLists.txt b/tests/automatic/full_chain/simple_chain_raw/CMakeLists.txt new file mode 100644 index 000000000..7f20b3748 --- /dev/null +++ b/tests/automatic/full_chain/simple_chain_raw/CMakeLists.txt @@ -0,0 +1,7 @@ +set(TARGET_NAME full_chain_simple_chain_raw) + +################################ +# Testing +################################ +prepare_asapo() +add_script_test("${TARGET_NAME}" "$<TARGET_FILE:dummy-data-producer> $<TARGET_FILE:getnext_broker> $<TARGET_PROPERTY:asapo,EXENAME>" nomem) diff --git a/tests/automatic/full_chain/simple_chain_raw/check_linux.sh b/tests/automatic/full_chain/simple_chain_raw/check_linux.sh new file mode 100644 index 000000000..ab1984a90 --- /dev/null +++ b/tests/automatic/full_chain/simple_chain_raw/check_linux.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash + +set -e + +trap Cleanup EXIT + +beamtime_id=asapo_test +token=`$3 token -secret auth_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 +facility=test_facility +year=2019 +receiver_folder=${receiver_root_folder}/beamline/${beamline}/current + +Cleanup() { + echo cleanup + rm -rf ${receiver_root_folder} + nomad stop nginx + nomad run nginx_kill.nmd && nomad stop -yes -purge nginx_kill + nomad stop receiver + nomad stop discovery + nomad stop broker + nomad stop authorizer + rm -rf out + # kill $producerid +# echo "db.dropDatabase()" | mongo ${beamtime_id}_detector + influx -execute "drop database ${monitor_database_name}" +} + +echo "db.${beamtime_id}_detector.insert({dummy:1})" | mongo ${beamtime_id}_detector + +echo "db.dropDatabase()" | mongo ${beamtime_id}_detector + + +nomad run nginx.nmd +nomad run authorizer.nmd +nomad run receiver.nmd +nomad run discovery.nmd +nomad run broker.nmd + +sleep 1 + +#producer +mkdir -p ${receiver_folder} +$1 localhost:8400 ${beamtime_id} 100 1000 4 100 100 +#producerid=`echo $!` + + +$2 ${proxy_address} ${receiver_folder} ${beamtime_id} 2 $token 5000 1 > out +cat out +cat out | grep "Processed 1000 file(s)" diff --git a/tests/automatic/full_chain/simple_chain_raw/check_windows.bat b/tests/automatic/full_chain/simple_chain_raw/check_windows.bat new file mode 100644 index 000000000..a25619e9b --- /dev/null +++ b/tests/automatic/full_chain/simple_chain_raw/check_windows.bat @@ -0,0 +1,40 @@ +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%\beamline\%beamline%\current" + + +"%3" token -secret auth_secret.key %beamtime_id% > token +set /P token=< token + +set proxy_address="127.0.0.1:8400" + +echo db.%beamtime_id%_detector.insert({dummy:1}) | %mongo_exe% %beamtime_id%_detector + +call start_services.bat + +REM producer +mkdir %receiver_folder% +start /B "" "%1" %proxy_address% %beamtime_id% 100 1000 4 100 100 +ping 1.0.0.0 -n 1 -w 100 > nul + +REM consumer +"%2" %proxy_address% %receiver_folder% %beamtime_id% 2 %token% 5000 1 > out.txt +type out.txt +findstr /i /l /c:"Processed 1000 file(s)" out.txt || goto :error + +goto :clean + +:error +call :clean +exit /b 1 + +:clean +call stop_services.bat +rmdir /S /Q %receiver_root_folder% +del /f token +echo db.dropDatabase() | %mongo_exe% %beamtime_id%_detector + + diff --git a/tests/automatic/settings/authorizer_settings.json.tpl.lin b/tests/automatic/settings/authorizer_settings.json.tpl.lin index bfab06d13..5430280f6 100644 --- a/tests/automatic/settings/authorizer_settings.json.tpl.lin +++ b/tests/automatic/settings/authorizer_settings.json.tpl.lin @@ -1,7 +1,8 @@ { "Port": {{ env "NOMAD_PORT_authorizer" }}, "LogLevel":"debug", - "AlwaysAllowedBeamtimes":[{"beamtimeId":"asapo_test","beamline":"test","core-path":"/tmp/asapo/receiver/files/test_facility/gpfs/test/2019/data/asapo_test"}, + "AlwaysAllowedBeamtimes":[{"beamtimeId":"asapo_test","beamline":"test","core-path":"/tmp/asapo/receiver/files/test_facility/gpfs/test/2019/data/asapo_test", + "beamline-path":"/tmp/asapo/receiver/files/beamline/test/current"}, {"beamtimeId":"asapo_test1","beamline":"test1","core-path":"/tmp/asapo/receiver/files/test_facility/gpfs/test1/2019/data/asapo_test1"}, {"beamtimeId":"asapo_test2","beamline":"test2","core-path":"/tmp/asapo/receiver/files/test_facility/gpfs/test2/2019/data/asapo_test2"}], "SecretFile":"auth_secret.key", diff --git a/tests/automatic/settings/authorizer_settings.json.tpl.win b/tests/automatic/settings/authorizer_settings.json.tpl.win index 755b4d25c..1d9e250b7 100644 --- a/tests/automatic/settings/authorizer_settings.json.tpl.win +++ b/tests/automatic/settings/authorizer_settings.json.tpl.win @@ -1,7 +1,8 @@ { "Port": {{ env "NOMAD_PORT_authorizer" }}, "LogLevel":"debug", - "AlwaysAllowedBeamtimes":[{"beamtimeId":"asapo_test","beamline":"test","core-path":"c:\\tmp\\asapo\\receiver\\files\\test_facility\\gpfs\\test\\2019\\data\\asapo_test"}, + "AlwaysAllowedBeamtimes":[{"beamtimeId":"asapo_test","beamline":"test","core-path":"c:\\tmp\\asapo\\receiver\\files\\test_facility\\gpfs\\test\\2019\\data\\asapo_test", + "beamline-path":"c:\\tmp\\asapo\\receiver\\files\\beamline\\test\\current"}}, {"beamtimeId":"asapo_test1","beamline":"test1","core-path":"c:\\tmp\\asapo\\receiver\\files\\test_facility\\gpfs\\test1\\2019\\data\\asapo_test1"}, {"beamtimeId":"asapo_test2","beamline":"test2","core-path":"c:\\tmp\\asapo\\receiver\\files\\test_facility\\gpfs\\test2\\2019\\data\\asapo_test2"}], "SecretFile":"auth_secret.key", -- GitLab