Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

behat failures related to touch() #108

Closed
stronk7 opened this issue Sep 12, 2019 · 3 comments · Fixed by #111
Closed

behat failures related to touch() #108

stronk7 opened this issue Sep 12, 2019 · 3 comments · Fixed by #111

Comments

@stronk7
Copy link
Member

stronk7 commented Sep 12, 2019

Was performing a complete run locally (docker on MacOSX) and got these 6 consistent failures (rerun them a number of times):

001 Scenario: All of the selected roles can award badges # /var/www/html/badges/tests/behat/award_badge.feature:321
      And I trigger cron                                 # /var/www/html/badges/tests/behat/award_badge.feature:389
        Other backtraces found:
        line 93 of /lib/classes/task/file_temp_cleanup_task.php: call to touch()
        line 110 of /lib/classes/task/file_temp_cleanup_task.php: call to core()
        line 189 of /lib/cronlib.php: call to core()
        line 114 of /lib/cronlib.php: call to cron_run_inner_scheduled_task()
        line 73 of /lib/cronlib.php: call to cron_run_scheduled_tasks()
        line 81 of /admin/cron.php: call to cron_run() (Exception)

002 Scenario: Backup and restore of meta enrolment instance # /var/www/html/enrol/meta/tests/behat/enrol_meta.feature:82
      And I trigger cron                                    # /var/www/html/enrol/meta/tests/behat/enrol_meta.feature:100
        Other backtraces found:
        line 93 of /lib/classes/task/file_temp_cleanup_task.php: call to touch()
        line 110 of /lib/classes/task/file_temp_cleanup_task.php: call to core()
        line 189 of /lib/cronlib.php: call to core()
        line 114 of /lib/cronlib.php: call to cron_run_inner_scheduled_task()
        line 73 of /lib/cronlib.php: call to cron_run_scheduled_tasks()
        line 81 of /admin/cron.php: call to cron_run() (Exception)

003 Scenario: Bulk accepting requests # /var/www/html/admin/tool/dataprivacy/tests/behat/manage_data_requests.feature:61
      And I trigger cron              # /var/www/html/admin/tool/dataprivacy/tests/behat/manage_data_requests.feature:88
        Other backtraces found:
        line 93 of /lib/classes/task/file_temp_cleanup_task.php: call to touch()
        line 110 of /lib/classes/task/file_temp_cleanup_task.php: call to core()
        line 189 of /lib/cronlib.php: call to core()
        line 114 of /lib/cronlib.php: call to cron_run_inner_scheduled_task()
        line 73 of /lib/cronlib.php: call to cron_run_scheduled_tasks()
        line 81 of /admin/cron.php: call to cron_run() (Exception)

004 Scenario: Bulk denying requests # /var/www/html/admin/tool/dataprivacy/tests/behat/manage_data_requests.feature:106
      And I trigger cron            # /var/www/html/admin/tool/dataprivacy/tests/behat/manage_data_requests.feature:133
        Other backtraces found:
        line 93 of /lib/classes/task/file_temp_cleanup_task.php: call to touch()
        line 110 of /lib/classes/task/file_temp_cleanup_task.php: call to core()
        line 189 of /lib/cronlib.php: call to core()
        line 114 of /lib/cronlib.php: call to cron_run_inner_scheduled_task()
        line 73 of /lib/cronlib.php: call to cron_run_scheduled_tasks()
        line 81 of /admin/cron.php: call to cron_run() (Exception)

005 Scenario: Receiving notification on site level # /var/www/html/admin/tool/monitor/tests/behat/subscription.feature:101
      And I trigger cron                           # /var/www/html/admin/tool/monitor/tests/behat/subscription.feature:114
        Other backtraces found:
        line 93 of /lib/classes/task/file_temp_cleanup_task.php: call to touch()
        line 110 of /lib/classes/task/file_temp_cleanup_task.php: call to core()
        line 189 of /lib/cronlib.php: call to core()
        line 114 of /lib/cronlib.php: call to cron_run_inner_scheduled_task()
        line 73 of /lib/cronlib.php: call to cron_run_scheduled_tasks()
        line 81 of /admin/cron.php: call to cron_run() (Exception)

006 Scenario: Receiving notification on course level # /var/www/html/admin/tool/monitor/tests/behat/subscription.feature:122
      And I trigger cron                             # /var/www/html/admin/tool/monitor/tests/behat/subscription.feature:135
        Other backtraces found:
        line 93 of /lib/classes/task/file_temp_cleanup_task.php: call to touch()
        line 110 of /lib/classes/task/file_temp_cleanup_task.php: call to core()
        line 189 of /lib/cronlib.php: call to core()
        line 114 of /lib/cronlib.php: call to cron_run_inner_scheduled_task()
        line 73 of /lib/cronlib.php: call to cron_run_scheduled_tasks()
        line 81 of /admin/cron.php: call to cron_run() (Exception)

6 scenarios (6 failed)
261 steps (192 passed, 6 failed, 63 skipped)
6m38.24s (51.80Mb)

Worth investigating them, usually touch cries when the user is not exactly the same and things like that...

Ciao :-)

@kabalin
Copy link
Member

kabalin commented Nov 1, 2019

I have seen similar thing recently. You are right regarding the cause. Basically, we initialise/execute Behat using command similar to bin/moodle-docker-compose exec webserver php admin/tool/behat/cli/init.php, this means some content within /var/www/behatdata will be owned by root:

root@2092ff11c900:/var/www/html# ls -la ../behatdata/behatrun/                
total 60
drwxrwxrwx 11 root     root     4096 Nov  1 11:24 .
drwxr-xr-x  3 www-data root     4096 Oct 31 12:41 ..
-rw-rw-rw-  1 root     root      128 Nov  1 11:21 .htaccess
drwxrwxrwx  2 root     root     4096 Oct 31 12:41 behat
-rw-rw-rw-  1 root     root       79 Oct 31 12:36 behattestdir.txt
drwxrwxrwx  4 root     root     4096 Nov  1 11:21 cache
drwxrwxrwx  8 root     root     4096 Oct 31 12:39 filedir
drwxrwxrwx  2 www-data www-data 4096 Nov  1 11:24 lang
drwxrwxrwx  7 root     root     4096 Nov  1 11:24 localcache
drwxrwxrwx  4 www-data www-data 4096 Nov  1 11:24 models
drwxrwxrwx  2 root     root     4096 Nov  1 11:21 muc
-rw-rw-rw-  1 root     root      613 Oct 31 12:40 originaldatafiles.json
drwxrwxrwx  2 www-data www-data 4096 Nov  1 11:24 sessions
-rw-rw-rw-  1 root     root     2206 Nov  1 11:24 tablesupdatedbyscenario.json
drwxrwxrwx  7 root     root     4096 Nov  1 11:23 temp

The actual steps are performed through the webserver, which means filesystem is accessed by www-data user, thus the conflict you may observe at And I trigger cron step (I believe it is calling /admin/cron.php in browser session). In my case it was content in /var/www/behatdata/behatrun/temp/backup which file_temp_cleanup_task has no right to touch.

The workaround, as you may guess, running behat using www-data by adding user parameter to docker exec:

bin/moodle-docker-compose exec -u www-data webserver php admin/tool/behat/cli/run.php --tags=@tool_dataprivacy

You would still need to initialise behat as normal (as root), since populating composer cache and vendor data requires write permission outside test data directories.

@scara
Copy link
Contributor

scara commented Nov 2, 2019

HI @kabalin,
would you mind to create a PR for the README?

TIA,
Matteo

@kabalin
Copy link
Member

kabalin commented Nov 5, 2019

Hi @scara, done ^.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants