Пример #1
0
def test_parse_diag():
    """happy path test for parsing a diag tarball"""
    config = types.SimpleNamespace()
    test_dir = os.path.join(current_dir(__file__), "testdata", "diag",
                            "DSE_CLUSTER")
    config.diag_dir = test_dir
    config.node_info_prefix = "node_info.json"
    config.system_log_prefix = "system.log"
    config.output_log_prefix = "output.log"
    config.cfstats_prefix = "cfstats"
    config.block_dev_prefix = "blockdev_report"
    env.DEBUG = True
    parsed = {}
    try:
        parsed = parse_diag(config)
    finally:
        env.DEBUG = False
    assert not parsed.get("warnings")
    first = parsed.get("configs")[0]
    assert first['busiest_table_writes']
    assert first['busiest_table_writes'][0] == 'my_solr.my_table'
    assert "%.2f" % first['busiest_table_writes'][1] == '96.18'
    assert first['busiest_table_reads'][0] == 'my_solr.my_table'
    assert "%.2f" % first['busiest_table_reads'][1] == '99.76'
    assert first['threads_per_core'] == 1
Пример #2
0
 def test_parse_diag(self):
     """happy path test for parsing a diag tarball"""
     config = types.SimpleNamespace()
     test_dir = os.path.join(current_dir(__file__), "testdata", "diag",
                             "DSE_CLUSTER")
     config.diag_dir = test_dir
     config.node_info_prefix = "node_info.json"
     config.system_log_prefix = "system.log"
     config.output_log_prefix = "output.log"
     config.cfstats_prefix = "cfstats"
     config.block_dev_prefix = "blockdev_report"
     env.DEBUG = True
     parsed = {}
     try:
         parsed = parse_diag(config)
     finally:
         env.DEBUG = False
     self.assertFalse(parsed.get("warnings"))
     first = parsed.get("configs")[0]
     self.assertTrue(first["busiest_table_writes"])
     self.assertEqual(first["busiest_table_writes"][0], "my_solr.my_table")
     self.assertEqual("%.2f" % first["busiest_table_writes"][1], "96.18")
     self.assertEqual(first["busiest_table_reads"][0], "my_solr.my_table")
     self.assertEqual("%.2f" % first["busiest_table_reads"][1], "99.76")
     self.assertEqual(first["threads_per_core"], 1)
Пример #3
0
def parse(args):
    """read diag tarball"""
    res = parse_diag(args, lambda n: [calculate(n)])
    # use debug logs for statuslogger output on 5.1.17+, 6.0.10+, 6.7.5+ and 6.8+
    debug_logs = diag.find_logs(args.diag_dir, args.debug_log_prefix)
    parsed = OrderedDict()
    parsed["diag_dir"] = args.diag_dir
    parsed["warnings"] = res.get("warnings")
    parsed["configs"] = res.get("original_configs")
    parsed["summary"] = res.get("configs")[0]
    parsed["rec_logs"] = res.get("system_logs") + debug_logs
    return parsed
Пример #4
0
def parse(args):
    """read diag tarball"""
    res = parse_diag(args, lambda n: [calculate(n)])
    #use debug logs for statuslogger output on 5.1.17+, 6.0.10+, 6.7.5+ and 6.8+
    debug_logs = diag.find_logs(args.diag_dir, args.debug_log_prefix)
    return {
        "diag_dir": args.diag_dir,
        "warnings": res.get("warnings"),
        "configs": res.get("original_configs"),
        "summary": res.get("configs")[0],
        "rec_logs": res.get("system_logs") + debug_logs,
    }
Пример #5
0
def test_parse_diag_reports_no_files_found():
    """should see missing files in the warning list"""
    config = types.SimpleNamespace()
    test_dir = os.path.join(current_dir(__file__), "testdata", "diag", "empty")
    config.diag_dir = test_dir
    config.node_info_prefix = "node_info.json"
    config.system_log_prefix = "system.log"
    config.output_log_prefix = "output.log"
    config.cfstats_prefix = "cfstats"
    config.block_dev_prefix = "blockdev_report"
    parsed = parse_diag(config)
    warnings = parsed.get("warnings")
    assert len(warnings) == 4
    assert "missing output logs: all nodes" in warnings
    assert "unable to read 'node_info.json'" in warnings
    assert "missing system logs: all nodes" in warnings
    assert "missing cfstats: all nodes" in warnings
Пример #6
0
 def test_parse_diag_reports_missing_files(self):
     """should see missing files in the warning list"""
     config = types.SimpleNamespace()
     test_dir = os.path.join(current_dir(__file__), "testdata", "diag",
                             "missing")
     config.diag_dir = test_dir
     config.node_info_prefix = "node_info.json"
     config.system_log_prefix = "system.log"
     config.output_log_prefix = "output.log"
     config.cfstats_prefix = "cfstats"
     config.block_dev_prefix = "blockdev_report"
     parsed = parse_diag(config)
     warnings = parsed.get("warnings")
     self.assertEqual(len(warnings), 4)
     self.assertTrue("missing output logs: node2" in warnings)
     self.assertTrue("missing blockdev_reports: node2" in warnings)
     self.assertTrue("missing system logs: node2" in warnings)
     self.assertTrue("missing cfstats: node2" in warnings)
Пример #7
0
def run(args):
    """launches 'sperf core diag'"""
    print("sperf core diag version: %s\n" % VERSION)
    parsed = parse_diag(args)
    print(generate_report(parsed))