From 4e5b5fb576cf040fde5fc4668dd10879e9063593 Mon Sep 17 00:00:00 2001
From: Sergey Yakubov <sergey.yakubov@desy.de>
Date: Tue, 25 May 2021 17:18:50 +0200
Subject: [PATCH] started refactoring tests

---
 tests/automatic/CMakeLists.txt                |  4 ++
 .../authorizer/check_authorize/CMakeLists.txt |  1 -
 .../authorizer/check_authorize/check_linux.sh | 54 +++++++++----------
 .../check_authorize/check_windows.bat         | 10 ++--
 .../check_authorize/settings.json.in          | 14 -----
 .../broker/check_monitoring/CMakeLists.txt    |  6 +--
 .../broker/check_monitoring/check_linux.sh    | 26 +++------
 .../automatic/broker/get_last/CMakeLists.txt  |  5 +-
 .../automatic/broker/get_last/check_linux.sh  | 35 +++++-------
 .../broker/get_last/check_windows.bat         | 39 +++++---------
 .../automatic/broker/get_meta/CMakeLists.txt  |  6 +--
 .../automatic/broker/get_meta/check_linux.sh  | 18 ++-----
 .../broker/get_meta/check_windows.bat         | 21 ++------
 .../automatic/broker/get_next/CMakeLists.txt  |  6 +--
 .../automatic/broker/get_next/check_linux.sh  | 26 +++------
 .../broker/get_next/check_windows.bat         | 30 ++++-------
 .../consumer_python_memleak/CMakeLists.txt    |  2 -
 .../consumer_python_memleak/check_linux.sh    |  9 ----
 .../CMakeLists.txt                            |  3 --
 .../bugfix_callback.py                        |  2 +
 .../check_linux.sh                            | 12 +----
 .../CMakeLists.txt                            |  2 +-
 .../check_linux.sh                            | 13 +----
 .../check_windows.bat                         |  6 ---
 .../bug_fixes/python_deadlock/CMakeLists.txt  |  2 -
 .../receiver_cpu_usage/CMakeLists.txt         |  1 -
 .../receiver_cpu_usage/check_linux.sh         | 12 -----
 .../CMakeLists.txt                            |  3 --
 .../check_linux.sh                            | 14 -----
 tests/automatic/common_scripts/CMakeLists.txt |  9 ++++
 .../common_scripts/start_services.sh          | 21 ++++++++
 .../automatic/common_scripts/stop_services.sh |  7 +++
 .../settings/authorizer_settings.json.tpl.lin |  2 +
 .../settings/authorizer_settings.json.tpl.win |  2 +
 34 files changed, 139 insertions(+), 284 deletions(-)
 delete mode 100644 tests/automatic/authorizer/check_authorize/settings.json.in
 create mode 100644 tests/automatic/common_scripts/CMakeLists.txt

diff --git a/tests/automatic/CMakeLists.txt b/tests/automatic/CMakeLists.txt
index 915166876..bf5f7ca3b 100644
--- a/tests/automatic/CMakeLists.txt
+++ b/tests/automatic/CMakeLists.txt
@@ -1,6 +1,10 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 3.7) # needed for fixtures
 find_package(Threads)
 
+add_subdirectory(common_scripts)
+
+
+
 add_subdirectory(common/cpp)
 add_subdirectory(system_io)
 
diff --git a/tests/automatic/authorizer/check_authorize/CMakeLists.txt b/tests/automatic/authorizer/check_authorize/CMakeLists.txt
index d0f3cdacc..8cfe77776 100644
--- a/tests/automatic/authorizer/check_authorize/CMakeLists.txt
+++ b/tests/automatic/authorizer/check_authorize/CMakeLists.txt
@@ -20,6 +20,5 @@ configure_file(${CMAKE_SOURCE_DIR}/tests/automatic/settings/auth_secret_admin.ke
 configure_file(beamtime-metadata-11111111.json beamtime-metadata-11111111.json COPYONLY)
 configure_file(beamtime-metadata-11111112.json beamtime-metadata-11111112.json COPYONLY)
 
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/settings.json.in settings.json @ONLY)
 add_script_test("${TARGET_NAME}-authorize" "$<TARGET_PROPERTY:${TARGET_NAME},EXENAME>" nomem
         )
diff --git a/tests/automatic/authorizer/check_authorize/check_linux.sh b/tests/automatic/authorizer/check_authorize/check_linux.sh
index 26864b195..ea92dadbc 100644
--- a/tests/automatic/authorizer/check_authorize/check_linux.sh
+++ b/tests/automatic/authorizer/check_authorize/check_linux.sh
@@ -6,62 +6,56 @@ trap Cleanup EXIT
 
 Cleanup() {
 	echo cleanup
-	kill -9 $authorizeid
-	sleep 1
 }
 
-$@ -config settings.json &
-sleep 1
-authorizeid=`echo $!`
-
-mkdir -p asap3/petra3/gpfs/p00/2019/comissioning/c20180508-000-COM20181
-mkdir -p asap3/petra3/gpfs/p00/2019/data/11000015
-mkdir -p beamline/p07/current
-mkdir -p beamline/p08/current
-cp beamtime-metadata-11111111.json beamline/p07/current/
-cp beamtime-metadata-11111112.json beamline/p08/current/
+mkdir -p /tmp/asapo/asap3/petra3/gpfs/p00/2019/comissioning/c20180508-000-COM20181
+mkdir -p /tmp/asapo/asap3/petra3/gpfs/p00/2019/data/11000015
+mkdir -p /tmp/asapo/beamline/p07/current
+mkdir -p /tmp/asapo/beamline/p08/current
+cp beamtime-metadata-11111111.json /tmp/asapo/beamline/p07/current/
+cp beamtime-metadata-11111112.json /tmp/asapo/beamline/p08/current/
 
 
 #tokens
 AdminToken=$ASAPO_CREATE_TOKEN
 echo admin $AdminToken
 
-curl -v --silent -H "Authorization: Bearer $AdminToken" --data '{"Subject": {"beamtimeId":"12345678"},"DaysValid":123,"AccessType":["read"]}' 127.0.0.1:5007/admin/issue --stderr -  | tee /dev/stderr | grep "bt_12345678"
-curl -v --silent -H "Authorization: Bearer blabla" --data '{"Subject": {"beamtimeId":"12345678"},"DaysValid":123,"AccessType":["read"]}' 127.0.0.1:5007/admin/issue --stderr -  | tee /dev/stderr | grep "token does not match"
+curl -v --silent -H "Authorization: Bearer $AdminToken" --data '{"Subject": {"beamtimeId":"12345678"},"DaysValid":123,"AccessType":["read"]}' 127.0.0.1:8400/asapo-authorizer/admin/issue --stderr -  | tee /dev/stderr | grep "bt_12345678"
+curl -v --silent -H "Authorization: Bearer blabla" --data '{"Subject": {"beamtimeId":"12345678"},"DaysValid":123,"AccessType":["read"]}' 127.0.0.1:8400/asapo-authorizer/admin/issue --stderr -  | tee /dev/stderr | grep "token does not match"
 
-curl -v --silent --data '{"SourceCredentials":"processed%c20180508-000-COM20181%%detector%","OriginHost":"127.0.0.1:5555"}' 127.0.0.1:5007/authorize --stderr -  | tee /dev/stderr  | grep c20180508-000-COM20181
-curl -v --silent --data '{"SourceCredentials":"processed%c20180508-000-COM20181%%detector%","OriginHost":"127.0.0.1:5555"}' 127.0.0.1:5007/authorize --stderr -  | tee /dev/stderr  | grep p00
-curl -v --silent --data '{"SourceCredentials":"processed%c20180508-000-COM20181%%detector%","OriginHost":"127.0.0.1:5555"}' 127.0.0.1:5007/authorize --stderr -  | tee /dev/stderr  | grep detector
+curl -v --silent --data '{"SourceCredentials":"processed%c20180508-000-COM20181%%detector%","OriginHost":"127.0.0.1:5555"}' 127.0.0.1:8400/asapo-authorizer/authorize --stderr -  | tee /dev/stderr  | grep c20180508-000-COM20181
+curl -v --silent --data '{"SourceCredentials":"processed%c20180508-000-COM20181%%detector%","OriginHost":"127.0.0.1:5555"}' 127.0.0.1:8400/asapo-authorizer/authorize --stderr -  | tee /dev/stderr  | grep p00
+curl -v --silent --data '{"SourceCredentials":"processed%c20180508-000-COM20181%%detector%","OriginHost":"127.0.0.1:5555"}' 127.0.0.1:8400/asapo-authorizer/authorize --stderr -  | tee /dev/stderr  | grep detector
 
 token=$C20180508_000_COM20181_TOKEN
 
-curl -v --silent --data "{\"SourceCredentials\":\"processed%c20180508-000-COM20181%%detector%$token\",\"OriginHost\":\"bla\"}" 127.0.0.1:5007/authorize --stderr -  | tee /dev/stderr  | grep detector
-curl -v --silent --data "{\"SourceCredentials\":\"processed%c20180508-000-COM20181%auto%detector%$token\",\"OriginHost\":\"bla\"}" 127.0.0.1:5007/authorize --stderr -  | tee /dev/stderr  | grep p00
-curl -v --silent --data '{"SourceCredentials":"processed%c20180508-000-COM20181%%detector%bla","OriginHost":"bla"}' 127.0.0.1:5007/authorize --stderr -  | tee /dev/stderr  | grep 401
+curl -v --silent --data "{\"SourceCredentials\":\"processed%c20180508-000-COM20181%%detector%$token\",\"OriginHost\":\"bla\"}" 127.0.0.1:8400/asapo-authorizer/authorize --stderr -  | tee /dev/stderr  | grep detector
+curl -v --silent --data "{\"SourceCredentials\":\"processed%c20180508-000-COM20181%auto%detector%$token\",\"OriginHost\":\"bla\"}" 127.0.0.1:8400/asapo-authorizer/authorize --stderr -  | tee /dev/stderr  | grep p00
+curl -v --silent --data '{"SourceCredentials":"processed%c20180508-000-COM20181%%detector%bla","OriginHost":"bla"}' 127.0.0.1:8400/asapo-authorizer/authorize --stderr -  | tee /dev/stderr  | grep 401
 
 token=$BT11000015_TOKEN
 #beamtine not online
-curl -v --silent --data "{\"SourceCredentials\":\"raw%11000015%%detector%$token\",\"OriginHost\":\"bla\"}" 127.0.0.1:5007/authorize --stderr -  | tee /dev/stderr  | grep 401
+curl -v --silent --data "{\"SourceCredentials\":\"raw%11000015%%detector%$token\",\"OriginHost\":\"bla\"}" 127.0.0.1:8400/asapo-authorizer/authorize --stderr -  | tee /dev/stderr  | grep 401
 
 token=$BT11000016_TOKEN
-curl -v --silent --data "{\"SourceCredentials\":\"raw%11000016%%detector%${token}\",\"OriginHost\":\"bla\"}" 127.0.0.1:5007/authorize --stderr -  | tee /dev/stderr  | grep 401
+curl -v --silent --data "{\"SourceCredentials\":\"raw%11000016%%detector%${token}\",\"OriginHost\":\"bla\"}" 127.0.0.1:8400/asapo-authorizer/authorize --stderr -  | tee /dev/stderr  | grep 401
 
 
 token=$BLP07_TOKEN
 
-curl -v --silent --data "{\"SourceCredentials\":\"processed%auto%p07%detector%$token\",\"OriginHost\":\"bla\"}" 127.0.0.1:5007/authorize --stderr -  | tee /dev/stderr  | grep 11111111
-curl -v --silent --data "{\"SourceCredentials\":\"raw%auto%p07%detector%$token\",\"OriginHost\":\"127.0.0.1:5007\"}" 127.0.0.1:5007/authorize --stderr -  | tee /dev/stderr  | grep 11111111
-curl -v --silent --data "{\"SourceCredentials\":\"raw%auto%p07%detector%$token\",\"OriginHost\":\"127.0.0.1:5007\"}" 127.0.0.1:5007/authorize --stderr -  | tee /dev/stderr  | grep p07
-curl -v --silent --data "{\"SourceCredentials\":\"raw%auto%p07%detector%$token\",\"OriginHost\":\"127.0.0.1:5007\"}" 127.0.0.1:5007/authorize --stderr -  | tee /dev/stderr  | grep /asap3/petra3/gpfs/p07/2020/data/11111111
+curl -v --silent --data "{\"SourceCredentials\":\"processed%auto%p07%detector%$token\",\"OriginHost\":\"bla\"}" 127.0.0.1:8400/asapo-authorizer/authorize --stderr -  | tee /dev/stderr  | grep 11111111
+curl -v --silent --data "{\"SourceCredentials\":\"raw%auto%p07%detector%$token\",\"OriginHost\":\"127.0.0.1:8400/asapo-authorizer\"}" 127.0.0.1:8400/asapo-authorizer/authorize --stderr -  | tee /dev/stderr  | grep 11111111
+curl -v --silent --data "{\"SourceCredentials\":\"raw%auto%p07%detector%$token\",\"OriginHost\":\"127.0.0.1:8400/asapo-authorizer\"}" 127.0.0.1:8400/asapo-authorizer/authorize --stderr -  | tee /dev/stderr  | grep p07
+curl -v --silent --data "{\"SourceCredentials\":\"raw%auto%p07%detector%$token\",\"OriginHost\":\"127.0.0.1:8400/asapo-authorizer\"}" 127.0.0.1:8400/asapo-authorizer/authorize --stderr -  | tee /dev/stderr  | grep /asap3/petra3/gpfs/p07/2020/data/11111111
 
 #wrong data in metafile
-curl -v --silent --data "{\"SourceCredentials\":\"processed%auto%p08%detector%$token\",\"OriginHost\":\"bla\"}" 127.0.0.1:5007/authorize --stderr -  | tee /dev/stderr  | grep "cannot set meta fields"
+curl -v --silent --data "{\"SourceCredentials\":\"processed%auto%p08%detector%$token\",\"OriginHost\":\"bla\"}" 127.0.0.1:8400/asapo-authorizer/authorize --stderr -  | tee /dev/stderr  | grep "cannot set meta fields"
 
 #read access
-curl -v --silent --data "{\"SourceCredentials\":\"processed%auto%p07%detector%$token\",\"OriginHost\":\"bla\"}" 127.0.0.1:5007/authorize --stderr - | tee /dev/stderr  | grep read
+curl -v --silent --data "{\"SourceCredentials\":\"processed%auto%p07%detector%$token\",\"OriginHost\":\"bla\"}" 127.0.0.1:8400/asapo-authorizer/authorize --stderr - | tee /dev/stderr  | grep read
 
 #write access
 token=$BLP07_W_TOKEN
-curl -v --silent --data "{\"SourceCredentials\":\"processed%auto%p07%detector%$token\",\"OriginHost\":\"bla\"}" 127.0.0.1:5007/authorize --stderr -  | tee /dev/stderr  | grep write
+curl -v --silent --data "{\"SourceCredentials\":\"processed%auto%p07%detector%$token\",\"OriginHost\":\"bla\"}" 127.0.0.1:8400/asapo-authorizer/authorize --stderr -  | tee /dev/stderr  | grep write
 
