コード例 #1
0
 def setUp(self):
     logging.basicConfig()
     __builtin__.__pillar__ = {}
     __builtin__.__grains__ = {}
     __builtin__.__salt__ = {'system.wait_for': system.wait_for, 'marathon_client.apps': lambda: {
         'chronos': [models.MarathonTask(app_id='chronos', host='host1', ports=[11]),
                     models.MarathonTask(app_id='chronos', host='host2', ports=[12])],
         'kafka-mesos': [models.MarathonTask(app_id='kafka-mesos', host='host1', ports=[12])]}}
コード例 #2
0
 def test_fetch_tasks_some_tasks(self):
     self.cli.list_tasks.return_value = [
         models.MarathonTask(app_id='/chronos', host='host1', id='task1', staged_at='2014-12-10T11:44:55.001Z'),
         models.MarathonTask(app_id='/chronos', host='host2', id='task2', staged_at='2014-12-10T11:43:55.001Z')]
     self.assertEqual(marathon_client._fetch_tasks(self.cli, 'chronos'),
                      {'chronos': [models.MarathonTask(app_id='/chronos', host='host2', id='task2',
                                                       staged_at='2014-12-10T11:43:55.001Z'),
                                   models.MarathonTask(app_id='/chronos', host='host1', id='task1',
                                                       staged_at='2014-12-10T11:44:55.001Z')]})
コード例 #3
0
 def test_unhealthy_task2(self):
     self.cli.list_tasks.return_value = [
         models.MarathonTask(
             app_id='/chronos',
             host='host1',
             id='task1',
             health_check_results=[
                 models.task.MarathonHealthCheckResult(alive=False)
             ])
     ]
     app = marathon_client._healthy_tasks(self.cli, 'chronos', 1)
     self.assertEquals(app, None)
コード例 #4
0
 def test_fetch_tasks_all_tasks(self):
     self.cli.list_tasks.return_value = [
         models.MarathonTask(app_id='/chronos',
                             host='host1',
                             id='task1',
                             staged_at='2014-12-10T11:44:55.001Z'),
         models.MarathonTask(app_id='/docker',
                             host='host2',
                             id='task2',
                             staged_at='2014-12-10T11:23:55.001Z'),
         models.MarathonTask(app_id='/chronos',
                             host='host2',
                             id='task2',
                             staged_at='2014-12-10T11:43:55.001Z')
     ]
     results = marathon_client._fetch_tasks(self.cli, None)
     self.assertEqual(
         results, {
             'chronos': [
                 models.MarathonTask(app_id='/chronos',
                                     host='host2',
                                     id='task2',
                                     staged_at='2014-12-10T11:43:55.001Z'),
                 models.MarathonTask(app_id='/chronos',
                                     host='host1',
                                     id='task1',
                                     staged_at='2014-12-10T11:44:55.001Z')
             ],
             'docker': [
                 models.MarathonTask(app_id='/docker',
                                     host='host2',
                                     id='task2',
                                     staged_at='2014-12-10T11:23:55.001Z')
             ]
         })
コード例 #5
0
 def test_unhealthy_task(self):
     self.cli.list_tasks.return_value = [
         models.MarathonTask(app_id='/chronos', id='task1')
     ]
     app = marathon_client._healthy_tasks(self.cli, 'chronos', 1)
     self.assertEquals(app, None)
コード例 #6
0
 def test_healthy_task(self):
     self.cli.list_tasks.return_value = [
         models.MarathonTask(app_id='/chronos', host='host1', id='task1')
     ]
     app = marathon_client._healthy_tasks(self.cli, 'chronos', 1)
     self.assertEquals(len(app['chronos']), 1)