Revision: 50574
Author:   kim
Date:     2009-05-14 00:32:02 +0000 (Thu, 14 May 2009)

Log Message:
-----------
Slight improvements to settings_handler
Adding a simple test program based on the extension tester. We'll use that with 
out test_system in a moment

Modified Paths:
--------------
    trunk/testing/installer/settings.py.example
    trunk/testing/installer/settings_handler.py
    trunk/testing/installer/test_system.py

Added Paths:
-----------
    trunk/testing/installer/wiki_works.py

Modified: trunk/testing/installer/settings.py.example
===================================================================
--- trunk/testing/installer/settings.py.example 2009-05-14 00:02:06 UTC (rev 
50573)
+++ trunk/testing/installer/settings.py.example 2009-05-14 00:32:02 UTC (rev 
50574)
@@ -27,14 +27,6 @@
 # base scriptpath for every installation (ie, where to reach the above over 
the web)
 base_scriptpath="/~kim/revisions/"
 
-# where to install the toolkit
-toolkit_dir='/home/kim/testing'
-
-
-#where check_isolation can be found
-isolation_create=toolkit_dir+'/check_isolation/create_and_ul.sh'
-isolation_test=toolkit_dir+'/check_isolation/dl_and_check.sh'
-
 # what mysql command should be used. (Who us? Use horrible hacks?)
 
 mysql_command="mysql -uroot"

Modified: trunk/testing/installer/settings_handler.py
===================================================================
--- trunk/testing/installer/settings_handler.py 2009-05-14 00:02:06 UTC (rev 
50573)
+++ trunk/testing/installer/settings_handler.py 2009-05-14 00:32:02 UTC (rev 
50574)
@@ -38,8 +38,11 @@
 
 # where to install the toolkit
 toolkit_dir=os.path.split(installerdir)[0]
+print toolkit_dir
 
 #where check_isolation can be found
+
+print toolkit_dir
 isolation_create=toolkit_dir+'/check_isolation/create_and_ul.sh'
 isolation_test=toolkit_dir+'/check_isolation/dl_and_check.sh'
 # run automated tests during installation

Modified: trunk/testing/installer/test_system.py
===================================================================
--- trunk/testing/installer/test_system.py      2009-05-14 00:02:06 UTC (rev 
50573)
+++ trunk/testing/installer/test_system.py      2009-05-14 00:32:02 UTC (rev 
50574)
@@ -60,7 +60,7 @@
 
        def tests_for_entity(self, entity):
                # TODO we only have one kind of test right right now.
-               return ["WETE"]
+               return ["exttest"]
 
        def entity_exists(self,entity_name):
                """checks to see if a particular installer exists"""
@@ -85,14 +85,14 @@
                        target=self.target
                if not target:
                        raise Test_Exception("What mediawiki instance would you 
like to test?")
-               if test=="WETE":
-                       self.run_WETE(entity)
+               if test=="exttest":
+                       self.run_exttest(entity)
                elif test=="wikiworks":
                        self.run_wikiworks()
                else:
                        raise Test_Exception("I don't know of a test called 
'"+str(test)+"'.")
 
-       def run_WETE(self,target,entity):
+       def run_exttest(self,target,entity):
                pass
        
        def run_wikiworks(self,target):

Added: trunk/testing/installer/wiki_works.py
===================================================================
--- trunk/testing/installer/wiki_works.py                               (rev 0)
+++ trunk/testing/installer/wiki_works.py       2009-05-14 00:32:02 UTC (rev 
50574)
@@ -0,0 +1,86 @@
+#!/usr/bin/python
+# originally adapted from the util/wiki_works script
+# (C) 2009 Kim Bruning
+# Distributed under the MIT License
+
+# Quick&dirty test to see if a wiki is up and running,
+# by asking pywikipedia to attempt to 
+# log in and read the version page
+# assumes default password settings.
+
+# can either be run as an independant program
+#      ./wiki_works.py <instance_name>
+#
+# returns either "wiki works" or "wiki doesn't work"
+
+# or be used as a module:
+#      from wiki_works import wiki_works
+#      wiki_works("instance_name")
+#
+# returns True or False
+
+
+import sys, os.path
+sys.path.append("..")
+
+import settings_handler as installersettings
+import exttest.settings        #for some reason
+from exttest.logindata import LoginData
+
+def do_test(login):
+       """given (hopefully) valid login data,
+       attempt to read the version.
+       If we get something that looks like a valid version array,
+       we assume that the wiki is working fine, and return True.
+       If something goes wrong, we return False."""
+       try:
+               site=login.login()
+               ver=site.live_version()
+               if isinstance(ver,list):
+                       return True
+               else:
+                       return False
+       except Exception, e:
+               return False
+       # or, if in doubt
+       return False # anyway 
+
+def make_login(target):
+       """Put together some valid login data"""
+       login=LoginData(
+               name="Does it blend",
+               protocol='http',
+               server='localhost',
+               scriptpath=installersettings.base_scriptpath+target,
+               lang='en',
+               encoding='utf-8',
+               user=installersettings.adminuser_name,
+               password=installersettings.adminuser_password
+       )
+       return login
+
+
+def wiki_works(target):
+               """test if the wiki works.
+               target is a valid installed mediawiki instance
+               returns True if wiki appears to be up, False if not."""
+               login=make_login(target)
+               result=do_test(login)
+               return result
+
+def main():
+       """run as an independent program"""
+       if len(sys.argv)<2:
+               print "syntax:    wiki_works.py instance_name"
+               sys.exit(1)
+       target=sys.argv[1]
+       
+       if wiki_works(target):
+               print "wiki works"
+               sys.exit(0)
+       else:
+               print "wiki doesn't work"
+               sys.exit(1)
+
+if __name__=="__main__":
+       main()


Property changes on: trunk/testing/installer/wiki_works.py
___________________________________________________________________
Added: svn:executable
   + *



_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to