예제 #1
0
    def test_smallerStats(self):
        """
        Make sure "uid" and "user-agent" are not in the
        L{RotatingFileAccessLoggingObserver} stats data.
        """

        logpath = self.mktemp()
        observer = RotatingFileAccessLoggingObserver(logpath)
        observer.systemStats = SystemMonitor()
        observer.start()
        stats = observer.initStats()
        observer.stop()
        self.assertTrue("uid" not in stats)
        self.assertTrue("user-agent" not in stats)
예제 #2
0
    def test_systemMonitor(self):
        """
        L{SystemMonitor} generates the correct data.
        """

        monitor = SystemMonitor()
        self.assertNotEqual(monitor.items["cpu count"], 0)
        self.assertEqual(monitor.items["cpu use"], 0.0)

        monitor.update()
        self.assertNotEqual(monitor.items["cpu count"], 0)

        monitor.stop()
        self.assertNotEqual(monitor.items["cpu count"], 0)
예제 #3
0
    def test_truncateStats(self):
        """
        Make sure L{RotatingFileAccessLoggingObserver.ensureSequentialStats}
        properly truncates stats data.
        """

        logpath = self.mktemp()
        observer = RotatingFileAccessLoggingObserver(logpath)
        observer.systemStats = SystemMonitor()
        observer.start()

        # Fill stats with some old entries
        t = int(time.time() / 60.0) * 60
        t -= 100 * 60
        for i in range(10):
            observer.statsByMinute.append((t + i * 60, observer.initStats(),))

        self.assertEqual(len(observer.statsByMinute), 10)
        observer.ensureSequentialStats()
        self.assertEqual(len(observer.statsByMinute), 65)
        observer.stop()