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

Random failure with mod_chat_lib_testcase::test_chat_get_sessions

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 3.5.2
    • 3.5, 3.6
    • 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.

      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.

            stronk7 Eloy Lafuente (stronk7)
            stronk7 Eloy Lafuente (stronk7)
            Carlos Escobedo Carlos Escobedo
            Jake Dallimore Jake Dallimore
            Janelle Barcega Janelle Barcega
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

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

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