Beispiel #1
0
    def test_indentation_is_required(self):
        lines = ["File System Counters", "   FILE: Number of bytes read=8"]

        with no_handlers_for_logger("mrjob.logs.parse"):
            stderr = StringIO()
            log_to_stream("mrjob.logs.parse", stderr)

            # counter line is interpreted as group
            self.assertEqual(_parse_indented_counters(lines), {})

            # should complain
            self.assertNotEqual(stderr.getvalue(), "")
Beispiel #2
0
    def test_no_empty_groups(self):
        lines = [
            '  File System Counters',
            '  Job Counters',
            '    Launched map tasks=2',
        ]

        self.assertEqual(_parse_indented_counters(lines), {
            'Job Counters': {
                'Launched map tasks': 2,
            },
        })
Beispiel #3
0
    def test_no_empty_groups(self):
        lines = [
            '  File System Counters',
            '  Job Counters',
            '    Launched map tasks=2',
        ]

        self.assertEqual(_parse_indented_counters(lines), {
            'Job Counters': {
                'Launched map tasks': 2,
            },
        })
Beispiel #4
0
    def test_with_header(self):
        lines = ["Counters: 1", "  File System Counters", "    FILE: Number of bytes read=86"]

        with no_handlers_for_logger("mrjob.logs.parse"):
            stderr = StringIO()
            log_to_stream("mrjob.logs.parse", stderr)

            self.assertEqual(
                _parse_indented_counters(lines), {"File System Counters": {"FILE: Number of bytes read": 86}}
            )

            # header shouldn't freak it out
            self.assertEqual(stderr.getvalue(), "")
Beispiel #5
0
    def test_indentation_is_required(self):
        lines = [
            'File System Counters',
            '   FILE: Number of bytes read=8',
        ]

        with no_handlers_for_logger('mrjob.logs.parse'):
            stderr = StringIO()
            log_to_stream('mrjob.logs.parse', stderr)

            # counter line is interpreted as group
            self.assertEqual(_parse_indented_counters(lines), {})

            # should complain
            self.assertNotEqual(stderr.getvalue(), '')
Beispiel #6
0
    def test_without_header(self):
        lines = [
            "  File System Counters",
            "    FILE: Number of bytes read=86",
            "    FILE: Number of bytes written=359982",
            "  Job Counters",
            "    Launched map tasks=2",
        ]

        self.assertEqual(
            _parse_indented_counters(lines),
            {
                "File System Counters": {"FILE: Number of bytes read": 86, "FILE: Number of bytes written": 359982},
                "Job Counters": {"Launched map tasks": 2},
            },
        )
Beispiel #7
0
    def test_without_header(self):
        lines = [
            '  File System Counters',
            '    FILE: Number of bytes read=86',
            '    FILE: Number of bytes written=359982',
            '  Job Counters',
            '    Launched map tasks=2',
        ]

        self.assertEqual(_parse_indented_counters(lines), {
            'File System Counters': {
                'FILE: Number of bytes read': 86,
                'FILE: Number of bytes written': 359982,
            },
            'Job Counters': {
                'Launched map tasks': 2,
            },
        })
Beispiel #8
0
    def test_without_header(self):
        lines = [
            '  File System Counters',
            '    FILE: Number of bytes read=86',
            '    FILE: Number of bytes written=359982',
            '  Job Counters',
            '    Launched map tasks=2',
        ]

        self.assertEqual(_parse_indented_counters(lines), {
            'File System Counters': {
                'FILE: Number of bytes read': 86,
                'FILE: Number of bytes written': 359982,
            },
            'Job Counters': {
                'Launched map tasks': 2,
            },
        })
Beispiel #9
0
    def test_with_header(self):
        lines = [
            'Counters: 1',
            '  File System Counters',
            '    FILE: Number of bytes read=86',
        ]

        with no_handlers_for_logger('mrjob.logs.parse'):
            stderr = StringIO()
            log_to_stream('mrjob.logs.parse', stderr)

            self.assertEqual(_parse_indented_counters(lines), {
                'File System Counters': {
                    'FILE: Number of bytes read': 86,
                },
            })

            # header shouldn't freak it out
            self.assertEqual(stderr.getvalue(), '')
Beispiel #10
0
    def test_with_header(self):
        lines = [
            'Counters: 1',
            '  File System Counters',
            '    FILE: Number of bytes read=86',
        ]

        with no_handlers_for_logger('mrjob.logs.parse'):
            stderr = StringIO()
            log_to_stream('mrjob.logs.parse', stderr)

            self.assertEqual(_parse_indented_counters(lines), {
                'File System Counters': {
                    'FILE: Number of bytes read': 86,
                },
            })

            # header shouldn't freak it out
            self.assertEqual(stderr.getvalue(), '')
Beispiel #11
0
    def test_no_empty_groups(self):
        lines = ["  File System Counters", "  Job Counters", "    Launched map tasks=2"]

        self.assertEqual(_parse_indented_counters(lines), {"Job Counters": {"Launched map tasks": 2}})
Beispiel #12
0
 def test_empty(self):
     self.assertEqual(_parse_indented_counters([]), {})
Beispiel #13
0
 def test_empty(self):
     self.assertEqual(_parse_indented_counters([]), {})