Exemplo n.º 1
0
    def test_can_merge_with_incomplete_ids(self):
        # this shouldn't happen if the _interpret_*() methods are
        # written correctly, but just in case

        errors = [
            dict(
                attempt_id='attempt_201512232143_0008_r_000000_0',
                hadoop_error=dict(message='BOOM'),
                split=dict(path='trade_secrets.dat'),
            ),
            dict(
                attempt_id='attempt_201512232143_0008_r_000000_0',
                hadoop_error=dict(message='BOOM'),
                task_id='task_201512232143_0008_r_000000',
            ),
        ]

        self.assertEqual(_merge_and_sort_errors(errors), [
            dict(
                attempt_id='attempt_201512232143_0008_r_000000_0',
                hadoop_error=dict(message='BOOM'),
                split=dict(path='trade_secrets.dat'),
                task_id='task_201512232143_0008_r_000000',
            ),
        ])
Exemplo n.º 2
0
    def test_single_error(self):
        error = dict(
            container_id='container_1450486922681_0005_01_000003',
            hadoop_error=dict(message='BOOM'),
        )

        self.assertEqual(_merge_and_sort_errors([error]), [error])
Exemplo n.º 3
0
    def test_single_error(self):
        error = dict(
            container_id='container_1450486922681_0005_01_000003',
            hadoop_error=dict(message='BOOM'),
        )

        self.assertEqual(_merge_and_sort_errors([error]), [error])
Exemplo n.º 4
0
    def test_can_merge_with_incomplete_ids(self):
        # this shouldn't happen if the _interpret_*() methods are
        # written correctly, but just in case

        errors = [
            dict(
                attempt_id='attempt_201512232143_0008_r_000000_0',
                hadoop_error=dict(message='BOOM'),
                split=dict(path='trade_secrets.dat'),
            ),
            dict(
                attempt_id='attempt_201512232143_0008_r_000000_0',
                hadoop_error=dict(message='BOOM'),
                task_id='task_201512232143_0008_r_000000',
            ),
        ]

        self.assertEqual(
            _merge_and_sort_errors(errors),
            [
                dict(
                    attempt_id='attempt_201512232143_0008_r_000000_0',
                    hadoop_error=dict(message='BOOM'),
                    split=dict(path='trade_secrets.dat'),
                    task_id='task_201512232143_0008_r_000000',
                ),
            ]
        )
Exemplo n.º 5
0
    def test_merge_errors(self):
        errors = [
            dict(container_id="container_1450486922681_0005_01_000003", hadoop_error=dict(message="BOOM")),
            dict(  # from a different container, shouldn't be merged
                container_id="container_1450486922681_0005_01_000004", hadoop_error=dict(message="bad stuff, maybe?")
            ),
            dict(
                container_id="container_1450486922681_0005_01_000003",
                hadoop_error=dict(message="BOOM", path="history.jhist"),
                split=dict(path="tricky_input"),
            ),
            dict(
                container_id="container_1450486922681_0005_01_000003",
                hadoop_error=dict(message="BOOM\n", path="some_syslog"),
                task_error=dict(message="it was probably snakes", path="some_stderr"),
            ),
        ]

        self.assertEqual(
            _merge_and_sort_errors(errors),
            [
                dict(
                    container_id="container_1450486922681_0005_01_000004",
                    hadoop_error=dict(message="bad stuff, maybe?"),
                ),
                dict(
                    container_id="container_1450486922681_0005_01_000003",
                    hadoop_error=dict(message="BOOM\n", path="some_syslog"),
                    split=dict(path="tricky_input"),
                    task_error=dict(message="it was probably snakes", path="some_stderr"),
                ),
            ],
        )
Exemplo n.º 6
0
    def test_merge_errors(self):
        errors = [
            dict(
                container_id='container_1450486922681_0005_01_000003',
                hadoop_error=dict(message='BOOM')
            ),
            dict(  # from a different container, shouldn't be merged
                container_id='container_1450486922681_0005_01_000004',
                hadoop_error=dict(message='bad stuff, maybe?')
            ),
            dict(
                container_id='container_1450486922681_0005_01_000003',
                hadoop_error=dict(
                    message='BOOM',
                    path='history.jhist',
                ),
                split=dict(path='tricky_input')
            ),
            dict(
                container_id='container_1450486922681_0005_01_000003',
                hadoop_error=dict(
                    message='BOOM\n',
                    path='some_syslog',
                ),
                task_error=dict(
                    message='it was probably snakes',
                    path='some_stderr',
                ),
            ),
        ]

        self.assertEqual(
            _merge_and_sort_errors(errors),
            [
                dict(
                    container_id='container_1450486922681_0005_01_000004',
                    hadoop_error=dict(message='bad stuff, maybe?')
                ),
                dict(
                    container_id='container_1450486922681_0005_01_000003',
                    hadoop_error=dict(
                        message='BOOM\n',
                        path='some_syslog',
                    ),
                    split=dict(path='tricky_input'),
                    task_error=dict(
                        message='it was probably snakes',
                        path='some_stderr'
                    ),
                )
            ])
