Skip to content

Commit

Permalink
Stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
newhoggy committed Aug 3, 2020
1 parent 9062645 commit 3d4ab28
Show file tree
Hide file tree
Showing 32 changed files with 1,299 additions and 11 deletions.
4 changes: 2 additions & 2 deletions cardano-node/cardano-node.cabal
Expand Up @@ -237,8 +237,7 @@ executable chairman
, contra-tracer
, cardano-prelude
, io-sim-classes
, network-mux
, cardano-node-config
, network-mux , cardano-node-config
, optparse-applicative
, ouroboros-consensus
, ouroboros-consensus-cardano
Expand Down Expand Up @@ -285,6 +284,7 @@ test-suite cardano-node-test
, process
, shelley-spec-ledger
, shelley-spec-ledger-test
, temporary
, time

other-modules: Test.Cardano.Node.Chairman
Expand Down
12 changes: 6 additions & 6 deletions cardano-node/test/Test/Cardano/Node/Chairman.hs
Expand Up @@ -23,13 +23,13 @@ prop_spawnOneNode = H.propertyOnce $ do

(_mIn, _mOut, _mErr, hProcess) <- H.createProcess =<< H.procNode
[ "run"
, "--database-path", base <> "/db/node-2/"
, "--socket-path", base <> "/socket/node-2-socket"
, "--database-path", base <> "/chairman/db/node-2"
, "--socket-path", base <> "/chairman/socket/node-2-socket"
, "--port", "3002"
, "--topology", base <> "/configuration/defaults/simpleview/topology-node-2.json"
, "--config", base <> "/configuration/defaults/simpleview/config-2.yaml"
, "--signing-key", base <> "/configuration/defaults/simpleview/genesis/delegate-keys.002.key"
, "--delegation-certificate", base <> "/configuration/defaults/simpleview/genesis/delegation-cert.002.json"
, "--topology", base <> "/chairman/configuration/defaults/simpleview/topology-node-2.json"
, "--config", base <> "/chairman/configuration/defaults/simpleview/config-2.yaml"
, "--signing-key", base <> "/chairman/configuration/defaults/simpleview/genesis/delegate-keys.002.key"
, "--delegation-certificate", base <> "/chairman/configuration/defaults/simpleview/genesis/delegation-cert.002.json"
]

H.threadDelay 10000000
Expand Down
47 changes: 44 additions & 3 deletions cardano-node/test/Test/Common/Base.hs
Expand Up @@ -2,24 +2,36 @@ module Test.Common.Base
( propertyOnce
, failWithCustom
, threadDelay
, workspace
, moduleWorkspace
) where

import Control.Monad.IO.Class (liftIO)
import Data.Bool
import Data.Either (Either (..))
import Data.Function (($), (.))
import Data.Functor
import Data.Int
import Data.Maybe (Maybe (..))
import Data.Maybe (Maybe (..), fromMaybe, listToMaybe)
import Data.Monoid (Monoid (..))
import Data.Semigroup (Semigroup (..))
import Data.String (String)
import GHC.Stack (CallStack)
import Data.Tuple
import GHC.Stack (CallStack, HasCallStack, callStack, getCallStack)
import Hedgehog (MonadTest)
import Hedgehog.Internal.Property (Diff, liftTest, mkTest)
import Hedgehog.Internal.Source (getCaller)
import System.IO (IO)
import System.IO (FilePath, IO)

import qualified Control.Concurrent as IO
import qualified GHC.Stack as GHC
import qualified Hedgehog as H
import qualified Hedgehog.Internal.Property as H
import qualified System.Directory as IO
import qualified System.IO.Temp as IO

cardanoCliPath :: FilePath
cardanoCliPath = "cardano-cli"

