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

Proposed by Jeroen T. Vermeulen
Status: Merged
Approved by: Jeroen T. Vermeulen
Approved revision: no longer in the source branch.
Merged at revision: 13951
Proposed branch: lp:~jtv/launchpad/bug-848954
Merge into: lp:launchpad
Diff against target: 174 lines (+23/-33)
3 files modified
lib/lp/soyuz/scripts/gina/handlers.py (+4/-7)
lib/lp/soyuz/scripts/gina/katie.py (+16/-17)
scripts/gina.py (+3/-9)
To merge this branch: bzr merge lp:~jtv/launchpad/bug-848954
Reviewer Review Type Date Requested Status
Graham Binns (community) code Approve
Review via email: mp+75188@code.launchpad.net

Commit message

[r=gmb][bug=848954] Remove Gina's untested, unappreciated dry-run mode.

Description of the change

= Summary =

Gina has a dry-run mode.

This turned out to be a big surprise to both William and Julian, the people I most expected to be familiar with it. So I'll say it again to avoid any confusion: Gina has a dry-run mode.

Is it useful? That depends on whether it works. Does it work? We don't know. Are there any tests to prove that it works? We know there aren't. Breaking dry-run mode, as I did earlier, did not break any tests.

== Proposed fix ==

Rather than fixing and testing dry-run mode (the test would involve an extra, expensive script run), and if necessary fixing it further for not good reason, we chose to ditch dry-run mode.

We can add it back later if there's any interest in it, but hopefully by then we'll be able to do it right: instantiate a Gina script object in-process, set up some test objects, run the script object, and verify that no changes were committed.

== Pre-implementation notes ==

The salient bit:

(20:18:00) bigjools: first question, do we need a dry run mode?
(20:18:14) bigjools: IOW, how does it help us?
(20:18:34) jtv: Well since young Will here had no idea it even existed, I was wondering whether you might know the answer.
(20:19:00) bigjools: I don't I'm afraid, the Gina code has been barely touched in years, well before I started working on LP

== Implementation details ==

I fixed some lint as well. Sorry for the diff pollution.

== Tests ==

{{{
./bin/test -vvc lp.soyuz -t gina -t katie
}}}

== Demo and Q/A ==

We're getting quite experienced at doing gina test runs!

= Launchpad lint =

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/soyuz/scripts/gina/katie.py
  scripts/gina.py
  lib/lp/soyuz/scripts/gina/handlers.py

./scripts/gina.py
      26: '_pythonpath' imported but unused

To post a comment you must log in.
Revision history for this message
Graham Binns (gmb) wrote :

[1]

71 + raise AssertionError(
72 + "%s killed us on %s %s" % (len(q), query, args))

