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

file_temp_cleanup_task fails unit tests when using multiple users.

    XMLWordPrintable

    Details

    • Affected Branches:
      MOODLE_27_STABLE, MOODLE_28_STABLE, MOODLE_29_STABLE
    • Fixed Branches:
      MOODLE_27_STABLE, MOODLE_28_STABLE
    • Pull Master Branch:
      wip-mdl-48605
    • Difficulty:
      Difficult
    • Testing Instructions:
      Hide
      1. Create system (unix) users and add it to your current user group (who can execute phpunit)
        1. sudo useradd -G CURRENT_USER_GROUP test
      2. Log in as current user and execute following phpunit test
        1. vendor/bin/phpunit /var/www/im/lib/tests/cronlib_test.php
      3. Log in as test user and execute above phpunit test
      4. Ensure they both pass without any problem.
      Show
      Create system (unix) users and add it to your current user group (who can execute phpunit) sudo useradd -G CURRENT_USER_GROUP test Log in as current user and execute following phpunit test vendor/bin/phpunit /var/www/im/lib/tests/cronlib_test.php Log in as test user and execute above phpunit test Ensure they both pass without any problem.

      Description

      This was discovered by Eloy in MDL-48252

      I found a really nasty (testing) regression happening because of this. The intensive use of touch() in that issue makes me to get constant failures in my environment. It did not happen before.

      Note I know it's because I use different users to init phpunit and to run phpunit (don't ask why, it's complex), but both users belong to the same group and, given default 777/6666 perms, the unit tests always have run perfectly.

      But with this issue integrated I get a constant failure here. About touch() not able to modify dates.

      There was 1 error:
       
      1) cronlib_testcase::test_cron_delete_from_temp with data set #0 (array(stdClass, stdClass, stdClass, stdClass, stdClass, stdClass, stdClass, stdClass, stdClass, stdClass, stdClass, stdClass, stdClass), array('/Users/stronk7/Sites/moodle_data_gitintegration/MOODLE_27_STABLE/postgres_phpunit/temp/dir1', '/Users/stronk7/Sites/moodle_data_gitintegration/MOODLE_27_STABLE/postgres_phpunit/temp/dir1/dir1_1', '/Users/stronk7/Sites/moodle_data_gitintegration/MOODLE_27_STABLE/postgres_phpunit/temp/dir1/dir1_1/dir1_1_1', '/Users/stronk7/Sites/moodle_data_gitintegration/MOODLE_27_STABLE/postgres_phpunit/temp/dir1/dir1_1/dir1_1_1/file1_1_1_2', '/Users/stronk7/Sites/moodle_data_gitintegration/MOODLE_27_STABLE/postgres_phpunit/temp/dir1/dir1_2', '/Users/stronk7/Sites/moodle_data_gitintegration/MOODLE_27_STABLE/postgres_phpunit/temp/dir1/dir1_2/file1_1_2_2', '/Users/stronk7/Sites/moodle_data_gitintegration/MOODLE_27_STABLE/postgres_phpunit/temp/dir2', '/Users/stronk7/Sites/moodle_data_gitintegration/MOODLE_27_STABLE/postgres_phpunit/temp/dir4', '/Users/stronk7/Sites/moodle_data_gitintegration/MOODLE_27_STABLE/postgres_phpunit/temp/dir4/dir4_1', '/Users/stronk7/Sites/moodle_data_gitintegration/MOODLE_27_STABLE/postgres_phpunit/temp/dir4/dir4_1/dir4_1_1', '/Users/stronk7/Sites/moodle_data_gitintegration/MOODLE_27_STABLE/postgres_phpunit/temp/file1'))
       
      touch(): Utime failed: Operation not permitted
       
       
       
      /Users/stronk7/git_moodle/integration/lib/classes/task/file_temp_cleanup_task.php:92
       
      /Users/stronk7/git_moodle/integration/lib/tests/cronlib_test.php:167
       
      /Users/stronk7/git_moodle/integration/lib/phpunit/classes/basic_testcase.php:64
      

      touch() is really evil together with ownership. grrr. Again, I know my installation is very particular, but it reveals a situation where it could fail (say cron executed by www user and apache running with www_xxx...).

      For your consideration if you want to investigate the case... I really had not time to look for workarounds like adding some missing chmods... or checking if the 2nd iteration in the tests is borking the directories... or what.

      Ciao

      Please read that issue for additional details.

        Attachments

          Activity

            People

            Assignee:
            rajeshtaneja Rajesh Taneja
            Reporter:
            abgreeve Adrian Greeve
            Peer reviewer:
            Adrian Greeve Adrian Greeve
            Integrator:
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Tester:
            John Okely John Okely
            Participants:
            Component watchers:
            Andrew Lyons, Dongsheng Cai, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
            Votes:
            4 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              11/May/15