propertyOnce :: H.PropertyT IO () -> H.Property
propertyOnce = H.withTests 1 . H.property
Expand All @@ -30,3 +42,32 @@ threadDelay = liftIO . IO.threadDelay
-- | Takes a 'CallStack' so the error can be rendered at the appropriate call site.
failWithCustom :: MonadTest m => CallStack -> Maybe Diff -> String -> m a
failWithCustom cs mdiff msg = liftTest $ mkTest (Left $ H.Failure (getCaller cs) msg mdiff, mempty)

-- | Create a workspace directory which will exist for at least the duration of
-- the supplied block.
--
-- The directory will have the supplied prefix but contain a generated random
-- suffix to prevent interference between tests
--
-- The directory will be deleted if the block succeeds, but left behind if
-- the block fails.
workspace :: HasCallStack => FilePath -> (FilePath -> H.PropertyT IO ()) -> H.PropertyT IO ()
workspace prefixPath f = GHC.withFrozenCallStack $ do
liftIO $ IO.createDirectoryIfMissing True prefixPath
ws <- liftIO $ IO.createTempDirectory prefixPath "test"
H.annotate $ "Workspace: " <> cardanoCliPath <> "/" <> ws
f ws
liftIO $ IO.removeDirectoryRecursive ws

-- | Create a workspace directory which will exist for at least the duration of
-- the supplied block.
--
-- The directory will have the prefix as "$prefixPath/$moduleName" but contain a generated random
-- suffix to prevent interference between tests
--
-- The directory will be deleted if the block succeeds, but left behind if
-- the block fails.
moduleWorkspace :: HasCallStack => FilePath -> (FilePath -> H.PropertyT IO ()) -> H.PropertyT IO ()
moduleWorkspace prefixPath f = GHC.withFrozenCallStack $ do
let srcModule = fromMaybe "UnknownModule" (fmap (GHC.srcLocModule . snd) (listToMaybe (getCallStack callStack)))
workspace (prefixPath <> "/" <> srcModule) f
212 changes: 212 additions & 0 deletions chairman/configuration/defaults/simpleview/config-0.yaml
@@ -0,0 +1,212 @@
# global filter; messages must have at least this severity to pass:
minSeverity: Debug

# global file rotation settings:
rotation:
rpLogLimitBytes: 5000000
rpKeepFilesNum: 10
rpMaxAgeHours: 24

# these backends are initialized:
setupBackends:
- KatipBK
# Uncomment it to enable trace forwarder backend, if the node should
# forward metrics to an external process.
# - TraceForwarderBK

# if not indicated otherwise, then messages are passed to these backends:
defaultBackends:
- KatipBK

# if wanted, the EKG interface is listening on this port:
#hasEKG: 12781

#hasPrometheus:
# - "127.0.0.1"
# - 13788

# here we set up outputs of logging in 'katip':
setupScribes:
- scKind: FileSK
scName: "logs/node-0.log"
scFormat: ScText
- scKind: StdoutSK
scName: stdout
scFormat: ScText
scRotation: null

# if not indicated otherwise, then log output is directed to this:
defaultScribes:
- - FileSK
- "logs/node-0.log"
- - StdoutSK
- stdout

# more options which can be passed as key-value pairs:
options:
mapSubtrace:
'#ekgview':
contents:
- - tag: Contains
contents: 'cardano.epoch-validation.benchmark'
- - tag: Contains
contents: .monoclock.basic.
- - tag: Contains
contents: 'cardano.epoch-validation.benchmark'
- - tag: Contains
contents: diff.RTS.cpuNs.timed.
- - tag: StartsWith
contents: '#ekgview.#aggregation.cardano.epoch-validation.benchmark'
- - tag: Contains
contents: diff.RTS.gcNum.timed.
subtrace: FilterTrace
'cardano.epoch-validation.utxo-stats':
# Change the `subtrace` value to `Neutral` in order to log
# `UTxO`-related messages during epoch validation.
subtrace: NoTrace
mapBackends:
cardano.node.ChainDB.metrics:
- EKGViewBK
- kind: UserDefinedBK
name: LiveViewBackend
cardano.node.metrics.Forge:
- EKGViewBK
cardano.node.metrics.Mempool:
- EKGViewBK
cardano.node.metrics:
- EKGViewBK
- kind: UserDefinedBK
name: LiveViewBackend
# Uncomment it to send 'cardano.node.metrics' to 'TraceForwarderBK' as well.
# - TraceForwarderBK
cardano.node.peers:
- EKGViewBK
cardano.node.BlockFetchDecision.peers:
- EKGViewBK
- kind: UserDefinedBK
name: LiveViewBackend
# Uncomment it to send node's release, version and commit to 'TraceForwarderBK'.
# cardano.node.release:
# - TraceForwarderBK
# cardano.node.version:
# - TraceForwarderBK
# cardano.node.commit:
# - TraceForwarderBK

