From 6e09678dc78558838e6412725292705ee9ecfc30 Mon Sep 17 00:00:00 2001 From: Moritz Kiefer Date: Tue, 20 Aug 2019 17:47:32 +0200 Subject: [PATCH] Upgrade nixpkgs to the latest nixpkgs-unstable (#84) * Upgrade nixpkgs to the latest nixpkgs-unstable * Bump proto3-suite --- .gitignore | 3 +++ nix/QuickCheck.nix | 16 ----------- nix/aeson.nix | 32 ---------------------- nix/cabal-doctest.nix | 10 ------- nix/grpc.nix | 6 +++-- nix/insert-ordered-containers.nix | 23 ---------------- nix/optparse-applicative.nix | 15 ----------- nix/optparse-generic.nix | 14 ---------- nix/proto3-suite.nix | 25 +++++++++--------- nix/proto3-wire.nix | 9 ++++--- nix/quickcheck-instances.nix | 22 ---------------- nix/swagger2.nix | 27 ------------------- nix/turtle.nix | 20 -------------- nixpkgs.nix | 6 ++--- release.nix | 44 +++++-------------------------- stack.yaml | 11 +++----- tests/GeneratedTests.hs | 6 ++--- tests/TestClient.hs | 22 ++++++++-------- tests/test-client.py | 18 +++++++------ tests/test-server.py | 7 +++-- 20 files changed, 67 insertions(+), 269 deletions(-) delete mode 100644 nix/QuickCheck.nix delete mode 100644 nix/aeson.nix delete mode 100644 nix/cabal-doctest.nix delete mode 100644 nix/insert-ordered-containers.nix delete mode 100644 nix/optparse-applicative.nix delete mode 100644 nix/optparse-generic.nix delete mode 100644 nix/quickcheck-instances.nix delete mode 100644 nix/swagger2.nix delete mode 100644 nix/turtle.nix diff --git a/.gitignore b/.gitignore index ad33332..05730fd 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,6 @@ examples/echo/echo-cpp/echo-server benchmarks.html result +*~ +cabal.project.local +dist-newstyle/ diff --git a/nix/QuickCheck.nix b/nix/QuickCheck.nix deleted file mode 100644 index 81c7c69..0000000 --- a/nix/QuickCheck.nix +++ /dev/null @@ -1,16 +0,0 @@ -{ mkDerivation, base, containers, deepseq, random, stdenv -, template-haskell, tf-random, transformers -}: -mkDerivation { - pname = "QuickCheck"; - version = "2.10"; - sha256 = "f6f55b798044ad985cce9c38a3d774b32811a0ffdb2066ca9ed45f32b25de7af"; - libraryHaskellDepends = [ - base containers deepseq random template-haskell tf-random - transformers - ]; - testHaskellDepends = [ base ]; - homepage = "https://github.com/nick8325/quickcheck"; - description = "Automatic testing of Haskell programs"; - license = stdenv.lib.licenses.bsd3; -} diff --git a/nix/aeson.nix b/nix/aeson.nix deleted file mode 100644 index da66e75..0000000 --- a/nix/aeson.nix +++ /dev/null @@ -1,32 +0,0 @@ -{ mkDerivation, attoparsec, base, base-compat, base-orphans -, base16-bytestring, bytestring, containers, deepseq, directory -, dlist, filepath, generic-deriving, ghc-prim, hashable -, hashable-time, HUnit, integer-logarithms, QuickCheck -, quickcheck-instances, scientific, stdenv, tagged -, template-haskell, test-framework, test-framework-hunit -, test-framework-quickcheck2, text, time, time-locale-compat -, unordered-containers, uuid-types, vector -}: -mkDerivation { - pname = "aeson"; - version = "1.1.1.0"; - sha256 = "1mkj4a09x9psmgq9sg5nz9va76756zfm97ds2gk2qpgxc7nr2dq8"; - revision = "2"; - editedCabalFile = "10bc20f8807990e71f5db74a1b7029f81f888c6f9d1c03e93883555fd1291e84"; - libraryHaskellDepends = [ - attoparsec base base-compat bytestring containers deepseq dlist - ghc-prim hashable scientific tagged template-haskell text time - time-locale-compat unordered-containers uuid-types vector - ]; - testHaskellDepends = [ - attoparsec base base-compat base-orphans base16-bytestring - bytestring containers directory dlist filepath generic-deriving - ghc-prim hashable hashable-time HUnit integer-logarithms QuickCheck - quickcheck-instances scientific tagged template-haskell - test-framework test-framework-hunit test-framework-quickcheck2 text - time time-locale-compat unordered-containers uuid-types vector - ]; - homepage = "https://github.com/bos/aeson"; - description = "Fast JSON parsing and encoding"; - license = stdenv.lib.licenses.bsd3; -} diff --git a/nix/cabal-doctest.nix b/nix/cabal-doctest.nix deleted file mode 100644 index 360c9a1..0000000 --- a/nix/cabal-doctest.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ mkDerivation, base, Cabal, directory, filepath, stdenv }: -mkDerivation { - pname = "cabal-doctest"; - version = "1.0.2"; - sha256 = "0h3wsjf2mg8kw1zvxc0f9nzchj5kzvza9z0arcyixkd9rkgqq6sa"; - libraryHaskellDepends = [ base Cabal directory filepath ]; - homepage = "https://github.com/phadej/cabal-doctest"; - description = "A Setup.hs helper for doctests running"; - license = stdenv.lib.licenses.bsd3; -} diff --git a/nix/grpc.nix b/nix/grpc.nix index 0f43b67..71861ba 100644 --- a/nix/grpc.nix +++ b/nix/grpc.nix @@ -1,4 +1,4 @@ -{ darwin, stdenv, lib, fetchgit, autoconf, automake, libtool, which, zlib +{ darwin, stdenv, lib, fetchgit, fixDarwinDylibNames, autoconf, automake, libtool, which, zlib , openssl }: @@ -12,6 +12,8 @@ stdenv.mkDerivation rec { sha256 = "19ldbjlnbc287hkaylsigm8w9fai2bjdbfxk6315kl75cq54iprr"; }; + NIX_CFLAGS_COMPILE = "-Wno-error"; + # `grpc`'s `Makefile` does some magic to detect the correct `ld` and `strip` # to use along with their flags, too. If Nix supplies `$LD` and `$STRIP` then # this auto-detection fails and the build fails, which is why we unset the @@ -30,7 +32,7 @@ stdenv.mkDerivation rec { which zlib openssl - ]; + ] ++ stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames; # Some versions of `ar` (such as the one provided by OS X) require an explicit # `-r` flag, whereas other versions assume `-r` is the default if no mode is diff --git a/nix/insert-ordered-containers.nix b/nix/insert-ordered-containers.nix deleted file mode 100644 index 5f95713..0000000 --- a/nix/insert-ordered-containers.nix +++ /dev/null @@ -1,23 +0,0 @@ -{ mkDerivation, aeson, base, base-compat, hashable, lens -, QuickCheck, semigroupoids, semigroups, stdenv, tasty -, tasty-quickcheck, text, transformers, unordered-containers -}: -mkDerivation { - pname = "insert-ordered-containers"; - version = "0.2.1.0"; - sha256 = "1612f455dw37da9g7bsd1s5kyi84mnr1ifnjw69892amyimi47fp"; - revision = "3"; - editedCabalFile = "6fdce987672b006226243aa17522b57ec7a9e1cab247802eddbdaa9dc5b06446"; - libraryHaskellDepends = [ - aeson base base-compat hashable lens semigroupoids semigroups text - transformers unordered-containers - ]; - testHaskellDepends = [ - aeson base base-compat hashable lens QuickCheck semigroupoids - semigroups tasty tasty-quickcheck text transformers - unordered-containers - ]; - homepage = "https://github.com/phadej/insert-ordered-containers#readme"; - description = "Associative containers retating insertion order for traversals"; - license = stdenv.lib.licenses.bsd3; -} diff --git a/nix/optparse-applicative.nix b/nix/optparse-applicative.nix deleted file mode 100644 index bdfc252..0000000 --- a/nix/optparse-applicative.nix +++ /dev/null @@ -1,15 +0,0 @@ -{ mkDerivation, ansi-wl-pprint, base, bytestring, process -, QuickCheck, stdenv, transformers, transformers-compat -}: -mkDerivation { - pname = "optparse-applicative"; - version = "0.14.0.0"; - sha256 = "06iwp1qsq0gjhnhxwyhdhldwvhlgcik6lx5jxpbb40fispyk4nxm"; - libraryHaskellDepends = [ - ansi-wl-pprint base process transformers transformers-compat - ]; - testHaskellDepends = [ base bytestring QuickCheck ]; - homepage = "https://github.com/pcapriotti/optparse-applicative"; - description = "Utilities and combinators for parsing command line options"; - license = stdenv.lib.licenses.bsd3; -} diff --git a/nix/optparse-generic.nix b/nix/optparse-generic.nix deleted file mode 100644 index 42bc130..0000000 --- a/nix/optparse-generic.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ mkDerivation, base, bytestring, optparse-applicative, semigroups -, stdenv, system-filepath, text, time, transformers, void -}: -mkDerivation { - pname = "optparse-generic"; - version = "1.2.1"; - sha256 = "1dk945dp98mwk1v4y0cky3z0ngmd29nbg6fbaaxnigcrgpbvkjml"; - libraryHaskellDepends = [ - base bytestring optparse-applicative semigroups system-filepath - text time transformers void - ]; - description = "Auto-generate a command-line parser for your datatype"; - license = stdenv.lib.licenses.bsd3; -} diff --git a/nix/proto3-suite.nix b/nix/proto3-suite.nix index d0df704..3bb081e 100644 --- a/nix/proto3-suite.nix +++ b/nix/proto3-suite.nix @@ -1,20 +1,21 @@ { mkDerivation, aeson, aeson-pretty, attoparsec, base , base64-bytestring, binary, bytestring, cereal, containers , contravariant, deepseq, doctest, fetchgit, filepath, foldl -, hashable, haskell-src, insert-ordered-containers, lens, mtl -, neat-interpolation, optparse-applicative, optparse-generic -, parsec, parsers, pretty, pretty-show, proto3-wire, QuickCheck -, quickcheck-instances, range-set-list, safe, semigroups, stdenv -, swagger2, system-filepath, tasty, tasty-hunit, tasty-quickcheck -, text, transformers, turtle, vector +, generic-arbitrary, hashable, haskell-src +, insert-ordered-containers, lens, mtl, neat-interpolation +, optparse-applicative, optparse-generic, parsec, parsers, pretty +, pretty-show, proto3-wire, QuickCheck, quickcheck-instances +, range-set-list, safe, semigroups, stdenv, swagger2 +, system-filepath, tasty, tasty-hunit, tasty-quickcheck, text +, transformers, turtle, vector }: mkDerivation { pname = "proto3-suite"; version = "0.4.0.0"; src = fetchgit { - url = "https://github.com/awakesecurity/proto3-suite.git"; - sha256 = "091db048hgcq5idvf5gaiqb6hzbs7g1dz6xjqdx61dw2yxgdm957"; - rev = "973c317b91405a11438e3a21706024bfa3d754df"; + url = "https://github.com/awakesecurity/proto3-suite"; + sha256 = "0g7j7axx9rkrzw32ky9xl08zj34rx4mqafd89lrpnsi8lcq2z06j"; + rev = "3f6dd6f612cf2eba3c05798926ff924b0d5ab4fa"; fetchSubmodules = true; }; isLibrary = true; @@ -34,9 +35,9 @@ mkDerivation { ]; testHaskellDepends = [ aeson attoparsec base base64-bytestring bytestring cereal - containers deepseq doctest mtl pretty-show proto3-wire QuickCheck - semigroups swagger2 tasty tasty-hunit tasty-quickcheck text - transformers turtle vector + containers deepseq doctest generic-arbitrary mtl pretty-show + proto3-wire QuickCheck semigroups swagger2 tasty tasty-hunit + tasty-quickcheck text transformers turtle vector ]; description = "A low level library for writing out data in the Protocol Buffers wire format"; license = stdenv.lib.licenses.asl20; diff --git a/nix/proto3-wire.nix b/nix/proto3-wire.nix index b0b85ee..f2c256d 100644 --- a/nix/proto3-wire.nix +++ b/nix/proto3-wire.nix @@ -4,11 +4,12 @@ }: mkDerivation { pname = "proto3-wire"; - version = "1.0.0"; + version = "1.1.0"; src = fetchgit { - url = "https://github.com/awakenetworks/proto3-wire.git"; - sha256 = "14n0d16an782ayipirm5v2mvp58jgf65xvffqzp08p50sksil3gi"; - rev = "a938330bf794cf3fa05591d03906915df98d157c"; + url = "https://github.com/awakesecurity/proto3-wire.git"; + sha256 = "16l1rnnygwk1b2sb3l6klhr6ad0wvry204icxnc81c6rbzbk6rqc"; + rev = "4f355bbac895d577d8a28f567ab4380f042ccc24"; + fetchSubmodules = true; }; libraryHaskellDepends = [ base bytestring cereal containers deepseq hashable QuickCheck safe diff --git a/nix/quickcheck-instances.nix b/nix/quickcheck-instances.nix deleted file mode 100644 index 2e0bc75..0000000 --- a/nix/quickcheck-instances.nix +++ /dev/null @@ -1,22 +0,0 @@ -{ mkDerivation, array, base, base-compat, bytestring -, case-insensitive, containers, hashable, old-time, QuickCheck -, scientific, stdenv, tagged, text, time, transformers -, transformers-compat, unordered-containers, uuid-types, vector -}: -mkDerivation { - pname = "quickcheck-instances"; - version = "0.3.15"; - sha256 = "9e0efd0debe1fe390c97d7b3d80d59f3221f2ff4aa1649a1929b4a118156dc0a"; - libraryHaskellDepends = [ - array base base-compat bytestring case-insensitive containers - hashable old-time QuickCheck scientific tagged text time - transformers transformers-compat unordered-containers uuid-types - vector - ]; - testHaskellDepends = [ - base containers QuickCheck tagged uuid-types - ]; - homepage = "https://github.com/phadej/qc-instances"; - description = "Common quickcheck instances"; - license = stdenv.lib.licenses.bsd3; -} diff --git a/nix/swagger2.nix b/nix/swagger2.nix deleted file mode 100644 index f98db58..0000000 --- a/nix/swagger2.nix +++ /dev/null @@ -1,27 +0,0 @@ -{ mkDerivation, aeson, aeson-qq, base, base-compat, bytestring -, Cabal, cabal-doctest, containers, doctest, generics-sop, Glob -, hashable, hspec, http-media, HUnit, insert-ordered-containers -, lens, mtl, network, QuickCheck, scientific, stdenv -, template-haskell, text, time, transformers, transformers-compat -, unordered-containers, uuid-types, vector -}: -mkDerivation { - pname = "swagger2"; - version = "2.1.6"; - sha256 = "01a29h56vfyw0ilij1pn6qwy50ca90kyj884vs1q52vvh572758j"; - setupHaskellDepends = [ base Cabal cabal-doctest ]; - libraryHaskellDepends = [ - aeson base base-compat bytestring containers generics-sop hashable - http-media insert-ordered-containers lens mtl network scientific - template-haskell text time transformers transformers-compat - unordered-containers uuid-types vector - ]; - testHaskellDepends = [ - aeson aeson-qq base base-compat bytestring containers doctest Glob - hashable hspec HUnit insert-ordered-containers lens mtl QuickCheck - text time unordered-containers vector - ]; - homepage = "https://github.com/GetShopTV/swagger2"; - description = "Swagger 2.0 data model"; - license = stdenv.lib.licenses.bsd3; -} diff --git a/nix/turtle.nix b/nix/turtle.nix deleted file mode 100644 index 4f66713..0000000 --- a/nix/turtle.nix +++ /dev/null @@ -1,20 +0,0 @@ -{ mkDerivation, ansi-wl-pprint, async, base, bytestring, clock -, directory, doctest, foldl, hostname, managed, optional-args -, optparse-applicative, process, semigroups, stdenv, stm -, system-fileio, system-filepath, temporary, text, time -, transformers, unix, unix-compat -}: -mkDerivation { - pname = "turtle"; - version = "1.3.6"; - sha256 = "0fr8p6rnk2lrsgbfh60jlqcjr0nxrh3ywxsj5d4psck0kgyhvg1m"; - libraryHaskellDepends = [ - ansi-wl-pprint async base bytestring clock directory foldl hostname - managed optional-args optparse-applicative process semigroups stm - system-fileio system-filepath temporary text time transformers unix - unix-compat - ]; - testHaskellDepends = [ base doctest system-filepath temporary ]; - description = "Shell programming, Haskell-style"; - license = stdenv.lib.licenses.bsd3; -} diff --git a/nixpkgs.nix b/nixpkgs.nix index 7c97753..b08c8a1 100644 --- a/nixpkgs.nix +++ b/nixpkgs.nix @@ -7,7 +7,7 @@ # The SHA256 will be printed as the last line of stdout. import ./fetch-nixpkgs.nix { - rev = "74286ec9e76be7cd00c4247b9acb430c4bd9f1ce"; - sha256 = "0njb3qd2wxj7gil8y61lwh7zacmvr6zklv67w5zmvifi1fvalvdg"; - outputSha256 = "13ydgpzl5nix4gc358iy9zjd5nrrpbpwpxmfhis4aai2zmkja3ak"; + rev = "fa12335f425808f53121713f501f3335878e6901"; + sha256 = "1fjyvjxvymz8yd65ahgm798jp9vdcfy7s58zb5ns2iq2ak0h9j8p"; + outputSha256 = "1qkihrm8xfrh93c7wh1d1x01p7mgv82b2ycpmn9jm5l7976g31vr"; } diff --git a/release.nix b/release.nix index 339c7e9..e19e0a9 100644 --- a/release.nix +++ b/release.nix @@ -64,7 +64,7 @@ let packageOverrides = pkgs: rec { protobuf3_2NoCheck = pkgs.stdenv.lib.overrideDerivation - pkgs.pythonPackages.protobuf3_2 + pkgs.pythonPackages.protobuf (oldAttrs : {doCheck = false; doInstallCheck = false;}); cython = pkgs.pythonPackages.buildPythonPackage rec { @@ -178,41 +178,23 @@ let preBuild = (oldAttributes.preBuild or "") + pkgs.lib.optionalString pkgs.stdenv.isDarwin '' export DYLD_LIBRARY_PATH=${grpc}/lib''${DYLD_LIBRARY_PATH:+:}$DYLD_LIBRARY_PATH + '' + + pkgs.lib.optionalString pkgs.stdenv.isLinux '' + export LD_LIBRARY_PATH=${grpc}/lib''${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH ''; shellHook = (oldAttributes.shellHook or "") + pkgs.lib.optionalString pkgs.stdenv.isDarwin '' export DYLD_LIBRARY_PATH=${grpc}/lib''${DYLD_LIBRARY_PATH:+:}$DYLD_LIBRARY_PATH + '' + + pkgs.lib.optionalString pkgs.stdenv.isLinux '' + export LD_LIBRARY_PATH=${grpc}/lib''${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH ''; } ); haskellPackages = pkgs.haskellPackages.override { overrides = haskellPackagesNew: haskellPackagesOld: rec { - attoparsec = - pkgs.haskell.lib.dontCheck haskellPackagesOld.attoparsec; - - aeson = - pkgs.haskell.lib.dontCheck - (haskellPackagesNew.callPackage ./nix/aeson.nix {}); - - cabal-doctest = - haskellPackagesNew.callPackage ./nix/cabal-doctest.nix { }; - - edit-distance = - pkgs.haskell.lib.dontCheck haskellPackagesOld.edit-distance; - - http-media = - pkgs.haskell.lib.dontCheck haskellPackagesOld.http-media; - - insert-ordered-containers = - haskellPackagesNew.callPackage ./nix/insert-ordered-containers.nix { }; - - optparse-applicative = - haskellPackagesNew.callPackage ./nix/optparse-applicative.nix { }; - - optparse-generic = - haskellPackagesNew.callPackage ./nix/optparse-generic.nix { }; proto3-wire = haskellPackagesNew.callPackage ./nix/proto3-wire.nix { }; @@ -221,12 +203,6 @@ let pkgs.haskell.lib.dontCheck (haskellPackagesNew.callPackage ./nix/proto3-suite.nix {}); - QuickCheck = - (haskellPackagesNew.callPackage ./nix/QuickCheck.nix {}); - - quickcheck-instances = - (haskellPackagesNew.callPackage ./nix/quickcheck-instances.nix {}); - grpc-haskell-core = usesGRPC (pkgs.haskell.lib.overrideCabal @@ -303,12 +279,6 @@ let }) ); - swagger2 = - pkgs.haskell.lib.dontCheck (pkgs.haskell.lib.dontHaddock (haskellPackagesNew.callPackage ./nix/swagger2.nix { })); - - turtle = - haskellPackagesNew.callPackage ./nix/turtle.nix { }; - }; }; }; diff --git a/stack.yaml b/stack.yaml index 5bf778f..f9ba8c2 100644 --- a/stack.yaml +++ b/stack.yaml @@ -2,7 +2,7 @@ # For more information, see: http://docs.haskellstack.org/en/stable/yaml_configuration/ # Specifies the GHC version and set of packages available (e.g., lts-3.5, nightly-2015-09-21, ghc-7.10.2) -resolver: lts-8.23 +resolver: lts-14.1 # Local packages, usually specified by relative directory name packages: @@ -10,17 +10,12 @@ packages: - 'core' - location: git: git@github.com:awakesecurity/proto3-suite.git - commit: bb66853dcaa7372ef061cf83f39e4ba5193898de + commit: 3f6dd6f612cf2eba3c05798926ff924b0d5ab4fa extra-dep: true - location: git: git@github.com:awakesecurity/proto3-wire.git - commit: a938330bf794cf3fa05591d03906915df98d157c + commit: 4f355bbac895d577d8a28f567ab4380f042ccc24 extra-dep: true -# Packages to be pulled from upstream that are not in the resolver (e.g., acme-missiles-0.3) -extra-deps: [ aeson-1.1.1.0 - , managed-1.0.5 - , swagger2-2.1.6 - ] # Override default flag values for local packages and extra-deps flags: {} diff --git a/tests/GeneratedTests.hs b/tests/GeneratedTests.hs index 056a11a..a9a0672 100644 --- a/tests/GeneratedTests.hs +++ b/tests/GeneratedTests.hs @@ -4,7 +4,7 @@ module GeneratedTests where import Test.Tasty -import Test.Tasty.HUnit (testCase, (@?=)) +import Test.Tasty.HUnit (assertEqual, testCase, (@?=)) import Data.String import Proto3.Suite.DotProto.Generate @@ -78,8 +78,8 @@ testClientGeneration = testCase "client generation" $ do serverExitCode <- liftIO (wait serverExitCodeA) clientExitCode <- liftIO (wait clientExitCodeA) - serverExitCode @?= ExitSuccess - clientExitCode @?= ExitSuccess + assertEqual "Server exit code" serverExitCode ExitSuccess + assertEqual "Client exit code" clientExitCode ExitSuccess rmtree hsTmpDir rmtree pyTmpDir diff --git a/tests/TestClient.hs b/tests/TestClient.hs index ba1958e..8ef96a1 100644 --- a/tests/TestClient.hs +++ b/tests/TestClient.hs @@ -31,7 +31,7 @@ import Proto3.Suite import System.Random import Test.Tasty -import Test.Tasty.HUnit ((@?=), assertString, testCase) +import Test.Tasty.HUnit ((@?=), assertFailure, testCase) testNormalCall client = testCase "Normal call" $ do randoms <- fromList <$> replicateM 1000 (randomRIO (1, 1000)) @@ -39,7 +39,7 @@ testNormalCall client = testCase "Normal call" $ res <- simpleServiceNormalCall client (ClientNormalRequest req 10 mempty) case res of - ClientErrorResponse err -> assertString ("ClientErrorResponse: " <> show err) + ClientErrorResponse err -> assertFailure ("ClientErrorResponse: " <> show err) ClientNormalResponse res _ _ stsCode _ -> do stsCode @?= StatusOk simpleServiceResponseResponse res @?= "NormalRequest" @@ -60,8 +60,8 @@ testClientStreamingCall client = testCase "Client-streaming call" $ (finalName, totalSum) <- readMVar v case res of - ClientErrorResponse err -> assertString ("ClientErrorResponse: " <> show err) - ClientWriterResponse Nothing _ _ _ _ -> assertString "No response received" + ClientErrorResponse err -> assertFailure ("ClientErrorResponse: " <> show err) + ClientWriterResponse Nothing _ _ _ _ -> assertFailure "No response received" ClientWriterResponse (Just res) _ _ stsCode _ -> do stsCode @?= StatusOk simpleServiceResponseResponse res @?= finalName @@ -74,14 +74,14 @@ testServerStreamingCall client = testCase "Server-streaming call" $ let checkResults [] recv = do res <- recv case res of - Left err -> assertString ("recv error: " <> show err) + Left err -> assertFailure ("recv error: " <> show err) Right Nothing -> pure () - Right (Just _) -> assertString "recv: elements past end of stream" + Right (Just _) -> assertFailure "recv: elements past end of stream" checkResults (expNum:nums) recv = do res <- recv case res of - Left err -> assertString ("recv error: " <> show err) - Right Nothing -> assertString ("recv: stream ended earlier than expected") + Left err -> assertFailure ("recv error: " <> show err) + Right Nothing -> assertFailure ("recv: stream ended earlier than expected") Right (Just (SimpleServiceResponse response num)) -> do response @?= "Test" num @?= expNum @@ -90,7 +90,7 @@ testServerStreamingCall client = testCase "Server-streaming call" $ ClientReaderRequest (SimpleServiceRequest "Test" (fromList nums)) 10 mempty (\_ -> checkResults nums) case res of - ClientErrorResponse err -> assertString ("ClientErrorResponse: " <> show err) + ClientErrorResponse err -> assertFailure ("ClientErrorResponse: " <> show err) ClientReaderResponse _ sts _ -> sts @?= StatusOk @@ -104,7 +104,7 @@ testBiDiStreamingCall client = testCase "Bidi-streaming call" $ res <- recv case res of - Left err -> assertString ("recv error: " <> show err) + Left err -> assertFailure ("recv error: " <> show err) Right Nothing -> pure () Right (Just (SimpleServiceResponse name total)) -> do name @?= testName @@ -116,7 +116,7 @@ testBiDiStreamingCall client = testCase "Bidi-streaming call" $ res <- simpleServiceBiDiStreamingCall client $ ClientBiDiRequest 10 mempty (\_ -> handleRequests iterations) case res of - ClientErrorResponse err -> assertString ("ClientErrorResponse: " <> show err) + ClientErrorResponse err -> assertFailure ("ClientErrorResponse: " <> show err) ClientBiDiResponse _ sts _ -> sts @?= StatusOk diff --git a/tests/test-client.py b/tests/test-client.py index 79c90e1..e9e1a23 100644 --- a/tests/test-client.py +++ b/tests/test-client.py @@ -1,12 +1,14 @@ from simple_pb2 import * +from simple_pb2_grpc import * +import grpc from uuid import uuid4 import random import Queue print "Starting python client" -channel = beta_implementations.insecure_channel('localhost', 50051) -stub = beta_create_SimpleService_stub(channel) +channel = grpc.insecure_channel('localhost:50051') +stub = SimpleServiceStub(channel) def runTests(): # Test normal call: return a sum of all numbers sent to it @@ -14,7 +16,7 @@ def runTests(): for i in xrange(100): randints = [random.randint(0, 1000) for _ in xrange(random.randint(10, 1000))] name = "test%d" % i - response = stub.normalCall(SimpleServiceRequest(request = name, num = randints), 10) + response = stub.normalCall(SimpleServiceRequest(request = name, num = randints), timeout = 10) assert response.response == name assert response.num == sum(randints) @@ -31,7 +33,7 @@ def runTests(): esum[0] += sum(nums) ename[0] += name yield SimpleServiceRequest(request = name, num = nums) - response = stub.clientStreamingCall(send_requests(expected_sum, expected_response_name), 10) + response = stub.clientStreamingCall(send_requests(expected_sum, expected_response_name), timeout = 10) assert response.response == expected_response_name[0] assert response.num == expected_sum[0] @@ -40,7 +42,7 @@ def runTests(): for i in xrange(100): nums = [random.randint(0, 1000) for _ in xrange(random.randint(0, 1000))] - for response in stub.serverStreamingCall(SimpleServiceRequest(request = "server streaming", num = nums), 60): + for response in stub.serverStreamingCall(SimpleServiceRequest(request = "server streaming", num = nums), timeout = 60): assert response.num == nums[0] assert response.response == "server streaming" nums = nums[1:] @@ -58,14 +60,14 @@ def runTests(): yield SimpleServiceRequest(request = name, num = nums) - for response in stub.biDiStreamingCall(send_requests(), 10): + for response in stub.biDiStreamingCall(send_requests(), timeout = 10): (exp_name, exp_sum) = requests.get() assert response.response == exp_name assert response.num == exp_sum print "Sending DONE message to server" - stub.done(SimpleServiceDone(), 10) + stub.done(SimpleServiceDone(), timeout = 10) print "All python client tests against the generated server were successful" @@ -76,6 +78,6 @@ except Exception as e: print e.__doc__ print e.message print "Sending DONE message to server before exiting" - stub.done(SimpleServiceDone(), 10) + stub.done(SimpleServiceDone(), timeout = 10) print "Exiting with failure status" exit(1) diff --git a/tests/test-server.py b/tests/test-server.py index c6c54b1..a58f444 100644 --- a/tests/test-server.py +++ b/tests/test-server.py @@ -1,5 +1,7 @@ from simple_pb2 import * +import simple_pb2_grpc from uuid import uuid4 +from concurrent import futures import random import Queue import grpc @@ -8,7 +10,7 @@ print "Starting python server" done_queue = Queue.Queue() -class SimpleServiceServer(BetaSimpleServiceServicer): +class SimpleServiceServer(simple_pb2_grpc.SimpleServiceServicer): def done(self, request, context): global server done_queue.put_nowait(()) @@ -34,7 +36,8 @@ class SimpleServiceServer(BetaSimpleServiceServicer): for request in requests: yield SimpleServiceResponse(response = request.request, num = sum(request.num)) -server = beta_create_SimpleService_server(SimpleServiceServer()) +server = grpc.server(futures.ThreadPoolExecutor(max_workers=1)) +simple_pb2_grpc.add_SimpleServiceServicer_to_server(SimpleServiceServer(), server) server.add_insecure_port('[::]:50051') server.start()