-rm -rf asap3 beamline
\ No newline at end of file
+rm -rf /tmp/asapo/asap3 /tmp/asapo/beamline
\ No newline at end of file
diff --git a/tests/automatic/authorizer/check_authorize/check_windows.bat b/tests/automatic/authorizer/check_authorize/check_windows.bat
index 9de776714..45cf77495 100644
--- a/tests/automatic/authorizer/check_authorize/check_windows.bat
+++ b/tests/automatic/authorizer/check_authorize/check_windows.bat
@@ -5,9 +5,9 @@ start /B "" "%full_name%" -config settings.json
 
 ping 192.0.2.1 -n 1 -w 1000 > nul
 
-mkdir asap3\petra3\gpfs\p00\2019\comissioning\c20180508-000-COM20181
-mkdir beamline\p07\current
-copy beamtime-metadata-11111111.json beamline\p07\current\ /y
+mkdir C:\tmp\asapo\asap3\petra3\gpfs\p00\2019\comissioning\c20180508-000-COM20181
+mkdir C:\tmp\asapo\beamline\p07\current
+copy beamtime-metadata-11111111.json C:\tmp\asapo\beamline\p07\current\ /y
 
 C:\Curl\curl.exe -v  --silent --data "{\"SourceCredentials\":\"processed%%c20180508-000-COM20181%%%%detector%%\",\"OriginHost\":\"127.0.0.1:5555\"}" 127.0.0.1:5007/authorize --stderr - | findstr c20180508-000-COM20181  || goto :error
 C:\Curl\curl.exe -v  --silent --data "{\"SourceCredentials\":\"processed%%c20180508-000-COM20181%%auto%%detector%%\",\"OriginHost\":\"127.0.0.1:5555\"}" 127.0.0.1:5007/authorize --stderr - | findstr p00  || goto :error
@@ -26,5 +26,5 @@ exit /b 1
 
 :clean
 Taskkill /IM "%short_name%" /F
-rmdir /S /Q asap3
-rmdir /S /Q beamline
+rmdir /S /Q C:\tmp\asapo\asap3
+rmdir /S /Q C:\tmp\asapo\beamline
diff --git a/tests/automatic/authorizer/check_authorize/settings.json.in b/tests/automatic/authorizer/check_authorize/settings.json.in
deleted file mode 100644
index 13950ebea..000000000
--- a/tests/automatic/authorizer/check_authorize/settings.json.in
+++ /dev/null
@@ -1,14 +0,0 @@
-{
-  "Port": 5007,
-  "LogLevel":"debug",
-  "RootBeamtimesFolder":"@ASAP3_FOLDER@",
-  "CurrentBeamlinesFolder":"@CURRENT_BEAMLINES_FOLDER@",
-  "UserSecretFile":"auth_secret.key",
-  "AdminSecretFile":"auth_secret_admin.key",
-  "Ldap":
-    {
-        "Uri" : "ldap://localhost:389",
-        "BaseDn" : "ou=rgy,o=desy,c=de",
-        "FilterTemplate" : "(cn=a3__BEAMLINE__-hosts)"
-    }
-}
\ No newline at end of file
diff --git a/tests/automatic/broker/check_monitoring/CMakeLists.txt b/tests/automatic/broker/check_monitoring/CMakeLists.txt
index 05ef150fd..db03b79a7 100644
--- a/tests/automatic/broker/check_monitoring/CMakeLists.txt
+++ b/tests/automatic/broker/check_monitoring/CMakeLists.txt
@@ -3,8 +3,4 @@ set(TARGET_NAME asapo-broker)
 ################################
 # Testing
 ################################
-prepare_asapo()
-configure_file(${CMAKE_SOURCE_DIR}/tests/automatic/settings/broker_settings.json settings.json COPYONLY)
-
-add_script_test("${TARGET_NAME}-monitoring" "$<TARGET_PROPERTY:${TARGET_NAME},EXENAME> $<TARGET_PROPERTY:asapo,EXENAME>" nomem
-        )
+add_script_test("${TARGET_NAME}-monitoring" "" nomem)
diff --git a/tests/automatic/broker/check_monitoring/check_linux.sh b/tests/automatic/broker/check_monitoring/check_linux.sh
index 291a0641d..734ffd75b 100644
--- a/tests/automatic/broker/check_monitoring/check_linux.sh
+++ b/tests/automatic/broker/check_monitoring/check_linux.sh
@@ -7,42 +7,28 @@ set -e
 trap Cleanup EXIT
 
 Cleanup() {
-    set +e
+  set +e
 	echo cleanup
 	influx -execute "drop database ${database_name}"
-	kill -9 $brokerid
-  nomad stop nginx
-  nomad run nginx_kill.nmd  && nomad stop -yes -purge nginx_kill
-  nomad stop authorizer
 }
 
 ! influx -execute "drop database ${database_name}"
 
 
-nomad run nginx.nmd
-nomad run authorizer.nmd
-sleep 1
-
-
 token=$BT_DATA_TOKEN
 
+broker=`curl --silent 127.0.0.1:8400/asapo-discovery/v0.1/asapo-broker?protocol=v0.3`
+echo found broker at $broker
 
-$1 -config settings.json &
-
-sleep 0.3
-
-brokerid=`echo $!`
-
-groupid=`curl -d '' --silent 127.0.0.1:5005/v0.2/creategroup`
+groupid=`curl -d '' --silent $broker/v0.2/creategroup`
 
 
 for i in `seq 1 50`;
 do
-    curl --silent 127.0.0.1:5005/v0.2/beamtime/data/source/stream/${groupid}/next?token=$token >/dev/null 2>&1 &
+    curl --silent $broker/v0.2/beamtime/data/source/stream/${groupid}/next?token=$token >/dev/null 2>&1 &
 done
 
-
 sleep 12
 
-influx -execute "select sum(rate) from RequestsRate" -database=${database_name} -format=json | jq .results[0].series[0].values[0][1] | tee /dev/stderr | grep 51
+influx -execute "select sum(rate) from RequestsRate" -database=${database_name} -format=json | jq .results[0].series[0].values[0][1]
 
diff --git a/tests/automatic/broker/get_last/CMakeLists.txt b/tests/automatic/broker/get_last/CMakeLists.txt
index 3b688f5db..5b06ea8d7 100644
--- a/tests/automatic/broker/get_last/CMakeLists.txt
+++ b/tests/automatic/broker/get_last/CMakeLists.txt
@@ -3,8 +3,5 @@ set(TARGET_NAME asapo-broker)
 ################################
 # Testing
 ################################
-prepare_asapo()
 
-configure_file(${CMAKE_SOURCE_DIR}/tests/automatic/settings/broker_settings.json settings.json COPYONLY)
-
-add_script_test("${TARGET_NAME}-getlast" "$<TARGET_PROPERTY:${TARGET_NAME},EXENAME> $<TARGET_PROPERTY:asapo,EXENAME>" nomem)
+add_script_test("${TARGET_NAME}-getlast" "" nomem)
diff --git a/tests/automatic/broker/get_last/check_linux.sh b/tests/automatic/broker/get_last/check_linux.sh
index c89bc54c8..f3cfc8b57 100644
--- a/tests/automatic/broker/get_last/check_linux.sh
+++ b/tests/automatic/broker/get_last/check_linux.sh
@@ -10,10 +10,6 @@ trap Cleanup EXIT
 Cleanup() {
 	echo cleanup
 	echo "db.dropDatabase()" | mongo ${database_name}
-	kill -9 $brokerid
-  nomad stop nginx
-  nomad run nginx_kill.nmd  && nomad stop -yes -purge nginx_kill
-  nomad stop authorizer
 }
 
 echo "db.data_${stream}.insert({"_id":2})" | mongo ${database_name}
@@ -21,33 +17,26 @@ echo "db.data_${stream}.insert({"_id":1})" | mongo ${database_name}
 
 token=$BT_DATA_TOKEN
 
-nomad run nginx.nmd
-nomad run authorizer.nmd
-sleep 1
+broker=`curl --silent 127.0.0.1:8400/asapo-discovery/v0.1/asapo-broker?protocol=v0.3`
+echo found broker at $broker
 
