mirror of
https://github.com/unclechu/gRPC-haskell.git
synced 2024-11-23 03:29:42 +01:00
Upgrade nix grpc version to 1.0.1 + fix tests (#86)
* Use GRPC v1.01 (grpc-1.0.1-6040b47) * Minor tweaks to GRPC request result processing (less exact matching on some StatusDetails due to GRPC rev bump)
This commit is contained in:
parent
89a5547dc0
commit
24681a619b
3 changed files with 12 additions and 20 deletions
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
function purge_grpc {
|
function purge_grpc {
|
||||||
|
|
|
@ -3,12 +3,12 @@
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
stdenv.mkDerivation rec {
|
||||||
name = "grpc-${version}";
|
name = "grpc-${version}";
|
||||||
version = "0.15-${lib.strings.substring 0 7 rev}";
|
version = "1.0.1-${lib.strings.substring 0 7 rev}";
|
||||||
rev = "03efbd34ce64615f58007eae667b375accc6c8e6";
|
rev = "6040b471bcd1d6bb05b25c126b6545180a1d3528";
|
||||||
src = fetchgit {
|
src = fetchgit {
|
||||||
inherit rev;
|
inherit rev;
|
||||||
url = "https://github.com/grpc/grpc.git";
|
url = "https://github.com/grpc/grpc.git";
|
||||||
sha256 = "0a48swsip09bd0yk80gl9r7pny9dal3byyd22bdz4fcvydna43m0";
|
sha256 = "1kx6jkx2dnnfnjfyc50ravfk7mfdszj988vndrlzs1zkd6627k4z";
|
||||||
};
|
};
|
||||||
preInstall = "export prefix";
|
preInstall = "export prefix";
|
||||||
buildInputs =
|
buildInputs =
|
||||||
|
|
|
@ -244,9 +244,7 @@ testAuthMetadataTransfer =
|
||||||
let authCtx = (channelAuthContext authMetaCtx)
|
let authCtx = (channelAuthContext authMetaCtx)
|
||||||
|
|
||||||
addAuthProperty authCtx (AuthProperty "foo1" "bar1")
|
addAuthProperty authCtx (AuthProperty "foo1" "bar1")
|
||||||
print "getting properties"
|
|
||||||
newProps <- getAuthProperties authCtx
|
newProps <- getAuthProperties authCtx
|
||||||
print "got properties"
|
|
||||||
let addedProp = find ((== "foo1") . authPropName) newProps
|
let addedProp = find ((== "foo1") . authPropName) newProps
|
||||||
addedProp @?= Just (AuthProperty "foo1" "bar1")
|
addedProp @?= Just (AuthProperty "foo1" "bar1")
|
||||||
return $ ClientMetadataCreateResult [("foo","bar")] StatusOk ""
|
return $ ClientMetadataCreateResult [("foo","bar")] StatusOk ""
|
||||||
|
@ -620,13 +618,13 @@ testGoaway =
|
||||||
rm <- clientRegisterMethodNormal c "/foo"
|
rm <- clientRegisterMethodNormal c "/foo"
|
||||||
clientRequest c rm 10 "" mempty
|
clientRequest c rm 10 "" mempty
|
||||||
clientRequest c rm 10 "" mempty
|
clientRequest c rm 10 "" mempty
|
||||||
lastResult <- clientRequest c rm 1 "" mempty
|
eer <- clientRequest c rm 1 "" mempty
|
||||||
assertBool "Client handles server shutdown gracefully" $
|
assertBool "Client handles server shutdown gracefully" $ case eer of
|
||||||
lastResult == badStatus StatusUnavailable
|
Left (GRPCIOBadStatusCode StatusUnavailable _) -> True
|
||||||
||
|
Left (GRPCIOBadStatusCode StatusDeadlineExceeded "Deadline Exceeded") -> True
|
||||||
lastResult == badStatus StatusDeadlineExceeded
|
Left GRPCIOTimeout -> True
|
||||||
||
|
_ -> False
|
||||||
lastResult == Left GRPCIOTimeout
|
|
||||||
server s = do
|
server s = do
|
||||||
let rm = head (normalMethods s)
|
let rm = head (normalMethods s)
|
||||||
serverHandleNormalCall s rm mempty dummyHandler
|
serverHandleNormalCall s rm mempty dummyHandler
|
||||||
|
@ -640,7 +638,7 @@ testSlowServer =
|
||||||
client c = do
|
client c = do
|
||||||
rm <- clientRegisterMethodNormal c "/foo"
|
rm <- clientRegisterMethodNormal c "/foo"
|
||||||
result <- clientRequest c rm 1 "" mempty
|
result <- clientRequest c rm 1 "" mempty
|
||||||
result @?= badStatus StatusDeadlineExceeded
|
result @?= Left (GRPCIOBadStatusCode StatusDeadlineExceeded "Deadline Exceeded")
|
||||||
server s = do
|
server s = do
|
||||||
let rm = head (normalMethods s)
|
let rm = head (normalMethods s)
|
||||||
serverHandleNormalCall s rm mempty $ \_ -> do
|
serverHandleNormalCall s rm mempty $ \_ -> do
|
||||||
|
@ -789,12 +787,6 @@ dummyResult' :: StatusDetails
|
||||||
-> IO (ByteString, MetadataMap, StatusCode, StatusDetails)
|
-> IO (ByteString, MetadataMap, StatusCode, StatusDetails)
|
||||||
dummyResult' = return . (mempty, mempty, StatusOk, )
|
dummyResult' = return . (mempty, mempty, StatusOk, )
|
||||||
|
|
||||||
badStatus :: StatusCode -> Either GRPCIOError a
|
|
||||||
badStatus st = Left . GRPCIOBadStatusCode st $ case st of
|
|
||||||
StatusDeadlineExceeded -> "Deadline Exceeded"
|
|
||||||
StatusCancelled -> "Received RST_STREAM err=8"
|
|
||||||
_ -> mempty
|
|
||||||
|
|
||||||
nop :: Monad m => a -> m ()
|
nop :: Monad m => a -> m ()
|
||||||
nop = const (return ())
|
nop = const (return ())
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue