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 |
1 | 88 | + * |
Index: trunk/testing/installer/settings.py.example |
— | — | @@ -27,14 +27,6 @@ |
28 | 28 | # base scriptpath for every installation (ie, where to reach the above over the web) |
29 | 29 | base_scriptpath="/~kim/revisions/" |
30 | 30 | |
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 | | - |
39 | 31 | # what mysql command should be used. (Who us? Use horrible hacks?) |
40 | 32 | |
41 | 33 | mysql_command="mysql -uroot" |
Index: trunk/testing/installer/settings_handler.py |
— | — | @@ -38,8 +38,11 @@ |
39 | 39 | |
40 | 40 | # where to install the toolkit |
41 | 41 | toolkit_dir=os.path.split(installerdir)[0] |
| 42 | +print toolkit_dir |
42 | 43 | |
43 | 44 | #where check_isolation can be found |
| 45 | + |
| 46 | +print toolkit_dir |
44 | 47 | isolation_create=toolkit_dir+'/check_isolation/create_and_ul.sh' |
45 | 48 | isolation_test=toolkit_dir+'/check_isolation/dl_and_check.sh' |
46 | 49 | # run automated tests during installation |
Index: trunk/testing/installer/test_system.py |
— | — | @@ -60,7 +60,7 @@ |
61 | 61 | |
62 | 62 | def tests_for_entity(self, entity): |
63 | 63 | # TODO we only have one kind of test right right now. |
64 | | - return ["WETE"] |
| 64 | + return ["exttest"] |
65 | 65 | |
66 | 66 | def entity_exists(self,entity_name): |
67 | 67 | """checks to see if a particular installer exists""" |
— | — | @@ -85,14 +85,14 @@ |
86 | 86 | target=self.target |
87 | 87 | if not target: |
88 | 88 | 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) |
91 | 91 | elif test=="wikiworks": |
92 | 92 | self.run_wikiworks() |
93 | 93 | else: |
94 | 94 | raise Test_Exception("I don't know of a test called '"+str(test)+"'.") |
95 | 95 | |
96 | | - def run_WETE(self,target,entity): |
| 96 | + def run_exttest(self,target,entity): |
97 | 97 | pass |
98 | 98 | |
99 | 99 | def run_wikiworks(self,target): |