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

[Cluster-devel] conga/luci/test CGA_0200_Create_cluster.py con ...



CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	ldimaggi sourceware org	2006-12-14 20:01:40

Modified files:
	luci/test      : CGA_0200_Create_cluster.py congaDemoTests.py 
	                 conga_Helpers.py conga_suite.py loggerObject.py 
Added files:
	luci/test      : CGA_0170_Online_Documentation_Portlet.py 
Removed files:
	luci/test      : CGA_0170_Online_Documenation_Portlet.py 

Log message:
	Added a 2-layer logging model. Pyunit generated text is written to a log file, debug/info/etc. messages are written to a debug log file.
	
	Also corrected the name of:  CGA_0170_Online_Documentation_Portlet.py

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

/cvs/cluster/conga/luci/test/CGA_0170_Online_Documentation_Portlet.py,v  -->  standard output
revision 1.1
--- conga/luci/test/CGA_0170_Online_Documentation_Portlet.py
+++ -	2006-12-14 20:01:41.217375000 +0000
@@ -0,0 +1,91 @@
+#! /usr/bin/env python
+
+# Copyright Red Hat, Inc. 2006
+#
+#  This program is free software; you can redistribute it and/or modify it
+#  under the terms of the GNU General Public License as published by the
+#  Free Software Foundation; either version 2, or (at your option) any
+#  later version.
+#
+#  This program is distributed in the hope that it will be useful, but
+#  WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+#  General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; see the file COPYING.  If not, write to the
+#  Free Software Foundation, Inc.,  675 Mass Ave, Cambridge, 
+#  MA 02139, USA.
+
+'''
+Script name:    GA_0170_Online_Documentation_Portlet.py
+Creation date:  Dec 2006
+Purpose:        Prototype automated GUI test for RHEL5 Conga (luci server web app) - automated
+                with Selenium RC (remote control) 0.9.0
+Summary:        Test for Conga use case CGA-0170 - verify the online user documentation
+                Regression test for: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=212991
+'''
+
+__author__ = 'Len DiMaggio <ldimaggi redhat com>'
+
+from selenium import selenium
+import unittest, time, re
+from conga_Helpers import *
+import time
+import logging
+from loggerObject import loggerObject
+
+class CGA_0170_Online_Documentation_Portlet (unittest.TestCase):
+
+    def setUp(self):      
+               
+        # Set up logging      
+        self.theloggerObject = setupLogger (CONGA_DEBUG_LOG)
+        self.logger = self.theloggerObject.getLogger()
+        self.logger.info('-----------------------------------------------------------') 
+  
+        """Establish connection to selenium server, login to luci """
+        self.verificationErrors = []
+        self.selenium = login (CONGA_ADMIN_USERNAME, CONGA_ADMIN_PASSWORD)
+
+        """Test to create and delete storage systems"""
+        sel = self.selenium
+
+    def test_docs(self):
+        """Test to verify on-line Help docs"""
+        self.logger.info('Starting test case CGA_0170_Online_Documentation_Portlet.test_docs')
+        
+        sel = self.selenium
+        
+        # Access the on-line help
+        sel.click("link=help")
+        sel.wait_for_pop_up("Conga Help", "30000")        
+        sel.select_window('Conga Help')
+        
+        # Grab all the text       
+        theText = sel.get_html_source()
+
+        # Validation - check the offsets for the items in the HELP list             
+        for theItem in HELP_LIST:
+            self.logger.debug('Verify offset of help text "' + theItem + '" = ' + str(theText.index(theItem)))
+            self.assertEqual (theText.index(theItem), HELP_DICTIONARY[theItem])
+            
+        # Select the main window    
+        sel.select_window('null')
+        
+        self.logger.info('Ending test case CGA_0170_Online_Documentation_Portlet.test_docs')
+  
+    def tearDown(self):  
+        """Logout and stop Selenium session"""
+        logout(self.selenium)
+        self.assertEqual([], self.verificationErrors)
+        closeLogger (self.theloggerObject)
+
+def suite():
+        suite = unittest.TestSuite()
+        suite.addTest(CGA_0170_Online_Documentation_Portlet('test_docs'))
+        return suite
+
+if __name__ == "__main__":
+    #unittest.main()
+    unittest.TextTestRunner( verbosity=2 ).run( suite() )
--- conga/luci/test/CGA_0200_Create_cluster.py	2006/12/08 16:17:23	1.1
+++ conga/luci/test/CGA_0200_Create_cluster.py	2006/12/14 20:01:40	1.2
@@ -34,6 +34,11 @@
 class CGA_0200_Create_cluster(unittest.TestCase):
 
     def setUp(self):