-$1 -config settings.json &
+groupid=`curl -d '' --silent $broker/v0.2/creategroup`
 
-sleep 0.3
-brokerid=`echo $!`
+curl -v  --silent $broker/v0.2/beamtime/data/detector/${stream}/0/last?token=$token --stderr -
 
-
-groupid=`curl -d '' --silent 127.0.0.1:5005/v0.2/creategroup`
-
-curl -v  --silent 127.0.0.1:5005/v0.2/beamtime/data/detector/${stream}/0/last?token=$token --stderr -
-
-curl -v  --silent 127.0.0.1:5005/v0.2/beamtime/data/detector/${stream}/0/last?token=$token --stderr - | grep '"_id":2'
-curl -v  --silent 127.0.0.1:5005/v0.2/beamtime/data/detector/${stream}/0/last?token=$token --stderr - | grep '"_id":2'
+curl -v  --silent $broker/v0.2/beamtime/data/detector/${stream}/0/last?token=$token --stderr - | grep '"_id":2'
+curl -v  --silent $broker/v0.2/beamtime/data/detector/${stream}/0/last?token=$token --stderr - | grep '"_id":2'
 
 echo "db.data_${stream}.insert({"_id":3})" | mongo ${database_name}
 
-curl -v  --silent 127.0.0.1:5005/v0.2/beamtime/data/detector/${stream}/0/last?token=$token --stderr - | grep '"_id":3'
+curl -v  --silent $broker/v0.2/beamtime/data/detector/${stream}/0/last?token=$token --stderr - | grep '"_id":3'
 
 echo "db.data_${stream}.insert({"_id":4})" | mongo ${database_name}
 
-curl -v  --silent 127.0.0.1:5005/v0.2/beamtime/data/detector/${stream}/${groupid}/next?token=$token --stderr - | grep '"_id":1'
-curl -v  --silent 127.0.0.1:5005/v0.2/beamtime/data/detector/${stream}/0/last?token=$token --stderr - | grep '"_id":4'
+curl -v  --silent $broker/v0.2/beamtime/data/detector/${stream}/${groupid}/next?token=$token --stderr - | grep '"_id":1'
+curl -v  --silent $broker/v0.2/beamtime/data/detector/${stream}/0/last?token=$token --stderr - | grep '"_id":4'
 
 #with a new group
-groupid=`curl -d '' --silent 127.0.0.1:5005/v0.2/creategroup`
-curl -v  --silent 127.0.0.1:5005/v0.2/beamtime/data/detector/${stream}/${groupid}/next?token=$token --stderr - | grep '"_id":1'
-curl -v  --silent 127.0.0.1:5005/v0.2/beamtime/data/detector/${stream}/0/last?token=$token --stderr - | grep '"_id":4'
\ No newline at end of file
+groupid=`curl -d '' --silent $broker/v0.2/creategroup`
+curl -v  --silent $broker/v0.2/beamtime/data/detector/${stream}/${groupid}/next?token=$token --stderr - | grep '"_id":1'
+curl -v  --silent $broker/v0.2/beamtime/data/detector/${stream}/0/last?token=$token --stderr - | grep '"_id":4'
\ No newline at end of file
diff --git a/tests/automatic/broker/get_last/check_windows.bat b/tests/automatic/broker/get_last/check_windows.bat
index 6ffe451b5..dacb2771c 100644
--- a/tests/automatic/broker/get_last/check_windows.bat
+++ b/tests/automatic/broker/get_last/check_windows.bat
@@ -4,43 +4,31 @@ SET mongo_exe="c:\Program Files\MongoDB\Server\4.2\bin\mongo.exe"
 echo db.data_default.insert({"_id":1}) | %mongo_exe% %database_name%  || goto :error
 echo db.data_default.insert({"_id":2}) | %mongo_exe% %database_name%  || goto :error
 
-set full_name="%1"
-set short_name="%~nx1"
-
-c:\opt\consul\nomad run authorizer.nmd
-c:\opt\consul\nomad run nginx.nmd
-
-ping 192.0.2.1 -n 1 -w 2000 > nul
-
-
-start /B "" "%full_name%" -config settings.json
-
-ping 192.0.2.1 -n 1 -w 5000 > nul
-
-
 set token=%BT_DATA_TOKEN%
 
+curl --silent 127.0.0.1:8400/asapo-discovery/v0.1/asapo-broker?protocol=v0.3 > broker
+set /P broker=< broker
 
-C:\Curl\curl.exe -d '' --silent 127.0.0.1:5005/v0.2/creategroup > groupid
+C:\Curl\curl.exe -d '' --silent %broker%/v0.2/creategroup > groupid
 set /P groupid=< groupid
 
 
-C:\Curl\curl.exe -v  --silent 127.0.0.1:5005/v0.2/beamtime/data/detector/default/0/last?token=%token% --stderr - | findstr /c:\"_id\":2  || goto :error
-C:\Curl\curl.exe -v  --silent 127.0.0.1:5005/v0.2/beamtime/data/detector/default/0/last?token=%token% --stderr - | findstr /c:\"_id\":2  || goto :error
+C:\Curl\curl.exe -v  --silent %broker%/v0.2/beamtime/data/detector/default/0/last?token=%token% --stderr - | findstr /c:\"_id\":2  || goto :error
+C:\Curl\curl.exe -v  --silent %broker%/v0.2/beamtime/data/detector/default/0/last?token=%token% --stderr - | findstr /c:\"_id\":2  || goto :error
 
 echo db.data_default.insert({"_id":3}) | %mongo_exe% %database_name%  || goto :error
-C:\Curl\curl.exe -v  --silent 127.0.0.1:5005/v0.2/beamtime/data/detector/default/0/last?token=%token% --stderr - | findstr /c:\"_id\":3  || goto :error
+C:\Curl\curl.exe -v  --silent %broker%/v0.2/beamtime/data/detector/default/0/last?token=%token% --stderr - | findstr /c:\"_id\":3  || goto :error
 
 echo db.data_default.insert({"_id":4}) | %mongo_exe% %database_name%  || goto :error
 
-C:\Curl\curl.exe -v  --silent 127.0.0.1:5005/v0.2/beamtime/data/detector/default/%groupid%/next?token=%token% --stderr - | findstr /c:\"_id\":1  || goto :error
-C:\Curl\curl.exe -v  --silent 127.0.0.1:5005/v0.2/beamtime/data/detector/default/0/last?token=%token% --stderr - | findstr /c:\"_id\":4  || goto :error
+C:\Curl\curl.exe -v  --silent %broker%/v0.2/beamtime/data/detector/default/%groupid%/next?token=%token% --stderr - | findstr /c:\"_id\":1  || goto :error
+C:\Curl\curl.exe -v  --silent %broker%/v0.2/beamtime/data/detector/default/0/last?token=%token% --stderr - | findstr /c:\"_id\":4  || goto :error
 
 
-C:\Curl\curl.exe -d '' --silent 127.0.0.1:5005/v0.2/creategroup > groupid
+C:\Curl\curl.exe -d '' --silent %broker%/v0.2/creategroup > groupid
 set /P groupid=< groupid
-C:\Curl\curl.exe -v  --silent 127.0.0.1:5005/v0.2/beamtime/data/detector/default/%groupid%/next?token=%token% --stderr - | findstr /c:\"_id\":1  || goto :error
-C:\Curl\curl.exe -v  --silent 127.0.0.1:5005/v0.2/beamtime/data/detector/default/0/last?token=%token% --stderr - | findstr /c:\"_id\":4  || goto :error
+C:\Curl\curl.exe -v  --silent %broker%/v0.2/beamtime/data/detector/default/%groupid%/next?token=%token% --stderr - | findstr /c:\"_id\":1  || goto :error
+C:\Curl\curl.exe -v  --silent %broker%/v0.2/beamtime/data/detector/default/0/last?token=%token% --stderr - | findstr /c:\"_id\":4  || goto :error
 
 
 goto :clean
