Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-52913

Behat suite hangs if a step throws an exception inside a database transaction.

XMLWordPrintable

    • MOODLE_29_STABLE
    • MOODLE_29_STABLE, MOODLE_30_STABLE
    • MDL-52913_master
    • Hide
      1. Place the attached behat_broken.php and broken.feature in lib/tests/behat
      2. Update your behat site
      3. Run the following command: vendor/bin/behat --config path/to/behat.yml --tags=broken_transaction,core /path/to/moodle/lib/tests/behat
      4. The test should run 4 scenarios (2 from action_menu.feature, 1 from broken.feature and 1 from timezone.feature). The scenario in broken.feature will fail, but timezone.feature will still run after it.
      Show
      Place the attached behat_broken.php and broken.feature in lib/tests/behat Update your behat site Run the following command: vendor/bin/behat --config path/to/behat.yml --tags=broken_transaction,core /path/to/moodle/lib/tests/behat The test should run 4 scenarios (2 from action_menu.feature , 1 from broken.feature and 1 from timezone.feature ). The scenario in broken.feature will fail, but timezone.feature will still run after it.

      If a behat step is executed, and throws an exception inside a database transaction, the next scenario will timeout while trying to load the behat site. The following error is output:

      [Guzzle\Http\Exception\CurlException]
        Exception has been thrown in "beforeScenario" hook, defined in behat_hooks::before_scenario()
        [curl] 28: Operation timed out after 30514 milliseconds with 29750 bytes received [url] http://127.0.0.1/ou-moodle2/
       
      behat [--init] [-f|--format="..."] [--out="..."] [--lang="..."] [--[no-]ansi] [--[no-]time] [--[no-]paths] [--[no-]snippets] [--[no-]snippets-paths] [--[no-]multiline] [--[no-]expand] [--story-syntax] [-d|--definitions="..."] [--name="..."] [--tags="..."] [--cache="..."] [--strict] [--dry-run] [--stop-on-failure] [--rerun="..."] [--append-snippets] [--append-to="..."] [features]
       
       
      Potential coding error - active database transaction detected during request shutdown:
      * line 13 of \lib\tests\behat\behat_broken.php: call to moodle_database->start_delegated_transaction()
      * line ? of unknownfile: call to behat_broken->i_throw_an_exception_within_a_database_transaction()
      * line 155 of \vendor\behat\behat\src\Behat\Behat\Definition\Annotation\Definition.php: call to call_user_func_array()
      * line 239 of \vendor\moodlehq\behat-extension\src\Moodle\BehatExtension\Tester\MoodleStepTester.php: call to Behat\Behat\Definition\Annotation\Definition->run()
      * line 126 of \vendor\behat\behat\src\Behat\Behat\Tester\StepTester.php: call to Moodle\BehatExtension\Tester\MoodleStepTester->executeStepDefinition()
      * line 177 of \vendor\moodlehq\behat-extension\src\Moodle\BehatExtension\Tester\MoodleStepTester.php: call to Behat\Behat\Tester\StepTester->executeStep()
      * line 153 of \vendor\moodlehq\behat-extension\src\Moodle\BehatExtension\Tester\MoodleStepTester.php: call to Moodle\BehatExtension\Tester\MoodleStepTester->executeStep()
      * line 42 of \vendor\behat\gherkin\src\Behat\Gherkin\Node\AbstractNode.php: call to Moodle\BehatExtension\Tester\MoodleStepTester->visit()
      * line 76 of \vendor\moodlehq\behat-extension\src\Moodle\BehatExtension\Tester\MoodleScenarioTester.php: call to Behat\Gherkin\Node\AbstractNode->accept()
      * line 87 of \vendor\behat\behat\src\Behat\Behat\Tester\ScenarioTester.php: call to Moodle\BehatExtension\Tester\MoodleScenarioTester->visitStep()
      * line 42 of \vendor\behat\gherkin\src\Behat\Gherkin\Node\AbstractNode.php: call to Behat\Behat\Tester\ScenarioTester->visit()
      * line 88 of \vendor\behat\behat\src\Behat\Behat\Tester\FeatureTester.php: call to Behat\Gherkin\Node\AbstractNode->accept()
      * line 42 of \vendor\behat\gherkin\src\Behat\Gherkin\Node\AbstractNode.php: call to Behat\Behat\Tester\FeatureTester->visit()
      * line 150 of \vendor\behat\behat\src\Behat\Behat\Console\Command\BehatCommand.php: call to Behat\Gherkin\Node\AbstractNode->accept()
      * line 128 of \vendor\behat\behat\src\Behat\Behat\Console\Command\BehatCommand.php: call to Behat\Behat\Console\Command\BehatCommand->runFeatures()
      * line 241 of \vendor\symfony\symfony\src\Symfony\Component\Console\Command\Command.php: call to Behat\Behat\Console\Command\BehatCommand->execute()
      * line 887 of \vendor\symfony\symfony\src\Symfony\Component\Console\Application.php: call to Symfony\Component\Console\Command\Command->run()
      * line 191 of \vendor\symfony\symfony\src\Symfony\Component\Console\Application.php: call to Symfony\Component\Console\Application->doRunCommand()
      * line 68 of \vendor\behat\behat\src\Behat\Behat\Console\BehatApplication.php: call to Symfony\Component\Console\Application->doRun()
      * line 121 of \vendor\symfony\symfony\src\Symfony\Component\Console\Application.php: call to Behat\Behat\Console\BehatApplication->doRun()
      * line 32 of \vendor\behat\behat\bin\behat: call to Symfony\Component\Console\Application->run()
      

      This happens because when the exception is caught by behat, the active database transactions are not closed.

      Full steps to reproduce

      1. Place the attached behat_broken.php and broken.feature in lib/tests/behat
      2. Update your behat site
      3. Run the following command: vendor/bin/behat --config path/to/behat.yml --tags=broken_no_transaction,core /path/to/moodle/lib/tests/behat
      4. This will run action_menu.feature, one scenario from broken.feature and timezone.feature. action_menu.feature will complete, broken.feature will fail with a coding_exception, then timezone.feature will run.
      5. Now run the following command: vendor/bin/behat --config path/to/behat.yml --tags=broken_transaction,core /path/to/moodle/lib/tests/behat
      6. This will run the same files, but use a different scenario in broken.feature. action_menu.feature will complete, broken.feature will fail, then timezone.feature will hang. However, this should behave the same way as the previous command.

        1. behat_broken.php
          0.8 kB
          Mark Johnson
        2. broken.feature
          0.4 kB
          Mark Johnson

            marxjohnson Mark Johnson
            marxjohnson Mark Johnson
            Rajesh Taneja Rajesh Taneja
            David Monllaó David Monllaó
            Mark Nelson Mark Nelson
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.