-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The problem is fixed in latest `http2` (`7036a3429fb08bfcd5947230c37d1f3e63dfb3a6`). See kazu-yamamoto/http2#151 for the `http2` bug report. Closes #257.
- Loading branch information
Showing
4 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
module Test.Sanity.Reclamation (tests) where | ||
|
||
import Control.Exception | ||
import Control.Monad | ||
import Test.Tasty | ||
import Test.Tasty.HUnit | ||
|
||
import Network.GRPC.Client qualified as Client | ||
import Network.GRPC.Common | ||
import Network.GRPC.Common.Protobuf | ||
import Network.GRPC.Server qualified as Server | ||
|
||
import Test.Driver.ClientServer | ||
|
||
import Proto.API.Ping | ||
|
||
tests :: TestTree | ||
tests = testGroup "Test.Sanity.Reclamation" [ | ||
testCase "serverException1" serverException1 | ||
, testCase "serverException2" serverException2 | ||
] | ||
|
||
{------------------------------------------------------------------------------- | ||
Server-side exception | ||
-------------------------------------------------------------------------------} | ||
|
||
-- | Handler that throws immediately | ||
brokenHandler :: Server.Call Ping -> IO () | ||
brokenHandler _call = throwIO $ DeliberateException $ userError "Broken handler" | ||
|
||
serverException1 :: Assertion | ||
serverException1 = testClientServer $ ClientServerTest { | ||
config = def | ||
, server = [Server.someRpcHandler $ Server.mkRpcHandler brokenHandler] | ||
, client = \params testServer delimitTestScope -> delimitTestScope $ | ||
replicateM_ 1000 $ do | ||
Client.withConnection params testServer $ \conn -> | ||
Client.withRPC conn def (Proxy @Ping) $ \call -> do | ||
resp <- try $ Client.recvFinalOutput call | ||
case resp of | ||
Left GrpcException{} -> return () | ||
Right _ -> assertFailure "Unexpected response" | ||
} | ||
|
||
serverException2 :: Assertion | ||
serverException2 = testClientServer $ ClientServerTest { | ||
config = def | ||
, server = [Server.someRpcHandler $ Server.mkRpcHandler brokenHandler] | ||
, client = \params testServer delimitTestScope -> delimitTestScope $ | ||
replicateM_ 1000 $ | ||
Client.withConnection params testServer $ \conn -> | ||
Client.withRPC conn def (Proxy @Ping) $ \call -> do | ||
|
||
-- The only difference between serverException1 is this line: | ||
Client.sendFinalInput call defMessage | ||
|
||
resp <- try $ Client.recvFinalOutput call | ||
case resp of | ||
Left GrpcException{} -> return () | ||
Right _ -> assertFailure "Unexpected response" | ||
} |