@@ -10,6 +10,10 @@ setup_file() {
10
10
create_user ' alice'
11
11
}
12
12
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
+
13
17
@test " notifications: list stateful transactions" {
14
18
btc_wallet_name=" alice.btc_wallet_id"
15
19
amount=" 0.01"
@@ -81,10 +85,44 @@ setup_file() {
81
85
}
82
86
83
87
@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 "
88
127
89
- # execute a trivial marketing notification
90
128
}
0 commit comments