Esempio n. 1
0
 def test_get_storage(self):
     envs = {
         "TSURU_METRICS_BACKEND": "fake",
     }
     os.environ.update(envs)
     stats = Stats("endpoint", "pubsub", 1.0, "ssh_server")
     storage = stats.get_storage()
     self.assertIsInstance(storage, FakeBackend)
Esempio n. 2
0
 def test_get_storage(self):
     envs = {
         "TSURU_METRICS_BACKEND": "fake",
     }
     os.environ.update(envs)
     stats = Stats("endpoint", "pubsub", 1.0, "ssh_server")
     storage = stats.get_storage()
     self.assertIsInstance(storage, FakeBackend)
Esempio n. 3
0
 def test_get_a_not_registered_backend(self):
     envs = {
         "TSURU_METRICS_BACKEND": "doesnotexist",
     }
     os.environ.update(envs)
     stats = Stats("endpoint", "pubsub", 1.0, "ssh_server")
     storage = stats.get_storage()
     # when a backend does not exists the default should be returned
     self.assertIsInstance(storage, StatsdBackend)
Esempio n. 4
0
 def test_get_a_not_registered_backend(self):
     envs = {
         "TSURU_METRICS_BACKEND": "doesnotexist",
     }
     os.environ.update(envs)
     stats = Stats("endpoint", "pubsub", 1.0, "ssh_server")
     storage = stats.get_storage()
     # when a backend does not exists the default should be returned
     self.assertIsInstance(storage, StatsdBackend)
Esempio n. 5
0
    def test_connections_established(self, conn_mock):
        conn = Mock(status="ESTABLISHED")
        conn_mock.return_value = [conn, conn, conn, conn, conn]

        stats = Stats("endpoint", "pubsub", 1.0, "ssh_server")
        established = stats.connections_established()

        self.assertEqual(5, established)

        conn_mock.assert_called_with("tcp")
Esempio n. 6
0
    def test_connections_established(self, conn_mock):
        conn = Mock(status="ESTABLISHED")
        conn_mock.return_value = [conn, conn, conn, conn, conn]

        stats = Stats("endpoint", "pubsub", 1.0, "ssh_server")
        established = stats.connections_established()

        self.assertEqual(5, established)

        conn_mock.assert_called_with("tcp")
Esempio n. 7
0
 def test_statsd_default_storage(self):
     del os.environ["TSURU_METRICS_BACKEND"]
     stats = Stats("endpoint", "pubsub", 1.0, "ssh_server")
     storage = stats.get_storage()
     self.assertIsInstance(storage, StatsdBackend)
Esempio n. 8
0
    def test_net_io(self, net_io_mock):
        stats = Stats("endpoint", "pubsub", 1.0, "ssh_server")
        stats.net_io()

        net_io_mock.assert_called_with()
Esempio n. 9
0
    def test_disk_usage(self, disk_usage_mock):
        stats = Stats("endpoint", "pubsub", 1.0, "ssh_server")
        stats.disk_usage()

        disk_usage_mock.assert_called_with("/")
Esempio n. 10
0
 def test_statsd_default_storage(self):
     del os.environ["TSURU_METRICS_BACKEND"]
     stats = Stats("endpoint", "pubsub", 1.0, "ssh_server")
     storage = stats.get_storage()
     self.assertIsInstance(storage, StatsdBackend)
Esempio n. 11
0
    def test_net_io(self, net_io_mock):
        stats = Stats("endpoint", "pubsub", 1.0, "ssh_server")
        stats.net_io()

        net_io_mock.assert_called_with()
Esempio n. 12
0
    def test_disk_usage(self, disk_usage_mock):
        stats = Stats("endpoint", "pubsub", 1.0, "ssh_server")
        stats.disk_usage()

        disk_usage_mock.assert_called_with("/")