source: branches/numpy_misc/tools/acceptance_tests/test_ssh_to_compute_nodes.py @ 6996

Last change on this file since 6996 was 6996, checked in by rwilson, 15 years ago

Changes to allow for python 2.4 and 2.5 testing.

  • Property svn:executable set to *
File size: 1.7 KB
Line 
1#!/bin/env python
2
3'''Testlet to check that can ssh to each subordinate node of the cluster.'''
4
5import os
6import time
7import test_utils as util
8
9
10def test(logfile):
11    result = True
12    start_time = time.time()
13
14    (cluster, domain) = util.get_hostname()
15
16    util.header(logfile, 'Test of compute-node accessibility via ssh on %s.' % cluster)
17
18    # get python to run
19    python_env_var = os.getenv('PYTHON')
20
21    # get cluster-specific information
22    cluster_dict = util.get_cluster_info(cluster)
23    if cluster_dict is None:
24        util.log_print_nl(logfile, 'Sorry, you must be on one of these clusters:')
25        for name in Cluster_Info:
26            util.log_print_nl(logfile, '\t%s' % name)
27        util.log_print_nl(logfile, 'You are on the %s machine.' % cluster)
28        util.footer(logfile, start_time)
29        return False
30
31    # get max width of the compute node names
32    width = len(cluster_dict['node_stem']) + len(str(cluster_dict['num_nodes']))
33
34    # test each node
35    for node_num in range(cluster_dict['num_nodes']):
36        node_name = cluster_dict['node_stem'] % node_num
37        util.log_print(logfile, "Testing: %s" % node_name.ljust(width+2))
38        (_, fd) = os.popen4('ssh %s exit' % node_name)
39        data = fd.read()
40        status = fd.close()
41        #if status is None:
42        if len(data) == 0:
43            util.log_print_nl(logfile, 'OK')
44        else:
45            util.log_print(logfile, data)
46            result = False
47
48    util.footer(logfile, start_time)
49    return result
50
51
52if __name__ == '__main__':
53    import sys
54
55    logfile = 'test.log'
56    if len(sys.argv) > 1:
57        logfile = sys.argv[1]
58
59    try:
60        os.remove(logfile)
61    except:
62        pass
63
64    if not test(logfile):
65        sys.exit(10)
66
67    sys.exit(0)
Note: See TracBrowser for help on using the repository browser.