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)
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()
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
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)
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)