@@ -50,9 +38,6 @@ call :clean
 exit /b 1
 
 :clean
-Taskkill /IM "%short_name%" /F
 echo db.dropDatabase() | %mongo_exe% %database_name%
 del /f groupid
-c:\opt\consul\nomad stop authorizer
-c:\opt\consul\nomad stop nginx
-c:\opt\consul\nomad run nginx_kill.nmd  && c:\opt\consul\nomad stop -yes -purge nginx_kill
+del /f broker
diff --git a/tests/automatic/broker/get_meta/CMakeLists.txt b/tests/automatic/broker/get_meta/CMakeLists.txt
index dc491f8bf..64a43e64b 100644
--- a/tests/automatic/broker/get_meta/CMakeLists.txt
+++ b/tests/automatic/broker/get_meta/CMakeLists.txt
@@ -3,9 +3,5 @@ set(TARGET_NAME asapo-broker)
 ################################
 # Testing
 ################################
-prepare_asapo()
 
-configure_file(${CMAKE_SOURCE_DIR}/tests/automatic/settings/broker_settings.json settings.json COPYONLY)
-
-add_script_test("${TARGET_NAME}-getmeta" "$<TARGET_PROPERTY:${TARGET_NAME},EXENAME> $<TARGET_PROPERTY:asapo,EXENAME>" nomem
-        )
+add_script_test("${TARGET_NAME}-getmeta" "" nomem)
diff --git a/tests/automatic/broker/get_meta/check_linux.sh b/tests/automatic/broker/get_meta/check_linux.sh
index 14b23b4d6..100138a7a 100644
--- a/tests/automatic/broker/get_meta/check_linux.sh
+++ b/tests/automatic/broker/get_meta/check_linux.sh
@@ -9,26 +9,16 @@ trap Cleanup EXIT
 Cleanup() {
 	echo cleanup
 	echo "db.dropDatabase()" | mongo ${database_name}
-	kill -9 $brokerid
-  nomad stop nginx
-  nomad run nginx_kill.nmd  && nomad stop -yes -purge nginx_kill
-  nomad stop authorizer
 }
 
 echo 'db.meta.insert({"_id":0,"data":"test"})' | mongo ${database_name}
 
 token=$BT_TEST_TOKEN
 
-nomad run nginx.nmd
-nomad run authorizer.nmd
-sleep 1
+broker=`curl --silent 127.0.0.1:8400/asapo-discovery/v0.1/asapo-broker?protocol=v0.3`
+echo found broker at $broker
 
 
-$1 -config settings.json &
-
-sleep 0.3
-brokerid=`echo $!`
-
-curl -v  --silent 127.0.0.1:5005/v0.2/beamtime/test/detector/default/0/meta/0?token=$token --stderr - | tee /dev/stderr | grep '"data":"test"'
-curl -v  --silent 127.0.0.1:5005/v0.2/beamtime/test/detector/default/0/meta/1?token=$token --stderr - | tee /dev/stderr | grep 'no documents'
+curl -v  --silent $broker/v0.2/beamtime/test/detector/default/0/meta/0?token=$token --stderr - | tee /dev/stderr | grep '"data":"test"'
+curl -v  --silent $broker/v0.2/beamtime/test/detector/default/0/meta/1?token=$token --stderr - | tee /dev/stderr | grep 'no documents'
 
diff --git a/tests/automatic/broker/get_meta/check_windows.bat b/tests/automatic/broker/get_meta/check_windows.bat
index c5dab94bb..d9b79672a 100644
--- a/tests/automatic/broker/get_meta/check_windows.bat
+++ b/tests/automatic/broker/get_meta/check_windows.bat
@@ -3,23 +3,14 @@ SET mongo_exe="c:\Program Files\MongoDB\Server\4.2\bin\mongo.exe"
 
 echo db.meta.insert({"_id":0}) | %mongo_exe% %database_name%  || goto :error
 
-set full_name="%1"
-set short_name="%~nx1"
-
-c:\opt\consul\nomad run authorizer.nmd
-c:\opt\consul\nomad run nginx.nmd
-
-ping 192.0.2.1 -n 1 -w 2000 > nul
-
-start /B "" "%full_name%" -config settings.json
-
-ping 192.0.2.1 -n 1 -w 5000 > nul
+curl --silent 127.0.0.1:8400/asapo-discovery/v0.1/asapo-broker?protocol=v0.3 > broker
+set /P broker=< broker
 
 set token=%BT_DATA_TOKEN%
 
 
-C:\Curl\curl.exe -v  --silent 127.0.0.1:5005/v0.2/beamtime/data/detector/default/0/meta/0?token=%token% --stderr - | findstr /c:\"_id\":0  || goto :error
-C:\Curl\curl.exe -v  --silent 127.0.0.1:5005/v0.2/beamtime/data/detector/default/0/meta/1?token=%token% --stderr - | findstr /c:"no documents"  || goto :error
+C:\Curl\curl.exe -v  --silent %broker%/v0.2/beamtime/data/detector/default/0/meta/0?token=%token% --stderr - | findstr /c:\"_id\":0  || goto :error
+C:\Curl\curl.exe -v  --silent %broker%/v0.2/beamtime/data/detector/default/0/meta/1?token=%token% --stderr - | findstr /c:"no documents"  || goto :error
 
 
 goto :clean
@@ -29,9 +20,5 @@ call :clean
 exit /b 1
 
 :clean
-Taskkill /IM "%short_name%" /F
 echo db.dropDatabase() | %mongo_exe% %database_name%
 del /f groupid
-c:\opt\consul\nomad stop authorizer
-c:\opt\consul\nomad stop nginx
-c:\opt\consul\nomad run nginx_kill.nmd  && c:\opt\consul\nomad stop -yes -purge nginx_kill
diff --git a/tests/automatic/broker/get_next/CMakeLists.txt b/tests/automatic/broker/get_next/CMakeLists.txt
index 1eba288a0..5caffad4a 100644
--- a/tests/automatic/broker/get_next/CMakeLists.txt
+++ b/tests/automatic/broker/get_next/CMakeLists.txt
@@ -3,9 +3,5 @@ set(TARGET_NAME asapo-broker)
 ################################
 # Testing
 ################################
-prepare_asapo()
 
-configure_file(${CMAKE_SOURCE_DIR}/tests/automatic/settings/broker_settings.json settings.json COPYONLY)
-
-add_script_test("${TARGET_NAME}-getnext" "$<TARGET_PROPERTY:${TARGET_NAME},EXENAME> $<TARGET_PROPERTY:asapo,EXENAME>" nomem
-        )
+add_script_test("${TARGET_NAME}-getnext" "" nomem)
diff --git a/tests/automatic/broker/get_next/check_linux.sh b/tests/automatic/broker/get_next/check_linux.sh
index 7bce26802..bcef1d69d 100644
--- a/tests/automatic/broker/get_next/check_linux.sh
+++ b/tests/automatic/broker/get_next/check_linux.sh
@@ -10,10 +10,6 @@ trap Cleanup EXIT
 Cleanup() {
 	echo cleanup
 	echo "db.dropDatabase()" | mongo ${database_name}
-	kill -9 $brokerid
-  nomad stop nginx
-  nomad run nginx_kill.nmd  && nomad stop -yes -purge nginx_kill
-  nomad stop authorizer
 }
 
 echo "db.data_${stream}.insert({"_id":2})" | mongo ${database_name}
@@ -21,21 +17,15 @@ echo "db.data_${stream}.insert({"_id":1})" | mongo ${database_name}
 
 token=$BT_DATA_TOKEN
 
