How do you use the Functional database tests

How do you use the Functional database tests

by Clarence Prudhoe -
Number of replies: 9

I opened >Site Administration > Development > Functional DB tests and ran the test on my database.

The result was 3 Exceptions and 6 Fails.  See the list below.

The report indicates the file name and line number of the script that triggered the failiers, but it doesn't indicate the database table name, record ID, or field name.  The exceptions point to "for column 'onetext' at row 1 INSERT INTO mdl_unit_table", but I can't find a table called mdl_unit_table.

I can't see how to use this report to fix the problems in my database.  I would like to clean up these problems.

Could someone shed some light on how to use the Functional DB Test?

Thanks,

Clarence

EXCEPTIONS:

Exception: lib/dml/simpletest/testdml.php /  dml_test /  test_insert_record
Unexpected exception of type [dml_write_exception] with message [Error writing to database] in [/home/musappc/public_html/Cm2Pm/lib/dml/moodle_database.php line 381]

Debug info:
Incorrect string value: '\xEC\xA0\x9C 1\xEC...' for column 'onetext' at row 1 INSERT INTO mdl_unit_table (course,oneint,onenum,onechar,onetext,onebinary) VALUES(?,?,?,?,?,?) 
Exception: lib/dml/simpletest/testdml.php /  dml_test /  test_update_record
Unexpected exception of type [dml_write_exception] with message [Error writing to database] in [/home/musappc/public_html/Cm2Pm/lib/dml/moodle_database.php line 381]
Debug info:
Incorrect string value: '\xEC\xA0\x9C 1\xEC...' for column 'onetext' at row 1 UPDATE mdl_unit_table SET course = ?,Xoneint= ?,Xonenum= ?,Xonechar= ?,Xonetext= ?,Xonebinary= ? WHERE id=? 
Exception: lib/dml/simpletest/testdml.php /  dml_test /  test_set_field_select
Unexpected exception of type [dml_write_exception] with message [Error writing to database] in [/home/musappc/public_html/Cm2Pm/lib/dml/moodle_database.php line 381]
Debug info:
Incorrect string value: '\xEC\xA0\x9C 1\xEC...' for column 'onetext' at row 1 UPDATE mdl_unit_table SET Xonetext= ? WHERE id = ? 
FAILS:
Fail: lib/dml/simpletest/testdml.php /  dml_test /  test_onelevel_rollback
Equal expectation fails because [Integer: 0] differs from [String: 1] by 1 at [/home/musappc/public_html/Cm2Pm/lib/dml/simpletest/testdml.php line 2454]
Fail: lib/dml/simpletest/testdml.php /  dml_test /  test_nested_transactions
Equal expectation fails because [Integer: 0] differs from [String: 2] by 2 at [/home/musappc/public_html/Cm2Pm/lib/dml/simpletest/testdml.php line 2501]
Fail: lib/dml/simpletest/testdml.php /  dml_test /  test_nested_transactions
Equal expectation fails because [Integer: 0] differs from [String: 2] by 2 at [/home/musappc/public_html/Cm2Pm/lib/dml/simpletest/testdml.php line 2530]
Fail: lib/dml/simpletest/testdml.php /  dml_test /  test_wrong_transactions
Equal expectation fails because [Integer: 0] differs from [String: 2] by 2 at [/home/musappc/public_html/Cm2Pm/lib/dml/simpletest/testdml.php line 2600]
Fail: lib/dml/simpletest/testdml.php /  dml_test /  test_concurent_transactions
Equal expectation fails because [Integer: 0] differs from [String: 1] by 1 at [/home/musappc/public_html/Cm2Pm/lib/dml/simpletest/testdml.php line 2687]
Fail: lib/dml/simpletest/testdml.php /  dml_test /  test_concurent_transactions
Equal expectation fails because [Integer: 1] differs from [String: 2] by 1 at [/home/musappc/public_html/Cm2Pm/lib/dml/simpletest/testdml.php line 2690]
Average of ratings: -
In reply to Clarence Prudhoe

Re: How do you use the Functional database tests

