Skip to content

Commit c3c6997

Browse files
authored
Merge pull request #379 from ambiata/topic/flake
Replace constant delay with retries to deflake test
2 parents c2aea93 + 58c5c5b commit c3c6997

File tree

1 file changed

+9
-5
lines changed
  • mismi-autoscaling/test/Test/IO/Mismi/Autoscaling

1 file changed

+9
-5
lines changed

mismi-autoscaling/test/Test/IO/Mismi/Autoscaling/Commands.hs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,16 @@ prop_scale_in_invalid_state = once . testGroup $ \c g -> do
104104
conf <- conf' c
105105
createConfiguration conf
106106
createGroup $ group' c g 1
107-
-- Allow ec2 instance to partially start up
108-
liftIO . snooze $ seconds 10
109-
d <- describeOrFail g
110-
let is = scalingInstanceId <$> groupResultInstances d
107+
108+
let retryX action =
109+
retrying
110+
(constantDelay 2000000 <> limitRetries 20) {- 2 seconds -}
111+
(const $ return . null)
112+
(const action)
113+
114+
is <- retryX $ (fmap scalingInstanceId . groupResultInstances) <$> describeOrFail g
111115
r <- runEitherT $ lockInstances g is
112-
pure $ r === Left InstanceProtectionInvalidState
116+
pure $ (r, length is) === (Left InstanceProtectionInvalidState, 1)
113117

114118
prop_scale_in = once . testGroup $ \c g -> do
115119
conf <- conf' c

0 commit comments

Comments
 (0)