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 | # 'test_inter_latency.py' - not needed |
---|
12 | |
---|
13 | # the test files, in desired order |
---|
14 | Tests = ['test_test_all.py', |
---|
15 | 'test_eqrm.py', |
---|
16 | '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 | ] |
---|
24 | |
---|
25 | Tests = ['test_eqrm.py'] |
---|
26 | |
---|
27 | if __name__ == '__main__': |
---|
28 | home_directory = os.getcwd() |
---|
29 | logfile = os.path.join(home_directory, 'test.log') |
---|
30 | if len(sys.argv) > 1: |
---|
31 | logfile = sys.argv[1] |
---|
32 | |
---|
33 | try: |
---|
34 | os.remove(logfile) |
---|
35 | except: |
---|
36 | pass |
---|
37 | |
---|
38 | # make sure we are running on a cluster machine |
---|
39 | (hostname, _) = util.get_hostname() |
---|
40 | cluster_info = util.get_cluster_info(hostname) |
---|
41 | if cluster_info is None: |
---|
42 | util.log_print_nl(logfile, |
---|
43 | 'Sorry, you must be running on a cluster master node.') |
---|
44 | util.log_print_nl(logfile, "You are on machine '%s'." % hostname) |
---|
45 | sys.exit(10) |
---|
46 | |
---|
47 | ## # copy machines_<name> files from here to ~ |
---|
48 | ## home = os.getenv('HOME') |
---|
49 | ## if not home: |
---|
50 | ## util.log_print_nl(logfile, "Sorry, you don't have the 'HOME' environment variable set.") |
---|
51 | ## sys.exit(10) |
---|
52 | ## machine_file = 'machines_%s' % hostname |
---|
53 | ## shutil.copyfile(machine_file, os.path.join(home, '.'+machine_file)) |
---|
54 | |
---|
55 | # make sure environment variables are set |
---|
56 | python = os.getenv('PYTHON') |
---|
57 | ANUGAPATH = os.getenv('ANUGAPATH') |
---|
58 | EQRMPATH = os.getenv('EQRMPATH') |
---|
59 | if EQRMPATH is None: |
---|
60 | EQRMPATH = '' |
---|
61 | if not python or not ANUGAPATH: |
---|
62 | if not python: |
---|
63 | util.log_print_nl(logfile, 'Sorry, you must set the PYTHON environment variable.') |
---|
64 | if not ANUGAPATH: |
---|
65 | util.log_print_nl(logfile, 'Sorry, you must set the ANUGAPATH environment variable.') |
---|
66 | sys.exit(10) |
---|
67 | |
---|
68 | # make sure all OK with user |
---|
69 | print '*' * 80 |
---|
70 | print '* Acceptance test for %s cluster' % hostname |
---|
71 | print '*' * 80 |
---|
72 | print '' |
---|
73 | print 'PYTHON=%s' % python |
---|
74 | print 'ANUGAPATH=%s' % ANUGAPATH |
---|
75 | print 'EQRMPATH=%s' % EQRMPATH |
---|
76 | print '' |
---|
77 | res = raw_input('This test will run with the above environment variables, OK? ') |
---|
78 | if len(res) == 0 or res[0].upper() != 'Y': |
---|
79 | sys.exit(10) |
---|
80 | print '' |
---|
81 | |
---|
82 | # put header on log |
---|
83 | test_start_time = time.time() |
---|
84 | |
---|
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) |
---|
106 | |
---|
107 | test_stop_time = time.time() |
---|
108 | test_elapsed_time = test_stop_time - test_start_time |
---|
109 | |
---|
110 | util.log_nl(logfile) |
---|
111 | util.log_nl(logfile, '#' * 80) |
---|
112 | util.log_nl(logfile, '# Acceptance test of cluster %s took %.1fs' |
---|
113 | % (hostname, test_elapsed_time)) |
---|
114 | util.log_nl(logfile, '#' * 80) |
---|