Ejemplo n.º 1
0
    def test_gen_stats_no_legit_response(self, send_command):
        send_command.return_value = None

        s = HAProxySocket(Mock(), "/var/run/sock.sock")

        result = s.gen_stats(include_frontends=True,
                             include_backends=True,
                             include_servers=True)

        self.assertEqual(list(result), [])
Ejemplo n.º 2
0
    def test_gen_stats_no_legit_response(self, send_command):
        send_command.return_value = None

        s = HAProxySocket(Mock(), "/var/run/sock.sock")

        result = s.gen_stats(
            include_frontends=True,
            include_backends=True,
            include_servers=True
        )

        self.assertEqual(list(result), [])
Ejemplo n.º 3
0
    def test_gen_stats__servers(self, send_command):
        send_command.return_value = None

        s = HAProxySocket(Mock(), "/var/run/sock.sock")

        result = s.gen_stats(include_frontends=False,
                             include_backends=False,
                             include_servers=True)

        list(result)

        send_command.assert_called_once_with("show stat -1 4 -1")
Ejemplo n.º 4
0
    def test_gen_stats__servers(self, send_command):
        send_command.return_value = None

        s = HAProxySocket(Mock(), "/var/run/sock.sock")

        result = s.gen_stats(
            include_frontends=False,
            include_backends=False,
            include_servers=True
        )

        list(result)

        send_command.assert_called_once_with("show stat -1 4 -1")
Ejemplo n.º 5
0
    def test_gen_stats(self, send_command):
        example_stats = None
        example_stats_file = os.path.join(
            os.path.dirname(__file__), "./example_stats.csv"
        )

        with open(example_stats_file, "r") as fd:
            example_stats = fd.read()

        send_command.return_value = example_stats.rstrip("\n")

        s = HAProxySocket(Mock(), "/var/run/sock.sock")

        result = s.gen_stats(
            include_frontends=True,
            include_backends=True,
            include_servers=True
        )

        result = list(result)

        proxy_name, values = result[0]

        self.assertEqual(proxy_name, "frontend")

        self.assertEqual(
            values,
            {
                "": "",
                "act": "",
                "bck": "",
                "bin": "16099928579",
                "bout": "10523206007",
                "check_code": "",
                "check_duration": "",
                "check_status": "",
                "chkdown": "",
                "chkfail": "",
                "cli_abrt": "",
                "comp_byp": "0",
                "comp_in": "0",
                "comp_out": "0",
                "comp_rsp": "0",
                "ctime": "",
                "downtime": "",
                "dreq": "0",
                "dresp": "0",
                "econ": "",
                "ereq": "44092",
                "eresp": "",
                "hanafail": "",
                "hrsp_1xx": "0",
                "hrsp_2xx": "1793812",
                "hrsp_3xx": "677495",
                "hrsp_4xx": "59183",
                "hrsp_5xx": "1495",
                "hrsp_other": "224",
                "iid": "2",
                "last_agt": "",
                "last_chk": "",
                "lastchg": "",
                "lastsess": "",
                "lbtot": "",
                "pid": "1",
                "qcur": "",
                "qlimit": "",
                "qmax": "",
                "qtime": "",
                "rate": "18",
                "rate_lim": "0",
                "rate_max": "64",
                "req_rate": "20",
                "req_rate_max": "62",
                "req_tot": "2532219",
                "rtime": "",
                "scur": "41",
                "sid": "0",
                "slim": "50000",
                "smax": "103",
                "srv_abrt": "",
                "status": "OPEN",
                "stot": "2532247",
                "svname": "FRONTEND",
                "throttle": "",
                "tracked": "",
                "ttime": "",
                "type": "0",
                "weight": "",
                "wredis": "",
                "wretr": "",
            }
        )
Ejemplo n.º 6
0
    def test_gen_stats(self, send_command):
        example_stats = None
        example_stats_file = os.path.join(os.path.dirname(__file__),
                                          "./example_stats.csv")

        with open(example_stats_file, "r") as fd:
            example_stats = fd.read()

        send_command.return_value = example_stats.rstrip("\n")

        s = HAProxySocket(Mock(), "/var/run/sock.sock")

        result = s.gen_stats(include_frontends=True,
                             include_backends=True,
                             include_servers=True)

        result = list(result)

        proxy_name, values = result[0]

        self.assertEqual(proxy_name, "frontend")

        self.assertEqual(
            values, {
                "": "",
                "act": "",
                "bck": "",
                "bin": "16099928579",
                "bout": "10523206007",
                "check_code": "",
                "check_duration": "",
                "check_status": "",
                "chkdown": "",
                "chkfail": "",
                "cli_abrt": "",
                "comp_byp": "0",
                "comp_in": "0",
                "comp_out": "0",
                "comp_rsp": "0",
                "ctime": "",
                "downtime": "",
                "dreq": "0",
                "dresp": "0",
                "econ": "",
                "ereq": "44092",
                "eresp": "",
                "hanafail": "",
                "hrsp_1xx": "0",
                "hrsp_2xx": "1793812",
                "hrsp_3xx": "677495",
                "hrsp_4xx": "59183",
                "hrsp_5xx": "1495",
                "hrsp_other": "224",
                "iid": "2",
                "last_agt": "",
                "last_chk": "",
                "lastchg": "",
                "lastsess": "",
                "lbtot": "",
                "pid": "1",
                "qcur": "",
                "qlimit": "",
                "qmax": "",
                "qtime": "",
                "rate": "18",
                "rate_lim": "0",
                "rate_max": "64",
                "req_rate": "20",
                "req_rate_max": "62",
                "req_tot": "2532219",
                "rtime": "",
                "scur": "41",
                "sid": "0",
                "slim": "50000",
                "smax": "103",
                "srv_abrt": "",
                "status": "OPEN",
                "stot": "2532247",
                "svname": "FRONTEND",
                "throttle": "",
                "tracked": "",
                "ttime": "",
                "type": "0",
                "weight": "",
                "wredis": "",
                "wretr": "",
            })