示例#1
0
    def test_handle_event_status_update(self, mock_marathon):
        app_ids = ['app_1', 'app_2']
        m = DeploymentMonitor(mock_marathon, app_ids, '')
        m._thread = Mock()

        ev = MarathonEvent({
            'appId': 'app_1',
            'taskStatus': 'some_status',
            'eventType': 'status_update_event'
        })
        m._handle_event(ev)
        self.assertFalse(m._deployment_failed)
        self.assertFalse(m._deployment_succeeded)
示例#2
0
    def test_handle_event_app_not_in_list(self, mock_marathon):
        app_ids = ['app_X', 'app_Y']
        m = DeploymentMonitor(mock_marathon, app_ids, '')
        m._thread = Mock()

        ev = MarathonEvent({
            'appId': 'app_1',
            'taskStatus': 'TASK_FAILED',
            'eventType': 'status_update_event',
            'message': 'somemessage'
        })
        m._handle_event(ev)
        self.assertFalse(m._deployment_failed)
        self.assertFalse(m._deployment_succeeded)
        self.assertFalse(m._stop_event.isSet())
        self.assertFalse(m._thread.stop.called)
        self.assertIsNone(m._failed_event)
示例#3
0
 def test_is_task_staging_true(self):
     m = MarathonEvent({'taskStatus': 'TASK_STAGING'})
     self.assertTrue(m.is_task_staging())
示例#4
0
 def test_is_deployment_succeeded_false(self):
     m = MarathonEvent({'eventType': 'BLAH'})
     self.assertFalse(m.is_deployment_succeeded())
示例#5
0
 def test_not_none(self):
     m = MarathonEvent({})
     self.assertIsNotNone(m)
示例#6
0
 def test_is_deployment_succeeded_true(self):
     m = MarathonEvent({'eventType': 'deployment_success'})
     self.assertTrue(m.is_deployment_succeeded())
示例#7
0
 def test_get_event_type_unknown(self):
     m = MarathonEvent({'blah': 'SomeEvent'})
     self.assertEqual(m._get_event_type(), 'UNKNOWN')
示例#8
0
 def test_is_task_running_true(self):
     m = MarathonEvent({'taskStatus': 'TASK_RUNNING'})
     self.assertTrue(m.is_task_running())
示例#9
0
 def test_get_task_status(self):
     m = MarathonEvent({'taskStatus': 'status'})
     self.assertEqual(m._get_task_status(), 'status')
示例#10
0
 def test_get_slave_id_missing(self):
     m = MarathonEvent({'blah': 'blah'})
     self.assertRaises(KeyError, m.slave_id)
示例#11
0
 def test_get_slave_id(self):
     m = MarathonEvent({'slaveId': 'slaveid'})
     self.assertEqual(m.slave_id(), 'slaveid')
示例#12
0
 def test_get_task_id(self):
     m = MarathonEvent({'taskId': 'taskid'})
     self.assertEqual(m.task_id(), 'taskid')
示例#13
0
 def test_get_app_id_missing(self):
     m = MarathonEvent({'blah': 'appid'})
     self.assertRaises(KeyError, m.app_id)
示例#14
0
 def test_get_app_id(self):
     m = MarathonEvent({'appId': 'appid'})
     self.assertEqual(m.app_id(), 'appid')
示例#15
0
 def test_is_task_killed_true(self):
     m = MarathonEvent({'taskStatus': 'TASK_KILLED'})
     self.assertTrue(m.is_task_killed())
示例#16
0
 def test_is_task_killed_false(self):
     m = MarathonEvent({'taskStatus': 'BLAH'})
     self.assertFalse(m.is_task_killed())
示例#17
0
 def test_get_task_status_missing(self):
     m = MarathonEvent({'blah': 'blah'})
     self.assertRaises(KeyError, m._get_task_status)
示例#18
0
 def test_is_task_running_false(self):
     m = MarathonEvent({'taskStatus': 'BLAH'})
     self.assertFalse(m.is_task_running())
示例#19
0
 def test_is_status_update_true(self):
     m = MarathonEvent({'eventType': 'status_update_event'})
     self.assertTrue(m.is_status_update())
示例#20
0
 def test_is_status_update_false(self):
     m = MarathonEvent({'eventType': 'BLAH'})
     self.assertFalse(m.is_status_update())
示例#21
0
 def test_get_event_type(self):
     m = MarathonEvent({'eventType': 'SomeEvent'})
     self.assertEqual(m._get_event_type(), 'SomeEvent')