Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions sdk/test/IntegrationSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1482,6 +1482,35 @@ needsClient = do
2
lift $ C.waitWorkflowResult wfH `shouldReturn` 25

it "processes signals in order of delivery" $ \TestEnv {..} -> do
let conf = provideCallStack $ configure () (discoverDefinitions @() $$(discoverInstances) $$(discoverInstances)) baseConf
withWorker conf $ do
let opts =
(C.startWorkflowOptions taskQueue)
{ C.workflowIdReusePolicy = Just W.WorkflowIdReusePolicyAllowDuplicate
, C.timeouts =
C.TimeoutOptions
{ C.runTimeout = Just $ seconds 4
, C.executionTimeout = Nothing
, C.taskTimeout = Nothing
}
}
useClient $ do
liftIO $ putStrLn "signalWithStart call"
wfH <-
C.signalWithStart
SignalEnqueuesItemWorkflow
"signalWithStartWithQueue"
opts
signalWithArgs
1

-- liftIO $ threadDelay 1_000
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the test succeeds if this line is uncommented, so it looks like there is some sort of window of time affecting how state var changes get sequenced


C.signal wfH signalWithArgs C.defaultSignalOptions 2
lift $ C.waitWorkflowResult wfH `shouldReturn` [1, 2]


-- specify "works as intended and returns correct runId" pending
describe "RetryPolicy" $ do
specify "is used for retryable failures" $ \TestEnv {..} -> do
Expand Down
15 changes: 15 additions & 0 deletions sdk/test/IntegrationSpec/Signals.hs
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,18 @@ signalWithArgsWorkflow init = provideCallStack do


registerWorkflow 'signalWithArgsWorkflow


signalEnqueuesItemWorkflow :: Workflow [Int]
signalEnqueuesItemWorkflow = provideCallStack do
var <- newStateVar []
setSignalHandler signalWithArgs $ \i -> do
$(logDebug) "updating value and unblocking workflow"
readStateVar var >>= \s -> writeStateVar var (s <> [i])

sleep (seconds 2)

waitCondition $ (not . null) <$> readStateVar var
readStateVar var

registerWorkflow 'signalEnqueuesItemWorkflow