Skip to content

Commit

Permalink
Test statistics as well
Browse files Browse the repository at this point in the history
  • Loading branch information
roekatz committed Aug 15, 2024
1 parent b28e568 commit a8aee53
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions app-tests/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand All @@ -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\"";
Expand All @@ -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
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -121,18 +121,25 @@ 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
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)

0 comments on commit a8aee53

Please sign in to comment.