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

Random failure with mod_chat_lib_testcase::test_chat_get_sessions

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.5, 3.6
    • 3.5.2
    • Chat, Unit tests
    • MOODLE_35_STABLE, MOODLE_36_STABLE
    • MOODLE_35_STABLE
    • Hide

      Requires hacking codebase:

      1) Edit mod/chat/lib.php and, in the chat_login_user() function, exactly before the chat_send_chatmessage() call, add a 2 seconds sleep.

              } else {
      +           sleep(2);
                  chat_send_chatmessage($chatuser, 'enter', true);
              }
      

      2) Initialise PHPUnit:

      php admin/tool/phpunit/cli/init.php

      3) Run the chat unit tests (100 repetitions, yes 200 seconds, be patient):

      $ vendor/bin/phpunit --repeat 100 "mod_chat_lib_testcase" mod/chat/tests/lib_test.php
      

      4) Verify that execution ends without error.

      5) Optional: Before the fix and with the sleep() manually added in 1) it was consistently causing an assertion to fail with a 2 seconds difference. You can verify it if you want, without the fix applied.

      Show
      Requires hacking codebase: 1) Edit mod/chat/lib.php and, in the  chat_login_user()  function, exactly before the chat_send_chatmessage() call, add a 2 seconds sleep. } else { + sleep(2); chat_send_chatmessage($chatuser, 'enter', true); } 2) Initialise PHPUnit: php admin/tool/phpunit/cli/init.php 3) Run the chat unit tests (100 repetitions, yes 200 seconds, be patient): $ vendor/bin/phpunit --repeat 100 "mod_chat_lib_testcase" mod/chat/tests/lib_test.php 4) Verify that execution ends without error. 5) Optional: Before the fix and with the sleep() manually added in 1) it was consistently causing an assertion to fail with a 2 seconds difference. You can verify it if you want, without the fix applied.

    Description

      Have got this at least twice lately:

      mod_chat_lib_testcase::test_chat_get_sessions
      Failed asserting that two strings are equal.
      --- Expected
      +++ Actual
      @@ @@
      -'1533713120'
      +'1533713121'
       
      /var/www/html/mod/chat/tests/lib_test.php:206
      /var/www/html/lib/phpunit/classes/advanced_testcase.php:80
      

      Usual timing random failure, at first sight. Looking to it.

      Attachments

        Issue Links

          Activity

            People

              stronk7 Eloy Lafuente (stronk7)
              stronk7 Eloy Lafuente (stronk7)
              Carlos Escobedo Carlos Escobedo
              Jake Dallimore Jake Dallimore
              Janelle Barcega Janelle Barcega
              Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Laurent David, Raquel Ortega, Sara Arjona (@sarjona), Andrew Lyons, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze, Stevani Andolo
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                10/Sep/18

                Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 hour
                  1h