From patchwork Wed Jul 20 05:00:50 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael-Doyle Hudson X-Patchwork-Id: 2782 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id D84252405F for ; Wed, 20 Jul 2011 05:00:53 +0000 (UTC) Received: from mail-qw0-f52.google.com (mail-qw0-f52.google.com [209.85.216.52]) by fiordland.canonical.com (Postfix) with ESMTP id 83C57A18642 for ; Wed, 20 Jul 2011 05:00:53 +0000 (UTC) Received: by qwb8 with SMTP id 8so3417927qwb.11 for ; Tue, 19 Jul 2011 22:00:53 -0700 (PDT) Received: by 10.229.68.200 with SMTP id w8mr7097729qci.114.1311138052220; Tue, 19 Jul 2011 22:00:52 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.229.217.78 with SMTP id hl14cs103672qcb; Tue, 19 Jul 2011 22:00:51 -0700 (PDT) Received: by 10.227.182.74 with SMTP id cb10mr7270931wbb.48.1311138051205; Tue, 19 Jul 2011 22:00:51 -0700 (PDT) Received: from adelie.canonical.com (adelie.canonical.com [91.189.90.139]) by mx.google.com with ESMTP id fq4si11159310wbb.120.2011.07.19.22.00.50; Tue, 19 Jul 2011 22:00:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.139 as permitted sender) client-ip=91.189.90.139; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.139 as permitted sender) smtp.mail=bounces@canonical.com Received: from loganberry.canonical.com ([91.189.90.37]) by adelie.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1QjOtu-0008Sg-9d for ; Wed, 20 Jul 2011 05:00:50 +0000 Received: from loganberry.canonical.com (localhost [127.0.0.1]) by loganberry.canonical.com (Postfix) with ESMTP id 416C92E8059 for ; Wed, 20 Jul 2011 05:00:50 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: lava-scheduler X-Launchpad-Branch: ~linaro-validation/lava-scheduler/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 36 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-validation/lava-scheduler/trunk] Rev 36: add a test, fix a slightly ridiculous problem, slightly whingy comment about said problem Message-Id: <20110720050050.8247.29231.launchpad@loganberry.canonical.com> Date: Wed, 20 Jul 2011 05:00:50 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="13405"; Instance="initZopeless config overlay" X-Launchpad-Hash: 637ead4b424e7fcab3cb7a2216b3e0c93af48425 ------------------------------------------------------------ revno: 36 committer: Michael-Doyle Hudson branch nick: trunk timestamp: Wed 2011-07-20 16:58:48 +1200 message: add a test, fix a slightly ridiculous problem, slightly whingy comment about said problem modified: lava_scheduler_app/tests.py lava_scheduler_daemon/dbjobsource.py --- lp:lava-scheduler https://code.launchpad.net/~linaro-validation/lava-scheduler/trunk You are subscribed to branch lp:lava-scheduler. To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-scheduler/trunk/+edit-subscription === modified file 'lava_scheduler_app/tests.py' --- lava_scheduler_app/tests.py 2011-07-06 22:39:01 +0000 +++ lava_scheduler_app/tests.py 2011-07-20 04:58:48 +0000 @@ -3,6 +3,7 @@ import json import xmlrpclib +from django.db import transaction from django.contrib.auth.models import Permission, User from django.test.client import Client @@ -195,13 +196,21 @@ definition = {'foo': 'bar'} self.factory.make_testjob( target=device, definition=json.dumps(definition)) + transaction.commit() self.assertEqual( definition, DatabaseJobSource().getJobForBoard_impl('panda01')) + def test_getJobForBoard_returns_None_if_no_job(self): + self.factory.make_device(hostname='panda01') + transaction.commit() + self.assertEqual( + None, DatabaseJobSource().getJobForBoard_impl('panda01')) + def test_getJobForBoard_sets_start_time(self): device = self.factory.make_device(hostname='panda01') job = self.factory.make_testjob(target=device) before = datetime.datetime.now() + transaction.commit() DatabaseJobSource().getJobForBoard_impl('panda01') after = datetime.datetime.now() # reload from the database @@ -211,6 +220,7 @@ def test_getJobForBoard_set_statuses(self): device = self.factory.make_device(hostname='panda01') job = self.factory.make_testjob(target=device) + transaction.commit() DatabaseJobSource().getJobForBoard_impl('panda01') # reload from the database job = TestJob.objects.get(pk=job.pk) @@ -222,6 +232,7 @@ def test_getJobForBoard_sets_running_job(self): device = self.factory.make_device(hostname='panda01') job = self.factory.make_testjob(target=device) + transaction.commit() DatabaseJobSource().getJobForBoard_impl('panda01') # reload from the database job = TestJob.objects.get(pk=job.pk) @@ -231,11 +242,13 @@ def get_device_and_running_job(self): device = self.factory.make_device(hostname='panda01') job = self.factory.make_testjob(target=device) + transaction.commit() DatabaseJobSource().getJobForBoard_impl('panda01') return device, job def test_jobCompleted_set_statuses(self): device, job = self.get_device_and_running_job() + transaction.commit() DatabaseJobSource().jobCompleted_impl('panda01', None) job = TestJob.objects.get(pk=job.pk) device = Device.objects.get(pk=device.pk) @@ -246,6 +259,7 @@ def test_jobCompleted_sets_end_time(self): device, job = self.get_device_and_running_job() before = datetime.datetime.now() + transaction.commit() DatabaseJobSource().jobCompleted_impl('panda01', None) after = datetime.datetime.now() job = TestJob.objects.get(pk=job.pk) @@ -253,6 +267,7 @@ def test_jobCompleted_clears_current_job(self): device, job = self.get_device_and_running_job() + transaction.commit() DatabaseJobSource().jobCompleted_impl('panda01', None) device = Device.objects.get(pk=device.pk) self.assertEquals(None, device.current_job) === modified file 'lava_scheduler_daemon/dbjobsource.py' --- lava_scheduler_daemon/dbjobsource.py 2011-07-06 21:59:57 +0000 +++ lava_scheduler_daemon/dbjobsource.py 2011-07-20 04:58:48 +0000 @@ -56,6 +56,11 @@ transaction.commit() return json.loads(job.definition) else: + # We don't really need to rollback here, as no modifying + # operations have been made to the database. But Django is + # stupi^Wconservative and assumes the queries that have been + # issued might have been modifications. + transaction.rollback() return None def getJobForBoard(self, board_name):