Пример #1
0
    def test_full_stats(self):
        dummy_process = 'circus.tests.support.run_process'
        yield self.start_arbiter(dummy_process)
        yield async_poll_for(self.test_file, 'START')

        config = {'loop_rate': 0.2}
        gauges = yield async_run_plugin(
            FullStats,
            config,
            plugin_info_callback=get_gauges,
            duration=1000,
            endpoint=self.arbiter.endpoint,
            pubsub_endpoint=self.arbiter.pubsub_endpoint)

        # we should have a bunch of stats events here
        self.assertTrue(len(gauges) >= 5)
        last_batch = sorted(name for name, value in gauges[-5:])
        wanted = [
            '_stats.test.cpu_sum', '_stats.test.mem_max',
            '_stats.test.mem_pct_max', '_stats.test.mem_pct_sum',
            '_stats.test.mem_sum'
        ]
        self.assertEqual(last_batch, wanted)

        yield self.stop_arbiter()
Пример #2
0
    def test_watchdog_discovery_not_found(self):
        yield self.start_arbiter(fqn)
        async_poll_for(self.test_file, "START")

        config = {"loop_rate": 0.1, "watchers_regex": "^foo.*$"}
        with warnings.catch_warnings():
            pid_status = yield async_run_plugin(WatchDog, config, get_pid_status)
        self.assertEqual(len(pid_status), 0, pid_status)
        yield self.stop_arbiter()
Пример #3
0
    def test_watchdog_discovery_not_found(self):
        yield self.start_arbiter(fqn)
        async_poll_for(self.test_file, 'START')

        config = {'loop_rate': 0.1, 'watchers_regex': "^foo.*$"}
        with warnings.catch_warnings():
            pid_status = yield async_run_plugin(WatchDog, config,
                                                get_pid_status)
        self.assertEqual(len(pid_status), 0, pid_status)
        yield self.stop_arbiter()
Пример #4
0
    def test_watchdog_discovery_found(self):
        yield self.start_arbiter(fqn)
        poll_for(self.test_file, 'START')

        config = {'loop_rate': 0.1, 'watchers_regex': "^test.*$"}
        with warnings.catch_warnings():
            pid_status = yield async_run_plugin(WatchDog, config,
                                                get_pid_status)
        self.assertEqual(len(pid_status), 1, pid_status)
        yield self.stop_arbiter()
Пример #5
0
    def test_resource_watcher_min_cpu(self):
        yield self.start_arbiter(fqn)
        async_poll_for(self.test_file, 'START')
        config = {'loop_rate': 0.1, 'min_cpu': 99.0, 'watcher': 'test'}

        statsd_increments = yield async_run_plugin(ResourceWatcher, config,
                                                   get_statsd_increments)

        self._check_statsd(statsd_increments,
                           '_resource_watcher.test.under_cpu')
        yield self.stop_arbiter()
Пример #6
0
    def test_resource_watcher_max_cpu(self):
        yield self.start_arbiter(fqn)
        async_poll_for(self.test_file, 'START')
        config = {'loop_rate': 0.1, 'max_cpu': 0.1, 'watcher': 'test'}

        statsd_increments = yield async_run_plugin(ResourceWatcher,
                                                   config,
                                                   get_statsd_increments)

        self._check_statsd(statsd_increments,
                           '_resource_watcher.test.over_cpu')
        yield self.stop_arbiter()
    def test_resource_watcher_min_mem(self):
        yield self.start_arbiter(fqn)
        poll_for(self.test_file, 'START')
        config = {'loop_rate': 0.1, 'min_mem': 100000.1, 'watcher': 'test'}

        statsd_increments = yield async_run_plugin(ResourceWatcher,
                                                   config,
                                                   get_statsd_increments)

        self._check_statsd(statsd_increments,
                           '_resource_watcher.test.under_memory')
        yield self.stop_arbiter()
Пример #8
0
    def test_resource_watcher_max_mem(self):
        yield self.start_arbiter(fqn)
        poll_for(self.test_file, 'START')
        config = {'loop_rate': 0.1, 'max_mem': 0.05, 'watcher': 'test'}

        statsd_increments = yield async_run_plugin(ResourceWatcher,
                                                   config,
                                                   get_statsd_increments)

        self._check_statsd(statsd_increments,
                           '_resource_watcher.test.over_memory')
        yield self.stop_arbiter()
Пример #9
0
    def test_resource_watcher_max_cpu(self):
        yield self.start_arbiter(fqn)
        yield async_poll_for(self.test_file, 'START')
        config = {'loop_rate': 0.1, 'max_cpu': -0.1, 'watcher': 'test'}
        kw = {'endpoint': self.arbiter.endpoint,
              'pubsub_endpoint': self.arbiter.pubsub_endpoint}

        statsd_increments = yield async_run_plugin(ResourceWatcher,
                                                   config,
                                                   get_statsd_increments, **kw)
        self._check_statsd(statsd_increments,
                           '_resource_watcher.test.over_cpu')
        yield self.stop_arbiter()
    def test_resource_watcher_max_mem_abs(self):
        yield self.start_arbiter(fqn)
        async_poll_for(self.test_file, 'START')
        config = {'loop_rate': 0.1, 'max_mem': '1M', 'watcher': 'test'}
        kw = {'endpoint': self.arbiter.endpoint,
              'pubsub_endpoint': self.arbiter.pubsub_endpoint}

        statsd_increments = yield async_run_plugin(ResourceWatcher,
                                                   config,
                                                   get_statsd_increments, **kw)

        self._check_statsd(statsd_increments,
                           '_resource_watcher.test.over_memory')
        yield self.stop_arbiter()
Пример #11
0
    def test_full_stats(self):
        dummy_process = 'circus.tests.support.run_process'
        yield self.start_arbiter(dummy_process)
        poll_for(self.test_file, 'START')

        config = {'loop_rate': 0.2}
        gauges = yield async_run_plugin(
            FullStats, config,
            plugin_info_callback=get_gauges,
            duration=1000)

        # we should have a bunch of stats events here
        self.assertTrue(len(gauges) >= 5)
        last_batch = sorted(name for name, value in gauges[-5:])
        wanted = ['_stats.test.cpu_max', '_stats.test.cpu_sum',
                  '_stats.test.mem_max', '_stats.test.mem_sum',
                  '_stats.test.watchers_num']
        self.assertEqual(last_batch, wanted)

        yield self.stop_arbiter()