[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] conga/luci/test congaDemoTests.py conga_Helper ...



CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	ldimaggi sourceware org	2006-12-14 02:12:42

Modified files:
	luci/test      : congaDemoTests.py conga_Helpers.py 
Added files:
	luci/test      : loggerObject.py 

Log message:
	Started to add some basic logging.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/test/loggerObject.py.diff?cvsroot=cluster&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/test/congaDemoTests.py.diff?cvsroot=cluster&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/test/conga_Helpers.py.diff?cvsroot=cluster&r1=1.8&r2=1.9

/cvs/cluster/conga/luci/test/loggerObject.py,v  -->  standard output
revision 1.1
--- conga/luci/test/loggerObject.py
+++ -	2006-12-14 02:12:42.345517000 +0000
@@ -0,0 +1,22 @@
+class loggerObject:
+    theLogger = 'null'
+    theHandler = 'null'
+    
+    # constructor - not sure if we want this
+    # def __init__(self, value):
+    #   self.name = value
+
+    # getters and setters methods
+    def setLogger( self, value ):
+        self.theLogger = value
+        
+    def setHandler( self, value ):
+        self.theHandler = value
+        
+    def getLogger( self ):
+        return self.theLogger
+    
+    def getHandler( self ):
+        return self.theHandler
+    
+    
--- conga/luci/test/congaDemoTests.py	2006/12/13 20:13:33	1.6
+++ conga/luci/test/congaDemoTests.py	2006/12/14 02:12:41	1.7
@@ -30,16 +30,28 @@
 from conga_Helpers import *
 from selenium import selenium
 import unittest, time, re
+import logging
+from loggerObject import loggerObject
 
 class congaDemoTests(unittest.TestCase):
 
     def setUp(self):
+        
+        self.testName = "congaDemoTests"
+        
         """Establish connection to selenium server, login to luci """
         self.verificationErrors = []
         self.selenium = login (CONGA_ADMIN_USERNAME, CONGA_ADMIN_PASSWORD)
  
     def test_congaStorage(self):
         """Test to create and delete storage systems"""
+
+        # Set up logging        
+        self.testName = "congaDemoTests.test_congaStorage"
+        self.theloggerObject = setupLogger (self.testName)
+        self.logger = self.theloggerObject.getLogger()       
+        self.logger.info('Starting test case ' + self.testName)
+        
         sel = self.selenium
 
         # Create the storage systems
@@ -63,8 +75,23 @@
             sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
             self.assertTrue (sel.is_text_present('Removed storage system "' + systemName + '" successfully'))
 
+        self.logger.info('Ending test case test_congaStorage')
+        closeLogger (self.theloggerObject)
+        
     def test_congaUsers(self):
         """Test to create and delete conga users"""
+                      
+        self.testName = "congaDemoTests.test_congaUsers"
+        self.theloggerObject = setupLogger (self.testName)
+        self.logger = self.theloggerObject.getLogger()       
+        self.logger.info('Starting test case ' + self.testName)
+
+        # Set up logging        
+        self.testName = "congaDemoTests.test_congaUsers"
+        self.theloggerObject = setupLogger (self.testName)
+        self.logger = self.theloggerObject.getLogger()       
+        self.logger.info('Starting test case ' + self.testName)        
+        
         sel = self.selenium
 
         # Create the users
@@ -87,12 +114,25 @@
             sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
             self.assertTrue (sel.is_text_present('User "' + userName + '" has been deleted'))  
 
+        self.logger.info('Ending test case test_congaUsers')
+        closeLogger (self.theloggerObject)
+
     def test_congaCluster(self):
         """Test to create and delete a cluster"""
 
-        # TODO - Need to generalize this function - but as of 20061129, note tng3-1 
-        # is not responding to the creation of a cluster
+        self.testName = "congaDemoTests.test_congaCluster"
+        self.theloggerObject = setupLogger (self.testName)
+        self.logger = self.theloggerObject.getLogger()       
+        self.logger.info('Starting test case ' + self.testName)
+        
+        # Set up logging        
+        self.testName = "congaDemoTests.test_congaCluster"
+        self.theloggerObject = setupLogger (self.testName)
+        self.logger = self.theloggerObject.getLogger()       
+        self.logger.info('Starting test case ' + self.testName)
+        
         sel = self.selenium
+           
         sel.open("/luci/homebase")
         sel.click("link=cluster")
         sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
@@ -151,6 +191,9 @@
             sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
             self.assertTrue (sel.is_text_present('Removed storage system "' + systemName + '" successfully'))
 
+        self.logger.info('Ending test case test_congaCluster')
+        closeLogger (self.theloggerObject)
+
     def tearDown(self):
         """Logout and stop Selenium session"""
         logout(self.selenium)
@@ -160,7 +203,7 @@
         suite = unittest.TestSuite()
         suite.addTest(congaDemoTests('test_congaStorage'))
         suite.addTest(congaDemoTests('test_congaUsers'))
-        suite.addTest(congaDemoTests('test_congaCluster'))
+        #suite.addTest(congaDemoTests('test_congaCluster'))
         return suite
 
 if __name__ == "__main__":
--- conga/luci/test/conga_Helpers.py	2006/12/13 20:13:33	1.8
+++ conga/luci/test/conga_Helpers.py	2006/12/14 02:12:41	1.9
@@ -29,10 +29,12 @@
 
 from selenium import selenium
 import unittest, time, re
+import logging
+import logging.handlers
+ 
+from loggerObject import loggerObject
 
-#class congaHelpers(unittest.TestCase):
-
-    # Define data to support tests - global for now
+# Define data to support tests - global for now
 
 CONGA_ADMIN_USERNAME = 'admin'
 CONGA_ADMIN_PASSWORD = 'password'
@@ -158,4 +160,33 @@
     sel.click("link=Log out")
     sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
     sel.stop()
-    
\ No newline at end of file
+    
+def setupLogger (testName):   
+    """Create logger - use this message format:  2003-07-08 16:49:45,896 ERROR We have a problem"""
+    logger = logging.getLogger('congaTestLogger')
+    
+    # Why use a RotatingFileHandler? To keep track of previous test results
+    hdlr = logging.handlers.RotatingFileHandler('/var/tmp/' + testName + '.log', 'w', 1024000, 10)
+    #hdlr = logging.FileHandler('/var/tmp/' + testName + '.log', 'w')
+    
+    formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
+    hdlr.setFormatter(formatter)
+    logger.addHandler(hdlr) 
+    #logger.setLevel(logging.WARNING)
+    logger.setLevel(logging.DEBUG)
+    
+    theloggerObject = loggerObject()
+    theloggerObject.setLogger(logger)
+    theloggerObject.setHandler(hdlr)
+    
+    return theloggerObject
+    
+def closeLogger (theloggerObject):
+    """Close the logger - roll the logs"""
+    theLogger = theloggerObject.getLogger()
+    theHandler = theloggerObject.getHandler()
+
+    theLogger.removeHandler(theHandler)
+    theHandler.close()
+    theHandler.doRollover()
+    


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]