From 99f248a8ceb24efd2765cd8cfa56a77bfd60b643 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Wed, 14 Dec 2022 18:08:03 +0100 Subject: [PATCH] Tests[SendParallel] (skipped for now) --- server/test/send_test.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/server/test/send_test.go b/server/test/send_test.go index 571b520..cc440eb 100644 --- a/server/test/send_test.go +++ b/server/test/send_test.go @@ -1341,6 +1341,42 @@ func TestQuotaExceededPro(t *testing.T) { }, 403, apierr.QUOTA_REACHED) } +func TestSendParallel(t *testing.T) { + t.SkipNow() + + _, baseUrl, stop := tt.StartSimpleWebserver(t) + defer stop() + + r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{ + "agent_model": "DUMMY_PHONE", + "agent_version": "4X", + "client_type": "ANDROID", + "fcm_token": "DUMMY_FCM", + "pro_token": "ANDROID|v2|PURCHASED:DUMMY_TOK_XX", + }) + + uid := int(r0["user_id"].(float64)) + sendtok := r0["send_key"].(string) + + sem := make(chan tt.Void, 900) // semaphore pattern + for i := 0; i < 900; i++ { + go func() { + defer func() { + sem <- tt.Void{} + }() + tt.RequestPost[gin.H](t, baseUrl, "/", gin.H{ + "user_key": sendtok, + "user_id": uid, + "title": tt.ShortLipsum0(2), + }) + }() + } + // wait for goroutines to finish + for i := 0; i < 900; i++ { + <-sem + } +} + //TODO post to foreign channel via send-key //TODO quota exceed (+ quota counter)