[7047] | 1 | #!/bin/env python |
---|
| 2 | |
---|
[7656] | 3 | """Run acceptance tests in order. |
---|
[7047] | 4 | |
---|
| 5 | Only run tests that don't need any compute nodes. |
---|
[7656] | 6 | """ |
---|
[7047] | 7 | |
---|
| 8 | import os |
---|
| 9 | import sys |
---|
| 10 | import time |
---|
| 11 | import shutil |
---|
| 12 | import test_utils as util |
---|
| 13 | |
---|
| 14 | |
---|
| 15 | # the test files, in desired order |
---|
| 16 | Tests = ['test_dump_python_environment.py', |
---|
| 17 | 'test_python_packages.py', |
---|
| 18 | # 'test_filesystem_accessibility.py', |
---|
| 19 | 'test_ssh_to_compute_nodes.py', |
---|
| 20 | # 'test_quadrature_parallel_interleaved.py', |
---|
| 21 | # 'test_latency_bandwidth.py', |
---|
| 22 | # 'test_test_pypar.py', |
---|
| 23 | # 'test_inter_latency.py', |
---|
| 24 | 'test_test_all.py', |
---|
| 25 | 'test_eqrm.py', |
---|
| 26 | ] |
---|
| 27 | |
---|
| 28 | |
---|
| 29 | if __name__ == '__main__': |
---|
| 30 | home_directory = os.getcwd() |
---|
| 31 | logfile = os.path.join(home_directory, 'test.log') |
---|
| 32 | if len(sys.argv) > 1: |
---|
| 33 | logfile = sys.argv[1] |
---|
| 34 | |
---|
| 35 | try: |
---|
| 36 | os.remove(logfile) |
---|
| 37 | except: |
---|
| 38 | pass |
---|
| 39 | |
---|
| 40 | # make sure we are running on a cluster machine |
---|
| 41 | (hostname, _) = util.get_hostname() |
---|
| 42 | cluster_info = util.get_cluster_info(hostname) |
---|
| 43 | if cluster_info is None: |
---|
| 44 | util.log_print_nl(logfile, |
---|
| 45 | 'Sorry, you must be running on a cluster master node.') |
---|
| 46 | util.log_print_nl(logfile, "You are on machine '%s'." % hostname) |
---|
| 47 | sys.exit(10) |
---|
| 48 | |
---|
| 49 | # copy machines_<name> files from here to ~ |
---|
| 50 | home = os.getenv('HOME') |
---|
| 51 | if not home: |
---|
| 52 | util.log_print_nl(logfile, "Sorry, you don't have the 'HOME' environment variable set.") |
---|
| 53 | sys.exit(10) |
---|
| 54 | machine_file = 'machines_%s' % hostname |
---|
| 55 | shutil.copyfile(machine_file, os.path.join(home, '.'+machine_file)) |
---|
| 56 | |
---|
| 57 | # make sure environment variables are set |
---|
| 58 | python = os.getenv('PYTHON') |
---|
[7656] | 59 | ANUGAPATH = os.getenv('ANUGAPATH') |
---|
| 60 | ANUGAPATH = os.getenv('ANUGAPATH') |
---|
| 61 | if ANUGAPATH is None: |
---|
| 62 | ANUGAPATH = '' |
---|
| 63 | if not python or not ANUGAPATH: |
---|
[7047] | 64 | if not python: |
---|
| 65 | util.log_print_nl(logfile, 'Sorry, you must set the PYTHON environment variable.') |
---|
[7656] | 66 | if not ANUGAPATH: |
---|
| 67 | util.log_print_nl(logfile, 'Sorry, you must set the ANUGAPATH environment variable.') |
---|
[7047] | 68 | sys.exit(10) |
---|
| 69 | |
---|
| 70 | # make sure all OK with user |
---|
| 71 | print '*' * 80 |
---|
| 72 | print '* Acceptance test for %s cluster' % hostname |
---|
| 73 | print '*' * 80 |
---|
| 74 | print '' |
---|
| 75 | print 'PYTHON=%s' % python |
---|
[7656] | 76 | print 'ANUGAPATH=%s' % ANUGAPATH |
---|
| 77 | print 'ANUGAPATH=%s' % ANUGAPATH |
---|
[7047] | 78 | print '' |
---|
| 79 | res = raw_input('This test will run with the above environment variables, OK? ') |
---|
| 80 | if len(res) == 0 or res[0].upper() != 'Y': |
---|
| 81 | sys.exit(10) |
---|
| 82 | print '' |
---|
| 83 | |
---|
| 84 | # put header on log |
---|
| 85 | util.log_nl(logfile, '#' * 80) |
---|
| 86 | util.log_nl(logfile, '# Acceptance test of cluster %s' % hostname) |
---|
| 87 | util.log_nl(logfile, '#' * 80) |
---|
| 88 | util.log_nl(logfile) |
---|
| 89 | |
---|
| 90 | # run the tests |
---|
| 91 | for test_module in Tests: |
---|
| 92 | (import_name, _) = test_module.split('.', 1) |
---|
| 93 | import_code = 'import %s as test' % import_name |
---|
| 94 | |
---|
| 95 | exec import_code |
---|
| 96 | |
---|
| 97 | start_time = time.time() |
---|
| 98 | test_name = test.name |
---|
| 99 | util.header(logfile, test_module, '%s on %s.' % (test_name, hostname)) |
---|
| 100 | #test_code = ("test.test('%s')" % logfile) |
---|
| 101 | |
---|
| 102 | test.test(logfile) |
---|
| 103 | #exec test_code |
---|
| 104 | |
---|
| 105 | util.footer(logfile, start_time) |
---|