diff mbox

[Branch,~linaro-validation/lava-scheduler/trunk] Rev 52: Sigh, another problem in device type targeting: the target wasn't being put

Message ID 20110727101220.12305.71306.launchpad@loganberry.canonical.com
State Accepted
Headers show

Commit Message

Michael-Doyle Hudson July 27, 2011, 10:12 a.m. UTC
------------------------------------------------------------
revno: 52
committer: Michael-Doyle Hudson <michael.hudson@linaro.org>
branch nick: trunk
timestamp: Wed 2011-07-27 22:10:10 +1200
message:
  Sigh, another problem in device type targeting: the target wasn't being put
  into the json data before being given to the dispatcher.
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
diff mbox

Patch

=== modified file 'lava_scheduler_app/tests.py'
--- lava_scheduler_app/tests.py	2011-07-27 10:09:09 +0000
+++ lava_scheduler_app/tests.py	2011-07-27 10:10:10 +0000
@@ -190,7 +190,7 @@ 
 
     def test_getJobForBoard_returns_json(self):
         device = self.factory.make_device(hostname='panda01')
-        definition = {'foo': 'bar'}
+        definition = {'foo': 'bar', 'target': 'panda01'}
         self.factory.make_testjob(
             requested_device=device, definition=json.dumps(definition))
         transaction.commit()
@@ -221,6 +221,7 @@ 
             requested_device_type=panda_type,
             definition=json.dumps(definition))
         transaction.commit()
+        definition['target'] = 'panda01'
         self.assertEqual(
             definition, DatabaseJobSource().getJobForBoard_impl('panda01')[0])
 
@@ -228,8 +229,8 @@ 
         panda_type = self.factory.ensure_device_type(name='panda')
         panda01 = self.factory.make_device(
             hostname='panda01', device_type=panda_type)
-        first_definition = {'foo': 'bar'}
-        second_definition = {'foo': 'baz'}
+        first_definition = {'foo': 'bar', 'target': 'panda01'}
+        second_definition = {'foo': 'baz', 'target': 'panda01'}
         self.factory.make_testjob(
             requested_device=panda01, definition=json.dumps(first_definition),
             submit_time=datetime.datetime.now() - datetime.timedelta(days=1))
@@ -246,11 +247,11 @@ 
         panda01 = self.factory.make_device(
             hostname='panda01', device_type=panda_type)
         type_definition = {'foo': 'bar'}
-        device_definition = {'foo': 'baz'}
         self.factory.make_testjob(
             requested_device_type=panda_type,
             definition=json.dumps(type_definition),
             submit_time=datetime.datetime.now() - datetime.timedelta(days=1))
+        device_definition = {'foo': 'baz', 'target': 'panda01'}
         self.factory.make_testjob(
             requested_device=panda01,
             definition=json.dumps(device_definition))
@@ -264,7 +265,7 @@ 
         panda01 = self.factory.make_device(
             hostname='panda01', device_type=panda_type)
         self.factory.make_device(hostname='panda02', device_type=panda_type)
-        definition = {'foo': 'bar'}
+        definition = {'foo': 'bar', 'target': 'panda01'}
         self.factory.make_testjob(
             requested_device=panda01,
             definition=json.dumps(definition))

=== modified file 'lava_scheduler_daemon/dbjobsource.py'
--- lava_scheduler_daemon/dbjobsource.py	2011-07-26 04:31:14 +0000
+++ lava_scheduler_daemon/dbjobsource.py	2011-07-27 10:10:10 +0000
@@ -62,8 +62,9 @@ 
                     job.log_file.save(
                         'job-%s.log' % job.id, ContentFile(''), save=False)
                     job.save()
+                    json_data = json.loads(job.definition)
+                    json_data['target'] = device.hostname
                     transaction.commit()
-                    json_data = json.loads(job.definition)
                     log_file = job.log_file
                     log_file.file.close()
                     log_file.open('wb')