Skip to contentSkip to conversation

conga/luci/test congaDemoTests.py conga_Helper ...

Cluster-devel [email protected] 1 participant 1 message Dec 1, 2006

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/cluster
Module name: conga
Changes by: ldimaggi at sourceware.org 2006-12-01 19:57:52

Added files:
luci/test : congaDemoTests.py conga_Helpers.py
conga_suite.py

Log message:
Checking in the first revision of the first parts of a test suite for Conga.

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

/cvs/cluster/conga/luci/test/congaDemoTests.py,v --> standard output revision 1.1

- renamed from luci/test/congaDemoTests.py +217 -0
@@ -0,0 +1,217 @@
+#! /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:    congaDemoTests.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, demo/prototype test for Conga
+'''
+
+__author__ = 'Len DiMaggio <[email protected]>'
+
+from conga_Helpers import *
+from selenium import selenium
+import unittest, time, re
+
+class congaDemoTests(unittest.TestCase):
+
+    def createUsers(self, sel, theUsers):
+        """Common code to create all users in user dictionary"""
+        for userName in theUsers.keys():            
+            print 'Create user: ' + userName
+            sel.click("link=Add a User")
+            sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
+            sel.type("newUserName", userName)
+            sel.type("newPassword", theUsers[userName])     
+            sel.type("newPasswordConfirm", theUsers[userName])
+            sel.click("Submit")
+            sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
+            self.assertEqual('Do you really want to add the user "' + userName + '"?', sel.get_confirmation())
+            # Validation - verify that the success message was displayed for each user
+            sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
+            self.assertTrue (sel.is_text_present('Added new user "' + userName + '" successfully')) 
+
+    def deleteUsers(self, sel, theUsers):
+        """"Common code to delete all users in user dictionary"""
+        for userName in theUsers.keys():      
+            print 'Delete user: ' + userName      
+            sel.click("link=Delete a User")
+            sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
+            sel.select("deluserId", "label=" + userName)
+            sel.click("Submit")
+            sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
+            self.assertEqual('Do you really want to remove the user "' + userName + '"?', sel.get_confirmation())
+            # Validation - verify that the success message was displayed for each user
+            sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
+            self.assertTrue (sel.is_text_present('User "' + userName + '" has been deleted'))  
+
+    def createStorageSystems(self, sel, theSystems):
+        """Common code to create storage systems in the input dictionary"""
+        for systemName in theSystems.keys():
+            print 'Create storage system: ' + systemName
+            sel.click("link=Add a System")
+            sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
+            sel.type("__SYSTEM0:Addr", systemName)        
+            sel.type("__SYSTEM0:Passwd", theSystems[systemName])
+            sel.click("Submit")
+            sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
+            # 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)
+            self.assertTrue (sel.is_text_present('Added storage system "' + systemName + '" successfully'))
+
+    def deleteStorageSystems(self, sel, theSystems):
+        """Common code to delete storage systems in the input dictionary"""
+        for systemName in theSystems.keys():            
+            print '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)
+            # 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'))
+
+    def setUp(self):
+        """Establish connection to selenium server, login to luci """
+        self.verificationErrors = []
+        self.selenium = selenium("localhost", 4444, "*firefox", CONGA_SERVER)
+        self.selenium.start()
+
+        #  Login to the luci web app
+        self.selenium.open(CONGA_SERVER)
+
+        # Wait for "Redirecting, please wait to complete" - it seems like this should not be needed,
+        # but as of 20061130, it still is
+        time.sleep(10)
+        self.selenium.type("__ac_name", CONGA_ADMIN_USERNAME)
+        self.selenium.type("__ac_password", CONGA_ADMIN_PASSWORD)
+        self.selenium.click("submit")
+        self.selenium.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
+ 
+    def test_congaStorage(self):
+        """Test to create and delete storage systems"""
+        sel = self.selenium
+
+        # Create the storage systems
+        self.createStorageSystems(sel, CONGA_STORAGE_SYSTEMS)
+
+        # View the defined storage systems 
+        sel.select_window("null")
+        sel.click("link=Manage Systems")
+        sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
+
+        # Delete the storage systems
+        self.deleteStorageSystems(sel, CONGA_STORAGE_SYSTEMS)
+
+    def test_congaUsers(self):
+        """Test to create and delete conga users"""
+        sel = self.selenium
+
+        # Create the users
+        self.createUsers (sel, CONGA_USERS)
+
+        # Return to homebase page
+        sel.click("link=homebase")
+        sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)     
+
+        # Delete the users 
+        self.deleteUsers (sel, CONGA_USERS)
+
+    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
+        sel = self.selenium
+        sel.open("/luci/homebase")
+        sel.click("link=cluster")
+        sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
+        sel.click("link=Create a New Cluster")
+
+        # Create the new "testCluster" cluster
+        sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
+        sel.type("clusterName", "testCluster")
+        print 'Create cluster: testCluster'  
+
+        # Add the nodes to the cluster
+        # Needed to generalize statements like this:
+        #     sel.type("__SYSTEM1:Addr", "tng3-2.lab.msp.redhat.com")
+        #     sel.type("__SYSTEM1:Passwd", "password")
+        #     sel.click("//input[@value='Add Another Row']")
+        systemCounter = 0
+        for systemName in CONGA_CLUSTER_SYSTEMS.keys():
+            sel.type("__SYSTEM" + str(systemCounter) + ":Addr", systemName)
+            sel.type("__SYSTEM" + str(systemCounter) + ":Passwd", CONGA_CLUSTER_SYSTEMS[systemName])
+            systemCounter = systemCounter + 1
+            if (systemCounter > 2):
+                sel.click("//input[@value='Add Another Row']")          
+        sel.click("document.adminform.rhn_dl[1]")
+        sel.click("Submit")
+        sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
+
+        self.assertEqual('Add the cluster "testCluster" to the Luci management interface?' , sel.get_confirmation())
+        #sel.click("link=testCluster")
+        sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
+
+        # Validation - verify that the newly created cluster shows up in the cluster list        
+        sel.click("link=homebase")
+        sel.wait_for_page_to_load("30000")
+        sel.click("link=Manage Systems")
+        sel.wait_for_page_to_load("30000")
+        self.assertTrue (sel.is_text_present('testCluster'))
+        self.assertTrue (sel.is_element_present("name=__CLUSTER:testCluster"))
+
+        # Delete the cluster - note that this only deletes the reference to the cluster
+        # 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'  
+        sel.click("name=__CLUSTER:testCluster")
+        sel.click("document.adminform.Submit")
+        sel.wait_for_page_to_load("30000")
+        self.assertEqual("Do you really want to remove the following managed systems:\nClusters:\n-testCluster", sel.get_confirmation())
+        sel.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
+        self.assertTrue (sel.is_text_present('Removed cluster "testCluster" successfully'))
+        
+        # Delete the storage systems created when the cluster was created
+        self.deleteStorageSystems(sel, CONGA_CLUSTER_SYSTEMS)
+
+    def tearDown(self):
+        """Logout and stop Selenium session"""
+        sel = self.selenium
+        self.selenium.click("link=Log out")
+        self.selenium.wait_for_page_to_load(PAGE_DISPLAY_DELAY)
+        self.selenium.stop()
+        self.assertEqual([], self.verificationErrors)
+
+def suite():
+        suite = unittest.TestSuite()
+        suite.addTest(congaDemoTests('test_congaStorage'))
+        suite.addTest(congaDemoTests('test_congaUsers'))
+        suite.addTest(congaDemoTests('test_congaCluster'))
+        return suite
+
+if __name__ == "__main__":
+    #unittest.main()
+    unittest.TextTestRunner(verbosity=2).run(suite())

/cvs/cluster/conga/luci/test/conga_Helpers.py,v --> standard output revision 1.1

- renamed from luci/test/conga_Helpers.py +83 -0

83 lines not on this page · raw message

/cvs/cluster/conga/luci/test/conga_suite.py,v --> standard output revision 1.1

- renamed from luci/test/conga_suite.py +66 -0

66 lines not on this page · raw message