-nomad run nginx.nmd
-nomad run authorizer.nmd
-sleep 1
+broker=`curl --silent 127.0.0.1:8400/asapo-discovery/v0.1/asapo-broker?protocol=v0.3`
+echo found broker at $broker
 
 
-$1 -config settings.json &
-
-sleep 0.3
-brokerid=`echo $!`
-
-groupid=`curl -d '' --silent 127.0.0.1:5005/v0.3/creategroup`
-curl -v  --silent 127.0.0.1:5005/v0.3/beamtime/data/source/${stream}/${groupid}/next?token=$token --stderr - | tee /dev/stderr  | grep '"_id":1'
-curl -v  --silent 127.0.0.1:5005/v0.3/beamtime/data/source/${stream}/${groupid}/next?token=$token --stderr - | tee /dev/stderr  | grep '"_id":2'
-curl -v  --silent 127.0.0.1:5005/v0.3/beamtime/data/source/${stream}/${groupid}/next?token=$token --stderr - | tee /dev/stderr  | grep '"id_max":2'
+groupid=`curl -d '' --silent $broker/v0.3/creategroup`
+curl -v  --silent $broker/v0.3/beamtime/data/source/${stream}/${groupid}/next?token=$token --stderr - | tee /dev/stderr  | grep '"_id":1'
+curl -v  --silent $broker/v0.3/beamtime/data/source/${stream}/${groupid}/next?token=$token --stderr - | tee /dev/stderr  | grep '"_id":2'
+curl -v  --silent $broker/v0.3/beamtime/data/source/${stream}/${groupid}/next?token=$token --stderr - | tee /dev/stderr  | grep '"id_max":2'
 
 # with a new group
-groupid=`curl -d '' --silent 127.0.0.1:5005/v0.3/creategroup`
-curl -v  --silent 127.0.0.1:5005/v0.3/beamtime/data/source/${stream}/${groupid}/next?token=$token --stderr - | tee /dev/stderr | grep '"_id":1'
\ No newline at end of file
+groupid=`curl -d '' --silent $broker/v0.3/creategroup`
+curl -v  --silent $broker/v0.3/beamtime/data/source/${stream}/${groupid}/next?token=$token --stderr - | tee /dev/stderr | grep '"_id":1'
\ No newline at end of file
diff --git a/tests/automatic/broker/get_next/check_windows.bat b/tests/automatic/broker/get_next/check_windows.bat
index 81330cd76..ba8760fa7 100644
--- a/tests/automatic/broker/get_next/check_windows.bat
+++ b/tests/automatic/broker/get_next/check_windows.bat
@@ -4,29 +4,23 @@ SET mongo_exe="c:\Program Files\MongoDB\Server\4.2\bin\mongo.exe"
 echo db.data_default.insert({"_id":1}) | %mongo_exe% %database_name%  || goto :error
 echo db.data_default.insert({"_id":2}) | %mongo_exe% %database_name%  || goto :error
 
-set full_name="%1"
-set short_name="%~nx1"
-
 set token=%BT_DATA_TOKEN%
 
-c:\opt\consul\nomad run authorizer.nmd
-c:\opt\consul\nomad run nginx.nmd
+curl --silent 127.0.0.1:8400/asapo-discovery/v0.1/asapo-broker?protocol=v0.3 > broker
+set /P broker=< broker
 
-ping 192.0.2.1 -n 1 -w 2000 > nul
 
-start /B "" "%full_name%" -config settings.json
+C:\Curl\curl.exe -d '' --silent %broker%/v0.3/creategroup > groupid
+set /P groupid=< groupid
 
-ping 192.0.2.1 -n 1 -w 5000 > nul
 
-C:\Curl\curl.exe -d '' --silent 127.0.0.1:5005/v0.3/creategroup > groupid
-set /P groupid=< groupid
-C:\Curl\curl.exe -v  --silent 127.0.0.1:5005/v0.3/beamtime/data/source/default/%groupid%/next?token=%token% --stderr - | findstr /c:\"_id\":1  || goto :error
-C:\Curl\curl.exe -v  --silent 127.0.0.1:5005/v0.3/beamtime/data/source/default/%groupid%/next?token=%token% --stderr - | findstr /c:\"_id\":2  || goto :error
-C:\Curl\curl.exe -v  --silent 127.0.0.1:5005/v0.3/beamtime/data/source/default/%groupid%/next?token=%token% --stderr - | findstr  /c:\"id_max\":2  || goto :error
+C:\Curl\curl.exe -v  --silent %broker%/v0.3/beamtime/data/source/default/%groupid%/next?token=%token% --stderr - | findstr /c:\"_id\":1  || goto :error
+C:\Curl\curl.exe -v  --silent %broker%/v0.3/beamtime/data/source/default/%groupid%/next?token=%token% --stderr - | findstr /c:\"_id\":2  || goto :error
+C:\Curl\curl.exe -v  --silent %broker%/v0.3/beamtime/data/source/default/%groupid%/next?token=%token% --stderr - | findstr  /c:\"id_max\":2  || goto :error
 
-C:\Curl\curl.exe -d '' --silent 127.0.0.1:5005/v0.3/creategroup > groupid
+C:\Curl\curl.exe -d '' --silent %broker%/v0.3/creategroup > groupid
 set /P groupid=< groupid
-C:\Curl\curl.exe -v  --silent 127.0.0.1:5005/v0.3/beamtime/data/source/default/%groupid%/next?token=%token% --stderr - | findstr /c:\"_id\":1  || goto :error
+C:\Curl\curl.exe -v  --silent %broker%/v0.3/beamtime/data/source/default/%groupid%/next?token=%token% --stderr - | findstr /c:\"_id\":1  || goto :error
 
 goto :clean
 
@@ -35,10 +29,6 @@ call :clean
 exit /b 1
 
 :clean
-Taskkill /IM "%short_name%" /F
 echo db.dropDatabase() | %mongo_exe% %database_name%
 del /f token
-del /f groupid
-c:\opt\consul\nomad stop authorizer
-c:\opt\consul\nomad stop nginx
-c:\opt\consul\nomad run nginx_kill.nmd  && c:\opt\consul\nomad stop -yes -purge nginx_kill
+del /f groupid
\ No newline at end of file
diff --git a/tests/automatic/bug_fixes/consumer_python_memleak/CMakeLists.txt b/tests/automatic/bug_fixes/consumer_python_memleak/CMakeLists.txt
index 352d76a2b..f269003b5 100644
--- a/tests/automatic/bug_fixes/consumer_python_memleak/CMakeLists.txt
+++ b/tests/automatic/bug_fixes/consumer_python_memleak/CMakeLists.txt
@@ -1,8 +1,6 @@
 set(TARGET_NAME consumer_python_memleak)
 
 
-prepare_asapo()
-
 if (UNIX)
     get_target_property(PYTHON_LIBS python-lib-consumer BINARY_DIR)
 else()
diff --git a/tests/automatic/bug_fixes/consumer_python_memleak/check_linux.sh b/tests/automatic/bug_fixes/consumer_python_memleak/check_linux.sh
index f06e41550..8b10f8421 100644
--- a/tests/automatic/bug_fixes/consumer_python_memleak/check_linux.sh
+++ b/tests/automatic/bug_fixes/consumer_python_memleak/check_linux.sh
@@ -13,21 +13,12 @@ token=$ASAPO_TEST_RW_TOKEN
 Cleanup() {
     echo cleanup
     rm -rf $fname
-    nomad stop nginx
-    nomad run nginx_kill.nmd  && nomad stop -yes -purge nginx_kill
-    nomad stop broker
-    nomad stop discovery
     echo "db.dropDatabase()" | mongo ${beamtime_id}_stream
 }
 
 fname=test.dat
 size=100000000 # 10MB
 
-nomad run nginx.nmd
-nomad run discovery.nmd
-nomad run broker.nmd
-
-sleep 1
 
 echo 'db.data_default.insert({"_id":'1',"size":'$size',"name":"'$fname'","timestamp":1,"source":"none","buf_id":0,"dataset_substream":0,"meta":{}})' | mongo ${beamtime_id}_stream
 dd if=/dev/zero of=$fname bs=$size count=1
