simpletest throws exceptions on pgsql

bjaspan - May 10, 2008 - 19:42
Project:Drupal
Version:6.x-dev
Component:system.module
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

It appears that the core simpletest framework re-runs the install process with a $db_prefix. On pgsql, we do CREATE DOMAIN {,small,big}int_unsigned CHECK (VALUE >= 0) in system.install. These have a single global name so re-running the install generates "already exists" errors.

There are a variety of ways out of this gotcha. My suggestion is http://drupal.org/node/257006. I do not think these are duplicate issues (this one is about unit tests throwing exceptions, that one is about unifying an inconsistency between how int, float, and numeric unsigned columns are handled), though my proposed solution conveniently fixes both.

#1

bjaspan - May 10, 2008 - 20:31
Status:active» needs review

Actually, I decided to fix this more expediently by simply not trying to create the unsigned domains if they already exist. This gives a very short patch that makes the simpletests stop throwing exceptions on pgsql. This fix does not prevent the more comprehensive one contemplated in http://drupal.org/node/257006, but certainly lessens my motivation to take on the complex update issues. :-)

To test this patch, run any tests on pgsql. If they pass without exceptions, the patch works.

AttachmentSizeStatusTest resultOperations
simpletest-pgsql-create-domain-257009-1.patch1.43 KBIgnoredNoneNone

#2

Freso - June 8, 2008 - 15:06
Component:unit testing» tests

For some reason, the patch didn't apply:

freso@nayru /s/h/l/h/drupal7> wget http://drupal.org/files/issues/simpletest-pgsql-create-domain-257009-1.p...
[...]
freso@nayru /s/h/l/h/drupal7> patch -p0 < simpletest-pgsql-create-domain-257009-1.patch
patching file modules/system/system.install
Hunk #1 FAILED at 305.
1 out of 1 hunk FAILED -- saving rejects to file modules/system/system.install.rej

The change was easy to do myself, so I did a re-roll using cvs diff -up. Reviewing now.

AttachmentSizeStatusTest resultOperations
simpletest-pgsql-create-domain-257009-2.patch1.41 KBIgnoredNoneNone

#3

Freso - June 8, 2008 - 15:23

I tested it against #264836: Bike shed test fails (PostgreSQL?), which removed the PHP exceptions there. So it works as advertised. :)

However, it being in system.install... won't that mean that old sites upgrading to Drupal 7 won't get the benefit of this? Just curious, as that wouldn't be something we'd want... right?

#4

bjaspan - June 9, 2008 - 16:02

This patch does not affect upgrade from pre-D7 sites. Upgrading does not run system_install(), so the pgsql domains are not re-created.

#5

Freso - June 10, 2008 - 11:48
Status:needs review» needs work

Well, I'd say it shouldn't go into CVS until that is resolved.

#6

bjaspan - June 10, 2008 - 14:13
Status:needs work» needs review

@Freso: You have not actually presented a problem with the current patch. The upgrade process from pre-D7 is not affected by the bug I reported and is not affected by the patch I've presented, so there is nothing to resolve regarding upgrading from pre-D7 sites pertaining to this bug before the patch can be committed.

I'm putting this back to "code needs review" so I do not forget to do so later. However, if you can describe an actual problem with the patch, by all means do so. Thanks!

#7

Freso - June 10, 2008 - 15:15

@bjaspan: The perceived problem (which I thought you confirmed #4) is that sites upgrading from 6.x will still have tests fail on pgsql systems, as the pgsql domains are not re-created as you put it. I haven't tested it, so can't say if this is really so, but, yeah. I thought you confirmed this in #4 - sorry to put words in your mouth if you didn't. :)

#8

catch - June 10, 2008 - 15:22

I think the issue is that simpletest.module is running that hunk of code for a second time - which would otherwise never happen - so the changes only exist to accommodate this behaviour, and therefore only in D7 (afaik the D6 contrib verson of simpletest doesn't do this either). Since this isn't immediately obvious (and I might not have it right anyway) a code comment might help.

#9

bjaspan - June 10, 2008 - 15:54

Comment added.

AttachmentSizeStatusTest resultOperations
simpletest-pgsql-create-domain-257009-9.patch1.74 KBIgnoredNoneNone

#10

mustafau - August 2, 2008 - 11:06
Status:needs review» reviewed & tested by the community

#9 eliminates exceptions on pgsql.

#11

Freso - August 2, 2008 - 15:03

There's a line with excessive whitespace introduced after the new comment lines. Looks okay apart from this. I didn't test.

#12

mustafau - August 2, 2008 - 15:17

Re-roll without whitespace.

AttachmentSizeStatusTest resultOperations
simpletest-pgsql-create-domain-257009-12.patch1.67 KBIgnoredNoneNone

#13

Dries - August 2, 2008 - 18:45
Status:reviewed & tested by the community» fixed

I've extended the documentation a bit and committed this patch to CVS HEAD. Thanks everyone.

#14

Anonymous (not verified) - August 16, 2008 - 18:51
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

#15

Darren Oh - December 18, 2008 - 22:32
Version:7.x-dev» 6.x-dev
Component:tests» system.module
Assigned to:bjaspan» Anonymous
Status:closed» patch (to be ported)

Drupal 6 needs this, too.

AttachmentSizeStatusTest resultOperations
system.install-257009-15_D6.patch1.79 KBIgnoredNoneNone

#16

Darren Oh - December 24, 2008 - 05:33
Status:patch (to be ported)» reviewed & tested by the community

#17

Gábor Hojtsy - January 6, 2009 - 16:19
Status:reviewed & tested by the community» fixed

Looks like you've even included Dries' comment changes. Looks good, committed.

#18

System Message - January 20, 2009 - 16:20
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.