I know you didn't write it, but this error message makes little sense to me... any mileage in changing it in this branch, or does it make sufficient sense to those In The Know that it should remain untouched?

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/soyuz/scripts/gina/handlers.py'
--- lib/lp/soyuz/scripts/gina/handlers.py 2011-09-13 04:31:22 +0000
+++ lib/lp/soyuz/scripts/gina/handlers.py 2011-09-13 14:48:25 +0000
@@ -165,9 +165,8 @@
165 This class is used to handle the import process.165 This class is used to handle the import process.
166 """166 """
167167
168 def __init__(self, ztm, distro_name, distroseries_name, dry_run,168 def __init__(self, ztm, distro_name, distroseries_name, ktdb,
169 ktdb, archive_root, keyrings, pocket, component_override):169 archive_root, keyrings, pocket, component_override):
170 self.dry_run = dry_run
171 self.pocket = pocket170 self.pocket = pocket
172 self.component_override = component_override171 self.component_override = component_override
173 self.ztm = ztm172 self.ztm = ztm
@@ -191,13 +190,11 @@
191190
192 def commit(self):191 def commit(self):
193 """Commit to the database."""192 """Commit to the database."""
194 if not self.dry_run:193 self.ztm.commit()
195 self.ztm.commit()
196194
197 def abort(self):195 def abort(self):
198 """Rollback changes to the database."""196 """Rollback changes to the database."""
199 if not self.dry_run:197 self.ztm.abort()
200 self.ztm.abort()
201198
202 def ensure_archinfo(self, archtag):199 def ensure_archinfo(self, archtag):
203 """Append retrived distroarchseries info to a dict."""200 """Append retrived distroarchseries info to a dict."""
204201
=== modified file 'lib/lp/soyuz/scripts/gina/katie.py'
--- lib/lp/soyuz/scripts/gina/katie.py 2011-09-06 05:00:26 +0000
+++ lib/lp/soyuz/scripts/gina/katie.py 2011-09-13 14:48:25 +0000
@@ -1,4 +1,4 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the1# Copyright 2009-2011 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4__metaclass__ = type4__metaclass__ = type
@@ -15,10 +15,9 @@
1515
1616
17class Katie:17class Katie:
18 def __init__(self, dbname, suite, dry_run):18 def __init__(self, dbname, suite):
19 self.suite = suite19 self.suite = suite
20 self.dbname = dbname20 self.dbname = dbname
21 self.dry_run = dry_run
22 log.info("Connecting to %s as %s" % (dbname, config.gina.dbuser))21 log.info("Connecting to %s as %s" % (dbname, config.gina.dbuser))
23 self.db = connect(user=config.gina.dbuser, dbname=dbname)22 self.db = connect(user=config.gina.dbuser, dbname=dbname)
2423
@@ -39,10 +38,6 @@
39 return s38 return s
4039
41 def commit(self):40 def commit(self):
42 if self.dry_run:
43 # Not committing -- we're on a dry run
44 log.debug("Not committing (dry run)")
45 return
46 log.debug("Committing")41 log.debug("Committing")
47 return self.db.commit()42 return self.db.commit()
4843
@@ -65,7 +60,6 @@
65 return self._get_dicts(cursor)60 return self._get_dicts(cursor)
6661
67 def _query(self, query, args=None):62 def _query(self, query, args=None):
68 #print repr(query), repr(args)
69 cursor = self.db.cursor()63 cursor = self.db.cursor()
70 cursor.execute(query, args or [])64 cursor.execute(query, args or [])
71 results = cursor.fetchall()65 results = cursor.fetchall()
@@ -78,11 +72,11 @@
78 elif not q:72 elif not q:
79 return None73 return None
80 else:74 else:
81 raise AssertionError, "%s killed us on %s %s" \75 raise AssertionError(
82 % (len(q), query, args)76 "Expected 0 or 1 result from this query, but got %d: "
77 "'%s' (with arguments: %s)." % (len(q), query, args))
8378
84 def _exec(self, query, args=None):79 def _exec(self, query, args=None):
85 #print repr(query), repr(args)
86 cursor = self.db.cursor()80 cursor = self.db.cursor()
87 cursor.execute(query, args or [])81 cursor.execute(query, args or [])
88 return cursor82 return cursor
@@ -93,12 +87,17 @@
9387
94 def getSourcePackageRelease(self, name, version):88 def getSourcePackageRelease(self, name, version):
95 log.debug("Hunting for release %s / %s" % (name, version))89 log.debug("Hunting for release %s / %s" % (name, version))
96 ret = self._query_to_dict("""SELECT * FROM source, fingerprint90 ret = self._query_to_dict("""
97 WHERE source = %s91 SELECT *
98 AND source.sig_fpr = fingerprint.id92 FROM source, fingerprint
99 AND version = %s""", (name, version))93 WHERE
94 source = %s AND
95 source.sig_fpr = fingerprint.id AND
96 version = %s""",
97 (name, version))
100 if not ret:98 if not ret:
101 log.debug("that spr didn't turn up. Attempting to find via ubuntu")99 log.debug(
100 "that spr didn't turn up. Attempting to find via ubuntu")
102 else:101 else:
103 return ret102 return ret
104103
@@ -119,6 +118,7 @@
119 architecture.id118 architecture.id
120 AND arch_string = %s""",119 AND arch_string = %s""",
121 (name, version, arch))120 (name, version, arch))
121
122 def getSections(self):122 def getSections(self):
123 return self._query("""SELECT section FROM section""")123 return self._query("""SELECT section FROM section""")
124124
@@ -134,4 +134,3 @@
134 AND override.package = %s134 AND override.package = %s
135 AND suite.suite_name = %s135 AND suite.suite_name = %s
136 """, (sourcepackage, self.suite))[0]136 """, (sourcepackage, self.suite))[0]
137
138137
=== modified file 'scripts/gina.py'
--- scripts/gina.py 2011-09-13 08:44:05 +0000
+++ scripts/gina.py 2011-09-13 14:48:25 +0000
@@ -87,8 +87,6 @@
87 source_only = target_section.source_only87 source_only = target_section.source_only
88 spnames_only = target_section.sourcepackagenames_only88 spnames_only = target_section.sourcepackagenames_only
8989
90 dry_run = options.dry_run
91
92 KTDB = target_section.katie_dbname90 KTDB = target_section.katie_dbname
9391
94 LIBRHOST = config.librarian.upload_host92 LIBRHOST = config.librarian.upload_host
@@ -107,7 +105,6 @@
107 log.info("SourcePackage Only: %s", source_only)105 log.info("SourcePackage Only: %s", source_only)
108 log.info("SourcePackageName Only: %s", spnames_only)106 log.info("SourcePackageName Only: %s", spnames_only)
109 log.debug("Librarian: %s:%s", LIBRHOST, LIBRPORT)107 log.debug("Librarian: %s:%s", LIBRHOST, LIBRPORT)
110 log.info("Dry run: %s", dry_run)
111 log.info("")108 log.info("")
112109
113 if not hasattr(PackagePublishingPocket, pocket.upper()):110 if not hasattr(PackagePublishingPocket, pocket.upper()):
@@ -126,7 +123,7 @@
126 kdb = None123 kdb = None
127 keyrings = None124 keyrings = None
128 if KTDB:125 if KTDB:
129 kdb = Katie(KTDB, distroseries, dry_run)126 kdb = Katie(KTDB, distroseries)
130 keyrings = _get_keyring(keyrings_root)127 keyrings = _get_keyring(keyrings_root)
131128
132 try:129 try:
@@ -140,8 +137,8 @@
140137
141 packages_map = PackagesMap(arch_component_items)138 packages_map = PackagesMap(arch_component_items)
142 importer_handler = ImporterHandler(139 importer_handler = ImporterHandler(
143 ztm, distro, distroseries, dry_run, kdb, package_root, keyrings,140 ztm, distro, distroseries, kdb, package_root, keyrings, pocket,
144 pocket, component_override)141 component_override)
145142
146 import_sourcepackages(143 import_sourcepackages(
147 packages_map, kdb, package_root, keyrings, importer_handler)144 packages_map, kdb, package_root, keyrings, importer_handler)
@@ -321,9 +318,6 @@
321 self.parser.add_option("-l", "--list-targets", action="store_true",318 self.parser.add_option("-l", "--list-targets", action="store_true",
322 help="List configured import targets", dest="list_targets",319 help="List configured import targets", dest="list_targets",
323 default=False)320 default=False)
324 self.parser.add_option("-n", "--dry-run", action="store_true",
325 help="Don't commit changes to the database",
326 dest="dry_run", default=False)
327321
328 def getConfiguredTargets(self):322 def getConfiguredTargets(self):
329 """Get the configured import targets.323 """Get the configured import targets.