source: misc/tools/acceptance_tests/test_offsite.py @ 7656

Last change on this file since 7656 was 7656, checked in by gray, 13 years ago

Updating acceptance test files. Still pre-2010 tests.

File size: 3.1 KB
Line 
1#!/bin/env python
2
3"""Run acceptance tests in order.
4
5Only run tests that don't need any compute nodes.
6"""
7
8import os
9import sys
10import time
11import shutil
12import test_utils as util
13
14
15# the test files, in desired order
16Tests = ['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
29if __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')
59    ANUGAPATH = os.getenv('ANUGAPATH')
60    ANUGAPATH = os.getenv('ANUGAPATH')
61    if ANUGAPATH is None:
62        ANUGAPATH = ''
63    if not python or not ANUGAPATH:
64        if not python:
65            util.log_print_nl(logfile, 'Sorry, you must set the PYTHON environment variable.')
66        if not ANUGAPATH:
67            util.log_print_nl(logfile, 'Sorry, you must set the ANUGAPATH environment variable.')
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
76    print 'ANUGAPATH=%s' % ANUGAPATH
77    print 'ANUGAPATH=%s' % ANUGAPATH
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)
Note: See TracBrowser for help on using the repository browser.