Merge lp:~gary/launchpad/bug-687951 into lp:launchpad
Status: | Rejected |
---|---|
Rejected by: | Robert Collins |
Proposed branch: | lp:~gary/launchpad/bug-687951 |
Merge into: | lp:launchpad |
Diff against target: |
52 lines (+28/-0) 1 file modified
test_on_merge.py (+28/-0) |
To merge this branch: | bzr merge lp:~gary/launchpad/bug-687951 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Robert Collins (community) | Disapprove | ||
Review via email: mp+44300@code.launchpad.net |
Description of the change
This is an expedient solution to the problem described in bug 687951--or put another way, it is a good solution to the buildbot and operational problem, while not addressing the underlying Launchpad problem. I will create another bug for the Launchpad problem, which Robert addressed in the IRC conversation I quoted in that bug's comments.
The test_on_merge.py is operational code for which we do not have tests. To demonstrate the way this patch works, do the following.
1) See if your machine already has some of the problematic old databases. Run psql -l and you may see database names of the form launchpad_
2) run test_on_merge.py, with some argument to limit the tests run. For instance, "./test_on_merge.py -t foobar" will not run any tests. There's probably a nicer way to do this, but I'm not worrying about it right now. When you do this, the first one or more lines will look like this: "Dropped old ftest database launchpad_
Unmerged revisions
- 12120. By Gary Poster
-
This is an expedient solution to the immediate problem of buildbot falling over.
As this stands it will break parallel testing via testr :(
On 21/12/2010 12:18 PM, "Gary Poster" <email address hidden> wrote:
Gary Poster has proposed merging lp:~gary/launchpad/bug-687951 into
lp:launchpad.
Requested reviews: reviewers) /bugs.launchpad .net/bugs/ 687951
Launchpad code reviewers (launchpad-
Related bugs:
#687951 Large number of DBs left around after test suite runs in buildbot
https:/
This is an expedient solution to the problem described in bug 687951--or put
another way, it is a good solution to the buildbot and operational problem,
while not addressing the underlying Launchpad problem. I will create
another bug for the Launchpad problem, which Robert addressed in the IRC
conversation I quoted in that bug's comments.
The test_on_merge.py is operational code for which we do not have tests. To
demonstrate the way this patch works, do the following.
1) See if your machine already has some of the problematic old databases. ftest_NUMBER, like lines 10 through 43 of /pastebin. canonical. com/40714/ . If you don't have any, you can ftest_30322; " will give you one to work with.
Run psql -l and you may see database names of the form
launchpad_
https:/
create some for the test using psql. "create database
launchpad_
2) run test_on_merge.py, with some argument to limit the tests run. For ftest_30322. This should not happen. See bug /code.launchpad .net/~gary/ launchpad/ bug-687951/ +merge/ 44300
instance, "./test_on_merge.py -t foobar" will not run any tests. There's
probably a nicer way to do this, but I'm not worrying about it right now.
When you do this, the first one or more lines will look like this: "Dropped
old ftest database launchpad_
687951." After test_on_merge.py runs, psql -l will show you that the
databases have been dropped.
--
https:/
Your team Launchpad code reviewers from Canonical is subscribed to branch
lp:launchpad.
=== modified file 'test_on_merge.py'
--- test_on_merge.py 2010-09-28 12:37:55 +0000
+++ test_on_merge.py 2010-12-20 23:18:07 +0000
@@ -8,6 +8,7 @@
import sys, time LEVEL_AUTOCOMMI T
import os, errno
+from psycopg2.extensions import ISOLATION_
import tabnanny
from StringIO import StringIO
import psycopg2
@@ -34,6 +35,7 @@
Returns 1 on error, otherwise it returns the testrunner's exit code. old_ftest_ databases( ) # See bug 687951. database( ) != 0:
"""
+ cleanup_
if setup_test_
return 1
@@ -224,6 +226,32 @@
return rv
+def cleanup_ old_ftest_ databases( ): connect( 'dbname= template1' ) isolation_ level(ISOLATION _LEVEL_ AUTOCOMMIT) pg_database d ftest_[ 0-9]+$' ;""")
+ """Kill old ftest databases."""
+ conn = psycopg2.
+ conn.set_
+ cur = conn.cursor()
+ try:
+ cur.execute(r"""
+ SELECT d.datname
+ FROM pg_catalog.
+ WHERE d.datname ~ '^launchpad_
+ old_databases = cur.fetchall()
+ for (database_name,) in old_databases:
+ print ("Dropped old ftest database %s. "
+ "This should not happen. See bug 687951.") % (
+ database_name,)
+ # We are not doing db-level parameterization because it does
not work
+ # (is not designed for) schema e...