/usr/share/pyshared/funkload/tests/test_monitor_plugins.py is in funkload 1.16.1-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | import unittest
import time
import pickle
from ConfigParser import ConfigParser
from funkload.MonitorPlugins import MonitorPlugins
class TestMonitorPlugins(unittest.TestCase):
default_plugins=['MonitorCPU', 'MonitorNetwork', 'MonitorMemFree', 'MonitorCUs']
def test_register_default(self):
""" Make sure all default plugins are loaded """
p=MonitorPlugins()
p.registerPlugins()
plugins_loaded=p.MONITORS.keys()
for plugin in self.default_plugins:
self.assertTrue(plugin in plugins_loaded)
def test_getStat(self):
""" Make sure getStat does not raise any exception """
p=MonitorPlugins()
p.registerPlugins()
for plugin in self.default_plugins:
p.MONITORS[plugin].getStat()
def test_network(self):
""" Make sure self.interface is properly read from config in MonitorNetwork plugin """
conf=ConfigParser()
conf.add_section('server')
conf.set('server', 'interface', 'eth9')
p=MonitorPlugins(conf)
p.registerPlugins()
self.assertTrue(p.MONITORS['MonitorNetwork'].interface == 'eth9')
def test_MonitorInfo(self):
""" Make sure Monitor.MonitorInfo still works with plugins """
from funkload.Monitor import MonitorInfo
p=MonitorPlugins()
p.registerPlugins()
m=MonitorInfo('somehost', p)
self.assertTrue(m.host=='somehost')
def test_MonitorThread(self):
""" Make sure Monitor.MonitorThread still works with plugins """
from funkload.Monitor import MonitorThread
p=MonitorPlugins()
p.registerPlugins()
records=[]
monitor = MonitorThread(records, p, 'localhost', 1)
monitor.start()
monitor.startRecord()
time.sleep(3)
monitor.stopRecord()
monitor.stop()
self.assertTrue(len(records)>0)
if __name__ == '__main__':
unittest.main()
|