Skip to content

Commit 4e4af14

Browse files
test(notifications): impl load test
1 parent 7458467 commit 4e4af14

File tree

1 file changed

+43
-5
lines changed

1 file changed

+43
-5
lines changed

bats/core/notifications/notifications.bats

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ setup_file() {
1010
create_user 'alice'
1111
}
1212

13+
NOTIFICATIONS_GRPC_ENDPOINT="localhost:6685"
14+
IMPORT_PATH="${REPO_ROOT}/core/notifications/proto"
15+
NOTIFICATIONS_PROTO_FILE="${REPO_ROOT}/core/notifications/proto/notifications.proto"
16+
1317
@test "notifications: list stateful transactions" {
1418
btc_wallet_name="alice.btc_wallet_id"
1519
amount="0.01"
@@ -81,10 +85,44 @@ setup_file() {
8185
}
8286

8387
@test "notifications: load test" {
84-
for in $(seq 1 100); do
85-
# create 100000 users
86-
# And update their language to spanish
87-
done
88+
update_user_locale_method="services.notifications.v1.NotificationsService/UpdateUserLocale"
89+
90+
declare -a user_ids
91+
92+
for i in $(seq 1 10000); do
93+
94+
create_user "user_$i"
95+
exec_graphql "user_$i" 'identity'
96+
user_id="$(graphql_output '.data.me.id')"
97+
user_ids+=("$user_id")
98+
99+
request_data=$(jq -n --arg userId "$user_id" --arg locale "es" '{
100+
"userId": $userId,
101+
"locale": $locale
102+
}')
103+
grpcurl_request $IMPORT_PATH $NOTIFICATIONS_PROTO_FILE $NOTIFICATIONS_GRPC_ENDPOINT "$update_user_locale_method" "$request_data"
104+
105+
done
106+
107+
localized_content_en='{"title": "Hello", "body": "World"}'
108+
localized_content_es='{"title": "Hola", "body": "World"}'
109+
request_data=$(jq -n \
110+
--arg user_ids "$user_ids[@]" \
111+
--argjson localized_content_en "$localized_content_en" \
112+
--argjson localized_content_es "$localized_content_es" \
113+
'{
114+
"event": {
115+
"marketingNotificationTriggered": {
116+
"user_ids": $user_ids,
117+
"localized_push_content": {
118+
"en": $localized_content_en,
119+
"es": $localized_content_es
120+
}
121+
}
122+
}
123+
}')
124+
125+
handle_notification_event_method="services.notifications.v1.NotificationsService/HandleNotificationEvent"
126+
grpcurl_request $IMPORT_PATH $NOTIFICATIONS_PROTO_FILE $NOTIFICATIONS_GRPC_ENDPOINT "$handle_notification_event_method" "$request_data"
88127

89-
# execute a trivial marketing notification
90128
}

0 commit comments

Comments
 (0)