r50574 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50573‎ | r50574 | r50575 >
Date:00:32, 14 May 2009
Author:kim
Status:deferred
Tags:
Comment:
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 (modified) (history)
  • /trunk/testing/installer/settings_handler.py (modified) (history)
  • /trunk/testing/installer/test_system.py (modified) (history)
  • /trunk/testing/installer/wiki_works.py (added) (history)

Diff [purge]

Index: trunk/testing/installer/wiki_works.py
@@ -0,0 +1,86 @@
 2+#!/usr/bin/python
 3+# originally adapted from the util/wiki_works script
 4+# (C) 2009 Kim Bruning
 5+# Distributed under the MIT License
 6+
 7+# Quick&dirty test to see if a wiki is up and running,
 8+# by asking pywikipedia to attempt to
 9+# log in and read the version page
 10+# assumes default password settings.
 11+
 12+# can either be run as an independant program
 13+# ./wiki_works.py <instance_name>
 14+#
 15+# returns either "wiki works" or "wiki doesn't work"
 16+
 17+# or be used as a module:
 18+# from wiki_works import wiki_works
 19+# wiki_works("instance_name")
 20+#
 21+# returns True or False
 22+
 23+
 24+import sys, os.path
 25+sys.path.append("..")
 26+
 27+import settings_handler as installersettings
 28+import exttest.settings #for some reason
 29+from exttest.logindata import LoginData
 30+
 31+def do_test(login):
 32+ """given (hopefully) valid login data,
 33+ attempt to read the version.
 34+ If we get something that looks like a valid version array,
 35+ we assume that the wiki is working fine, and return True.
 36+ If something goes wrong, we return False."""
 37+ try:
 38+ site=login.login()
 39+ ver=site.live_version()
 40+ if isinstance(ver,list):
 41+ return True
 42+ else:
 43+ return False
 44+ except Exception, e:
 45+ return False
 46+ # or, if in doubt
 47+ return False # anyway
 48+
 49+def make_login(target):
 50+ """Put together some valid login data"""
 51+ login=LoginData(
 52+ name="Does it blend",
 53+ protocol='http',
 54+ server='localhost',
 55+ scriptpath=installersettings.base_scriptpath+target,
 56+ lang='en',
 57+ encoding='utf-8',
 58+ user=installersettings.adminuser_name,
 59+ password=installersettings.adminuser_password
 60+ )
 61+ return login
 62+
 63+
 64+def wiki_works(target):
 65+ """test if the wiki works.
 66+ target is a valid installed mediawiki instance
 67+ returns True if wiki appears to be up, False if not."""
 68+ login=make_login(target)
 69+ result=do_test(login)
 70+ return result
 71+
 72+def main():
 73+ """run as an independent program"""
 74+ if len(sys.argv)<2:
 75+ print "syntax: wiki_works.py instance_name"
 76+ sys.exit(1)
 77+ target=sys.argv[1]
 78+
 79+ if wiki_works(target):
 80+ print "wiki works"
 81+ sys.exit(0)
 82+ else:
 83+ print "wiki doesn't work"
 84+ sys.exit(1)
 85+
 86+if __name__=="__main__":
 87+ main()
Property changes on: trunk/testing/installer/wiki_works.py
___________________________________________________________________
Name: svn:executable
188 + *
Index: trunk/testing/installer/settings.py.example
@@ -27,14 +27,6 @@
2828 # base scriptpath for every installation (ie, where to reach the above over the web)
2929 base_scriptpath="/~kim/revisions/"
3030
31 -# where to install the toolkit
32 -toolkit_dir='/home/kim/testing'
33 -
34 -
35 -#where check_isolation can be found
36 -isolation_create=toolkit_dir+'/check_isolation/create_and_ul.sh'
37 -isolation_test=toolkit_dir+'/check_isolation/dl_and_check.sh'
38 -
3931 # what mysql command should be used. (Who us? Use horrible hacks?)
4032
4133 mysql_command="mysql -uroot"
Index: trunk/testing/installer/settings_handler.py
@@ -38,8 +38,11 @@
3939
4040 # where to install the toolkit
4141 toolkit_dir=os.path.split(installerdir)[0]
 42+print toolkit_dir
4243
4344 #where check_isolation can be found
 45+
 46+print toolkit_dir
4447 isolation_create=toolkit_dir+'/check_isolation/create_and_ul.sh'
4548 isolation_test=toolkit_dir+'/check_isolation/dl_and_check.sh'
4649 # run automated tests during installation
Index: trunk/testing/installer/test_system.py
@@ -60,7 +60,7 @@
6161
6262 def tests_for_entity(self, entity):
6363 # TODO we only have one kind of test right right now.
64 - return ["WETE"]
 64+ return ["exttest"]
6565
6666 def entity_exists(self,entity_name):
6767 """checks to see if a particular installer exists"""
@@ -85,14 +85,14 @@
8686 target=self.target
8787 if not target:
8888 raise Test_Exception("What mediawiki instance would you like to test?")
89 - if test=="WETE":
90 - self.run_WETE(entity)
 89+ if test=="exttest":
 90+ self.run_exttest(entity)
9191 elif test=="wikiworks":
9292 self.run_wikiworks()
9393 else:
9494 raise Test_Exception("I don't know of a test called '"+str(test)+"'.")
9595
96 - def run_WETE(self,target,entity):
 96+ def run_exttest(self,target,entity):
9797 pass
9898
9999 def run_wikiworks(self,target):

Status & tagging log