Skip to content

Commit

Permalink
Merge #1420 #1422
Browse files Browse the repository at this point in the history
1420: Fix test failure by making clean shutdown handler optional r=rvl a=rvl

# Issue Number

#1314 

# Overview

- Fixes integration test failure which occurs locally - #1314 (comment)


1422: Disable running integration tests on Hydra CI r=rvl a=rvl

# Overview

Reduces the load on Hydra by not running integration tests for PR builds. The test executables are still built however.

This uses the `pr` input which was added to [ci-ops/jobsets/default.nix](https://github.com/input-output-hk/ci-ops/blob/30d4685beded3e54caff4a22718aa6acde48d367/jobsets/default.nix#L326).

# Comments

Tested with:

    rodney@blue:~/iohk/cardano-wallet % nix-build --argstr pr 1234 release.nix -A native.checks.cardano-wallet-jormungandr.integration.x86_64-linux
    error: attribute 'integration' in selection path 'native.checks.cardano-wallet-jormungandr.integration.x86_64-linux' not found

    rodney@blue:~/iohk/cardano-wallet % nix-build release.nix -A native.checks.cardano-wallet-jormungandr.integration.x86_64-linux
    ...

[Hydra jobset](https://hydra.iohk.io/jobset/Cardano/cardano-wallet-pr-1422#tabs-jobs)

Co-authored-by: Rodney Lorrimar <rodney.lorrimar@iohk.io>
  • Loading branch information
iohk-bors[bot] and rvl committed Mar 10, 2020
3 parents 7482427 + 8229443 + fbc7844 commit 9314321
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 33 deletions.
4 changes: 3 additions & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
, gitrev ? pkgs.commonLib.commitIdFromGitRepoOrZero ./.git
# Use this to reference local sources rather than the niv pinned versions (see nix/default.nix)
, sourcesOverride ? {}
# GitHub PR number (as a string), set when building a Hydra PR jobset.
, pr ? null
}:

# commonLib includes iohk-nix utilities, our util.nix and nixpkgs lib.
Expand All @@ -60,7 +62,7 @@ let
haskellPackages = import ./nix/haskell.nix {
inherit config lib stdenv pkgs buildPackages;
inherit (pkgs) haskell-nix;
inherit src;
inherit src pr;
};

filterCardanoPackages = lib.filterAttrs (_: package: isCardanoWallet package);
Expand Down
66 changes: 38 additions & 28 deletions lib/jormungandr/exe/cardano-wallet-jormungandr.hs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ import Options.Applicative
, metavar
, option
, progDesc
, switch
, value
)
import Options.Applicative.Types
Expand Down Expand Up @@ -241,31 +242,29 @@ cmdLaunch dataDir = command "launch" $ info (helper <*> helper' <*> cmd) $ mempt
exec args@(LaunchArgs hostPreference listen nodePort mStateDir sTolerance logOpt jArgs) = do
withTracers logOpt $ \tr tracers -> do
installSignalHandlers (logNotice tr MsgSigTerm)
let trShutdown = trMessage (contramap (fmap MsgShutdownHandler) tr)
void $ withShutdownHandler trShutdown $ do
logInfo tr $ MsgLaunchArgs args
case genesisBlock jArgs of
Right block0File -> requireFilePath block0File
Left _ -> pure ()
let stateDir = fromMaybe (dataDir </> "testnet") mStateDir
let databaseDir = stateDir </> "wallets"
let cp = JormungandrConfig
{ _stateDir = stateDir
, _genesisBlock = genesisBlock jArgs
, _restApiPort = fromIntegral . getPort <$> nodePort
, _outputStream = Inherit
, _extraArgs = extraJormungandrArgs jArgs
}
setupDirectory (logInfo tr . MsgSetupStateDir) stateDir
setupDirectory (logInfo tr . MsgSetupDatabases) databaseDir
exitWith =<< serveWallet @'Testnet
tracers
sTolerance
(Just databaseDir)
hostPreference
listen
(Launch cp)
(beforeMainLoop tr)
logInfo tr $ MsgLaunchArgs args
case genesisBlock jArgs of
Right block0File -> requireFilePath block0File
Left _ -> pure ()
let stateDir = fromMaybe (dataDir </> "testnet") mStateDir
let databaseDir = stateDir </> "wallets"
let cp = JormungandrConfig
{ _stateDir = stateDir
, _genesisBlock = genesisBlock jArgs
, _restApiPort = fromIntegral . getPort <$> nodePort
, _outputStream = Inherit
, _extraArgs = extraJormungandrArgs jArgs
}
setupDirectory (logInfo tr . MsgSetupStateDir) stateDir
setupDirectory (logInfo tr . MsgSetupDatabases) databaseDir
exitWith =<< serveWallet @'Testnet
tracers
sTolerance
(Just databaseDir)
hostPreference
listen
(Launch cp)
(beforeMainLoop tr)

{-------------------------------------------------------------------------------
Command - 'serve'
Expand All @@ -279,6 +278,7 @@ data ServeArgs = ServeArgs
, _database :: Maybe FilePath
, _syncTolerance :: SyncTolerance
, _block0H :: Hash "Genesis"
, _enableShutdownHandler :: Bool
, _logging :: LoggingOptions TracerSeverities
} deriving (Show, Eq)

Expand All @@ -296,15 +296,15 @@ cmdServe = command "serve" $ info (helper <*> helper' <*> cmd) $ mempty
<*> optional databaseOption
<*> syncToleranceOption
<*> genesisHashOption
<*> shutdownHandlerFlag
<*> loggingOptions tracerSeveritiesOption
exec
:: ServeArgs
-> IO ()
exec args@(ServeArgs hostPreference listen nodePort databaseDir sTolerance block0H logOpt) = do
exec args@(ServeArgs hostPreference listen nodePort databaseDir sTolerance block0H enableShutdownHandler logOpt) = do
withTracers logOpt $ \tr tracers -> do
installSignalHandlers (logNotice tr MsgSigTerm)
let trShutdown = trMessage (contramap (fmap MsgShutdownHandler) tr)
void $ withShutdownHandler trShutdown $ do
withShutdownHandlerMaybe tr enableShutdownHandler $ do
logInfo tr $ MsgServeArgs args
let baseUrl = localhostBaseUrl $ getPort nodePort
let cp = JormungandrConnParams block0H baseUrl
Expand All @@ -322,6 +322,11 @@ cmdServe = command "serve" $ info (helper <*> helper' <*> cmd) $ mempty
Nothing -> pure ()
Just a -> fn a

withShutdownHandlerMaybe _ False = void
withShutdownHandlerMaybe tr True = void . withShutdownHandler trShutdown
where
trShutdown = trMessage (contramap (fmap MsgShutdownHandler) tr)

{-------------------------------------------------------------------------------
Options
-------------------------------------------------------------------------------}
Expand Down Expand Up @@ -368,6 +373,11 @@ extraArguments = many $ argument jmArg $ mempty
<> " command.\nIf you need to use this option,"
<> " run Jörmungandr separately and use 'serve'."

shutdownHandlerFlag :: Parser Bool
shutdownHandlerFlag = switch
( long "shutdown-handler"
<> help "Enable the clean shutdown handler (exits when stdin is closed)" )

tracerSeveritiesOption :: Parser TracerSeverities
tracerSeveritiesOption = Tracers
<$> traceOpt applicationTracer (Just Info)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ spec = do
, "--node-port", show nPort
, "--random-port"
, "--genesis-block-hash", block0H
, "--shutdown-handler"
]
(pure ())
CreatePipe
Expand Down
9 changes: 9 additions & 0 deletions nix/haskell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
, profiling ? config.haskellNix.profiling or false
# Project top-level source tree
, src
# GitHub PR number (when building on Hydra)
, pr ? null
}:

let
Expand Down Expand Up @@ -55,6 +57,10 @@ let
# Add dependencies
{
packages.cardano-wallet-jormungandr.components.tests = {
# Only run integration tests on non-PR jobsets. Note that
# the master branch jobset will just re-use the cached Bors
# staging build and test results.
integration.doCheck = !isHydraPRJobset;
# Some tests want to write ~/.local/share/cardano-wallet
integration.preCheck = "export HOME=`pwd`";
# provide jormungandr command to test suites
Expand Down Expand Up @@ -127,5 +133,8 @@ let
];
};

# Hydra will pass the GitHub PR number as a string argument to release.nix.
isHydraPRJobset = toString pr != "";

in
pkgSet.config.hsPkgs // { _config = pkgSet.config; }
14 changes: 10 additions & 4 deletions release.nix
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
, projectArgs ? {
config = { allowUnfree = false; inHydra = true; };
gitrev = cardano-wallet.rev;
inherit pr;
}

# The systems that the jobset will be built for.
Expand All @@ -51,6 +52,8 @@
# Import pkgs, including IOHK common nix lib
, pkgs ? import ./nix { inherit sourcesOverride; }

# GitHub PR number (as a string), provided as a Hydra input
, pr ? null
}:

with (import pkgs.iohkNix.release-lib) {
Expand All @@ -73,15 +76,18 @@ let
map (drv: drv // { inherit packageName; }) (collectTests' package)
) ds);

# Remove build jobs for which cross compiling does not make sense.
filterJobsCross = filterAttrs (n: _: n != "dockerImage" && n != "shell" && n != "stackShell");

inherit (systems.examples) mingwW64 musl64;

jobs = {
native = mapTestOn (packagePlatformsOrig project);
# Cross compilation, excluding the dockerImage and shells that we cannnot cross compile
"${mingwW64.config}" = mapTestOnCross mingwW64 (packagePlatformsCross
(filterAttrs (n: _: n != "dockerImage" && n != "shell" && n != "stackShell") project));
musl64 = mapTestOnCross musl64 (packagePlatformsCross
(filterAttrs (n: _: n != "dockerImage" && n != "shell") project));
"${mingwW64.config}" = mapTestOnCross mingwW64
(packagePlatformsCross (filterJobsCross project));
musl64 = mapTestOnCross musl64
(packagePlatformsCross (filterJobsCross project));
}
// {
# This aggregate job is what IOHK Hydra uses to update
Expand Down

0 comments on commit 9314321

Please sign in to comment.