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