From a8aee5312b8650cd283fb7d469e9b0fb1de220cc Mon Sep 17 00:00:00 2001 From: Ro'e Katz Date: Thu, 15 Aug 2024 12:59:20 +0300 Subject: [PATCH] Test statistics as well --- app-tests/run.sh | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/app-tests/run.sh b/app-tests/run.sh index 873b5766..fd782373 100755 --- a/app-tests/run.sh +++ b/app-tests/run.sh @@ -8,7 +8,7 @@ export OPAL_CLIENT_TOKEN export OPAL_DATA_SOURCE_TOKEN function generate_opal_keys { - echo "generating OPAL keys" + echo "- Generating OPAL keys" ssh-keygen -q -t rsa -b 4096 -m pem -f opal_crypto_key -N "" OPAL_AUTH_PUBLIC_KEY="$(cat opal_crypto_key.pub)" @@ -23,7 +23,7 @@ function generate_opal_keys { pkill opal sleep 5; - echo "create .env file" + echo "- Create .env file" rm -f .env ( echo "OPAL_AUTH_PUBLIC_KEY=\"$OPAL_AUTH_PUBLIC_KEY\""; @@ -35,7 +35,7 @@ function generate_opal_keys { } function prepare_policy_repo { - echo "clone tests policy repo to create test's branch" + echo "- Clone tests policy repo to create test's branch" export POLICY_REPO_BRANCH POLICY_REPO_BRANCH=test-$RANDOM$RANDOM rm -rf ./opal-tests-policy-repo @@ -66,7 +66,7 @@ function check_clients_logged { function check_no_error { # Without index would output all replicas if compose logs opal_client | grep -q 'ERROR'; then - echo "Found error in logs" + echo "- Found error in logs" exit 1 fi } @@ -121,10 +121,17 @@ function test_data_publish { check_clients_logged "PUT /v1/data/users/$user/location -> 204" } +function test_statistics { + echo "- Testing statistics feature" + # Make sure 2 servers & 2 clients (repeat few times cause different workers might response) + for _ in {1..10}; do + curl localhost:7002/stats | grep '"client_count":2,"server_count":2' + done +} + test_data_publish "bob" test_push_policy "something" - -# TODO: Test statistic +test_statistics echo "- Testing broadcast channel disconnection" compose restart broadcast_channel @@ -132,7 +139,7 @@ sleep 10 test_data_publish "alice" test_push_policy "another" - test_data_publish "sunil" test_data_publish "eve" test_push_policy "best_one_yet" +# TODO: Test statistics feature again after broadcaster restart (should first fix statistics bug)