#!/bin/env python """Run acceptance tests in order. Only run tests that don't need any compute nodes. """ import os import sys import time import shutil import test_utils as util # the test files, in desired order Tests = ['test_dump_python_environment.py', 'test_python_packages.py', # 'test_filesystem_accessibility.py', 'test_ssh_to_compute_nodes.py', # 'test_quadrature_parallel_interleaved.py', # 'test_latency_bandwidth.py', # 'test_test_pypar.py', # 'test_inter_latency.py', 'test_test_all.py', 'test_eqrm.py', ] if __name__ == '__main__': home_directory = os.getcwd() logfile = os.path.join(home_directory, 'test.log') if len(sys.argv) > 1: logfile = sys.argv[1] try: os.remove(logfile) except: pass # make sure we are running on a cluster machine (hostname, _) = util.get_hostname() cluster_info = util.get_cluster_info(hostname) if cluster_info is None: util.log_print_nl(logfile, 'Sorry, you must be running on a cluster master node.') util.log_print_nl(logfile, "You are on machine '%s'." % hostname) sys.exit(10) # copy machines_ files from here to ~ home = os.getenv('HOME') if not home: util.log_print_nl(logfile, "Sorry, you don't have the 'HOME' environment variable set.") sys.exit(10) machine_file = 'machines_%s' % hostname shutil.copyfile(machine_file, os.path.join(home, '.'+machine_file)) # make sure environment variables are set python = os.getenv('PYTHON') ANUGAPATH = os.getenv('ANUGAPATH') ANUGAPATH = os.getenv('ANUGAPATH') if ANUGAPATH is None: ANUGAPATH = '' if not python or not ANUGAPATH: if not python: util.log_print_nl(logfile, 'Sorry, you must set the PYTHON environment variable.') if not ANUGAPATH: util.log_print_nl(logfile, 'Sorry, you must set the ANUGAPATH environment variable.') sys.exit(10) # make sure all OK with user print '*' * 80 print '* Acceptance test for %s cluster' % hostname print '*' * 80 print '' print 'PYTHON=%s' % python print 'ANUGAPATH=%s' % ANUGAPATH print 'ANUGAPATH=%s' % ANUGAPATH print '' res = raw_input('This test will run with the above environment variables, OK? ') if len(res) == 0 or res[0].upper() != 'Y': sys.exit(10) print '' # put header on log util.log_nl(logfile, '#' * 80) util.log_nl(logfile, '# Acceptance test of cluster %s' % hostname) util.log_nl(logfile, '#' * 80) util.log_nl(logfile) # run the tests for test_module in Tests: (import_name, _) = test_module.split('.', 1) import_code = 'import %s as test' % import_name exec import_code start_time = time.time() test_name = test.name util.header(logfile, test_module, '%s on %s.' % (test_name, hostname)) #test_code = ("test.test('%s')" % logfile) test.test(logfile) #exec test_code util.footer(logfile, start_time)