Exemple #1
0
    def test_set_draining_with_cache(self, mock_logger, mock_session,
                                     event_no_cache):
        cid = ContainerInstanceDrainer(event_no_cache, None)
        cid.cache = dict(InstanceIsDraining=True)

        cid.set_draining('SomeCluster', 'SomeCiArn')
        cid.ecs_client.update_container_instances_state.assert_not_called()
Exemple #2
0
    def test_set_draining_no_cache(self, mock_logger, mock_session,
                                   event_no_cache):
        cid = ContainerInstanceDrainer(event_no_cache, None)
        cid.cache = {}

        cid.set_draining('SomeCluster', 'SomeCiArn')
        cid.ecs_client.update_container_instances_state.assert_called_with(
            cluster='SomeCluster',
            containerInstances=['SomeCiArn'],
            status='DRAINING')
Exemple #3
0
    def test_get_ecs_details_no_cache(self, mock_logger, mock_session,
                                      event_no_cache):
        cid = ContainerInstanceDrainer(event_no_cache, None)

        cid.cache = {}
        expected = ('my_cluster_1', 'my_ci_1')
        cid.search_for_ecs_details = Mock(return_value=expected)
        rv = cid.get_ecs_details('dummy')

        cid.search_for_ecs_details.assert_called_with('dummy')
        assert rv == expected
Exemple #4
0
    def test_get_ecs_details_with_cache(self, mock_logger, mock_session,
                                        event_no_cache):
        cid = ContainerInstanceDrainer(event_no_cache, None)

        cid.cache = dict(EcsCluster='my_cluster_2',
                         ContainerInstanceArn='my_ci_2')
        expected = ('my_cluster_2', 'my_ci_2')
        cid.search_for_ecs_details = Mock()

        rv = cid.get_ecs_details('dummy')
        assert rv == expected
        cid.search_for_ecs_details.assert_not_called()