Esempio n. 1
0
 def test_make_dict(self):
     """Test make_dict works"""
     objref_dict = kubelet_parser.make_dict(lines, regex.wordRE("abc"))
     self.assertEqual(objref_dict, {
         "UID": "uid",
         "Namespace": "podName",
         "Name": "abc"
     })
Esempio n. 2
0
def parse_log_file(log_filename, pod, filters=None, make_dict=False, objref_dict=None):
    """Based on make_dict, either returns the objref_dict or the parsed log file"""
    log = gcs_async.read(log_filename).get_result()
    if log is None:
        return None
    pod_re = regex.wordRE(pod)

    if make_dict:
        return kubelet_parser.make_dict(log.decode('utf8', 'replace'), pod_re)
    else:
        return log_parser.digest(log.decode('utf8', 'replace'),
        error_re=pod_re, filters=filters, objref_dict=objref_dict)
Esempio n. 3
0
def parse_log_file(log_filename, pod, filters=None, make_dict=False, objref_dict=None):
    """Based on make_dict, either returns the objref_dict or the parsed log file"""
    log = gcs_async.read(log_filename).get_result()
    if log is None:
        return {}, False if make_dict else None
    if pod:
        bold_re = regex.wordRE(pod)
    else:
        bold_re = regex.error_re
    if objref_dict is None:
        objref_dict = {}
    if make_dict and pod:
        return kubelet_parser.make_dict(log.decode('utf8', 'replace'), bold_re, objref_dict)
    else:
        return log_parser.digest(log.decode('utf8', 'replace'),
            error_re=bold_re, filters=filters, objref_dict=objref_dict)
Esempio n. 4
0
 def test_make_dict_fail(self):
     """Test when objref line not in file"""
     objref_dict = kubelet_parser.make_dict(["pod failed"],
                                            regex.wordRE("abc"))
     self.assertEqual(objref_dict, None)
Esempio n. 5
0
 def test_make_dict_fail(self):
     """Test when objref line not in file"""
     objref_dict = kubelet_parser.make_dict(["pod failed"], regex.wordRE("abc"))
     self.assertEqual(objref_dict, None)
Esempio n. 6
0
 def test_make_dict(self):
     """Test make_dict works"""
     objref_dict = kubelet_parser.make_dict(lines, regex.wordRE("abc"))
     self.assertEqual(
         objref_dict, {"UID": "uid", "Namespace": "podName", "Name": "abc"})