mirror of https://github.com/BOINC/boinc.git
*** empty log message ***
svn path=/trunk/boinc/; revision=1539
This commit is contained in:
parent
8dee83eb13
commit
5282a8e719
|
@ -1,4 +1,4 @@
|
||||||
#! /usr/local/bin/php
|
#! /usr/local/bin/php -q
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// watchdog script to ensure that the number of result records
|
// watchdog script to ensure that the number of result records
|
||||||
|
|
102
test/boinc.py
102
test/boinc.py
|
@ -105,6 +105,17 @@ def check_deleted(file):
|
||||||
error("file wasn't deleted: " + file)
|
error("file wasn't deleted: " + file)
|
||||||
return 1
|
return 1
|
||||||
return 0
|
return 0
|
||||||
|
def check_files_match(file, correct, descr=''):
|
||||||
|
if not os.path.isfile(file):
|
||||||
|
error("file doesn't exist: %s (needs to match %s)" % (file,correct))
|
||||||
|
return 1
|
||||||
|
if os.system("diff %s %s" % (file, correct)):
|
||||||
|
error("File mismatch%s: %s %s" % (descr, file, correct))
|
||||||
|
return 1
|
||||||
|
else:
|
||||||
|
verbose_echo(2, "Files match%s: %s %s" % (descr, file, correct))
|
||||||
|
return 0
|
||||||
|
|
||||||
def check_program_exists(prog):
|
def check_program_exists(prog):
|
||||||
if not os.path.isfile(prog):
|
if not os.path.isfile(prog):
|
||||||
fatal_error("""
|
fatal_error("""
|
||||||
|
@ -166,7 +177,10 @@ def map_xml(dic, keys):
|
||||||
s = ''
|
s = ''
|
||||||
for key in keys:
|
for key in keys:
|
||||||
s += " <%s>%s</%s>\n" % (key, dic[key], key)
|
s += " <%s>%s</%s>\n" % (key, dic[key], key)
|
||||||
return s
|
return s[:-1]
|
||||||
|
|
||||||
|
class STARTS_WITH(str):
|
||||||
|
pass
|
||||||
|
|
||||||
def dict_match(dict, resultdict):
|
def dict_match(dict, resultdict):
|
||||||
'''match values in DICT against RESULTDICT'''
|
'''match values in DICT against RESULTDICT'''
|
||||||
|
@ -177,7 +191,11 @@ def dict_match(dict, resultdict):
|
||||||
except KeyError:
|
except KeyError:
|
||||||
error("Database query result didn't have key '%s'!" % key)
|
error("Database query result didn't have key '%s'!" % key)
|
||||||
continue
|
continue
|
||||||
if found != expected:
|
if isinstance(expected,STARTS_WITH):
|
||||||
|
match = found.startswith(expected)
|
||||||
|
else:
|
||||||
|
match = found == expected
|
||||||
|
if not match:
|
||||||
id = resultdict.get('id', '?')
|
id = resultdict.get('id', '?')
|
||||||
if str(found).count('\n') or str(expected).count('\n'):
|
if str(found).count('\n') or str(expected).count('\n'):
|
||||||
format = """result %s: unexpected %s:
|
format = """result %s: unexpected %s:
|
||||||
|
@ -425,12 +443,10 @@ class Project:
|
||||||
|
|
||||||
verbose_echo(1, "Setting up server files: writing config files");
|
verbose_echo(1, "Setting up server files: writing config files");
|
||||||
|
|
||||||
config = '<config>\n'
|
config = map_xml(self,
|
||||||
config += map_xml(self,
|
|
||||||
[ 'db_name', 'db_passwd', 'shmem_key',
|
[ 'db_name', 'db_passwd', 'shmem_key',
|
||||||
'key_dir', 'download_url', 'download_dir',
|
'key_dir', 'download_url', 'download_dir',
|
||||||
'upload_url', 'upload_dir', 'project_dir', 'user_name' ])
|
'upload_url', 'upload_dir', 'project_dir', 'user_name' ])
|
||||||
config += '</config>\n'
|
|
||||||
self.append_config(config)
|
self.append_config(config)
|
||||||
|
|
||||||
# put a file with the database name and other info in each HTML
|
# put a file with the database name and other info in each HTML
|
||||||
|
@ -505,11 +521,12 @@ class Project:
|
||||||
def _run_cgi_onepass(self, prog, args=''):
|
def _run_cgi_onepass(self, prog, args=''):
|
||||||
self._run_cgi_prog(prog, '-d 3 -one_pass '+args)
|
self._run_cgi_prog(prog, '-d 3 -one_pass '+args)
|
||||||
def start_servers(self):
|
def start_servers(self):
|
||||||
|
self.restart()
|
||||||
self._run_cgi_prog('start_servers')
|
self._run_cgi_prog('start_servers')
|
||||||
verbose_sleep("Starting servers for project '%s'" % self.short_name, 1)
|
verbose_sleep("Starting servers for project '%s'" % self.short_name, 1)
|
||||||
|
|
||||||
def _install_prog(self, prog, args=''):
|
def _install_prog(self, prog, args=''):
|
||||||
self.append_config('<start>./%s -d 3 -asynch %s >>%s.out 2>&1</start>\n' % (
|
self.append_config('<start>./%s -d 3 -asynch %s >>%s.out 2>&1</start>' % (
|
||||||
prog, args, prog))
|
prog, args, prog))
|
||||||
def install_feeder(self):
|
def install_feeder(self):
|
||||||
self._install_prog('feeder')
|
self._install_prog('feeder')
|
||||||
|
@ -537,10 +554,10 @@ class Project:
|
||||||
self._run_cgi_onepass('file_deleter')
|
self._run_cgi_onepass('file_deleter')
|
||||||
def install_assimilator(self):
|
def install_assimilator(self):
|
||||||
for app_version in self.app_versions:
|
for app_version in self.app_versions:
|
||||||
self._install_prog('assimilator', app_version.app.name)
|
self._install_prog('assimilator', '-app %s' % app_version.app.name)
|
||||||
def assimilate(self):
|
def assimilate(self):
|
||||||
for app_version in self.app_versions:
|
for app_version in self.app_versions:
|
||||||
self._run_cgi_onepass('assimilator', app_version.app.name)
|
self._run_cgi_onepass('assimilator', '-app %s' % app_version.app.name)
|
||||||
|
|
||||||
def start_stripcharts(self):
|
def start_stripcharts(self):
|
||||||
map(lambda l: self.copy(os.path.join('stripchart', l), 'cgi/'),
|
map(lambda l: self.copy(os.path.join('stripchart', l), 'cgi/'),
|
||||||
|
@ -568,12 +585,18 @@ class Project:
|
||||||
|
|
||||||
def restart(self):
|
def restart(self):
|
||||||
'''remove the stop_server trigger'''
|
'''remove the stop_server trigger'''
|
||||||
|
try:
|
||||||
os.unlink(self.dir('cgi', 'stop_server'))
|
os.unlink(self.dir('cgi', 'stop_server'))
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
configlines = ''
|
||||||
def append_config(self, line):
|
def append_config(self, line):
|
||||||
f = open(self.dir('cgi/.htconfig.xml'), 'a')
|
self.configlines += '\n' + line
|
||||||
print >>f, line
|
f = open(self.dir('cgi/.htconfig.xml'), 'w')
|
||||||
f.close()
|
print >>f, '<config>'
|
||||||
|
print >>f, self.configlines
|
||||||
|
print >>f, '</config>'
|
||||||
|
|
||||||
def remove_config(self, pattern):
|
def remove_config(self, pattern):
|
||||||
config = self.dir('cgi/.htconfig.xml')
|
config = self.dir('cgi/.htconfig.xml')
|
||||||
|
@ -609,29 +632,29 @@ class Project:
|
||||||
self.db_open(self.db_name)
|
self.db_open(self.db_name)
|
||||||
return self.db_query("select count(*) from result where server_state=4")[0][0]
|
return self.db_query("select count(*) from result where server_state=4")[0][0]
|
||||||
|
|
||||||
def check_files_match(self, result, correct):
|
def check_files_match(self, result, correct, count=None):
|
||||||
if not check_exists(result):
|
'''if COUNT is specified then [0,COUNT) is mapped onto the %d in RESULT'''
|
||||||
return 0
|
if count != None:
|
||||||
if os.system("diff %s %s" % (self.dir(result), correct)):
|
errs = 0
|
||||||
error("File mismatch for project '%s': %s %s" % (self.short_name, result, correct))
|
for i in range(count):
|
||||||
return 1
|
errs += self.check_files_match(result%i, correct)
|
||||||
else:
|
return errs
|
||||||
verbose_echo(2, "Files match for project '%s': %s %s" % (self.short_name, result, correct))
|
return check_files_match(self.dir(result),
|
||||||
return 0
|
correct, " for project '%s'"%self.short_name)
|
||||||
def check_all_files_match(self, num, result, correct):
|
def check_deleted(self, file, count=None):
|
||||||
'''result should contain a "%d" which is replaced by [0,NUM)'''
|
if count != None:
|
||||||
for i in range(num):
|
errs = 0
|
||||||
self.check_files_match(result%i, correct)
|
for i in range(count):
|
||||||
def check_deleted(self, file):
|
errs += self.check_deleted(file%i)
|
||||||
check_deleted(self.dir(file))
|
return errs
|
||||||
def check_all_deleted(self, num, file):
|
return check_deleted(self.dir(file))
|
||||||
for i in range(num):
|
def check_exists(self, file, count=None):
|
||||||
self.check_deleted(file%i)
|
if count != None:
|
||||||
def check_exists(self, file):
|
errs = 0
|
||||||
|
for i in range(count):
|
||||||
|
errs += self.check_exists(file%i)
|
||||||
|
return errs
|
||||||
return check_exists(self.dir(file))
|
return check_exists(self.dir(file))
|
||||||
def check_all_exist(self, file):
|
|
||||||
for i in range(num):
|
|
||||||
self.check_exists(file%i)
|
|
||||||
|
|
||||||
class User:
|
class User:
|
||||||
'''represents an account on a particular project'''
|
'''represents an account on a particular project'''
|
||||||
|
@ -666,18 +689,19 @@ class Host:
|
||||||
verbose_echo(2, "Setting up host '%s': writing %s" % (self.name, filename))
|
verbose_echo(2, "Setting up host '%s': writing %s" % (self.name, filename))
|
||||||
|
|
||||||
f = open(filename, "w")
|
f = open(filename, "w")
|
||||||
print >>f, "<account>\n"
|
print >>f, "<account>"
|
||||||
print >>f, map_xml(project, ['master_url'])
|
print >>f, map_xml(project, ['master_url'])
|
||||||
print >>f, map_xml(user, ['authenticator'])
|
print >>f, map_xml(user, ['authenticator'])
|
||||||
print >>f, user.project_prefs
|
print >>f, user.project_prefs
|
||||||
print >>f, "</account>\n"
|
print >>f, "</account>"
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
# copy log flags and global prefs, if any
|
# copy log flags and global prefs, if any
|
||||||
if self.log_flags:
|
if self.log_flags:
|
||||||
shutil.copy(self.log_flags, self.dir('log_flags.xml'))
|
shutil.copy(self.log_flags, self.dir('log_flags.xml'))
|
||||||
if self.global_prefs:
|
if self.global_prefs:
|
||||||
shutil.copy(self.global_prefs, self.dir('global_prefs.xml'))
|
shell_call("cp %s %s" % (self.global_prefs, self.dir('global_prefs.xml')))
|
||||||
|
# shutil.copy(self.global_prefs, self.dir('global_prefs.xml'))
|
||||||
|
|
||||||
def run(self, args, asynch=False):
|
def run(self, args, asynch=False):
|
||||||
if asynch:
|
if asynch:
|
||||||
|
@ -778,11 +802,15 @@ def test_msg(msg):
|
||||||
def test_done():
|
def test_done():
|
||||||
global errors
|
global errors
|
||||||
if sys.__dict__.get('last_traceback'):
|
if sys.__dict__.get('last_traceback'):
|
||||||
|
if sys.last_type == KeyboardInterrupt:
|
||||||
|
errors += 0.1
|
||||||
|
sys.stderr.write("\nTest canceled by user\n")
|
||||||
|
else:
|
||||||
errors += 1
|
errors += 1
|
||||||
sys.stderr.write("\nException thrown - bug in test scripts?\n")
|
sys.stderr.write("\nException thrown - bug in test scripts?\n")
|
||||||
if errors:
|
if errors:
|
||||||
verbose_echo(0, "ERRORS: %d" % errors)
|
verbose_echo(0, "ERRORS: %d" % errors)
|
||||||
sys.exit(errors)
|
sys.exit(int(errors))
|
||||||
else:
|
else:
|
||||||
verbose_echo(1, "Passed test!")
|
verbose_echo(1, "Passed test!")
|
||||||
if VERBOSE == 1:
|
if VERBOSE == 1:
|
||||||
|
|
|
@ -14,15 +14,14 @@ class ProjectUC(Project):
|
||||||
self.add_core_version()
|
self.add_core_version()
|
||||||
self.add_app_and_version("upper_case")
|
self.add_app_and_version("upper_case")
|
||||||
self.user = User()
|
self.user = User()
|
||||||
self.user.project_prefs = "<project_specific>\nfoobar\n</project_specific>\n"
|
self.user.project_prefs = "<project_specific>\nfoobar\n</project_specific>"
|
||||||
self.user.global_prefs = """<venue name=\"home\">
|
self.user.global_prefs = """<venue name=\"home\">
|
||||||
<work_buf_min_days>0</work_buf_min_days>
|
<work_buf_min_days>0</work_buf_min_days>
|
||||||
<work_buf_max_days>2</work_buf_max_days>
|
<work_buf_max_days>2</work_buf_max_days>
|
||||||
<disk_interval>1</disk_interval>
|
<disk_interval>1</disk_interval>
|
||||||
<run_on_batteries/>
|
<run_on_batteries/>
|
||||||
<max_bytes_sec_down>400000</max_bytes_sec_down>
|
<max_bytes_sec_down>400000</max_bytes_sec_down>
|
||||||
</venue>
|
</venue>"""
|
||||||
"""
|
|
||||||
self.add_user(self.user)
|
self.add_user(self.user)
|
||||||
# must install projects before adding hosts (WHY?)
|
# must install projects before adding hosts (WHY?)
|
||||||
self.install()
|
self.install()
|
||||||
|
@ -53,16 +52,16 @@ class ProjectUC(Project):
|
||||||
self.validate(self.work.redundancy)
|
self.validate(self.work.redundancy)
|
||||||
result = {}
|
result = {}
|
||||||
result['server_state'] = RESULT_SERVER_STATE_OVER
|
result['server_state'] = RESULT_SERVER_STATE_OVER
|
||||||
result['stderr_out'] = """APP: upper_case: starting, argc 1
|
result['stderr_out'] = STARTS_WITH("""APP: upper_case: starting, argc 1
|
||||||
APP: upper_case: argv[0] is upper_case
|
APP: upper_case: argv[0] is upper_case
|
||||||
APP: upper_case ending, wrote """
|
APP: upper_case ending, wrote """)
|
||||||
result['exit_status'] = 0
|
# result['exit_status'] = 0
|
||||||
self.check_results(2, result)
|
self.check_results(2, result)
|
||||||
self.check_all_files_match(2, "uc_wu_%d_0", "uc_correct_output")
|
self.check_files_match("upload/uc_wu_%d_0", "uc_correct_output", count=2)
|
||||||
self.assimilate()
|
self.assimilate()
|
||||||
self.file_delete()
|
self.file_delete()
|
||||||
self.check_server_deleted("download/input")
|
self.check_deleted("download/input")
|
||||||
self.check_all_deleted(2, "upload/uc_wu_%d_0")
|
self.check_deleted("upload/uc_wu_%d_0", count=2)
|
||||||
self.stop()
|
self.stop()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Reference in New Issue