-
Notifications
You must be signed in to change notification settings - Fork 334
FS-51 Report unavailable clients for Proteus messages #3097
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
08547d1
96e3a46
fa2c871
c1d3b77
90d6bc4
7c168a6
db81b2f
3209933
f21d92d
cb91824
e66a9cb
175fbfb
47cafd2
752e1f5
3b95fb5
eab18a6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Report federated Proteus message sending errors to clients |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -220,6 +220,7 @@ tests s = | |
| test s "post message qualified - local owning backend - redundant and deleted clients" postMessageQualifiedLocalOwningBackendRedundantAndDeletedClients, | ||
| test s "post message qualified - local owning backend - ignore missing" postMessageQualifiedLocalOwningBackendIgnoreMissingClients, | ||
| test s "post message qualified - local owning backend - failed to send clients" postMessageQualifiedLocalOwningBackendFailedToSendClients, | ||
| test s "post message qualified - local owning backend - failed to send clients 2" postMessageQualifiedLocalOwningBackendFailedToSendClients2, | ||
|
mdimjasevic marked this conversation as resolved.
Outdated
|
||
| test s "post message qualified - remote owning backend - federation failure" postMessageQualifiedRemoteOwningBackendFailure, | ||
| test s "post message qualified - remote owning backend - success" postMessageQualifiedRemoteOwningBackendSuccess, | ||
| test s "join conversation" postJoinConvOk, | ||
|
|
@@ -1148,6 +1149,85 @@ postMessageQualifiedLocalOwningBackendFailedToSendClients = do | |
| WS.assertMatch_ t wsBob (wsAssertOtr' encodedData convId aliceOwningDomain aliceClient bobClient encodedTextForBob) | ||
| WS.assertMatch_ t wsChad (wsAssertOtr' encodedData convId aliceOwningDomain aliceClient chadClient encodedTextForChad) | ||
|
|
||
| -- This test is similar to postMessageQualifiedLocalOwningBackendFailedToSendClients | ||
| -- except that both of the calls to the federated server are failing. | ||
| postMessageQualifiedLocalOwningBackendFailedToSendClients2 :: TestM () | ||
| postMessageQualifiedLocalOwningBackendFailedToSendClients2 = do | ||
| -- WS receive timeout | ||
| let t = 5 # Second | ||
| -- Cannon for local users | ||
| cannon <- view tsCannon | ||
| -- Domain which owns the converstaion | ||
| owningDomain <- viewFederationDomain | ||
|
|
||
| (aliceOwningDomain, aliceClient) <- randomUserWithClientQualified (head someLastPrekeys) | ||
| (bobOwningDomain, bobClient) <- randomUserWithClientQualified (someLastPrekeys !! 1) | ||
| bobClient2 <- randomClient (qUnqualified bobOwningDomain) (someLastPrekeys !! 2) | ||
| (chadOwningDomain, chadClient) <- randomUserWithClientQualified (someLastPrekeys !! 3) | ||
| deeId <- randomId | ||
| deeClient <- liftIO $ generate arbitrary | ||
| let remoteDomain = Domain "far-away.example.com" | ||
| deeRemote = Qualified deeId remoteDomain | ||
|
|
||
| let aliceUnqualified = qUnqualified aliceOwningDomain | ||
| bobUnqualified = qUnqualified bobOwningDomain | ||
| chadUnqualified = qUnqualified chadOwningDomain | ||
|
|
||
| connectLocalQualifiedUsers aliceUnqualified (list1 bobOwningDomain [chadOwningDomain]) | ||
| connectWithRemoteUser aliceUnqualified deeRemote | ||
|
|
||
| -- FUTUREWORK: Do this test with more than one remote domains | ||
| resp <- | ||
| postConvWithRemoteUsers | ||
| aliceUnqualified | ||
| defNewProteusConv {newConvQualifiedUsers = [bobOwningDomain, chadOwningDomain, deeRemote]} | ||
| let convId = (`Qualified` owningDomain) . decodeConvId $ resp | ||
|
|
||
| WS.bracketR2 cannon bobUnqualified chadUnqualified $ \(wsBob, wsChad) -> do | ||
| let message = | ||
| [ (bobOwningDomain, bobClient, "text-for-bob"), | ||
| (bobOwningDomain, bobClient2, "text-for-bob2"), | ||
| (chadOwningDomain, chadClient, "text-for-chad"), | ||
| (deeRemote, deeClient, "text-for-dee") | ||
| ] | ||
|
|
||
| let mock = | ||
| ( guardRPC "get-user-clients" | ||
| *> throw (MockErrorResponse HTTP.status503 "Down for maintenance.") | ||
| ) | ||
| <|> ( guardRPC "on-message-sent" | ||
| *> throw (MockErrorResponse HTTP.status503 "Down for maintenance.") | ||
| ) | ||
|
|
||
| (resp2, _requests) <- withTempMockFederator' mock $ | ||
| postProteusMessageQualified | ||
| aliceUnqualified | ||
| aliceClient | ||
| convId | ||
| message | ||
| "data" | ||
| Message.MismatchReportAll | ||
|
|
||
| let expectedFailedToSend = | ||
| QualifiedUserClients . Map.fromList $ | ||
| [ ( remoteDomain, | ||
| Map.fromList | ||
| [ (deeId, Set.singleton deeClient) | ||
| ] | ||
| ) | ||
| ] | ||
| expectedRedundant = expectedFailedToSend | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is due to other tests expecting redundant clients under similar circumstances. If I add code to filter out users from the redundant field those tests will fail.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, but I still don't understand why. It would also be beneficial for your understanding to get to the bottom of it. |
||
| pure resp2 !!! do | ||
| const 201 === statusCode | ||
| assertMismatchQualified expectedFailedToSend mempty expectedRedundant mempty | ||
|
|
||
| liftIO $ do | ||
| let encodedTextForBob = toBase64Text "text-for-bob" | ||
| encodedTextForChad = toBase64Text "text-for-chad" | ||
| encodedData = toBase64Text "data" | ||
| WS.assertMatch_ t wsBob (wsAssertOtr' encodedData convId aliceOwningDomain aliceClient bobClient encodedTextForBob) | ||
| WS.assertMatch_ t wsChad (wsAssertOtr' encodedData convId aliceOwningDomain aliceClient chadClient encodedTextForChad) | ||
|
|
||
| postMessageQualifiedRemoteOwningBackendFailure :: TestM () | ||
| postMessageQualifiedRemoteOwningBackendFailure = do | ||
| (aliceLocal, aliceClient) <- randomUserWithClientQualified (head someLastPrekeys) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.