3

I have two Silverstripe websites running in the same WAMP 2.5 environment, sharing the same _ss_environment.php file (which sets database permissions etc.)

Both are:

  • Silverstripe 3.2.0RC1
  • Installed/ updated via Composer
  • PHPUnit 3.7.28

When I go to localhost.example/dev/tests I get completely different behaviour:

Site #1 runs the tests without any issues and returns the expected output.

Site #2 won't run any test and comes back with this sort of error:

Couldn't run query:

SELECT DISTINCT "Group"."ClassName", "Group"."LastEdited", "Group"."Created", "Group"."Title", "Group"."Description", "Group"."Code", "Group"."Locked", "Group"."Sort", "Group"."HtmlEditorConfig", "Group"."ParentID", "Group"."ID", CASE WHEN "Group"."ClassName" IS NOT NULL THEN "Group"."ClassName" ELSE 'Group' END AS "RecordClassName"

FROM "Group"

WHERE ("Group"."ID" = ?)

LIMIT 1

Table 'ss_tmpdb6760406.group' doesn't exist

What the heck is going on?

The Site #2 does have more modules installed but I can't see how that'd affect MySQL permissions/behavior.

The only difference that makes sense to me is Site #1 was a clean composer install on 3.2.0RC1 when Site #2 has been upgraded from an earlier version of Silverstripe (via composer).

Does anyone have any idea of what is going on and how I can get Site #2 to test properly?

NoNaMe
  • 6,020
  • 30
  • 82
  • 110
BaronGrivet
  • 4,364
  • 5
  • 37
  • 52
  • Does the `ss_tmpdb6760406` database have a `Group` table on your localhost? – 3dgoo Sep 29 '15 at 03:50
  • did you run dev/build and ?flush on site #2... though group table should be there for ages... – wmk Sep 29 '15 at 05:41
  • @3dgoo - I haven't see any ss_tmp databases appear. But I'm unsure of their expected behaviour. Are they created and deleted during unit testing? – BaronGrivet Sep 29 '15 at 06:55
  • @wmk - built and flushed a number of times for both sites. – BaronGrivet Sep 29 '15 at 06:56
  • do both sites just share the same database or just the same server? Have you tried setting up sqlite3 for unit tests? See http://www.silverstrip.es/blog/how-to-speed-up-unit-tests-using-sqlite/ (disclaimer: my blog) – wmk Sep 29 '15 at 07:09
  • @wmk - both sites share the same database server/ MySQL user/ permissions. If I get totally stuck I'll look into the sqlite3 option. – BaronGrivet Sep 29 '15 at 07:13
  • as it's just for testing funcitonality and they install a complete new, temporarly database for each test you can totally speed up things by using sqlite, and even more by using sqlite in memory only. Educated guess: you have some relicts of broken tests in your database? Or user cannot create a new database for the test? – wmk Sep 29 '15 at 07:16
  • @BaronGrivet did you ever get this working? I'm having the exact same problem and it's very puzzling. – jjjjjjjjjjjjjjjjjjjj Jun 10 '16 at 09:53
  • @JanneKlouman - for some reason I deleted my answer. Here it is: http://stackoverflow.com/a/32878259/348485 – BaronGrivet Jun 12 '16 at 20:47
  • @BaronGrivet Thank you! – jjjjjjjjjjjjjjjjjjjj Jun 13 '16 at 09:02

3 Answers3

1

After removing two unmaintained modules from Site #2 the unit testing is working fine.

I'm guessing there were bugs in the modules but I don't understand how they would have caused database errors in unrelated tests.

BaronGrivet
  • 4,364
  • 5
  • 37
  • 52
1

I had a similar issue. My solution was to completely purge the contents of silverstripe-cache directory (or whichever directory your particular TEMP_FOLDER constant points to) and run sake dev/build.

Not exactly sure why, but I believe there was an error at some point in building a class manifest and that was cached and was somehow preventing the proper rebuilding of the database schema, resulting in most tables being created except for just a few which were then being inserted into by a fixture file (which then triggered this error). Explains why it worked in the CI server, but not on my local machine. Unit tests are supposed to be totally isolated...

patricknelson
  • 977
  • 10
  • 16
0

I'd suggest that you try changing the case-sensitivity setting in MySQL. I've seen similar things before, seemingly randomly occurring, and usually on the main database rather than under test.

I don't have a ton of experience with WAMP, but it sounds like you need to find my.ini (saving MySQL settings) and adjust the following setting:

lower_case_table_names=2

Have a look at the docs: http://dev.mysql.com/doc/refman/5.1/en/identifier-case-sensitivity.html And this other question: How to force case sensitive table names?

I can't guarantee that will solve your problem but it's the first place I would check, assuming SQLite is not an option for you as indicated in the comments above.

Community
  • 1
  • 1
Mark Guinn
  • 619
  • 3
  • 8