Exemplo n.º 7
0
    def test_merge_errors(self):
        errors = [
            dict(
                container_id='container_1450486922681_0005_01_000003',
                hadoop_error=dict(message='BOOM')
            ),
            dict(  # from a different container, shouldn't be merged
                container_id='container_1450486922681_0005_01_000004',
                hadoop_error=dict(message='bad stuff, maybe?')
            ),
            dict(
                container_id='container_1450486922681_0005_01_000003',
                hadoop_error=dict(
                    message='BOOM',
                    path='history.jhist',
                ),
                split=dict(path='tricky_input')
            ),
            dict(
                container_id='container_1450486922681_0005_01_000003',
                hadoop_error=dict(
                    message='BOOM\n',
                    path='some_syslog',
                ),
                task_error=dict(
                    message='it was probably snakes',
                    path='some_stderr',
                ),
            ),
        ]

        self.assertEqual(
            _merge_and_sort_errors(errors),
            [
                dict(
                    container_id='container_1450486922681_0005_01_000004',
                    hadoop_error=dict(message='bad stuff, maybe?')
                ),
                dict(
                    container_id='container_1450486922681_0005_01_000003',
                    hadoop_error=dict(
                        message='BOOM\n',
                        path='some_syslog',
                    ),
                    split=dict(path='tricky_input'),
                    task_error=dict(
                        message='it was probably snakes',
                        path='some_stderr'
                    ),
                )
            ])
Exemplo n.º 8
0
    def test_attempt_to_container_id(self):
        errors = [
            dict(
                attempt_id='attempt_201512232143_0008_r_000000_0',
                hadoop_error=dict(message='BOOM'),
            ),
            dict(
                attempt_id='attempt_201512232143_0008_r_000000_1',
                hadoop_error=dict(message='BOOM again'),
            ),
            dict(
                container_id='container_1450486922681_0005_01_000003',
                task_error=dict(message='it was probably snakes'),
            ),
        ]

        attempt_to_container_id = {
            'attempt_201512232143_0008_r_000000_1':
            'container_1450486922681_0005_01_000003',
        }

        self.assertEqual(
            _merge_and_sort_errors(errors, attempt_to_container_id),
            [
                dict(
                    attempt_id='attempt_201512232143_0008_r_000000_1',
                    container_id='container_1450486922681_0005_01_000003',
                    hadoop_error=dict(message='BOOM again'),
                    task_error=dict(message='it was probably snakes'),
                ),
                dict(
                    attempt_id='attempt_201512232143_0008_r_000000_0',
                    hadoop_error=dict(message='BOOM'),
                ),
            ],
        )
Exemplo n.º 9
0
    def test_attempt_to_container_id(self):
        errors = [
            dict(
                attempt_id='attempt_201512232143_0008_r_000000_0',
                hadoop_error=dict(message='BOOM'),
            ),
            dict(
                attempt_id='attempt_201512232143_0008_r_000000_1',
                hadoop_error=dict(message='BOOM again'),
            ),
            dict(
                container_id='container_1450486922681_0005_01_000003',
                task_error=dict(message='it was probably snakes'),
            ),
        ]

        attempt_to_container_id = {
            'attempt_201512232143_0008_r_000000_1':
            'container_1450486922681_0005_01_000003',
        }

        self.assertEqual(
            _merge_and_sort_errors(errors, attempt_to_container_id),
            [
                dict(
                    attempt_id='attempt_201512232143_0008_r_000000_0',
                    hadoop_error=dict(message='BOOM'),
                ),
                dict(
                    attempt_id='attempt_201512232143_0008_r_000000_1',
                    container_id='container_1450486922681_0005_01_000003',
                    hadoop_error=dict(message='BOOM again'),
                    task_error=dict(message='it was probably snakes'),
                ),
            ],
        )
Exemplo n.º 10
0
 def test_empty(self):
     self.assertEqual(_merge_and_sort_errors([]), [])
Exemplo n.º 11
0
 def test_empty(self):
     self.assertEqual(_merge_and_sort_errors([]), [])