Ver Fonte

test cases and requirements

Steve L. Nyemba há 8 anos atrás
pai
commit
cd81534d78
3 ficheiros alterados com 21 adições e 24 exclusões
  1. 7 0
      requirements.txt
  2. BIN
      test/.demo.py.swp
  3. 14 24
      test/TestServerMonitor.py

+ 7 - 0
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

BIN
test/.demo.py.swp


+ 14 - 24
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()