Merge lp:~jtv/launchpad/bug-684669 into lp:launchpad

Proposed by Jeroen T. Vermeulen on 2010-12-03
Status: Merged
Approved by: Jeroen T. Vermeulen on 2010-12-03
Approved revision: no longer in the source branch.
Merged at revision: 12049
Proposed branch: lp:~jtv/launchpad/bug-684669
Merge into: lp:launchpad
Diff against target: 99 lines (+11/-9)
5 files modified
lib/canonical/launchpad/webapp/adapter.py (+6/-0)
lib/lp/soyuz/doc/archive-override-check.txt (+1/-1)
lib/lp/soyuz/doc/soyuz-upload.txt (+1/-1)
lib/lp/translations/doc/poexport-request.txt (+1/-1)
lib/lp/translations/scripts/tests/test_reupload_translations.py (+2/-6)
To merge this branch: bzr merge lp:~jtv/launchpad/bug-684669
Reviewer Review Type Date Requested Status
Stuart Bishop code 2010-12-03 Approve on 2010-12-04
Brad Crittenden (community) code Approve on 2010-12-03
Review via email: mp+42621@code.launchpad.net

Commit Message

[r=bac,stub][ui=none] [r=bac][ui=none][bug=684669] Log database connections.

Description of the Change

= Bug 684669 =

When we have problems with scripts, we keep running into the same questions: what store(s) are we connected to? As what database user? What database backend processes are connected to our process?

In this branch I add a bit of logging when connecting to the main database. It provides all this information, as well as the isolation level.

The extra information is logged at DEBUG2, so add lots of -v.

Jeroen

To post a comment you must log in.
Brad Crittenden (bac) :
review: Approve (code)
Stuart Bishop (stub) wrote :

You can now do 'logging.debug2(msg, args)' and avoid the import.

I didn't realize we could drop the test_suite() now. Cool!

review: Approve (code)
Brad Crittenden (bac) wrote :

Please clean up the commit message before landing. It looks like the code creating the message doesn't handle multiple reviewers very well.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/canonical/launchpad/webapp/adapter.py'
2--- lib/canonical/launchpad/webapp/adapter.py 2010-11-17 09:49:16 +0000
3+++ lib/canonical/launchpad/webapp/adapter.py 2010-12-03 18:33:47 +0000
4@@ -68,6 +68,7 @@
5 from canonical.lazr.utils import get_current_browser_request, safe_hasattr
6 from canonical.lazr.timeout import set_default_timeout_function
7 from lp.services import features
8+from lp.services.log.loglevels import DEBUG2
9 from lp.services.timeline.timeline import Timeline
10 from lp.services.timeline.requesttimeline import (
11 get_request_timeline,
12@@ -487,6 +488,11 @@
13 'DB connection URL %s does not meet naming convention.')
14
15 _reset_dirty_commit_flags(*flags)
16+
17+ logging.log(
18+ DEBUG2,
19+ "Connected to %s backend %d, as user %s, at isolation level %s.",
20+ flavor, raw_connection.get_backend_pid(), dbuser, self._isolation)
21 return raw_connection
22
23 @property
24
25=== modified file 'lib/lp/soyuz/doc/archive-override-check.txt'
26--- lib/lp/soyuz/doc/archive-override-check.txt 2009-04-28 12:59:43 +0000
27+++ lib/lp/soyuz/doc/archive-override-check.txt 2010-12-03 18:33:47 +0000
28@@ -22,7 +22,7 @@
29 >>> script = os.path.join(config.root, "scripts", "ftpmaster-tools",
30 ... "archive-override-check.py")
31
32- >>> process = subprocess.Popen([sys.executable, script, "-vv",
33+ >>> process = subprocess.Popen([sys.executable, script, "-v",
34 ... "-d", "ubuntu",
35 ... "-s", "warty"],
36 ... stdout=subprocess.PIPE,
37
38=== modified file 'lib/lp/soyuz/doc/soyuz-upload.txt'
39--- lib/lp/soyuz/doc/soyuz-upload.txt 2010-11-06 12:45:26 +0000
40+++ lib/lp/soyuz/doc/soyuz-upload.txt 2010-12-03 18:33:47 +0000
41@@ -738,7 +738,7 @@
42
43 >>> script = os.path.join(config.root, "scripts", "ftpmaster-tools",
44 ... "archive-cruft-check.py")
45- >>> process = subprocess.Popen([sys.executable, script, "-vvn",
46+ >>> process = subprocess.Popen([sys.executable, script, "-vn",
47 ... "-d", "ubuntutest",
48 ... "-s", "breezy-autotest",
49 ... "/var/tmp/archive"],
50
51=== modified file 'lib/lp/translations/doc/poexport-request.txt'
52--- lib/lp/translations/doc/poexport-request.txt 2010-08-17 11:54:55 +0000
53+++ lib/lp/translations/doc/poexport-request.txt 2010-12-03 18:33:47 +0000
54@@ -263,7 +263,7 @@
55
56 >>> import subprocess
57 >>> process = subprocess.Popen([
58- ... sys.executable, 'cronscripts/rosetta-export-queue.py', '-vv'
59+ ... sys.executable, 'cronscripts/rosetta-export-queue.py', '-v'
60 ... ], stdin=subprocess.PIPE, stdout=subprocess.PIPE,
61 ... stderr=subprocess.STDOUT
62 ... )
63
64=== modified file 'lib/lp/translations/scripts/tests/test_reupload_translations.py'
65--- lib/lp/translations/scripts/tests/test_reupload_translations.py 2010-10-04 19:50:45 +0000
66+++ lib/lp/translations/scripts/tests/test_reupload_translations.py 2010-12-03 18:33:47 +0000
67@@ -10,7 +10,6 @@
68 import re
69 from StringIO import StringIO
70 import tarfile
71-from unittest import TestLoader
72
73 import transaction
74 from zope.security.proxy import removeSecurityProxy
75@@ -38,6 +37,7 @@
76 getLatestTranslationsUploads method return the given library file
77 alias.
78 """
79+
80 def __init__(self, script, tar_alias):
81 self.tar_alias = tar_alias
82 self.script = script
83@@ -190,7 +190,7 @@
84 '-s', self.distroseries.name,
85 '-p', self.sourcepackagename1.name,
86 '-p', self.sourcepackagename2.name,
87- '-vv',
88+ '-v',
89 '--dry-run',
90 ])
91
92@@ -207,7 +207,3 @@
93 self.assertTrue(
94 re.match(expected_output, stderr),
95 'expected %s, got %s' % (expected_output, stderr))
96-
97-
98-def test_suite():
99- return TestLoader().loadTestsFromName(__name__)