diff --git a/tests/automatic/full_chain/CMakeLists.txt b/tests/automatic/full_chain/CMakeLists.txt index 24928ac777e7b2c07adb7be8bc14984be2ba0c31..49d58db5778bfacf1c47dc634d3dcecee55b89aa 100644 --- a/tests/automatic/full_chain/CMakeLists.txt +++ b/tests/automatic/full_chain/CMakeLists.txt @@ -1 +1,2 @@ add_subdirectory(simple_chain) +add_subdirectory(two_beamlines) diff --git a/tests/automatic/full_chain/two_beamlines/CMakeLists.txt b/tests/automatic/full_chain/two_beamlines/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..5a352cfc77a224b717ed42e5fe0b89efb086c1f2 --- /dev/null +++ b/tests/automatic/full_chain/two_beamlines/CMakeLists.txt @@ -0,0 +1,7 @@ +set(TARGET_NAME full_chain_two_beamlines) + +################################ +# 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/two_beamlines/check_linux.sh b/tests/automatic/full_chain/two_beamlines/check_linux.sh new file mode 100644 index 0000000000000000000000000000000000000000..d089d59f3c0bbee48ded9ee8bba173edbd305783 --- /dev/null +++ b/tests/automatic/full_chain/two_beamlines/check_linux.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash + +set -e + +trap Cleanup EXIT + +beamtime_id1=asapo_test1 +token1=`$3 token -secret broker_secret.key $beamtime_id1` + +beamtime_id2=asapo_test2 +token2=`$3 token -secret broker_secret.key $beamtime_id2` + +monitor_database_name=db_test +proxy_address=127.0.0.1:8400 + +beamline1=test1 +beamline2=test2 +receiver_root_folder=/tmp/asapo/receiver/files +receiver_folder1=${receiver_root_folder}/${beamline1}/${beamtime_id1} +receiver_folder2=${receiver_root_folder}/${beamline2}/${beamtime_id2} + +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 ${beamtime_id1} + echo "db.dropDatabase()" | mongo ${beamtime_id2} + influx -execute "drop database ${monitor_database_name}" +} + +influx -execute "create database ${monitor_database_name}" +echo "db.${beamtime_id1}.insert({dummy:1})" | mongo ${beamtime_id1} +echo "db.${beamtime_id2}.insert({dummy:1})" | mongo ${beamtime_id2} + +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_folder1} +mkdir -p ${receiver_folder2} +$1 localhost:8400 ${beamtime_id1} 100 1000 4 0 100 & +$1 localhost:8400 ${beamtime_id2} 100 900 4 0 100 & +#producerid=`echo $!` + + +$2 ${proxy_address} ${beamtime_id1} 2 $token1 | grep "Processed 1000 file(s)" +$2 ${proxy_address} ${beamtime_id2} 2 $token2 | grep "Processed 900 file(s)" diff --git a/tests/automatic/full_chain/two_beamlines/check_windows.bat b/tests/automatic/full_chain/two_beamlines/check_windows.bat new file mode 100644 index 0000000000000000000000000000000000000000..cb8ef418fe03a370cad97f805accb2d514dafb92 --- /dev/null +++ b/tests/automatic/full_chain/two_beamlines/check_windows.bat @@ -0,0 +1,60 @@ +SET mongo_exe="c:\Program Files\MongoDB\Server\3.6\bin\mongo.exe" +SET beamtime_id1=asapo_test1 +SET beamline1=test1 +SET beamtime_id2=asapo_test2 +SET beamline2=test2 + +SET receiver_root_folder=c:\tmp\asapo\receiver\files +SET receiver_folder1="%receiver_root_folder%\%beamline1%\%beamtime_id1%" +SET receiver_folder2="%receiver_root_folder%\%beamline2%\%beamtime_id2%" + + +"%3" token -secret broker_secret.key %beamtime_id1% > token +set /P token1=< token +"%3" token -secret broker_secret.key %beamtime_id2% > token +set /P token2=< token + +set proxy_address="127.0.0.1:8400" + +echo db.%beamtime_id1%.insert({dummy:1}) | %mongo_exe% %beamtime_id1% +echo db.%beamtime_id2%.insert({dummy:1}) | %mongo_exe% %beamtime_id2% + +c:\opt\consul\nomad run receiver.nmd +c:\opt\consul\nomad run authorizer.nmd +c:\opt\consul\nomad run discovery.nmd +c:\opt\consul\nomad run broker.nmd +c:\opt\consul\nomad run nginx.nmd + +ping 1.0.0.0 -n 10 -w 100 > nul + +REM producer +mkdir %receiver_folder1% +mkdir %receiver_folder2% +start /B "" "%1" %proxy_address% %beamtime_id1% 100 1000 4 0 100 +start /B "" "%1" %proxy_address% %beamtime_id2% 100 900 4 0 100 +ping 1.0.0.0 -n 1 -w 100 > nul + +REM worker +"%2" %proxy_address% %beamtime_id1% 2 %token1% | findstr /c:"Processed 1000 file(s)" || goto :error +"%2" %proxy_address% %beamtime_id2% 2 %token2% | findstr /c:"Processed 900 file(s)" || goto :error + + +goto :clean + +:error +call :clean +exit /b 1 + +:clean +c:\opt\consul\nomad stop receiver +c:\opt\consul\nomad stop discovery +c:\opt\consul\nomad stop broker +c:\opt\consul\nomad stop authorizer +c:\opt\consul\nomad stop nginx +rmdir /S /Q %receiver_root_folder% +del /f token1 +del /f token2 +echo db.dropDatabase() | %mongo_exe% %beamtime_id1% +echo db.dropDatabase() | %mongo_exe% %beamtime_id2% + + diff --git a/tests/automatic/settings/authorizer_settings.json.tpl b/tests/automatic/settings/authorizer_settings.json.tpl index 052462d535427c936717390da210fd9df3867e7e..74729610ed30516e94842279fe5a30e1f6b1a3c1 100644 --- a/tests/automatic/settings/authorizer_settings.json.tpl +++ b/tests/automatic/settings/authorizer_settings.json.tpl @@ -1,7 +1,9 @@ { "Port": {{ env "NOMAD_PORT_authorizer" }}, "LogLevel":"debug", - "AlwaysAllowedBeamtimes":[{"BeamtimeId":"asapo_test","Beamline":"test"}] + "AlwaysAllowedBeamtimes":[{"BeamtimeId":"asapo_test","Beamline":"test"}, + {"BeamtimeId":"asapo_test1","Beamline":"test1"}, + {"BeamtimeId":"asapo_test2","Beamline":"test2"}] }