Revision fb68bc0c

b/test/hs/Test/Ganeti/Locking/Allocation.hs
257 257
        . F.foldl freeLocks state
258 258
        $ S.filter (/= blocker) blockers
259 259

  
260
-- | Verify that opportunistic union only increases the locks held.
261
prop_OpportunisticMonotone :: Property
262
prop_OpportunisticMonotone =
263
  forAll (arbitrary :: Gen (LockAllocation TestLock TestOwner)) $ \state ->
264
  forAll (arbitrary :: Gen TestOwner) $ \a ->
265
  forAll ((choose (1,3) >>= vector) :: Gen [(TestLock, OwnerState)]) $ \req ->
266
  let (state', _) = opportunisticLockUnion a req state
267
      oldOwned = listLocks a state
268
      oldLocks = M.keys oldOwned
269
      newOwned = listLocks a state'
270
  in printTestCase "Opportunistic union may only increase the set of locks held"
271
     . flip all oldLocks $ \lock ->
272
       M.lookup lock newOwned >= M.lookup lock oldOwned
273

  
260 274
testSuite "Locking/Allocation"
261 275
 [ 'prop_LocksDisjoint
262 276
 , 'prop_LockImplicationX
......
266 280
 , 'prop_LockReleaseSucceeds
267 281
 , 'prop_BlockSufficient
268 282
 , 'prop_BlockNecessary
283
 , 'prop_OpportunisticMonotone
269 284
 ]

Also available in: Unified diff