예제 #1
0
def test_end_to_end_sample_1(_mock):
    config = cli.load_config("../config/config_sample_1.py")
    collector = SockPuppetCollector(config)
    items = list(collector.collect())
    for i in items:
        for sample in i.samples:
            assert sample.labels["flow"] == "ceph-mds"
    assert len(items) == len(collector.metric_definitions)
예제 #2
0
def test_collect():
    config_basic = """
flow_definitions = [
    {
        "class": "https",
        "flows": [
            {
                "flow": "https-inbound",
                "src_port": 443
            },
            {
                "flow": "https-outbound",
                "dst_port": 443
            },
        ],
    },
]
"""
    config = mock_module(config_basic)
    collector = SockPuppetCollector(config)
    collector.collect()
예제 #3
0
def test_end_to_end_negative(_mock):
    config_basic = """
flow_definitions = [
    {
        "class": "https",
        "flows": [
            {
                "flow": "https-inbound",
                "src_port": 1
            },
        ]
    },
]
"""
    config = mock_module(config_basic)
    collector = SockPuppetCollector(config)
    items = list(collector.collect())
    assert len(items) == 0
예제 #4
0
def test_end_to_end_dst_set(_mock):
    config_basic = """
flow_definitions = [
    {
        "class": "example",
        "flows": [
            {
                "flow": "in",
                "src_port": 1,
            },
        ]
    },
]
"""
    config = mock_module(config_basic)
    collector = SockPuppetCollector(config)
    items = list(collector.collect())
    assert len(items) == len(collector.metric_definitions)
예제 #5
0
def test_process_cmd_negative(mock_):
    config_basic = """
flow_definitions = [
    {
        "class": "example",
        "flows": [
            {
                "flow": "in",
                "src_port": 4444
            },
        ]
    },
]
"""
    config = mock_module(config_basic)
    collector = SockPuppetCollector(config)
    items = list(collector.collect())
    for i in items:
        for sample in i.samples:
            assert sample.labels["process"] == "None"
    assert len(items) == len(collector.metric_definitions)