Question about wait_for

28 views
Skip to first unread message

John Roberts

unread,
Feb 17, 2012, 12:31:17 PM2/17/12
to openwfe...@googlegroups.com
Is there a way to cause engine.wait_for to time out after a certain period of time?  

In our testing process, our tests hang in the event that an expected work item is not generated, as the engine quite happily (and appropriately) blocks when we ask it to wait for a specific work item.  Though this indicates that there is a problem to the human running the test, the automated CI testing just hangs.  My goal is to be able to generate a red test when this occurs, so I can enter testing nirvana by making it green...

Thanks for any input or advice!

John Mettraux

unread,
Feb 17, 2012, 9:05:59 PM2/17/12
to openwfe...@googlegroups.com

On Fri, Feb 17, 2012 at 09:31:17AM -0800, John Roberts wrote:
>
> Is there a way to cause engine.wait_for to time out after a certain period
> of time?

Hello John,

welcome to the ruote mailing list.

How about using Ruby's timeout?

http://www.ruby-doc.org/stdlib-1.9.3/libdoc/timeout/rdoc/Timeout.html

Is that sufficient?

--
John Mettraux - http://lambda.io/processi

John Roberts

unread,
Feb 17, 2012, 10:52:32 PM2/17/12
to openwfe...@googlegroups.com
Hmmm, that may.  I'll play with that a little on Monday when I get back into the office!

Thanks!

John Mettraux

unread,
Feb 18, 2012, 3:57:12 PM2/18/12
to openwfe...@googlegroups.com
Hello John,

maybe that :or_error could help:

https://github.com/jmettraux/ruote/commit/5e1084b71195b8c7e16d88c9a67854098dd7c063

You can wait for a participant to receive a workitem or for an error to
happen:

dashboard.wait_for(:alpha, :or_error)


I hope it helps, best regards,

John Roberts

unread,
Feb 20, 2012, 5:33:08 PM2/20/12
to openwfe...@googlegroups.com
Hello,

We have an error participant that takes care of a host of things in the event that a runtime error occurs...  I think the type of error I want to catch at this stage in the development process is that we have incorrectly defined the workflow logic in a new or modified workflow, which results in an unexpected workitem getting generated.  In this case, our test suite is calling dashboard.wait_for(expected_workitem), so it just hangs, waiting ever so patiently for a workitem to appear that will never appear due to our (usually my) logic error.

I think the timeout is still the best approach for the moment, I just haven't had time to play with it yet.  We know from trial and error about how long it takes for workitems to get generated during the testing process, so I can conceivably just set the timeout at a second or two past that, and throw an exception.  This would at least have the benefit of allowing the testing suite to continue with a red test and an error noisy enough that we can figure out how to correct it.

Thanks for your help!!

- jrob

John Mettraux

unread,
Feb 20, 2012, 7:39:35 PM2/20/12
to openwfe...@googlegroups.com

On Mon, Feb 20, 2012 at 02:33:08PM -0800, John Roberts wrote:
>
> We have an error participant that takes care of a host of things in the
> event that a runtime error occurs... I think the type of error I want to
> catch at this stage in the development process is that we have incorrectly
> defined the workflow logic in a new or modified workflow, which results in
> an unexpected workitem getting generated. In this case, our test suite is
> calling dashboard.wait_for(expected_workitem), so it just hangs, waiting
> ever so patiently for a workitem to appear that will never appear due to
> our (usually my) logic error.

Hello John,

I interpret your

> our test suite is calling dashboard.wait_for(expected_workitem)

as

> our test suite is calling

> dashboard.wait_for(:name_of_the_participant_expected_receive_a_workitem)


In this case, you could write something like

---8<---
r = dashboard.wait_for('dispatched')
assert_equal 'expected_participant_name', r['participant_name']
--->8---

The wait_for will return as soon as a workitem is dispatched. The resulting
message, stored in "r", yields useful info for assertions.

John Mettraux

unread,
Mar 18, 2012, 4:03:02 AM3/18/12
to openwfe...@googlegroups.com
Hello,

just a quick note, I added a :timeout option to Ruote::Dashboard#wait_for

https://github.com/jmettraux/ruote/commit/4d1b46ef39dec237a08ed9b680f8bc184e673997

and also set a default timeout of 1 minute (I'll see how it goes with the
various storages).


Hope it helps,

Reply all
Reply to author
Forward
0 new messages