← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~gmb/launchpad/mark-db-dirty-for-cronscripts-bug-849056 into lp:launchpad

 

Graham Binns has proposed merging lp:~gmb/launchpad/mark-db-dirty-for-cronscripts-bug-849056 into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #849056 in Launchpad itself: "ERROR:  duplicate key value violates unique constraint "scriptactivity_pkey"  in unit tests"
  https://bugs.launchpad.net/launchpad/+bug/849056

For more details, see:
https://code.launchpad.net/~gmb/launchpad/mark-db-dirty-for-cronscripts-bug-849056/+merge/103084

This branch fixes bug 849056 by following William's advice and having all the tests that just run cronscripts explicitly mark the DB dirty.
-- 
https://code.launchpad.net/~gmb/launchpad/mark-db-dirty-for-cronscripts-bug-849056/+merge/103084
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~gmb/launchpad/mark-db-dirty-for-cronscripts-bug-849056 into lp:launchpad.
=== modified file 'lib/lp/hardwaredb/scripts/tests/test_hwdbsubmissions.py'
--- lib/lp/hardwaredb/scripts/tests/test_hwdbsubmissions.py	2012-01-01 02:58:52 +0000
+++ lib/lp/hardwaredb/scripts/tests/test_hwdbsubmissions.py	2012-04-23 11:57:20 +0000
@@ -16,7 +16,10 @@
     ProcessingLoopForReprocessingBadSubmissions,
     )
 from lp.testing import TestCaseWithFactory
-from lp.testing.layers import LaunchpadScriptLayer
+from lp.testing.layers import (
+    DatabaseLayer,
+    LaunchpadScriptLayer,
+    )
 from lp.testing.matchers import Contains
 from lp.testing.script import run_script
 
@@ -108,8 +111,7 @@
         submissions = loop.getUnprocessedSubmissions(1)
         self.assertEqual(1, len(submissions))
 
-    # XXX 2011-09-13, Abel Deuring: Disabled due to bug 849056.
-    def xxx_test_BadSubmissions_respects_start(self):
+    def test_BadSubmissions_respects_start(self):
         # It is possible to request a start id. Previous entries are ignored.
         submission1 = self.factory.makeHWSubmission(
             status=HWSubmissionProcessingStatus.INVALID)
@@ -120,18 +122,18 @@
         # The sample data already contains one submission.
         submissions = loop.getUnprocessedSubmissions(2)
         self.assertEqual([submission2], submissions)
+        DatabaseLayer.force_dirty_database()
 
-    # XXX 2011-09-13, Abel Deuring: Disabled due to bug 849056.
-    def xxx_test_run_reprocessing_script_no_params(self):
+    def test_run_reprocessing_script_no_params(self):
         # cronscripts/reprocess-hwdb-submissions.py needs at least the
         # parameter --start-file
         retcode, stdout, stderr = run_script(
             'cronscripts/reprocess-hwdb-submissions.py', [])
         self.assertThat(
             stderr, Contains('Option --start-file not specified.'))
+        DatabaseLayer.force_dirty_database()
 
-    # XXX 2011-09-13, Abel Deuring: Disabled due to bug 849056.
-    def xxx_test_run_reprocessing_script_startfile_does_not_exist(self):
+    def test_run_reprocessing_script_startfile_does_not_exist(self):
         # If the specified start file does not exist,
         # cronscripts/reprocess-hwdb-submissions.py reports an error.
         does_not_exist = mktemp()
@@ -140,9 +142,9 @@
             ['--start-file', does_not_exist])
         self.assertThat(
             stderr, Contains('Cannot access file %s' % does_not_exist))
+        DatabaseLayer.force_dirty_database()
 
-    # XXX 2011-09-13, Abel Deuring: Disabled due to bug 849056.
-    def xxx_test_run_reprocessing_script_startfile_without_integer(self):
+    def test_run_reprocessing_script_startfile_without_integer(self):
         # If the specified start file contains any non-integer string,
         # cronscripts/reprocess-hwdb-submissions.py reports an error.
         start_file_name = mktemp()
@@ -155,9 +157,9 @@
         self.assertThat(
             stderr,
             Contains('%s must contain only an integer' % start_file_name))
+        DatabaseLayer.force_dirty_database()
 
-    # XXX 2011-09-13, Abel Deuring: Disabled due to bug 849056.
-    def xxx_test_run_reprocessing_script_startfile_with_negative_integer(self):
+    def test_run_reprocessing_script_startfile_with_negative_integer(self):
         # If the specified start file contains any non-integer string,
         # cronscripts/reprocess-hwdb-submissions.py reports an error.
         start_file_name = mktemp()
@@ -170,9 +172,9 @@
         self.assertThat(
             stderr,
             Contains('%s must contain a positive integer' % start_file_name))
+        DatabaseLayer.force_dirty_database()
 
-    # XXX 2011-09-13, Abel Deuring: Disabled due to bug 849056.
-    def xxx_test_run_reprocessing_script_max_submission_not_integer(self):
+    def test_run_reprocessing_script_max_submission_not_integer(self):
         # If the parameter --max-submissions is not an integer,
         # cronscripts/reprocess-hwdb-submissions.py reports an error.
         retcode, stdout, stderr = run_script(
@@ -180,6 +182,7 @@
             ['--max-submissions', 'nonsense'])
         expected = "Invalid value for --max_submissions specified: 'nonsense'"
         self.assertThat(stderr, Contains(expected))
+        DatabaseLayer.force_dirty_database()
 
     def test_run_reprocessing_script_two_batches(self):
         # cronscripts/reprocess-hwdb-submissions.py begings to process


Follow ups