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

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

Updating acceptance test files. Still pre-2010 tests.

  • 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
9name = 'Test of compute-node accessibility via ssh'
10
11def test(logfile):
12    result = True
13
14    (cluster, domain) = util.get_hostname()
15
16    # get python to run
17    python_env_var = os.getenv('PYTHON')
18
19    # get cluster-specific information
20    cluster_dict = util.get_cluster_info(cluster)
21    if cluster_dict is None:
22        util.log_print_nl(logfile, 'Sorry, you must be on one of these clusters:')
23        for name in Cluster_Info:
24            util.log_print_nl(logfile, '\t%s' % name)
25        util.log_print_nl(logfile, 'You are on the %s machine.' % cluster)
26        return False
27
28    # get max width of the compute node names
29    width = len(cluster_dict['node_stem']) + len(str(cluster_dict['num_nodes']))
30
31    # get list of non-bad nodes
32    test_nodes = util.get_node_numbers(cluster, strip_bad_nodes=True)
33
34    # test each node
35    for node_num in test_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    return result
49
50
51if __name__ == '__main__':
52    import sys
53
54    logfile = 'test.log'
55    if len(sys.argv) > 1:
56        logfile = sys.argv[1]
57
58    try:
59        os.remove(logfile)
60    except:
61        pass
62
63    if not test(logfile):
64        sys.exit(10)
65
66    sys.exit(0)
Note: See TracBrowser for help on using the repository browser.