Behat corruption

Behat corruption

by Richard Lobb -
Number of replies: 2
Picture of Plugin developers

I appear to have a corrupted behat installation. The problems began when I upgraded moodle and went to re-initialise behat. I inadvertently did this as root and got the output

You are running composer as "root", while "/home/rjl83/.composer" is owned by "rjl83"
You are already using composer version 1.9.1 (stable channel).
Do not run Composer as root/super user! See https://getcomposer.org/root for details

Seeing that message (somewhat belatedly), I hit CTRL/C (I'm on Unix) which killed the initialisation. Unfortunately behat was by now halfway through dropping all the tables.

Now, just about anything I do with behat results in the output

Generating autoload files
!!! Table "context" does not exist !!!

Debug info:
Error code: ddltablenotexist
Stack trace: * line 665 of /lib/dml/moodle_database.php: dml_exception thrown
* line 1537 of /lib/dml/moodle_database.php: call to moodle_database->where_clause()
* line 6167 of /lib/accesslib.php: call to moodle_database->get_record()
* line 747 of /lib/setup.php: call to context_system::instance()
* line 119 of /admin/tool/behat/cli/util_single_run.php: call to require()

Does anyone know if there's a way to get completely reinitialise the behat environment? I could write a script to delete all the "b_" tables but I suspect that that wouldn't solve the problem anyway.

Average of ratings: -
In reply to Richard Lobb

Re: Behat corruption

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Can you successfully call:

php admin/tool/behat/util.php --drop

That often manages to clear out the broken database.

If not, you might try again after manually deleting the 'b_config' table (you need to get rid of just the right tables to convince Moodle that it can do a clean install).

One trick I sometimes end up with having to do (especially if it is the 'config' table that is missing), is to comment-out the line of code that checks to see if this is a behat site, so that it will let me drop the tables and start again (if the 'config' table is missing or empty, then it can get stuck believing it is not a behat site, so you can't fix it ...).

Average of ratings: Useful (2)
In reply to Davo Smith

Re: Behat corruption

by Richard Lobb -
Picture of Plugin developers
Many thanks Davo - you solved my problem! I couldn't run "util.php --drop" and when I deleted b_config I got the "This is not a behat site" message. But commenting out the line that does that check then got everything running again.

Phew, and thanks again!