[6991] | 1 | #!/bin/env python |
---|
| 2 | |
---|
[7890] | 3 | """Run all acceptance tests in order. |
---|
[6991] | 4 | |
---|
[7890] | 5 | Currently runing with; |
---|
| 6 | python test_all.py cyclone_log_short2.asc *> cyclone_log_long2.asc |
---|
| 7 | |
---|
| 8 | To capture the output. EQRM unit test info is going to screen. |
---|
| 9 | Do not know why. |
---|
| 10 | |
---|
| 11 | """ |
---|
| 12 | |
---|
[6991] | 13 | import os |
---|
| 14 | import sys |
---|
| 15 | import time |
---|
[6996] | 16 | import shutil |
---|
[6991] | 17 | import test_utils as util |
---|
| 18 | |
---|
[7659] | 19 | # 'test_inter_latency.py' - not needed |
---|
[7890] | 20 | # 'test_validation_anuga.py' - This might take days apparently. |
---|
| 21 | # Not the test for us. |
---|
[6991] | 22 | |
---|
[7890] | 23 | # 'test_ssh_to_compute_nodes.py', this relies on the internal |
---|
| 24 | # structure of test_utils, which is a complication I don't need right now. |
---|
| 25 | |
---|
[6991] | 26 | # the test files, in desired order |
---|
[7656] | 27 | Tests = ['test_test_all.py', |
---|
| 28 | 'test_eqrm.py', |
---|
| 29 | 'test_dump_python_environment.py', |
---|
[6991] | 30 | 'test_python_packages.py', |
---|
| 31 | 'test_filesystem_accessibility.py', |
---|
| 32 | 'test_quadrature_parallel_interleaved.py', |
---|
| 33 | 'test_latency_bandwidth.py', |
---|
[7904] | 34 | #'test_test_pypar.py' |
---|
[7025] | 35 | ] |
---|
[7904] | 36 | # Note, test_test_pypar.py is not working in this script, |
---|
| 37 | # but is working as a stand-alone. |
---|
[7890] | 38 | #Tests += ['test_more_python_packages.py'] |
---|
[6991] | 39 | if __name__ == '__main__': |
---|
| 40 | home_directory = os.getcwd() |
---|
| 41 | logfile = os.path.join(home_directory, 'test.log') |
---|
| 42 | if len(sys.argv) > 1: |
---|
| 43 | logfile = sys.argv[1] |
---|
| 44 | |
---|
| 45 | try: |
---|
| 46 | os.remove(logfile) |
---|
| 47 | except: |
---|
| 48 | pass |
---|
| 49 | |
---|
[6992] | 50 | # make sure we are running on a cluster machine |
---|
| 51 | (hostname, _) = util.get_hostname() |
---|
| 52 | cluster_info = util.get_cluster_info(hostname) |
---|
| 53 | if cluster_info is None: |
---|
| 54 | util.log_print_nl(logfile, |
---|
| 55 | 'Sorry, you must be running on a cluster master node.') |
---|
| 56 | util.log_print_nl(logfile, "You are on machine '%s'." % hostname) |
---|
| 57 | sys.exit(10) |
---|
| 58 | |
---|
[7230] | 59 | ## # copy machines_<name> files from here to ~ |
---|
| 60 | ## home = os.getenv('HOME') |
---|
| 61 | ## if not home: |
---|
| 62 | ## util.log_print_nl(logfile, "Sorry, you don't have the 'HOME' environment variable set.") |
---|
| 63 | ## sys.exit(10) |
---|
| 64 | ## machine_file = 'machines_%s' % hostname |
---|
| 65 | ## shutil.copyfile(machine_file, os.path.join(home, '.'+machine_file)) |
---|
[6996] | 66 | |
---|
| 67 | # make sure environment variables are set |
---|
| 68 | python = os.getenv('PYTHON') |
---|
[7656] | 69 | ANUGAPATH = os.getenv('ANUGAPATH') |
---|
| 70 | EQRMPATH = os.getenv('EQRMPATH') |
---|
| 71 | if EQRMPATH is None: |
---|
| 72 | EQRMPATH = '' |
---|
| 73 | if not python or not ANUGAPATH: |
---|
[6996] | 74 | if not python: |
---|
| 75 | util.log_print_nl(logfile, 'Sorry, you must set the PYTHON environment variable.') |
---|
[7656] | 76 | if not ANUGAPATH: |
---|
| 77 | util.log_print_nl(logfile, 'Sorry, you must set the ANUGAPATH environment variable.') |
---|
[6996] | 78 | sys.exit(10) |
---|
| 79 | |
---|
[7017] | 80 | # make sure all OK with user |
---|
| 81 | print '*' * 80 |
---|
| 82 | print '* Acceptance test for %s cluster' % hostname |
---|
| 83 | print '*' * 80 |
---|
| 84 | print '' |
---|
| 85 | print 'PYTHON=%s' % python |
---|
[7656] | 86 | print 'ANUGAPATH=%s' % ANUGAPATH |
---|
| 87 | print 'EQRMPATH=%s' % EQRMPATH |
---|
[7017] | 88 | print '' |
---|
[7890] | 89 | # res = raw_input('This test will run with the above environment variables, OK? ') |
---|
| 90 | # if len(res) == 0 or res[0].upper() != 'Y': |
---|
| 91 | # sys.exit(10) |
---|
| 92 | # print '' |
---|
[7017] | 93 | |
---|
| 94 | # put header on log |
---|
[7054] | 95 | test_start_time = time.time() |
---|
| 96 | |
---|
[7017] | 97 | util.log_nl(logfile, '#' * 80) |
---|
| 98 | util.log_nl(logfile, '# Acceptance test of cluster %s' % hostname) |
---|
| 99 | util.log_nl(logfile, '#' * 80) |
---|
| 100 | util.log_nl(logfile) |
---|
| 101 | |
---|
[6991] | 102 | # run the tests |
---|
| 103 | for test_module in Tests: |
---|
| 104 | (import_name, _) = test_module.split('.', 1) |
---|
[7017] | 105 | import_code = 'import %s as test' % import_name |
---|
[6991] | 106 | |
---|
[7017] | 107 | exec import_code |
---|
| 108 | |
---|
| 109 | start_time = time.time() |
---|
| 110 | test_name = test.name |
---|
| 111 | util.header(logfile, test_module, '%s on %s.' % (test_name, hostname)) |
---|
| 112 | #test_code = ("test.test('%s')" % logfile) |
---|
| 113 | |
---|
| 114 | test.test(logfile) |
---|
| 115 | #exec test_code |
---|
| 116 | |
---|
| 117 | util.footer(logfile, start_time) |
---|
[7054] | 118 | |
---|
| 119 | test_stop_time = time.time() |
---|
| 120 | test_elapsed_time = test_stop_time - test_start_time |
---|
| 121 | |
---|
| 122 | util.log_nl(logfile) |
---|
| 123 | util.log_nl(logfile, '#' * 80) |
---|
| 124 | util.log_nl(logfile, '# Acceptance test of cluster %s took %.1fs' |
---|
| 125 | % (hostname, test_elapsed_time)) |
---|
| 126 | util.log_nl(logfile, '#' * 80) |
---|