@@ -37,6 +37,9 @@ import Cardano.Logging.Test.Messages
37
37
import Cardano.Logging.Test.Types
38
38
39
39
40
+ import Debug.Trace
41
+
42
+
40
43
data TestSetup a
41
44
= TestSetup
42
45
{ tsTime :: ! (a Double )
@@ -111,7 +114,8 @@ runScriptForwarding ::
111
114
-> Trace IO FormattedMessage
112
115
-> IORef Int
113
116
-> Property
114
- runScriptForwarding TestSetup {.. } fwdTracer stdoutTracer' accumulationCounter = do
117
+ runScriptForwarding ts@ TestSetup {.. } fwdTracer stdoutTracer' accumulationCounter =
118
+ trace (" Test setup " ++ show ts) $ do
115
119
let generator :: Gen [Script ] = vectorOf (runIdentity tsThreads) $
116
120
case runIdentity tsMessages of
117
121
Nothing -> scale (* 1000 ) arbitrary
@@ -127,14 +131,16 @@ runScriptForwarding TestSetup{..} fwdTracer stdoutTracer' accumulationCounter =
127
131
severityForMessage
128
132
privacyForMessage
129
133
configureTracers simpleTestConfig docMessage [tr]
130
- let scripts' = map (\ (Script sc) ->
131
- Script (sort sc)) scripts
132
- scripts'' = map (\ (Script sc) ->
133
- Script (withMessageIds 0 sc)) scripts'
134
- scripts''' = map (\ (Script sc) ->
135
- Script $ map (withTimeFactor (runIdentity tsTime)) sc) scripts''
136
- scripts'''' = map (\ (Script sc) ->
137
- Script $ filter (\ (ScriptedMessage _ msg) -> namesForMessage msg /= [" Message2" ]) sc) scripts'''
134
+ let scripts' = map (\ (Script sc) -> Script
135
+ $ filter (\ (ScriptedMessage _ msg) ->
136
+ namesForMessage msg /= [" Message2" ]) sc) scripts
137
+ scripts'' = map (\ (Script sc) -> Script (sort sc)) scripts'
138
+ scripts''' = zipWith (\ (Script sc) ind -> Script (
139
+ withMessageIds (runIdentity tsThreads) ind sc)) scripts'' [0 .. ]
140
+ scripts'''' = map (\ (Script sc) -> Script
141
+ $ map (withTimeFactor (runIdentity tsTime)) sc) scripts'''
142
+
143
+
138
144
-- putStrLn ("runTest " ++ show scripts)
139
145
children :: MVar [MVar (Either SomeException () )] <- newMVar []
140
146
mapM_ (\ sc -> forkChild children (playIt sc tr 0.0 )) scripts''''
@@ -150,7 +156,7 @@ runScriptForwarding TestSetup{..} fwdTracer stdoutTracer' accumulationCounter =
150
156
let numMsg = sum (map (\ (Script sc) -> length sc) scripts'''')
151
157
in if numMsg > 0 then do
152
158
-- TODO mutiple files
153
- contents <- readFile " /tmp/cardano-tracer -logs/tmp-tracersock@0/node.json"
159
+ contents <- readFile " /tmp/cardano-forwarder-test -logs/tmp-tracersock@0/node.json"
154
160
let lineLength = length (lines contents) - 1
155
161
putStrLn $ " Line length " ++ show lineLength
156
162
putStrLn $ " Msg length " ++ show numMsg
@@ -198,12 +204,12 @@ playIt (Script (ScriptedMessage d1 m1 : rest)) tr d = do
198
204
-- MessageId gives the id to start with.
199
205
-- Returns a tuple with the messages with ids and
200
206
-- the successor of the last used messageId
201
- withMessageIds :: MessageID -> [ScriptedMessage ] -> [ScriptedMessage ]
202
- withMessageIds mid sMsgs = go mid sMsgs []
207
+ withMessageIds :: Int -> MessageID -> [ScriptedMessage ] -> [ScriptedMessage ]
208
+ withMessageIds numThreads mid sMsgs = go mid sMsgs []
203
209
where
204
210
go _mid' [] acc = reverse acc
205
211
go mid' (ScriptedMessage time msg : tl) acc =
206
- go (mid' + 1 ) tl (ScriptedMessage time (setMessageID msg mid') : acc)
212
+ go (mid' + numThreads ) tl (ScriptedMessage time (setMessageID msg mid') : acc)
207
213
208
214
withTimeFactor :: Double -> ScriptedMessage -> ScriptedMessage
209
215
withTimeFactor factor (ScriptedMessage time msg) =
0 commit comments