Example #1
0
 def test_parse_cfstats(self):
     """happy path"""
     parser = cfstats.Parser()
     lines = [
         "Total number of tables: 44",
         "----------------",
         "Keyspace : keyspace1",
         "\tRead Count: 0",
         "\tRead Latency: NaN ms",
         "\tWrite Count: 330000",
         "\tWrite Latency: 0.04408098181818182 ms",
         "\tPending Flushes: 0",
         "\t\tTable: counter1",
         "\t\tSSTable count: 20",
         "",
         "\t\tTable: standard1",
         "\t\tSSTable count: 2",
         "----------------",
         "Keyspace : keyspace2",
         "\tRead Count: 0",
         "\tRead Latency: NaN ms",
         "\tWrite Count: 330000",
         "\tWrite Latency: 0.04408098181818182 ms",
         "\tPending Flushes: 0",
         "\t\tTable: counter2",
         "\t\tSSTable count: 10",
         "\t\tLocal read latency: NaN ms",
         "\t\tLocal write latency: 0.050 ms",
         "\t\tMaximum tombstones per slice (last five minutes): 5",
     ]
     for line in lines:
         parser.capture_line(line)
     parsed = parser.parsed
     self.assertEqual(len(parsed), 2)
     self.assertEqual(parsed["keyspace1"]["counter1"]["SSTable count"], 20)
     self.assertEqual(parsed["keyspace1"]["standard1"]["SSTable count"], 2)
     self.assertEqual(parsed["keyspace2"]["counter2"]["SSTable count"], 10)
     self.assertEqual(
         parsed["keyspace2"]["counter2"]
         ["Maximum tombstones per slice (last five minutes)"],
         5,
     )
     self.assertTrue(
         math.isnan(parsed["keyspace2"]["counter2"]["Local read latency"]))
     self.assertEqual(
         "%.3f" % parsed["keyspace2"]["counter2"]["Local write latency"],
         "0.050")
Example #2
0
def test_parse_cfstats():
    """happy path"""
    parser = cfstats.Parser()
    lines = [
        "Total number of tables: 44",
        "----------------",
        "Keyspace : keyspace1",
        "\tRead Count: 0",
        "\tRead Latency: NaN ms",
        "\tWrite Count: 330000",
        "\tWrite Latency: 0.04408098181818182 ms",
        "\tPending Flushes: 0",
        "\t\tTable: counter1",
        "\t\tSSTable count: 20",
        "",
        "\t\tTable: standard1",
        "\t\tSSTable count: 2",
        "----------------",
        "Keyspace : keyspace2",
        "\tRead Count: 0",
        "\tRead Latency: NaN ms",
        "\tWrite Count: 330000",
        "\tWrite Latency: 0.04408098181818182 ms",
        "\tPending Flushes: 0",
        "\t\tTable: counter2",
        "\t\tSSTable count: 10",
        "\t\tLocal read latency: NaN ms",
        "\t\tLocal write latency: 0.050 ms",
        "\t\tMaximum tombstones per slice (last five minutes): 5",
    ]
    for line in lines:
        parser.capture_line(line)
    parsed = parser.parsed
    assert len(parsed) == 2
    assert parsed['keyspace1']["counter1"]["SSTable count"] == 20
    assert parsed['keyspace1']["standard1"]["SSTable count"] == 2
    assert parsed['keyspace2']["counter2"]["SSTable count"] == 10
    assert parsed['keyspace2']["counter2"][
        "Maximum tombstones per slice (last five minutes)"] == 5
    assert math.isnan(parsed['keyspace2']["counter2"]["Local read latency"])
    assert "%.3f" % parsed['keyspace2']["counter2"][
        "Local write latency"] == "0.050"
Example #3
0
 def test_spaceless_keyspace_line_cfstats_format(self):
     """keyspace has no space before :"""
     parser = cfstats.Parser()
     lines = [
         "Keyspace: dse_analytics",
         "\t\tTable: alwayson_sql_cache_table",
         "\t\tSSTable count: 0",
         "",
         "\t\tTable: alwayson_sql_info",
         "\t\tSSTable count: 3",
         "",
         "----------------",
         "Keyspace: abc",
         "\t\tTable: fancy_name",
         "\t\tSSTable count: 10",
     ]
     for line in lines:
         parser.capture_line(line + "\n")
     self.assertEqual(parser.parsed["abc"]["fancy_name"]["SSTable count"],
                      10)
Example #4
0
def test_spaceless_keyspace_line_cfstats_format():
    """keyspace has no space before :"""
    parser = cfstats.Parser()
    lines = [
        "Keyspace: dse_analytics",
        "\t\tTable: alwayson_sql_cache_table",
        "\t\tSSTable count: 0",
        "",
        "\t\tTable: alwayson_sql_info",
        "\t\tSSTable count: 3",
        "",
        "----------------",
        "Keyspace: abc",
        "\t\tTable: fancy_name",
        "\t\tSSTable count: 10",
    ]
    for line in lines:
        parser.capture_line(line + "\n")
    import pprint
    pp = pprint.PrettyPrinter()
    pp.pprint(parser.parsed)
    assert parser.parsed['abc']['fancy_name']['SSTable count'] == 10
Example #5
0
def test_parse_cfstats_unable_to_parse_index():
    """regression test against problems parsing table name with ()"""
    parser = cfstats.Parser()
    lines = [
        "Keyspace : dse_analytics",
        "\t\tTable: alwayson_sql_cache_table",
        "\t\tSSTable count: 0",
        "",
        "\t\tTable: alwayson_sql_info",
        "\t\tSSTable count: 3",
        "",
        "----------------",
        "Keyspace : abc",
        "\t\tTable (index): summary.fancy_accountvalue.fancy_accountvalue_summary_class_name_idx",
        "\t\tSSTable count: 10",
    ]
    for line in lines:
        parser.capture_line(line + "\n")
    import pprint
    pp = pprint.PrettyPrinter()
    pp.pprint(parser.parsed)
    assert parser.parsed['abc'][
        'summary.fancy_accountvalue.fancy_accountvalue_summary_class_name_idx'][
            'SSTable count'] == 10
Example #6
0
 def test_parse_cfstats_unable_to_parse_index(self):
     """regression test against problems parsing table name with ()"""
     parser = cfstats.Parser()
     lines = [
         "Keyspace : dse_analytics",
         "\t\tTable: alwayson_sql_cache_table",
         "\t\tSSTable count: 0",
         "",
         "\t\tTable: alwayson_sql_info",
         "\t\tSSTable count: 3",
         "",
         "----------------",
         "Keyspace : abc",
         "\t\tTable (index): summary.fancy_accountvalue.fancy_accountvalue_summary_class_name_idx",
         "\t\tSSTable count: 10",
     ]
     for line in lines:
         parser.capture_line(line + "\n")
     self.assertEqual(
         parser.parsed["abc"]
         ["summary.fancy_accountvalue.fancy_accountvalue_summary_class_name_idx"]
         ["SSTable count"],
         10,
     )