diff --git a/tests/automatic/bug_fixes/error-sending-data-using-callback-method/CMakeLists.txt b/tests/automatic/bug_fixes/error-sending-data-using-callback-method/CMakeLists.txt
index 08bd8372e..5ce9b9f96 100644
--- a/tests/automatic/bug_fixes/error-sending-data-using-callback-method/CMakeLists.txt
+++ b/tests/automatic/bug_fixes/error-sending-data-using-callback-method/CMakeLists.txt
@@ -3,9 +3,6 @@ set(TARGET_NAME bugfix_callback)
 ################################
 # Testing
 ################################
-prepare_asapo()
-
-prepare_asapo()
 
 if (UNIX)
     get_target_property(PYTHON_LIBS python-lib-producer BINARY_DIR)
diff --git a/tests/automatic/bug_fixes/error-sending-data-using-callback-method/bugfix_callback.py b/tests/automatic/bug_fixes/error-sending-data-using-callback-method/bugfix_callback.py
index c0858795a..485410e11 100644
--- a/tests/automatic/bug_fixes/error-sending-data-using-callback-method/bugfix_callback.py
+++ b/tests/automatic/bug_fixes/error-sending-data-using-callback-method/bugfix_callback.py
@@ -28,6 +28,8 @@ class AsapoSender:
 producer  = asapo_producer.create_producer(endpoint,'processed',beamtime,'auto', data_source, token, nthreads, 600000)
 producer.set_log_level("debug")
 
+print(asapo_producer.__version__)
+
 sender = AsapoSender(producer)
 
 meta={}
diff --git a/tests/automatic/bug_fixes/error-sending-data-using-callback-method/check_linux.sh b/tests/automatic/bug_fixes/error-sending-data-using-callback-method/check_linux.sh
index 09e978362..c52598140 100644
--- a/tests/automatic/bug_fixes/error-sending-data-using-callback-method/check_linux.sh
+++ b/tests/automatic/bug_fixes/error-sending-data-using-callback-method/check_linux.sh
@@ -16,23 +16,13 @@ receiver_folder=${receiver_root_folder}/${facility}/gpfs/${beamline}/${year}/dat
 Cleanup() {
 	echo cleanup
 	rm -rf ${receiver_root_folder}
-    nomad stop receiver >/dev/null
-    nomad stop discovery >/dev/null
-    nomad stop authorizer >/dev/null
-    nomad stop nginx >/dev/null
-    nomad run nginx_kill.nmd  && nomad stop -yes -purge nginx_kill > /dev/null
-    echo "db.dropDatabase()" | mongo ${beamtime_id}_${data_source} >/dev/null
+  echo "db.dropDatabase()" | mongo ${beamtime_id}_${data_source} >/dev/null
 }
 
 export PYTHONPATH=$2:${PYTHONPATH}
 
 echo "db.${beamtime_id}_${data_source}.insert({dummy:1})" | mongo ${beamtime_id}_${data_source} >/dev/null
 
-nomad run authorizer.nmd >/dev/null
-nomad run nginx.nmd >/dev/null
-nomad run receiver_tcp.nmd >/dev/null
-nomad run discovery.nmd >/dev/null
-
 mkdir -p ${receiver_folder}
 
 echo test > file1
diff --git a/tests/automatic/bug_fixes/producer_send_after_restart/CMakeLists.txt b/tests/automatic/bug_fixes/producer_send_after_restart/CMakeLists.txt
index e974aa40b..08fb1205f 100644
--- a/tests/automatic/bug_fixes/producer_send_after_restart/CMakeLists.txt
+++ b/tests/automatic/bug_fixes/producer_send_after_restart/CMakeLists.txt
@@ -13,4 +13,4 @@ endif()
 
 configure_file(test.json.in test.json @ONLY)
 
-add_script_test("${TARGET_NAME}-tcp" "$<TARGET_FILE:event-monitor-producer-bin> $<TARGET_FILE:getnext> $<TARGET_PROPERTY:asapo,EXENAME> tcp" nomem)
+add_script_test("${TARGET_NAME}-tcp" "$<TARGET_FILE:event-monitor-producer-bin> $<TARGET_FILE:getnext> $<TARGET_PROPERTY:asapo,EXENAME>" nomem)
diff --git a/tests/automatic/bug_fixes/producer_send_after_restart/check_linux.sh b/tests/automatic/bug_fixes/producer_send_after_restart/check_linux.sh
index ea36e9886..038868ae5 100644
--- a/tests/automatic/bug_fixes/producer_send_after_restart/check_linux.sh
+++ b/tests/automatic/bug_fixes/producer_send_after_restart/check_linux.sh
@@ -7,7 +7,6 @@ trap Cleanup EXIT
 producer_bin=$1
 consumer_bin=$2
 asapo_tool_bin=$3
-network_type=$4
 
 beamtime_id=asapo_test
 
@@ -27,19 +26,9 @@ Cleanup() {
     echo cleanup
     rm -rf ${receiver_root_folder}
     rm -rf /tmp/asapo/test_in
-    nomad stop nginx
-    nomad run nginx_kill.nmd  && nomad stop -yes -purge nginx_kill
-    nomad stop receiver
-    nomad stop discovery
-    nomad stop authorizer
     echo "db.dropDatabase()" | mongo ${beamtime_id}_detector
 }
 
-nomad run nginx.nmd
-nomad run authorizer.nmd
-nomad run receiver_${network_type}.nmd
-nomad run discovery.nmd
-
 sleep 1
 mkdir  /tmp/asapo/test_in/processed
 #producer
@@ -53,7 +42,7 @@ echo hello > /tmp/asapo/test_in/processed/file1
 sleep 1
 nomad stop receiver
 sleep 1
-nomad run receiver_${network_type}.nmd
+nomad run receiver_tcp.nmd
 
 echo hello > /tmp/asapo/test_in/processed/file1
 sleep 1
diff --git a/tests/automatic/bug_fixes/producer_send_after_restart/check_windows.bat b/tests/automatic/bug_fixes/producer_send_after_restart/check_windows.bat
index b039195e0..986a5506e 100644
--- a/tests/automatic/bug_fixes/producer_send_after_restart/check_windows.bat
+++ b/tests/automatic/bug_fixes/producer_send_after_restart/check_windows.bat
@@ -1,5 +1,3 @@
-
-
 SET mongo_exe="c:\Program Files\MongoDB\Server\4.2\bin\mongo.exe"
 SET beamtime_id=asapo_test
 SET beamline=test
@@ -12,8 +10,6 @@ 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
-
 "%3" token -endpoint http://127.0.0.1:8400/asapo-authorizer -secret admin_token.key -types read %beamtime_id% > token
 set /P token=< token
 
@@ -46,8 +42,6 @@ call :clean
 exit /b 1
 
 :clean
-call stop_services.bat
-
 rmdir /S /Q %receiver_root_folder%
 rmdir /S /Q c:\tmp\asapo\test_in
 Taskkill /IM "%producer_short_name%" /F
diff --git a/tests/automatic/bug_fixes/python_deadlock/CMakeLists.txt b/tests/automatic/bug_fixes/python_deadlock/CMakeLists.txt
index b4007ef63..b2d5a3ccf 100644
--- a/tests/automatic/bug_fixes/python_deadlock/CMakeLists.txt
+++ b/tests/automatic/bug_fixes/python_deadlock/CMakeLists.txt
@@ -1,8 +1,6 @@
 set(TARGET_NAME python_deadlock_producer)
 
 
-prepare_asapo()
-
 find_package (Python3 REQUIRED)
 
 if (UNIX)
