JBehave
  1. JBehave
  2. JBEHAVE-1051

The method StoryManager.waitUntilAllDoneOrFailed(BatchFailures) can cancel un-started stories

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Duplicate
    • Affects Version/s: 3.x
    • Fix Version/s: 3.9.5
    • Component/s: Core
    • Labels:
      None
    • Environment:
    • Number of attachments :
      0

      Description

      I run several stories in parallel using the default multi-threaded Embedder.executorService and configure it with EmbedderControls.threads > 1
      Sometimes the JBEHAVE ends and no scenario (but before- and after- scenario) of my stories was even started. It is not repeatable, sometims it goes good.
      I founded out, that the method StoryManager.waitUntilAllDoneOrFailed fails, if there are ONLY stories, which are already SUBMITTED, but not yet really STARTED. The method StoryManager.waitUntilAllDoneOrFailed doesn't consider them while is defining, whether all stories are done or not. However waitUntilAllDoneOrFailed cancells them later.

      The success or failure of stories depend therefore on the race condition of starting the stories and waitUntilAllDoneOrFailed.

        Activity

        Hide
        Jewgenij Moldawski added a comment -

        With this patch I could solve this problem. I didn't refactor the "if (true)" in order to show the real change.

        diff --git a/jbehave-core/src/main/java/org/jbehave/core/embedder/StoryManager.java b/jbehave-core/src/main/java/org/jbehave/core/embedder/StoryManager.java
        index 2414cf7..ad70587 100644
        — a/jbehave-core/src/main/java/org/jbehave/core/embedder/StoryManager.java
        +++ b/jbehave-core/src/main/java/org/jbehave/core/embedder/StoryManager.java
        @@ -143,7 +143,7 @@
        while (!allDone) {
        allDone = true;
        for (RunningStory runningStory : runningStories.values()) {

        • if ( runningStory.isStarted() ){
          + if ( true ){
          Story story = runningStory.getStory();
          Future<ThrowableStory> future = runningStory.getFuture();
          if (!future.isDone()) {
        Show
        Jewgenij Moldawski added a comment - With this patch I could solve this problem. I didn't refactor the "if (true)" in order to show the real change. diff --git a/jbehave-core/src/main/java/org/jbehave/core/embedder/StoryManager.java b/jbehave-core/src/main/java/org/jbehave/core/embedder/StoryManager.java index 2414cf7..ad70587 100644 — a/jbehave-core/src/main/java/org/jbehave/core/embedder/StoryManager.java +++ b/jbehave-core/src/main/java/org/jbehave/core/embedder/StoryManager.java @@ -143,7 +143,7 @@ while (!allDone) { allDone = true; for (RunningStory runningStory : runningStories.values()) { if ( runningStory.isStarted() ){ + if ( true ){ Story story = runningStory.getStory(); Future<ThrowableStory> future = runningStory.getFuture(); if (!future.isDone()) {
        Hide
        Mauro Talevi added a comment -

        Duplicate of JBEHAVE-1046.

        Show
        Mauro Talevi added a comment - Duplicate of JBEHAVE-1046 .
        Mauro Talevi made changes -
        Field Original Value New Value
        Resolution Duplicate [ 3 ]
        Fix Version/s 3.9.5 [ 20598 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Hide
        Rodrigo Machado added a comment -

        Hey guys, I just saw this fix for 4.0-beta-11. I have a suggestion to make.

        This was happening because the thread that changes the value of the isStarted flag to true doesnt have time to execute before the StoryMangar passes trhough it.

        To fix that, I simple change the code to call the tickTock before the execution, and not after. Then everything worked fine.
        I belive that this is more elegant than create another flag.

        Show
        Rodrigo Machado added a comment - Hey guys, I just saw this fix for 4.0-beta-11. I have a suggestion to make. This was happening because the thread that changes the value of the isStarted flag to true doesnt have time to execute before the StoryMangar passes trhough it. To fix that, I simple change the code to call the tickTock before the execution, and not after. Then everything worked fine. I belive that this is more elegant than create another flag.
        Hide
        Mauro Talevi added a comment -

        You mean before the loop over the RunningStory collection, and not after?

        You think that 100ms would make such a difference?

        Show
        Mauro Talevi added a comment - You mean before the loop over the RunningStory collection, and not after? You think that 100ms would make such a difference?

          People

          • Assignee:
            Unassigned
            Reporter:
            Jewgenij Moldawski
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: