Exemplo n.º 1
0
    def test_initialize_sets_up_metrics(self):
        collectd = Mock()

        p = HAProxyPlugin(collectd)

        p.initialize()

        self.assertEqual(
            p.metrics,
            {
                "CurrConns": collectd.Values.return_value,
                "hrsp_5xx": collectd.Values.return_value,
            }
        )

        collectd.Values.assert_has_calls([
            call(
                plugin="haproxy",
                type="gauge", type_instance="current_connections"
            ),
            call(
                plugin="haproxy",
                type="counter", type_instance="http_response_5xx"
            ),
        ], any_order=True)
Exemplo n.º 2
0
    def test_initialize_sets_socket_attribute(self, HAProxySocket):
        collectd = Mock()

        p = HAProxyPlugin(collectd)
        p.socket_file_path = "/var/run/asdf.sock"

        p.initialize()

        self.assertEqual(p.socket, HAProxySocket.return_value)
        HAProxySocket.assert_called_once_with(collectd, "/var/run/asdf.sock")
Exemplo n.º 3
0
    def test_initialize_sets_socket_attribute(self, HAProxySocket):
        collectd = Mock()

        p = HAProxyPlugin(collectd)
        p.socket_file_path = "/var/run/asdf.sock"

        p.initialize()

        self.assertEqual(p.socket, HAProxySocket.return_value)
        HAProxySocket.assert_called_once_with(collectd, "/var/run/asdf.sock")
Exemplo n.º 4
0
    def test_initialize_sets_up_metrics(self):
        collectd = Mock()

        p = HAProxyPlugin(collectd)

        p.initialize()

        self.assertEqual(
            p.metrics, {"CurrConns": collectd.Values.return_value, "hrsp_5xx": collectd.Values.return_value}
        )

        collectd.Values.assert_has_calls(
            [
                call(plugin="haproxy", type="gauge", type_instance="current_connections"),
                call(plugin="haproxy", type="counter", type_instance="http_response_5xx"),
            ],
            any_order=True,
        )