LGTM
On Fri, Apr 11, 2014 at 12:43 PM, Klaus Aehlig <[email protected]> wrote: > Verify that a request to opportunistically allocate locks never > reduces the amount of locks held. > > Signed-off-by: Klaus Aehlig <[email protected]> > --- > test/hs/Test/Ganeti/Locking/Waiting.hs | 15 +++++++++++++++ > 1 file changed, 15 insertions(+) > > diff --git a/test/hs/Test/Ganeti/Locking/Waiting.hs > b/test/hs/Test/Ganeti/Locking/Waiting.hs > index 6a0ab15..1e2b8c8 100644 > --- a/test/hs/Test/Ganeti/Locking/Waiting.hs > +++ b/test/hs/Test/Ganeti/Locking/Waiting.hs > @@ -290,6 +290,20 @@ prop_ReadShow = > forAll (arbitrary :: Gen (LockWaiting TestLock TestOwner Integer)) $ > \state -> > (liftM extRepr . J.readJSON $ J.showJSON state) ==? (J.Ok $ extRepr > state) > > +-- | Verify that opportunistic union only increases the locks held. > +prop_OpportunisticMonotone :: Property > +prop_OpportunisticMonotone = > + forAll (arbitrary :: Gen (LockWaiting TestLock TestOwner Integer)) $ > \state -> > + forAll (arbitrary :: Gen TestOwner) $ \a -> > + forAll ((choose (1,3) >>= vector) :: Gen [(TestLock, L.OwnerState)]) $ > \req -> > + let (state', _) = opportunisticLockUnion a req state > + oldOwned = listLocks a $ getAllocation state > + oldLocks = M.keys oldOwned > + newOwned = listLocks a $ getAllocation state' > + in printTestCase "Opportunistic union may only increase the set of > locks held" > + . flip all oldLocks $ \lock -> > + M.lookup lock newOwned >= M.lookup lock oldOwned > + > testSuite "Locking/Waiting" > [ 'prop_NoActionWithPendingRequests > , 'prop_WaitingRequestsGetPending > @@ -302,4 +316,5 @@ testSuite "Locking/Waiting" > , 'prop_SimulateUpdateLocks > , 'prop_SimulateUpdateLocksWaiting > , 'prop_ReadShow > + , 'prop_OpportunisticMonotone > ] > -- > 1.9.1.423.g4596e3a > >
