-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFastSpec.hs
60 lines (51 loc) · 1.88 KB
/
FastSpec.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
-- | Special properties for fast version of algorithm.
module Test.Sdn.Overall.FastSpec
( spec
) where
import Universum
import qualified Control.TimeWarp.Rpc as D
import Data.Default
import Test.Hspec (Spec, describe)
import Test.Hspec.QuickCheck (prop)
import Test.QuickCheck (Small (..), arbitrary, forAll, suchThat)
import Sdn.Base
import qualified Sdn.Extra.Schedule as S
import Sdn.Policy.Fake
import Sdn.Protocol
import Test.Sdn.Overall.Launcher
import Test.Sdn.Overall.Properties
spec :: Spec
spec = do
let testLaunchF = testLaunch @Fast
describe "no recovery" $ do
prop "normal condition" $
testLaunchF $ def
{ testProperties =
eventually (recoveryWasUsed False)
: basicProperties
}
prop "acceptor unavailable" $
testLaunchF def
{ testSettings = def
{ topologyMembers = def { acceptorsNum = 5 }
}
, testDelays =
D.forAddress (processAddress (Acceptor 1)) D.blackout
, testProperties =
eventually (recoveryWasUsed False)
: basicProperties
}
describe "recovery" $ do
prop "1 ballot, many conflicting policies" $
forAll (arbitrary `suchThat` (>= 5)) $
\(Small n :: Small Word) ->
testLaunchF def
{ testSettings = defTopologySettings
{ topologyProposalSchedule = do
S.times n
S.generate (BadPolicy <$> arbitrary)
}
, testProperties =
-- eventually (recoveryWasUsed True) : -- dunno how to force recovery
basicProperties
}