# Uncomment it to forward node's metrics to remote socket '127.0.0.1:2997'.
# traceForwardTo:
# tag: RemoteSocket
# contents:
# - "127.0.0.1"
# - "2997"

##########################################################
############### Cardano Node Configuration ###############
##########################################################


NodeId:
Protocol: RealPBFT
GenesisFile: genesis/genesis.json
NumCoreNodes: 1
RequiresNetworkMagic: RequiresMagic
PBftSignatureThreshold:
TurnOnLogging: True
ViewMode: SimpleView
TurnOnLogMetrics: True
SocketPath:



##### Update Parameters #####

ApplicationName: cardano-sl
ApplicationVersion: 1
LastKnownBlockVersion-Major: 0
LastKnownBlockVersion-Minor: 2
LastKnownBlockVersion-Alt: 0

##### Tracing #####

# MinimalVerbosity: Minimal level of the rendering of captured items
# MaximalVerbosity: Maximal level of the rendering of captured items
# NormalVerbosity: the default level of the rendering of captured items
TracingVerbosity: NormalVerbosity

# Trace BlockFetch client.
TraceBlockFetchClient: True

# Trace BlockFetch decisions made by the BlockFetch client.
TraceBlockFetchDecisions: True

# Trace BlockFetch protocol messages.
TraceBlockFetchProtocol: True

# Serialised Trace BlockFetch protocol messages.
TraceBlockFetchProtocolSerialised: False

# Trace BlockFetch server.
TraceBlockFetchServer: True

# Verbose tracer of ChainDB
TraceChainDb: False

# Trace ChainSync client.
TraceChainSyncClient: False

# Trace ChainSync server (blocks).
TraceChainSyncBlockServer: False

# Trace ChainSync server (headers)
TraceChainSyncHeaderServer: False

# Trace ChainSync protocol messages.
TraceChainSyncProtocol: True

# Trace DNS Resolver messages.
TraceDNSResolver: False

# Trace DNS Subscription messages.
TraceDNSSubscription: False

# Trace error policy resolution.
TraceErrorPolicy: False

# Trace local error policy resolution.
TraceLocalErrorPolicy: True

# Trace block forging.
TraceForge: True

# Trace Handshake protocol messages.
TraceHandshake: False

# Trace IP Subscription messages.
TraceIpSubscription: False

# Trace local ChainSync protocol messages.
TraceLocalChainSyncProtocol: True

# Trace local Handshake protocol messages.
TraceLocalHandshake: False

# Trace local TxSubmission protocol messages.
TraceLocalTxSubmissionProtocol: True

# Trace local TxSubmission server.
TraceLocalTxSubmissionServer: True

# Trace mempool.
TraceMempool: True

# Trace Mux Events
TraceMux: False

# Trace TxSubmission server (inbound transactions).
TraceTxInbound: True

# Trace TxSubmission client (outbound transactions).
TraceTxOutbound: True

# Trace TxSubmission protocol messages.
TraceTxSubmissionProtocol: True

0 comments on commit 3d4ab28

Please sign in to comment.