Ejemplo n.º 1
0
    def test_select_prometheus_node_targets(self):
        expected_targets = [{
            'labels': {
                'machine': 'mlab2.abc01.measurement-lab.org'
            },
            'targets': ['mlab2.abc01.measurement-lab.org:9090']
        }]

        actual_targets = mlabconfig.select_prometheus_node_targets(
            self.sites, "mlab2.*", '{{hostname}}:9090', {})

        self.assertEqual(len(actual_targets), 1)
        self.assertItemsEqual(actual_targets, expected_targets)
Ejemplo n.º 2
0
    def test_select_prometheus_node_targets_decorated_names(self):
        expected_targets = [{
            'labels': {
                'ipv6': 'present',
                'machine': 'mlab1.abc01.measurement-lab.org'
            },
            'targets': ['mlab1v6.abc01.measurement-lab.org:9090']
        }]

        actual_targets = mlabconfig.select_prometheus_node_targets(
            self.sites, "mlab-sandbox", "mlab1.*", ['{{hostname}}:9090'], {},
            'v6', False)

        self.assertEqual(len(actual_targets), 1)
        self.assertCountEqual(actual_targets, expected_targets)
Ejemplo n.º 3
0
    def test_select_prometheus_node_targets(self):
        expected_targets = [
            {
                'labels': {
                    'machine': 'mlab2.abc01.measurement-lab.org'
                },
                'targets': [
                    'mlab2.abc01.measurement-lab.org:9090'
                ]
            }
        ]

        actual_targets = mlabconfig.select_prometheus_node_targets(
            self.sites, "mlab2.*", ['{{hostname}}:9090'], {})

        self.assertEqual(len(actual_targets), 1)
        self.assertItemsEqual(actual_targets, expected_targets)
Ejemplo n.º 4
0
    def test_select_prometheus_node_targets_ipv6_disabled(self):
        expected_targets = [{
            'labels': {
                'ipv6': 'missing',
                'machine': 'mlab1.abc01.measurement-lab.org'
            },
            'targets': ['mlab1.abc01.measurement-lab.org:9090']
        }]

        sites_ipv6_disabled = sites
        sites_ipv6_disabled[0]['nodes'][0]['v6']['ip'] = ""

        actual_targets = mlabconfig.select_prometheus_node_targets(
            sites_ipv6_disabled, "mlab-sandbox", "mlab1.*",
            ['{{hostname}}:9090'], {}, '', False)

        self.assertEqual(len(actual_targets), 1)
        self.assertCountEqual(actual_targets, expected_targets)
        self.assertEqual(actual_targets[0]['labels']['ipv6'], "missing")
Ejemplo n.º 5
0
    def test_select_prometheus_node_targets_excludes_unselected_project(self):
        actual_targets = mlabconfig.select_prometheus_node_targets(
            self.sites, "mlab-oti", "mlab1.*", ['{{hostname}}:9090'], {}, '',
            False)

        self.assertEqual(len(actual_targets), 0)