X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/17cd77ac947e2c8f4ca51aa930ffc235051d7f72..297c4aaf43858eff5022a1e72eb8e09660bde4b0:/services/nodemanager/tests/test_jobqueue.py?ds=sidebyside diff --git a/services/nodemanager/tests/test_jobqueue.py b/services/nodemanager/tests/test_jobqueue.py index 669b624711..de83b68fed 100644 --- a/services/nodemanager/tests/test_jobqueue.py +++ b/services/nodemanager/tests/test_jobqueue.py @@ -154,22 +154,22 @@ class JobQueueMonitorActorTestCase(testutil.RemotePollLoopActorTestMixin, super(JobQueueMonitorActorTestCase, self).build_monitor(*args, **kwargs) self.client.jobs().queue().execute.side_effect = side_effect - @mock.patch("subprocess.check_call") - @mock.patch("subprocess.check_output") + @mock.patch("subprocess32.check_call") + @mock.patch("subprocess32.check_output") def test_unsatisfiable_jobs(self, mock_squeue, mock_scancel): - #mock_scancel.return_value = "" job_uuid = 'zzzzz-8i9sb-zzzzzzzzzzzzzzz' container_uuid = 'yyyyy-dz642-yyyyyyyyyyyyyyy' - mock_squeue.return_value = "1|1024|0|Resources|" + container_uuid + "\n" + mock_squeue.return_value = "1|1024|0|(Resources)|" + container_uuid + "||1234567890\n" self.build_monitor([{'items': [{'uuid': job_uuid}]}], self.MockCalculatorUnsatisfiableJobs(), True, True) self.monitor.subscribe(self.subscriber).get(self.TIMEOUT) + self.monitor.ping().get(self.TIMEOUT) self.stop_proxy(self.monitor) self.client.jobs().cancel.assert_called_with(uuid=job_uuid) mock_scancel.assert_called_with(['scancel', '--name='+container_uuid]) - @mock.patch("subprocess.check_output") + @mock.patch("subprocess32.check_output") def test_subscribers_get_server_lists(self, mock_squeue): mock_squeue.return_value = "" @@ -179,10 +179,10 @@ class JobQueueMonitorActorTestCase(testutil.RemotePollLoopActorTestMixin, self.subscriber.assert_called_with([testutil.MockSize(1), testutil.MockSize(2)]) - @mock.patch("subprocess.check_output") + @mock.patch("subprocess32.check_output") def test_squeue_server_list(self, mock_squeue): - mock_squeue.return_value = """1|1024|0|Resources|zzzzz-zzzzz-zzzzzzzzzzzzzzy -2|1024|0|Resources|zzzzz-zzzzz-zzzzzzzzzzzzzzz + mock_squeue.return_value = """1|1024|0|(Resources)|zzzzz-dz642-zzzzzzzzzzzzzzy|(null)|1234567890 +2|1024|0|(Resources)|zzzzz-dz642-zzzzzzzzzzzzzzz|(null)|1234567890 """ super(JobQueueMonitorActorTestCase, self).build_monitor(jobqueue.ServerCalculator( @@ -193,10 +193,10 @@ class JobQueueMonitorActorTestCase(testutil.RemotePollLoopActorTestMixin, self.subscriber.assert_called_with([testutil.MockSize(1), testutil.MockSize(2)]) - @mock.patch("subprocess.check_output") + @mock.patch("subprocess32.check_output") def test_squeue_server_list_suffix(self, mock_squeue): - mock_squeue.return_value = """1|1024M|0|ReqNodeNotAvail, UnavailableNod|zzzzz-zzzzz-zzzzzzzzzzzzzzy -1|2G|0|ReqNodeNotAvail, UnavailableNod|zzzzz-zzzzz-zzzzzzzzzzzzzzz + mock_squeue.return_value = """1|1024M|0|(ReqNodeNotAvail, UnavailableNodes:compute123)|zzzzz-dz642-zzzzzzzzzzzzzzy|(null)|1234567890 +1|2G|0|(ReqNodeNotAvail)|zzzzz-dz642-zzzzzzzzzzzzzzz|(null)|1234567890 """ super(JobQueueMonitorActorTestCase, self).build_monitor(jobqueue.ServerCalculator( @@ -207,6 +207,16 @@ class JobQueueMonitorActorTestCase(testutil.RemotePollLoopActorTestMixin, self.subscriber.assert_called_with([testutil.MockSize(1), testutil.MockSize(2)]) + @mock.patch("subprocess32.check_output") + def test_squeue_server_list_instancetype_constraint(self, mock_squeue): + mock_squeue.return_value = """1|1024|0|(Resources)|zzzzz-dz642-zzzzzzzzzzzzzzy|instancetype=z2.test|1234567890\n""" + super(JobQueueMonitorActorTestCase, self).build_monitor(jobqueue.ServerCalculator( + [(testutil.MockSize(n), {'cores': n, 'ram': n*1024, 'scratch': n}) for n in range(1, 3)]), + True, True) + self.monitor.subscribe(self.subscriber).get(self.TIMEOUT) + self.stop_proxy(self.monitor) + self.subscriber.assert_called_with([testutil.MockSize(2)]) + def test_coerce_to_mb(self): self.assertEqual(1, jobqueue.JobQueueMonitorActor.coerce_to_mb("1")) self.assertEqual(512, jobqueue.JobQueueMonitorActor.coerce_to_mb("512"))