+        # Set up logging      
+        self.theloggerObject = setupLogger (CONGA_DEBUG_LOG)
+        self.logger = self.theloggerObject.getLogger()
+        self.logger.info('-----------------------------------------------------------') 
+        
         """Establish connection to selenium server, login to luci """
         self.verificationErrors = []
         self.selenium = login (CONGA_ADMIN_USERNAME, CONGA_ADMIN_PASSWORD)
@@ -41,6 +46,8 @@
     def test_congaCluster(self):
         """Test to create and delete a cluster"""
 
+        self.logger.info('Starting test case CGA_0200_Create_cluster.test_congaCluster')
+
         # TODO - Need to generalize this function - but as of 20061129, note tng3-1 
         # is not responding to the creation of a cluster
         sel = self.selenium
@@ -52,7 +59,7 @@
         # Create the new "testCluster" cluster
         sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
         sel.type("clusterName", "testCluster")
-        print 'Create cluster: testCluster'  
+        self.logger.debug('Create cluster: testCluster')
 
         # Add the nodes to the cluster
         # Needed to generalize statements like this:
@@ -86,7 +93,7 @@
         # in the luci web app - need to build a way to delete /etc/cluster/cluster.conf
         # and stop cman service on cluster nodes - TODO - see bug #
         # https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=213076        
-        print 'Delete cluster: testCluster'  
+        self.logger.debug('Delete cluster: testCluster')
         sel.click("name=__CLUSTER:testCluster")
         sel.click("document.adminform.Submit")
         sel.wait_for_page_to_load("30000")
@@ -102,10 +109,13 @@
             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 CGA_0200_Create_cluster.test_congaCluster')
+
     def tearDown(self):
         """Logout and stop Selenium session"""
         logout(self.selenium)
         self.assertEqual([], self.verificationErrors)
+        closeLogger (self.theloggerObject)
 
 def suite():
         suite = unittest.TestSuite()
--- conga/luci/test/congaDemoTests.py	2006/12/14 02:12:41	1.7
+++ conga/luci/test/congaDemoTests.py	2006/12/14 20:01:40	1.8
@@ -37,26 +37,23 @@
 
     def setUp(self):
         
-        self.testName = "congaDemoTests"
+        # Set up logging      
+        self.theloggerObject = setupLogger (CONGA_DEBUG_LOG)
+        self.logger = self.theloggerObject.getLogger()
+        self.logger.info('-----------------------------------------------------------') 
         
         """Establish connection to selenium server, login to luci """
         self.verificationErrors = []
-        self.selenium = login (CONGA_ADMIN_USERNAME, CONGA_ADMIN_PASSWORD)
+        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)
-        
+        self.logger.info('Starting test case congaDemoTests.test_congaStorage')    
         sel = self.selenium
 
         # Create the storage systems
         for systemName in CONGA_STORAGE_SYSTEMS:
-            createStorageSystem(sel, systemName, CONGA_STORAGE_SYSTEMS[systemName])
+            createStorageSystem(sel, systemName, CONGA_STORAGE_SYSTEMS[systemName], self.logger)
             # Validation - verify that the success message was displayed for each storage system
             self.assertEqual("Do you really want to add the following Storage Systems:\n" + systemName, sel.get_confirmation())
             sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
@@ -69,34 +66,22 @@
 
         # Delete the storage systems
         for systemName in CONGA_STORAGE_SYSTEMS:
-            deleteStorageSystem(sel, systemName)
+            deleteStorageSystem(sel, systemName, self.logger)
            # Validation - verify that the success message was displayed for each storage system
             self.assertEqual("Do you really want to remove the following managed systems:\nStorage Systems:\n-" + systemName, sel.get_confirmation())
             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)
+        self.logger.info('Ending test case congaDemoTests.test_congaStorage')
         
     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)        
-        
+        self.logger.info('Starting test case congaDemoTests.test_congaUsers')        
         sel = self.selenium
 
         # Create the users
         for userName in CONGA_USERS.keys(): 
-            createUser (sel, userName, CONGA_USERS[userName])
+            createUser (sel, userName, CONGA_USERS[userName], self.logger)
             # Validation - verify that the success message was displayed for each user
             self.assertEqual('Do you really want to add the user "' + userName + '"?', sel.get_confirmation())
             sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
@@ -108,29 +93,17 @@
 
         # Delete the users 
         for userName in CONGA_USERS.keys(): 
-            deleteUser (sel, userName)
+            deleteUser (sel, userName, self.logger)
             # Validation - verify that the success message was displayed for each user
             self.assertEqual('Do you really want to remove the user "' + userName + '"?', sel.get_confirmation())
             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)
