Skip to content

Commit a8f2ddc

Browse files
committed
Struggling with E2E test
1 parent 6f1613d commit a8f2ddc

File tree

7 files changed

+33
-16
lines changed

7 files changed

+33
-16
lines changed

mithril-aggregator/src/runtime.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::dependency::BeaconStoreWrapper;
22
use crate::Snapshotter;
33
use mithril_common::fake_data;
44
use mithril_common::immutable_digester::ImmutableDigester;
5-
use slog_scope::{error, info};
5+
use slog_scope::{debug, error, info};
66
use tokio::time::{sleep, Duration};
77

88
/// AggregatorRuntime
@@ -46,6 +46,7 @@ impl AggregatorRuntime {
4646
async fn do_work(&self) -> Result<(), String> {
4747
let snapshotter = Snapshotter::new(self.db_directory.clone());
4848
let digester = ImmutableDigester::new(self.db_directory.clone(), slog_scope::logger());
49+
debug!("Making snapshot"; "directory" => &self.db_directory);
4950

5051
match digester.compute_digest() {
5152
Ok(digest_result) => {

mithril-common/src/immutable_digester.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ struct Progress {
9898
impl Progress {
9999
fn report(&mut self, ix: usize) -> bool {
100100
self.index = ix;
101-
ix % (self.total / 20) == 0
101+
(20 * ix) % self.total == 0
102102
}
103103

104104
fn percent(&self) -> f64 {
@@ -195,6 +195,8 @@ mod tests {
195195
}
196196
}
197197

198+
// TODO: Test the case where number of immutable files is lower than 20
199+
198200
#[test]
199201
fn reports_progress_every_5_percent() {
200202
let mut progress = Progress {

mithril-test-lab/mithril-end-to-end/config/cardano-node.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
"RequiresNetworkMagic": "RequiresNoMagic",
1616

17-
"minSeverity": "Info",
17+
"minSeverity": "Trace",
1818
"defaultBackends": ["KatipBK"],
1919
"defaultScribes": [[ "StdoutSK", "stdout" ]],
2020
"setupBackends": ["KatipBK"],
@@ -30,7 +30,7 @@
3030
"TurnOnLogMetrics": true,
3131
"TurnOnLogging": true,
3232

33-
"TracingVerbosity": "NormalVerbosity",
33+
"TracingVerbosity": "MaximalVerbosity",
3434
"TraceBlockFetchClient": false,
3535
"TraceBlockFetchDecisions": false,
3636
"TraceBlockFetchProtocol": false,

mithril-test-lab/mithril-end-to-end/config/genesis-shelley.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,5 @@
5454
"slotsPerKESPeriod": 129600,
5555
"slotLength": 0.1,
5656
"maxKESEvolutions": 60,
57-
"securityParam": 2160
57+
"securityParam": 21
5858
}

mithril-test-lab/mithril-end-to-end/mithril-end-to-end.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ test-suite integration
180180
, cardano-ledger-shelley-ma
181181
, containers
182182
, contra-tracer
183+
, directory
183184
, filepath
184185
, hedgehog-quickcheck
185186
, hspec

mithril-test-lab/mithril-end-to-end/src/Mithril/Aggregator.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,4 @@ aggregatorProcess cwd port = do
100100
]
101101
<> baseEnv
102102
unlessM (doesFileExist aggregator) $ failure $ "cannot find mithril-aggregator executable in expected location (" <> binDir <> ")"
103-
pure $ (proc aggregator ["--server-port", show port, "-vvv"]) {cwd, env}
103+
pure $ (proc aggregator ["--db-directory", "db", "--server-port", show port, "-vvv"]) {cwd, env}

mithril-test-lab/mithril-end-to-end/test/Test/EndToEndSpec.hs

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ import Mithril.Aggregator
2828
import Mithril.Client (runClient)
2929
import Mithril.Signer (Signer, withSigner)
3030
import Network.HTTP.Simple (getResponseBody, getResponseStatusCode, httpJSON, httpLBS, parseRequest)
31+
import System.Directory (listDirectory)
32+
import System.FilePath (takeDirectory, takeExtension, (</>))
3133
import Test.Hydra.Prelude
3234

3335
spec :: Spec
@@ -40,20 +42,22 @@ spec =
4042
{ parentStateDirectory = tmp,
4143
networkId = defaultNetworkId
4244
}
43-
-- Start aggregator service on some random port
44-
withAggregator tmp (contramap AggregatorLog tr) $ \aggregator@Aggregator {aggregatorPort} -> do
45-
-- Start cardano nodes cluster
46-
withCluster tr config $
47-
\cluster -> do
48-
-- basic verification, we check the nodes are producing blocks
49-
assertNetworkIsProducingBlock tr cluster
50-
case cluster of
51-
RunningCluster {clusterNodes = node : _} -> do
45+
-- Start cardano nodes cluster
46+
withCluster tr config $
47+
\cluster -> do
48+
-- basic verification, we check the nodes are producing blocks
49+
assertNetworkIsProducingBlock tr cluster
50+
case cluster of
51+
RunningCluster {clusterNodes = node@(RunningNode _ nodeSocket) : _} -> do
52+
waitForDBToBePopulated (takeDirectory nodeSocket)
53+
-- Start aggregator service on some random port
54+
withAggregator (takeDirectory nodeSocket) (contramap AggregatorLog tr) $ \aggregator@Aggregator {aggregatorPort} -> do
55+
threadDelay 2
5256
digest <- assertNodeIsProducingSnapshot tr node aggregatorPort
5357
withSigner tmp (contramap SignerLog tr) aggregatorPort node $ \signer -> do
5458
assertSignerIsSigningSnapshot signer aggregatorPort digest
5559
assertClientCanVerifySnapshot tmp aggregator digest
56-
_ -> failure "No nodes in the cluster"
60+
_ -> failure "No nodes in the cluster"
5761

5862
newtype Snapshots = Snapshots [Value]
5963
deriving newtype (FromJSON)
@@ -112,6 +116,15 @@ assertNetworkIsProducingBlock tracer = failAfter 30 . go (-1)
112116
waitForNewBlock :: IO ()
113117
waitForNewBlock = threadDelay (2 * slotLength)
114118

119+
waitForDBToBePopulated :: FilePath -> IO ()
120+
waitForDBToBePopulated nodeDirectory = do
121+
let immutableDir = nodeDirectory </> "db" </> "immutable"
122+
isChunk = ((== ".chunk") . takeExtension)
123+
immutableFiles <- filter isChunk <$> listDirectory immutableDir
124+
when (length immutableFiles < 2) $ do
125+
putStrLn $ "waiting for immutable directory " <> immutableDir <> " to have at least 2 chunk files"
126+
threadDelay 1 >> waitForDBToBePopulated nodeDirectory
127+
115128
slotLength :: DiffTime
116129
slotLength = 1 -- FIXME this should be found in the genesis file
117130

0 commit comments

Comments
 (0)