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

started refactoring tests

parent 19c06593
No related branches found
No related tags found
No related merge requests found
Showing
with 95 additions and 222 deletions
CMAKE_MINIMUM_REQUIRED(VERSION 3.7) # needed for fixtures
find_package(Threads)
add_subdirectory(common_scripts)
add_subdirectory(common/cpp)
add_subdirectory(system_io)
......
......@@ -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
)
......@@ -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
......@@ -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
{
"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
......@@ -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)
......@@ -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]
......@@ -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)
......@@ -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
......@@ -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
......@@ -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)
......@@ -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'
......@@ -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
......@@ -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)
......@@ -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
......@@ -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
set(TARGET_NAME consumer_python_memleak)
prepare_asapo()
if (UNIX)
get_target_property(PYTHON_LIBS python-lib-consumer BINARY_DIR)
else()
......
......@@ -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
......
......@@ -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)
......
......@@ -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={}
......
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