+        self.logger.info('Ending test case congaDemoTests.test_congaUsers')
 
     def test_congaCluster(self):
         """Test to create and delete 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)
-        
+        self.logger.info('Starting test case congaDemoTests.test_congaCluster')
         sel = self.selenium
            
         sel.open("/luci/homebase")
@@ -141,7 +114,7 @@
         # Create the new "testCluster" cluster
         sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
         sel.type("clusterName", "testCluster")
-        print 'Create cluster: testCluster'  
+        self.logger.debug('Create cluster: testCluster')
 
         # Add the nodes to the cluster
         # Needed to generalize statements like this:
@@ -175,7 +148,7 @@
         # in the luci web app - need to build a way to delete /etc/cluster/cluster.conf
         # and stop cman service on cluster nodes - TODO - see bug #
         # https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=213076        
-        print 'Delete cluster: testCluster'  
+        self.logger.debug('Delete cluster: testCluster')
         sel.click("name=__CLUSTER:testCluster")
         sel.click("document.adminform.Submit")
         sel.wait_for_page_to_load("30000")
@@ -191,13 +164,13 @@
             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)
+        self.logger.info('Ending test case congaDemoTests.test_congaCluster')
 
     def tearDown(self):
         """Logout and stop Selenium session"""
         logout(self.selenium)
         self.assertEqual([], self.verificationErrors)
+        closeLogger (self.theloggerObject)
 
 def suite():
         suite = unittest.TestSuite()
@@ -209,3 +182,9 @@
 if __name__ == "__main__":
     #unittest.main()
     unittest.TextTestRunner(verbosity=2).run(suite())
+    
+# To write pyunit-generated output to file
+#    tests = unittest.defaultTestLoader.loadTestsFromTestCase(congaDemoTests) 
+#    output = open("/var/tmp/output-file.txt", "w") 
+#    unittest.TextTestRunner(output).run(tests) 
+#    output.close() 
--- conga/luci/test/conga_Helpers.py	2006/12/14 02:12:41	1.9
+++ conga/luci/test/conga_Helpers.py	2006/12/14 20:01:40	1.10
@@ -38,8 +38,10 @@
 
 CONGA_ADMIN_USERNAME = 'admin'
 CONGA_ADMIN_PASSWORD = 'password'
-CONGA_SERVER = "http://tng3-5.lab.msp.redhat.com:8080";
-PAGE_DISPLAY_DELAY = "30000"
+CONGA_SERVER = 'http://tng3-5.lab.msp.redhat.com:8080'
+PAGE_DISPLAY_DELAY = '30000'
+CONGA_LOG = '/var/tmp/congaTest.log'
+CONGA_DEBUG_LOG = '/var/tmp/congaTest_debug.log'
 
 # 20061130 - Node tng3-1 isn't booting, node tng3-4 is having some problems too
 
@@ -49,10 +51,6 @@
 #                         'tng3-4.lab.msp.redhat.com':'password',
                          'tng3-5.lab.msp.redhat.com':'password'}
 
-#CONGA_STORAGE_SYSTEMS = {'tng3-2.lab.msp.redhat.com':'password', 
-#                         'tng3-3.lab.msp.redhat.com':'password', 
-#                         'tng3-5.lab.msp.redhat.com':'password'}
-
 #CONGA_CLUSTER_SYSTEMS = {'tng3-1.lab.msp.redhat.com':'password', 
 #                         'tng3-2.lab.msp.redhat.com':'password', 
 #                         'tng3-3.lab.msp.redhat.com':'password', 
@@ -99,9 +97,9 @@
                    'Cluster Tab':10121,
                    'Storage Tab':20452 }
 
-def createStorageSystem(sel, systemName, systemPassword):
+def createStorageSystem(sel, systemName, systemPassword, theLogger):
     """Common code to create storage systems"""
-    print 'Create storage system: ' + systemName
+    theLogger.debug ('Create storage system: ' + systemName)
     sel.click("link=Add a System")
     sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
     sel.type("__SYSTEM0:Addr", systemName)        
@@ -109,18 +107,18 @@
     sel.click("Submit")
     sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
 
-def deleteStorageSystem(sel, systemName):
+def deleteStorageSystem(sel, systemName, theLogger):
     """Common code to delete storage systems"""
-    print 'Delete storage system: ' + systemName
+    theLogger.debug('Delete storage system: ' + systemName)
     # Need to handle artifacts names - underscores in strings, not periods
     systemNameMod = systemName.replace('.', '_')
     sel.click("name=__SYSTEM:" + systemNameMod)
     sel.click("document.adminform.Submit")
     sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)          
 
-def createUser(sel, userName, userPassword):
+def createUser(sel, userName, userPassword, theLogger):
     """Common code to create users"""
-    print 'Create user: ' + userName
+    theLogger.debug('Create user: ' + userName)
     sel.click("link=Add a User")
     sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
     sel.type("newUserName", userName)
@@ -129,9 +127,9 @@
     sel.click("Submit")
     sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
     
-def deleteUser(sel, userName):
+def deleteUser(sel, userName, theLogger):
     """Common code to delete users"""
-    print 'Delete user: ' + userName      
+    theLogger.debug('Delete user: ' + userName)
     sel.click("link=Delete a User")
     sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
     sel.select("deluserId", "label=" + userName)
@@ -162,12 +160,13 @@
     sel.stop()
     
 def setupLogger (testName):   
-    """Create logger - use this message format:  2003-07-08 16:49:45,896 ERROR We have a problem"""
+    """Create logger - use this message format:  2003-07-08 16:49:45,896 ERROR We have a problem
+    For now - 20061213 - just append all log messages to a single log file """
     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')
+    # Why use a RotatingFileHandler? To keep track of previous test results - maybe?
+    #hdlr = logging.handlers.RotatingFileHandler(testName, 'a', 1024000, 10)
+    hdlr = logging.FileHandler(testName, 'a')
     
     formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
     hdlr.setFormatter(formatter)
@@ -178,15 +177,13 @@
     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()
-    
+#    theHandler.doRollover()
+    
\ No newline at end of file
--- conga/luci/test/conga_suite.py	2006/12/13 20:13:33	1.6
+++ conga/luci/test/conga_suite.py	2006/12/14 20:01:40	1.7
@@ -30,6 +30,7 @@
 # Import the test suites
 import unittest
 import congaDemoTests
+from conga_Helpers import *
 import CGA_0160_Add_User
 import CGA_0170_Online_Documentation_Portlet
 import CGA_0200_Create_cluster
@@ -61,15 +62,20 @@
 # Define the suite elements
 congaDemoSuite = congaDemoTests.suite()
 CGA_0160_Add_UserSuite = CGA_0160_Add_User.suite()
-CGA_0170_Online_Documentation_Portlet_Suite = GA_0170_Online_Documentation_Portlet.suite()
+CGA_0170_Online_Documentation_Portlet_Suite = CGA_0170_Online_Documentation_Portlet.suite()
 CGA_0200_Create_cluster_Suite = CGA_0200_Create_cluster.suite()
 
 # Assemble the suite
 suite = unittest.TestSuite()
 suite.addTest(congaDemoSuite)
-suite.addTest(CGA_0160_Add_UserSuite)
+#suite.addTest(CGA_0160_Add_UserSuite)
 suite.addTest(CGA_0170_Online_Documentation_Portlet_Suite)
-suite.addTest(CGA_0200_Create_cluster_Suite)
+#suite.addTest(CGA_0200_Create_cluster_Suite)
 
 # Run the test suite
-unittest.TextTestRunner(verbosity=2).run(suite)
+# unittest.TextTestRunner(verbosity=2).run(suite)
+
+# Write all pyunit-generated messages to a log file
+output = open(CONGA_LOG, "w") 
+unittest.TextTestRunner(output).run(suite) 
+output.close() 
--- conga/luci/test/loggerObject.py	2006/12/14 02:12:41	1.1
+++ conga/luci/test/loggerObject.py	2006/12/14 20:01:40	1.2
@@ -1,3 +1,33 @@
+#! /usr/bin/env python
+
+# Copyright Red Hat, Inc. 2006
+#
+#  This program is free software; you can redistribute it and/or modify it
+#  under the terms of the GNU General Public License as published by the
+#  Free Software Foundation; either version 2, or (at your option) any
+#  later version.
+#
+#  This program is distributed in the hope that it will be useful, but
+#  WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+#  General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; see the file COPYING.  If not, write to the
+#  Free Software Foundation, Inc.,  675 Mass Ave, Cambridge, 
+#  MA 02139, USA.
+
+'''
+Script name:    loggerObject.py
+Creation date:  Dec 2006
+Purpose:        Prototype automated GUI test for RHEL5 Conga (luci server web app) - automated
+                with Selenium RC (remote control) 0.9.0 (http://www.openqa.org/selenium/)
+Summary:        Simple object to let us get/set the logger and its handler
+'''
+
+__author__ = 'Len DiMaggio <ldimaggi redhat com>'
+
+
 class loggerObject:
     theLogger = 'null'
     theHandler = 'null'
@@ -18,5 +48,3 @@
     
     def getHandler( self ):
         return self.theHandler
-    
-    


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