From 82b01bc7df06ca89a26ab7c9a4c999bbd00faf86 Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Wed, 4 Mar 2020 15:40:42 +0100 Subject: [PATCH 1/3] address that network/clock is not available on Windows at this stage --- .../Test/Integration/Scenario/API/Network.hs | 19 +++++++++++++------ specifications/api/swagger.yaml | 5 ++++- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/lib/core-integration/src/Test/Integration/Scenario/API/Network.hs b/lib/core-integration/src/Test/Integration/Scenario/API/Network.hs index e437f51ee96..06f9440ed99 100644 --- a/lib/core-integration/src/Test/Integration/Scenario/API/Network.hs +++ b/lib/core-integration/src/Test/Integration/Scenario/API/Network.hs @@ -30,6 +30,8 @@ import Data.Time.Clock ( getCurrentTime ) import Data.Word.Odd ( Word31 ) +import System.Info + ( os ) import Test.Hspec ( SpecWith, describe, it, shouldBe, shouldSatisfy ) import Test.Integration.Framework.DSL @@ -199,15 +201,20 @@ spec = do HTTP.status404 (errMsg404NoEpochNo (T.unpack maxEpochValue)) - it "NETWORK - Can query network clock" $ \ctx -> - eventually "ntp status = available" $ do + it "NETWORK_CLOCK - Can query network clock" $ \ctx -> + eventually "ntp status = (un)available" $ do r <- request @ApiNetworkClock ctx Link.getNetworkClock Default Empty expectResponseCode @IO HTTP.status200 r - verify r - [ expectField (#ntpStatus . #status) - (`shouldBe` NtpSyncingStatusAvailable) - ] + -- network/clock at this point is not supported on Windows + if os == "windows" + then + expectField (#ntpStatus . #status) + (`shouldBe` NtpSyncingStatusUnavailable) r + else + expectField (#ntpStatus . #status) + (`shouldBe` NtpSyncingStatusAvailable) r + where verifyEpochNumWrong :: Context t diff --git a/specifications/api/swagger.yaml b/specifications/api/swagger.yaml index 1d88700730b..3e50655fa2c 100644 --- a/specifications/api/swagger.yaml +++ b/specifications/api/swagger.yaml @@ -1992,7 +1992,10 @@ paths: tags: ["Network"] summary: Clock description: | -

status: under development

+

status: stable

+ + > ⚠️ At this stage the endpoint is not supported on Windows platform. Invoked on + > Windows will return `status: unavailable` in the response message. responses: *responsesGetNetworkClock /network/parameters/{epochId}: From 0f7c759ae15bb505b87a8c9d4039d1e25d9bdb3a Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Thu, 5 Mar 2020 10:05:53 +0100 Subject: [PATCH 2/3] use pendingOnWindows for network/clock integration test --- .../cardano-wallet-core-integration.cabal | 3 ++- .../Test/Integration/Scenario/API/Network.hs | 18 ++++++------------ lib/test-utils/cardano-wallet-test-utils.cabal | 2 +- .../cardano-wallet-core-integration.nix | 3 ++- nix/.stack.nix/cardano-wallet-test-utils.nix | 2 +- 5 files changed, 12 insertions(+), 16 deletions(-) diff --git a/lib/core-integration/cardano-wallet-core-integration.cabal b/lib/core-integration/cardano-wallet-core-integration.cabal index eccbc2fee13..c18f5d1607b 100644 --- a/lib/core-integration/cardano-wallet-core-integration.cabal +++ b/lib/core-integration/cardano-wallet-core-integration.cabal @@ -1,5 +1,5 @@ name: cardano-wallet-core-integration -version: 2019.6.24 +version: 2020.3.3 synopsis: Core integration test library. description: Shared core functionality for our integration test suites. homepage: https://github.com/input-output-hk/cardano-wallet @@ -36,6 +36,7 @@ library , bytestring , cardano-wallet-cli , cardano-wallet-core + , cardano-wallet-test-utils , command , containers , cryptonite diff --git a/lib/core-integration/src/Test/Integration/Scenario/API/Network.hs b/lib/core-integration/src/Test/Integration/Scenario/API/Network.hs index 06f9440ed99..5a53ea5d7d7 100644 --- a/lib/core-integration/src/Test/Integration/Scenario/API/Network.hs +++ b/lib/core-integration/src/Test/Integration/Scenario/API/Network.hs @@ -30,8 +30,6 @@ import Data.Time.Clock ( getCurrentTime ) import Data.Word.Odd ( Word31 ) -import System.Info - ( os ) import Test.Hspec ( SpecWith, describe, it, shouldBe, shouldSatisfy ) import Test.Integration.Framework.DSL @@ -54,6 +52,8 @@ import Test.Integration.Framework.DSL ) import Test.Integration.Framework.TestData ( errMsg404NoEpochNo ) +import Test.Utils.Windows + ( pendingOnWindows ) import qualified Cardano.Wallet.Api.Link as Link import qualified Data.Text as T @@ -201,20 +201,14 @@ spec = do HTTP.status404 (errMsg404NoEpochNo (T.unpack maxEpochValue)) - it "NETWORK_CLOCK - Can query network clock" $ \ctx -> + it "NETWORK_CLOCK - Can query network clock" $ \ctx -> do + pendingOnWindows "network/clock at this point is not supported on Windows" eventually "ntp status = (un)available" $ do r <- request @ApiNetworkClock ctx Link.getNetworkClock Default Empty expectResponseCode @IO HTTP.status200 r - -- network/clock at this point is not supported on Windows - if os == "windows" - then - expectField (#ntpStatus . #status) - (`shouldBe` NtpSyncingStatusUnavailable) r - else - expectField (#ntpStatus . #status) - (`shouldBe` NtpSyncingStatusAvailable) r - + expectField (#ntpStatus . #status) + (`shouldBe` NtpSyncingStatusAvailable) r where verifyEpochNumWrong :: Context t diff --git a/lib/test-utils/cardano-wallet-test-utils.cabal b/lib/test-utils/cardano-wallet-test-utils.cabal index 01120d77be2..de0a5007136 100644 --- a/lib/test-utils/cardano-wallet-test-utils.cabal +++ b/lib/test-utils/cardano-wallet-test-utils.cabal @@ -1,5 +1,5 @@ name: cardano-wallet-test-utils -version: 2019.6.24 +version: 2020.3.3 synopsis: Shared utilities for writing unit and property tests. description: Shared utilities for writing unit and property tests. homepage: https://github.com/input-output-hk/cardano-wallet diff --git a/nix/.stack.nix/cardano-wallet-core-integration.nix b/nix/.stack.nix/cardano-wallet-core-integration.nix index 72e1e0d73e6..dc23d970b87 100644 --- a/nix/.stack.nix/cardano-wallet-core-integration.nix +++ b/nix/.stack.nix/cardano-wallet-core-integration.nix @@ -44,7 +44,7 @@ in { system, compiler, flags, pkgs, hsPkgs, pkgconfPkgs, ... }: specVersion = "1.10"; identifier = { name = "cardano-wallet-core-integration"; - version = "2019.6.24"; + version = "2020.3.3"; }; license = "Apache-2.0"; copyright = "2018-2020 IOHK"; @@ -67,6 +67,7 @@ in { system, compiler, flags, pkgs, hsPkgs, pkgconfPkgs, ... }: (hsPkgs."bytestring" or (buildDepError "bytestring")) (hsPkgs."cardano-wallet-cli" or (buildDepError "cardano-wallet-cli")) (hsPkgs."cardano-wallet-core" or (buildDepError "cardano-wallet-core")) + (hsPkgs."cardano-wallet-test-utils" or (buildDepError "cardano-wallet-test-utils")) (hsPkgs."command" or (buildDepError "command")) (hsPkgs."containers" or (buildDepError "containers")) (hsPkgs."cryptonite" or (buildDepError "cryptonite")) diff --git a/nix/.stack.nix/cardano-wallet-test-utils.nix b/nix/.stack.nix/cardano-wallet-test-utils.nix index 7ab42ca0e5f..a2628a0d532 100644 --- a/nix/.stack.nix/cardano-wallet-test-utils.nix +++ b/nix/.stack.nix/cardano-wallet-test-utils.nix @@ -44,7 +44,7 @@ in { system, compiler, flags, pkgs, hsPkgs, pkgconfPkgs, ... }: specVersion = "1.10"; identifier = { name = "cardano-wallet-test-utils"; - version = "2019.6.24"; + version = "2020.3.3"; }; license = "Apache-2.0"; copyright = "2018-2020 IOHK"; From dd073826c22132f3228a3e4509b5943e31e9c085 Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Fri, 6 Mar 2020 11:16:10 +0100 Subject: [PATCH 3/3] revise log error levels --- lib/core/src/Network/Ntp.hs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/core/src/Network/Ntp.hs b/lib/core/src/Network/Ntp.hs index 4d91604e00f..ca75e71b35a 100644 --- a/lib/core/src/Network/Ntp.hs +++ b/lib/core/src/Network/Ntp.hs @@ -106,28 +106,28 @@ instance ToText NtpTrace where instance DefinePrivacyAnnotation NtpTrace instance DefineSeverity NtpTrace where defineSeverity ev = case ev of + NtpTraceRunProtocolSuccess _ -> Debug + NtpTraceSocketOpen _ -> Debug + NtpTraceSocketClosed _ -> Debug + NtpTracePacketSent _ -> Debug + NtpTracePacketReceived _ -> Debug NtpTraceStartNtpClient -> Info NtpTraceTriggerUpdate -> Info NtpTraceRestartDelay _ -> Info NtpTraceRestartingClient -> Info NtpTraceClientSleeping -> Info - NtpTraceIOError _ -> Alert - NtpTraceLookupServerFailed _ -> Alert NtpTraceClientStartQuery -> Info - NtpTraceNoLocalAddr -> Alert NtpTraceIPv4IPv6NoReplies -> Info - NtpTraceReportPolicyQueryFailed -> Alert NtpTraceQueryResult _ -> Info - NtpTraceRunProtocolError _ _ -> Alert NtpTraceRunProtocolNoResult _ -> Info - NtpTraceRunProtocolSuccess _ -> Debug - NtpTraceSocketOpen _ -> Debug - NtpTraceSocketClosed _ -> Debug - NtpTracePacketSent _ -> Debug - NtpTracePacketSentError _ _ -> Alert - NtpTracePacketDecodeError _ _-> Alert - NtpTracePacketReceived _ -> Debug - NtpTraceWaitingForRepliesTimeout _ -> Alert + NtpTraceRunProtocolError _ _ -> Notice + NtpTracePacketSentError _ _ -> Notice + NtpTracePacketDecodeError _ _-> Notice + NtpTraceWaitingForRepliesTimeout _ -> Notice + NtpTraceIOError _ -> Notice + NtpTraceLookupServerFailed _ -> Notice + NtpTraceNoLocalAddr -> Notice + NtpTraceReportPolicyQueryFailed -> Notice getNtpStatus :: NtpClient -> IO ApiNetworkClock getNtpStatus client = ntpQueryBlocking client >>= \case