From cd81534d7821b4c0233c725171958d801d326eba Mon Sep 17 00:00:00 2001 From: "Steve L. Nyemba" Date: Tue, 17 Jan 2017 07:31:15 -0600 Subject: [PATCH] test cases and requirements --- requirements.txt | 7 +++++++ test/.demo.py.swp | Bin 0 -> 12288 bytes test/TestServerMonitor.py | 38 ++++++++++++++------------------------ 3 files changed, 21 insertions(+), 24 deletions(-) create mode 100644 test/.demo.py.swp diff --git a/requirements.txt b/requirements.txt index bfdf737..b7bb58c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,13 +1,20 @@ +aniso8601==1.2.0 click==6.6 couchdbkit==0.6.5 Flask==0.11.1 Flask-Session==0.3.0 +Flask-SocketIO==2.8.2 http-parser==0.8.3 itsdangerous==0.24 Jinja2==2.8 MarkupSafe==0.23 numpy==1.11.3 pika==0.10.0 +python-dateutil==2.6.0 +python-engineio==1.1.0 +python-socketio==1.6.2 +pytz==2016.10 restkit==4.2.2 +six==1.10.0 socketpool==0.5.3 Werkzeug==0.11.11 diff --git a/test/.demo.py.swp b/test/.demo.py.swp new file mode 100644 index 0000000000000000000000000000000000000000..37d2731e94ccd575773b66611892d66d400202f3 GIT binary patch literal 12288 zcmeI%&r2LJ6bJC9^dL%G(W{52UKGa6kKJ`u@Yah3kJ`erNSuv2xS0&uC_5Lu^ndYR z>HpDl{{g);*&RVGSnyB~zJW(xUgm|&=Qhk~a(r;eUC|;x7KtwJ?Dq>Z_aRy#8aZ{X zLj4~@OJfT$G`SqU`sB^z!1#;Fue2)NC_XP-tW8-sV`HaAE*>atL{-0f3N|4Cfwu{K zq*j(Dp?7_4m6w-}-gXSSAOHafKmY;|fB*y_0D*TY;HnwA^*5hwZa?45GcV?5i3tJ_ zfB*y_009U<00Izz00bZafp;h%2Sh(U5&iTL{{KII|Ns6>^wr0KkFJkZ9}7O_eLVPQ z@0*@qp$`KB5P$##AOHafKmY;|fB*y_@Sg73VrdmyB?mP-!NT>B~$g?MT bQ=i;ods=VuJ{7t$)^T~ItD5D=zdZc`of3D{ literal 0 HcmV?d00001 diff --git a/test/TestServerMonitor.py b/test/TestServerMonitor.py index 47443fc..c9130b1 100644 --- a/test/TestServerMonitor.py +++ b/test/TestServerMonitor.py @@ -3,6 +3,14 @@ import unittest from monitor import Env, DetailProcess, ProcessCounter, Sandbox import monitor import os +import json +from utils.workers import Top, Learner +from multiprocessing import Lock +path = os.environ['MONITOR_CONFIG_PATH'] +f = open(path) +CONFIG = json.loads( f.read()) +f.close() + class TestMonitorServer(unittest.TestCase): def test_Environment(self): @@ -14,7 +22,7 @@ class TestMonitorServer(unittest.TestCase): r = p.composite() value = r['value'] - self.assertTrue(value > 0 and value == 2/3) + self.assertTrue(value > 0 and value >= (100*2/3),value) self.assertTrue(p.evaluate('PATH') == 0) def test_RunningProcess(self): p = DetailProcess() @@ -35,28 +43,10 @@ class TestMonitorServer(unittest.TestCase): p = Sandbox() p.init({"sandbox":sandbox_path,"requirements":requirements_path}) p.composite() - def test_map(self): - p = DetailProcess() - p.init(['rabbitmq-server','python','apache2']) - r ={"test": p.composite()} - logs = [r,{"x-test":p.composite()}] - key = "test" - id = "memory_usage" - - def mapper(row,emit): - [emit(item['label'],item) for item in row ] - def reducer(values): - end = len(values)-1 - beg = 0 if end < 100 else end - 100 - return values[beg:] - - - #def reducer(values): - - mrh = monitor.mapreducer() - logs = mrh.filter('test',logs) - - print mrh.run(logs,mapper,None) - + def test_StartTop(self): + lock = Lock() + p = Top(CONFIG,lock) + p.start() + p.join() if __name__ == '__main__' : unittest.main()