diff --git a/tests/automatic/bug_fixes/receiver_cpu_usage/CMakeLists.txt b/tests/automatic/bug_fixes/receiver_cpu_usage/CMakeLists.txt
index 15daad97f..f566fedf0 100644
--- a/tests/automatic/bug_fixes/receiver_cpu_usage/CMakeLists.txt
+++ b/tests/automatic/bug_fixes/receiver_cpu_usage/CMakeLists.txt
@@ -3,7 +3,6 @@ set(TARGET_NAME receiver_cpu_usage)
 ################################
 # Testing
 ################################
-prepare_asapo()
 set (ROOT_PATH "/tmp/asapo/")
 
 configure_file(test.json.in test.json @ONLY)
diff --git a/tests/automatic/bug_fixes/receiver_cpu_usage/check_linux.sh b/tests/automatic/bug_fixes/receiver_cpu_usage/check_linux.sh
index 8877ee587..0d74d4cdd 100644
--- a/tests/automatic/bug_fixes/receiver_cpu_usage/check_linux.sh
+++ b/tests/automatic/bug_fixes/receiver_cpu_usage/check_linux.sh
@@ -23,21 +23,9 @@ Cleanup() {
     kill $producerid
     rm -rf /tmp/asapo/test_in/test1
     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 authorizer
     echo "db.dropDatabase()" | mongo ${beamtime_id}_detector
 }
 
-nomad run nginx.nmd
-nomad run authorizer.nmd
-nomad run receiver_tcp.nmd
-nomad run discovery.nmd
-
-sleep 1
-
 #producer
 mkdir -p ${receiver_folder}
 $1 test.json &
diff --git a/tests/automatic/bug_fixes/streamlist_python_multithread/CMakeLists.txt b/tests/automatic/bug_fixes/streamlist_python_multithread/CMakeLists.txt
index 704002fc8..e61d987ed 100644
--- a/tests/automatic/bug_fixes/streamlist_python_multithread/CMakeLists.txt
+++ b/tests/automatic/bug_fixes/streamlist_python_multithread/CMakeLists.txt
@@ -1,11 +1,8 @@
 set(TARGET_NAME streamlist_python)
 
 
-prepare_asapo()
-
 find_package (Python3 REQUIRED)
 
-
 if (UNIX)
     get_target_property(PYTHON_LIBS python-lib-consumer BINARY_DIR)
     get_target_property(PYTHON_LIBS_PRODUCER python-lib-producer BINARY_DIR)
diff --git a/tests/automatic/bug_fixes/streamlist_python_multithread/check_linux.sh b/tests/automatic/bug_fixes/streamlist_python_multithread/check_linux.sh
index 678925935..51ab3ef4c 100644
--- a/tests/automatic/bug_fixes/streamlist_python_multithread/check_linux.sh
+++ b/tests/automatic/bug_fixes/streamlist_python_multithread/check_linux.sh
@@ -9,24 +9,10 @@ token=$ASAPO_TEST_RW_TOKEN
 
 Cleanup() {
     echo cleanup
-    nomad stop nginx
-    nomad run nginx_kill.nmd  && nomad stop -yes -purge nginx_kill
-    nomad stop broker
-    nomad stop discovery
-    nomad stop authorizer
-    nomad stop receiver
     echo "db.dropDatabase()" | mongo ${beamtime_id}_source_1
     echo "db.dropDatabase()" | mongo ${beamtime_id}_source_2
 }
 
-nomad run nginx.nmd
-nomad run discovery.nmd
-nomad run broker.nmd
-nomad run receiver_tcp.nmd
-nomad run authorizer.nmd
-
-sleep 1
-
 export PYTHONPATH=$1:$2:${PYTHONPATH}
 export Python3_EXECUTABLE=$3
 
diff --git a/tests/automatic/common_scripts/CMakeLists.txt b/tests/automatic/common_scripts/CMakeLists.txt
new file mode 100644
index 000000000..788be8b54
--- /dev/null
+++ b/tests/automatic/common_scripts/CMakeLists.txt
@@ -0,0 +1,9 @@
+prepare_asapo()
+
+IF (WIN32)
+    configure_file(start_services.bat start_services.bat @ONLY)
+    configure_file(stop_services.bat stop_services.bat @ONLY)
+ELSE ()
+    configure_file(start_services.sh start_services.sh @ONLY)
+    configure_file(stop_services.sh stop_services.sh @ONLY)
+ENDIF()
diff --git a/tests/automatic/common_scripts/start_services.sh b/tests/automatic/common_scripts/start_services.sh
index e69de29bb..566fe3dfc 100644
--- a/tests/automatic/common_scripts/start_services.sh
+++ b/tests/automatic/common_scripts/start_services.sh
@@ -0,0 +1,21 @@
+nomad run receiver_tcp.nmd
+nomad run authorizer.nmd
+nomad run discovery.nmd
+nomad run broker.nmd
+nomad run nginx.nmd
+nomad run file_transfer.nmd
+
+while true
+do
+  sleep 1
+  echo starting services
+  curl --silent 127.0.0.1:8400/asapo-discovery/v0.1/asapo-receiver?protocol=v0.1 --stderr - | grep 127.0.0.1  || continue
+  echo nginx,discovery, recevier started
+  curl --silent 127.0.0.1:8400/asapo-discovery/v0.1/asapo-broker?protocol=v0.1 --stderr - | grep 127.0.0.1 || continue
+  echo broker started
+  curl --silent 127.0.0.1:8400/asapo-discovery/v0.1/asapo-file-transfer?protocol=v0.1 --stderr -  | grep 127.0.0.1 || continue
+  echo file transfer started
+  break
+done
+
+echo services ready
\ No newline at end of file
diff --git a/tests/automatic/common_scripts/stop_services.sh b/tests/automatic/common_scripts/stop_services.sh
index e69de29bb..d10019f51 100644
--- a/tests/automatic/common_scripts/stop_services.sh
+++ b/tests/automatic/common_scripts/stop_services.sh
@@ -0,0 +1,7 @@
+nomad stop nginx
+nomad run nginx_kill.nmd  && nomad stop -yes -purge nginx_kill
+nomad stop discovery
+nomad stop broker
+nomad stop receiver
+nomad stop authorizer
+nomad stop file_transfer
diff --git a/tests/automatic/settings/authorizer_settings.json.tpl.lin b/tests/automatic/settings/authorizer_settings.json.tpl.lin
index 62e187d4e..0980b029a 100644
--- a/tests/automatic/settings/authorizer_settings.json.tpl.lin
+++ b/tests/automatic/settings/authorizer_settings.json.tpl.lin
@@ -1,6 +1,8 @@
 {
   "Port": {{ env "NOMAD_PORT_authorizer" }},
   "LogLevel":"debug",
+  "RootBeamtimesFolder":"/tmp/asapo/asap3",
+  "CurrentBeamlinesFolder":"/tmp/asapo/beamline",
   "AlwaysAllowedBeamtimes":[{"beamtimeId":"asapo_test","beamline":"test","corePath":"/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","corePath":"/tmp/asapo/receiver/files/test_facility/gpfs/test1/2019/data/asapo_test1"},
diff --git a/tests/automatic/settings/authorizer_settings.json.tpl.win b/tests/automatic/settings/authorizer_settings.json.tpl.win
index 810ad2e5a..a34aeee04 100644
--- a/tests/automatic/settings/authorizer_settings.json.tpl.win
+++ b/tests/automatic/settings/authorizer_settings.json.tpl.win
@@ -1,6 +1,8 @@
 {
   "Port": {{ env "NOMAD_PORT_authorizer" }},
   "LogLevel":"debug",
+  "RootBeamtimesFolder":"c:\\tmp\\asapo\\asap3",
+  "CurrentBeamlinesFolder":"c:\\tmp\\asapo\\beamline",
   "AlwaysAllowedBeamtimes":[{"beamtimeId":"asapo_test","beamline":"test","corePath":"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","corePath":"c:\\tmp\\asapo\\receiver\\files\\test_facility\\gpfs\\test1\\2019\\data\\asapo_test1"},
-- 
GitLab