by Andrew Davis -
I just ran the tests and I get the same errors so its most likely actually the tests that are broken and not your database.

I've raised http://tracker.moodle.org/browse/MDL-23411
In reply to Andrew Davis

Re: How do you use the Functional database tests

by Clarence Prudhoe -

Thanks Andrew.

I ported my database from Moodle 1.9.9 and I had to do a lot of cleanup to make it work.  It seems to be ok now, but that Functional database test had me worried.thoughtful

Clarence

In reply to Clarence Prudhoe

Re: How do you use the Functional database tests

by Eloy Lafuente (stronk7) -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Hi,

those DB tests are about support for transactions, in order to test how coomit/rollback/isolation is working in your DB.

If you are using MySQL with the MyISAM engine (that I guess is the case) you will get those test failing, as far as that engine doesn't support transactions.

But if you are using MySQL with the InnoDB engine those tests will pass perfectly, because that engine is ACID compliant.

In any case, the two important things are:

1) Moodle 2.0 (and previous versions) will work perfectly using the MyISAM engine because we aren't using those "advanced" features in a hard way.
2) Someday in the future (2.x) we'll make the use of InnoDB mandatory in order to start using those ACID features within Moodle.

And finally, one recommendation:

1) If you've the opportunity to move from MyISAM to InnoDB, do it ASAP. That way you will be already ready for the future change commented and, at the same time, you will getting some benefits, like better locking (less concurrence problems, very important in any medium site) and, of course, your test will pass ok.

Ciao smile
Average of ratings: Useful (1)
In reply to Eloy Lafuente (stronk7)

Re: How do you use the Functional database tests

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Hi Eloy,
How can one find out whether one is using MyISAM or InnoDB? I'm doing my tests on my local WAMP install.
Joseph
In reply to Joseph Rézeau

Re: How do you use the Functional database tests

by Eloy Lafuente (stronk7) -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Hi Joseph,

To see all the available engines in your DB:

SHOW ENGINES;

To see the engine used on each table:

SELECT table_name, engine
FROM information_schema.tables
WHERE table_schema = 'xxxxx'

xxxx = your database name

Note both informations are also available under phpMyAdmin (main page->engines and table listing).

Ciao smile
Average of ratings: Useful (1)
In reply to Eloy Lafuente (stronk7)

Re: How do you use the Functional database tests

by Andrew Davis -
Surely the tests shouldnt be failing if they cover unsupported functionality? Failure indicates something is wrong, which is how this thread came about.
In reply to Andrew Davis

Re: How do you use the Functional database tests

by Clarence Prudhoe -

Hi,

How do you go about switching from  MyISAM to InnoDB.  I am currently using a shared server (will convert to a dedicated server this Fall).  Do I have to have my host make the change or can I do it from phpMySQL?

Will I have to convert the current database to use the InnoDB or will it automatically work after the change.

EDIT:    To answer my own question, I found this site with instructions on how to make the switch:

http://www.linux.com/archive/feed/46370

Thanks,

Clarence

In reply to Clarence Prudhoe

Re: How do you use the Functional database tests

by Eloy Lafuente (stronk7) -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Hi Clarence,

two important setting that the guide is missing are, in the my.cnf file:

#skip-innodb
default-storage-engine = innodb

The first, if present, must be commented (#) or InnoDB won't work in the server. If missing, nothing to do.

The second, very important, as far as it decides the storage engine that will be used by default when creating new tables (and, in Moodle, I'd say we are really prone to create new tables here and there). So, look for it and, if present, set it to innodb. If missing, add it.

Hi Andrew,

I see your point, but I really think it's better to have those tests running and warning about people that, perhaps, their DB and its current configuration, isn't the best one. Those tests can be skipped/faked, but I don't think it's a good idea.

Ciao smile
In reply to Eloy Lafuente (stronk7)

Re: How do you use the Functional database tests

by Helen Foster -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Thanks everyone for this informative discussion.

I've added a link to it in the newly created Moodle Docs page Functional database tests, so if anyone feels like checking their understanding by editing the page and transferring information from this discussion, please feel free... wink
Average of ratings: Useful (1)