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