source: misc/tools/acceptance_tests/test_all.py @ 7667

Last change on this file since 7667 was 7667, checked in by gray, 14 years ago

minor modifications in acceptance testing

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