Ejemplo n.º 1
0
def test_group_configurations():
    """all grouped"""
    node_config = OrderedDict([("node1", OrderedDict([("abc", "xyz")])),
                               ("node2", OrderedDict([("abc", "xyz")]))])
    groups = config_diff.group_configurations(node_config)
    assert len(groups) == 1
    first_group = groups[0]
    assert first_group["nodes_list"] == ["node1", "node2"]
    assert first_group["nodes"] == 2
    assert first_group["abc"] == "xyz"
Ejemplo n.º 2
0
 def test_group_configurations(self):
     """all grouped"""
     node_config = OrderedDict([
         ("node1", OrderedDict([("abc", "xyz")])),
         ("node2", OrderedDict([("abc", "xyz")])),
     ])
     groups = config_diff.group_configurations(node_config)
     self.assertEqual(len(groups), 1)
     first_group = groups[0]
     self.assertEqual(first_group["nodes_list"], ["node1", "node2"])
     self.assertEqual(first_group["nodes"], 2)
     self.assertEqual(first_group["abc"], "xyz")
Ejemplo n.º 3
0
def test_group_configurations_with_diffs():
    """one of each"""
    node_config = OrderedDict([("node1", OrderedDict([("abc", "zzz")])),
                               ("node2", OrderedDict([("abc", "xyz")]))])
    groups = config_diff.group_configurations(node_config)
    assert len(groups) == 2
    first_group = groups[0]
    assert first_group["nodes_list"] == ["node1"]
    assert first_group["nodes"] == 1
    assert first_group["abc"] == "zzz"
    second_group = groups[1]
    assert second_group["nodes_list"] == ["node2"]
    assert second_group["nodes"] == 1
    assert second_group["abc"] == "xyz"
Ejemplo n.º 4
0
 def test_group_configurations_with_diffs(self):
     """one of each"""
     node_config = OrderedDict([
         ("node1", OrderedDict([("abc", "zzz")])),
         ("node2", OrderedDict([("abc", "xyz")])),
     ])
     groups = config_diff.group_configurations(node_config)
     self.assertEqual(len(groups), 2)
     first_group = groups[0]
     self.assertEqual(first_group["nodes_list"], ["node1"])
     self.assertEqual(first_group["nodes"], 1)
     self.assertEqual(first_group["abc"], "zzz")
     second_group = groups[1]
     self.assertEqual(second_group["nodes_list"], ["node2"])
     self.assertEqual(second_group["nodes"], 1)
     self.assertEqual(second_group["abc"], "xyz")
Ejemplo n.º 5
0
def test_group_configurations():
    """all grouped"""
    node_config = {
        "node1": {
            "abc": "xyz",
        },
        "node2": {
            "abc": "xyz",
        },
    }
    groups = config_diff.group_configurations(node_config)
    assert len(groups) == 1
    first_group = groups[0]
    assert first_group["nodes_list"] == ["node1", "node2"]
    assert first_group["nodes"] == 2
    assert first_group["abc"] == "xyz"
Ejemplo n.º 6
0
def parse_diag(args):
    """
    parses the following files to generate a report object:
    - all system.log (GC pause times)
    - all output.log (configuration at runtime from last reboot)
    - all cfsats files (table stats)
    -- node_info.json (drive configuration)
    -- all blockdev_report (read ahead)
    """
    #find output logs
    node_configs = node_env.initialize_node_configs(args.diag_dir)
    output_logs = diag.find_logs(args.diag_dir, args.output_log_prefix)
    #find system.logs
    system_logs = diag.find_logs(args.diag_dir, args.system_log_prefix)
    warnings = node_env.find_config_in_logs(node_configs, output_logs, system_logs)
    warn_missing(node_configs, output_logs, warnings, "missing output logs")
    warn_missing(node_configs, system_logs, warnings, "missing system logs")
    #find block dev
    node_info_list = diag.find_logs(args.diag_dir, args.node_info_prefix)
    if node_info_list:
        #only set block_dev_results if we find a single node_info.json
        with diag.FileWithProgress(node_info_list[0]) as node_info_json:
            #read all the block dev reports
            if node_info_json.error:
                warnings.append("unable to read node_info.json with error: '%s'" % node_info_json.error)
            block_dev_reports = diag.find_logs(args.diag_dir, args.block_dev_prefix)
            warn_missing(node_configs, block_dev_reports, warnings, "missing blockdev_reports")
            cass_drive_ra = read_ahead.get_cass_drive_read_ahead(node_info_json, block_dev_reports)
            read_ahead.add_block_dev_to_config(cass_drive_ra, node_configs)
    else:
        warnings.append("unable to read '%s'" % args.node_info_prefix)
    #group the configurations together
    unique_configs = config_diff.group_configurations(node_configs)
    for config in unique_configs:
        config["nodes_list"] = sorted(config["nodes_list"], reverse=True)
    for warn in node_env.add_gc_to_configs(unique_configs, system_logs):
        warnings.append(warn)
    #add cfstats if present
    cfstats_files = diag.find_logs(args.diag_dir, args.cfstats_prefix)
    warn_missing(node_configs, cfstats_files, warnings, "missing cfstats")
    for warn in table_stats.add_stats_to_config(unique_configs, cfstats_files):
        warnings.append(warn)
    return {
        "diag_dir": args.diag_dir,
        "warnings": warnings,
        "configs": unique_configs,
        }
Ejemplo n.º 7
0
def test_group_configurations_with_diffs():
    """one of each"""
    node_config = {
        "node1": {
            "abc": "zzz",
        },
        "node2": {
            "abc": "xyz",
        },
    }
    groups = config_diff.group_configurations(node_config)
    assert len(groups) == 2
    first_group = groups[0]
    assert first_group["nodes_list"] == ["node1"]
    assert first_group["nodes"] == 1
    assert first_group["abc"] == "zzz"
    second_group = groups[1]
    assert second_group["nodes_list"] == ["node2"]
    assert second_group["nodes"] == 1
    assert second_group["abc"] == "xyz"
Ejemplo n.º 8
0
def _group_uniq(node_configs):
    #group the configurations together
    unique_configs = config_diff.group_configurations(node_configs)
    for config in unique_configs:
        config["nodes_list"] = sorted(config["nodes_list"], reverse=True)
    return unique_configs