示例#1
0
def run(simulator, sim_dir = '/tmp', opensm = 'opensm', memchk = False, osmargs = []):
  
    status = 0
    parser = OptionParser()
    parser.add_option('-t', dest = 'topology', help = 'Provide file with SSA setup topology', metavar = 'setup_example.ini')
    parser.add_option('-i', '--tests', dest = 'tests', help = 'Run specific tests', metavar = ','.join(find_all_tests()))

    (options, _) = parser.parse_args()
    if not options.topology:
        parser.print_help()
        sys.exit(1)

    rch_global_dict['topology'] = options.topology
    tests = find_all_tests(options.tests)

    #Simulator/Real Fabric Support    
    rch_global_dict.update(ssa_tools_utils.read_config(rch_global_dict['topology']))
    rch_global_dict['log_dir'] = '%s/%s_%s' % ( ssa_tools_utils.NFS_LOGS_DIR,  time.strftime("%Y%m%d_%H%M%S"), os.path.basename(__file__).rstrip('.py'))
    os.mkdir(rch_global_dict['log_dir'])

    rch_global_dict['nodes'] = []
    rch_global_dict['tests_results'] = {}
    pprint(rch_global_dict)
    rch_global_dict['acm_nodes'] =  list(set(rch_global_dict['acm_nodes']) - set(rch_global_dict['exclude_nodes']))

    print 'The following tests will be executed', tests
    failed_tests = []
    for test in tests:
        if test == '':
            continue
        print '-I- STARTED %s' % test
        start_time = time.time()        
        rc = eval(test)(None)        
        total_time = round(time.time() - start_time, 2)
        if rc > 0:
            print '-I- ****************   Failed test %s **************************' % test
            rch_global_dict['tests_results'][test] = 'FAILED %s        %s sec' % (rch_global_dict['test_description'][test], total_time)
            status += 1
            failed_tests.append(test)
        elif rc == 0:
            rch_global_dict['tests_results'][test] = 'PASSED %s        %s sec' % (rch_global_dict['test_description'][test], total_time)
        elif rc == -1:
            rch_global_dict['tests_results'][test] = 'SKIPPED %s        %s sec' % (rch_global_dict['test_description'][test], total_time)        
        else:
            rch_global_dict['tests_results'][test] = 'UNKNOWN %s        %s sec' % (rch_global_dict['test_description'][test], total_time)
        
        print '-I- FINISHED %s and %s' % (test, rch_global_dict['tests_results'][test])

    for stat in ['PASSED', 'SKIPPED', 'FAILED']:
        for k in sorted(rch_global_dict['tests_results'].keys()):
            if rch_global_dict['tests_results'][k].find(stat) >= 0 :
                print k, rch_global_dict['tests_results'][k]
    if len(failed_tests) > 0:
        print 'TEST_RUN_NOTE: Failed %s' % ','.join(failed_tests)
        print 'FAILED %s' %  rch_global_dict['log_dir']
    else:
        print commands.getoutput('zip %s.zip -r %s >/dev/null' % (rch_global_dict['log_dir'], rch_global_dict['log_dir']))
        os.system('rm -rf %s' % rch_global_dict['log_dir'])
        print 'PASSED %s.zip' %  rch_global_dict['log_dir'] 
    return status
示例#2
0
def run(simulator, sim_dir = '/tmp', opensm = 'opensm', memchk = False, osmargs = []):
    
    status = 0
    tests = find_all_tests()
    #Simulator/Real Fabric Support    
    rch_global_dict.update(ssa_tools_utils.read_config(rch_global_dict['topology']))
    
    rch_global_dict['nodes'] = []
    rch_global_dict['tests_results'] = {}
    pprint(rch_global_dict)
   
    rch_global_dict['acm_nodes'] =  list(set(rch_global_dict['acm_nodes']) - set(rch_global_dict['exclude_nodes']))

    print 'The following tests will be executed', tests
    failed_tests = []
    for test in tests:
        if test == '':
            continue
        print '-I- STARTED %s' % test
        start_time = time.time()        
        rc = eval(test)(None)        
        total_time = round(time.time() - start_time, 2)
        if rc > 0:
            print '-I- ****************   Failed test %s **************************' % test
            rch_global_dict['tests_results'][test] = 'FAILED %s        %s sec' % (rch_global_dict['test_description'][test], total_time)
            status += 1
            failed_tests.append(test)
        elif rc == 0:
            rch_global_dict['tests_results'][test] = 'PASSED %s        %s sec' % (rch_global_dict['test_description'][test], total_time)
        elif rc == -1:
            rch_global_dict['tests_results'][test] = 'SKIPPED %s        %s sec' % (rch_global_dict['test_description'][test], total_time)        
        else:
            rch_global_dict['tests_results'][test] = 'UNKNOWN %s        %s sec' % (rch_global_dict['test_description'][test], total_time)
        
        print '-I- FINISHED %s and %s' % (test, rch_global_dict['tests_results'][test])

    for stat in ['PASSED', 'SKIPPED', 'FAILED']:
        for k in sorted(rch_global_dict['tests_results'].keys()):
            if rch_global_dict['tests_results'][k].find(stat) >= 0 :
                print k, rch_global_dict['tests_results'][k]
    if len(failed_tests) > 0:
        print 'TEST_RUN_NOTE: Failed %s' % ','.join(failed_tests)

    print commands.getoutput('zip %s.zip -r %s >/dev/null' % (rch_global_dict['test_folder'], rch_global_dict['test_folder']))
    os.system('rm -rf %s' % rch_global_dict['test_folder'])
    print 'Test logs saved under %s.zip' % rch_global_dict['test_folder']

    return status
示例#3
0
def main(argv):

    print '%s %s' % (__file__, ' '.join(argv))

    parser = OptionParser()
    parser.add_option('-t',
                      '--topology_file',
                      dest='topology',
                      help='Provide file with SSA setup topology',
                      metavar='topofile.ini')
    parser.add_option('-o',
                      '--output_folder',
                      dest='output_folder',
                      help='Output folder')
    parser.add_option('-s',
                      '--shared_folder',
                      dest='shared_folder',
                      help='Shared network folder')
    (options, _) = parser.parse_args(argv)

    if not options.topology:
        parser.print_help()
        return 1

    if options.shared_folder:
        dict_global['dest_dir'] = options.shared_folder

    if options.output_folder:
        dict_global['dest_dir_archive'] = False

    dict_global['topology'] = options.topology
    dict_global.update(ssa_tools_utils.read_config(options.topology))

    collect_logs(dict_global)

    if options.output_folder:
        os.system('chmod 777 -R %s' % (dict_global['dest_dir']))
        os.system('mv %s %s' %
                  (dict_global['dest_dir'], options.output_folder))
        print 'All logs saved under %s' % (options.output_folder)

    return 0
示例#4
0
def main(argv):

    print '%s %s' % (__file__, ' '.join(argv))

    status = 0

    actions = ['stop', 'start', 'status', 'clean', 'restart']

    parser = OptionParser()
    parser.add_option('-t',
                      dest='topology',
                      help='Provide file with SSA setup topology',
                      metavar='setup_example.ini')
    parser.add_option(
        '--setup',
        dest='setup',
        help='Start/Stop SSA daemons or clean all logs and procs',
        metavar='<%s>' % '|'.join(actions))
    parser.add_option('-e',
                      '--err_check',
                      dest='check_error',
                      help='Check SSA logs for errors',
                      action='store_true')
    parser.add_option('-c',
                      '--command',
                      dest='cmd',
                      help='Run cmd on all nodes')
    parser.add_option('--ignore_nodes',
                      dest='ignore_nodes',
                      help='cs list of nodes to be ignored')
    parser.add_option('-n',
                      dest='no_random',
                      help='no random stop|start',
                      action='store_true')

    (options, _) = parser.parse_args()
    if options.setup and options.setup not in actions:
        options.setup = 'status'

    if not options.topology:
        parser.print_help()
        return 1

    if not os.path.exists(options.topology):
        print 'Error: %s is missing' % options.topology
        return 1

    ssa_global_dict.update(ssa_tools_utils.read_config(options.topology))
    ssa_global_dict['topology'] = os.path.basename(options.topology)

    if options.ignore_nodes:
        for typ in ['distrib', 'access', 'acm', 'core']:
            for n in options.ignore_nodes.split(','):
                if n in ssa_global_dict['%s_nodes' % typ]:
                    ssa_global_dict['%s_nodes' % typ].remove(n)

    if options.no_random:
        ssa_global_dict['no_random'] = True

    if options.setup:
        status = status + action_setup(ssa_global_dict, options.setup)

    if options.check_error:
        status = status + check_error(ssa_global_dict)

    if options.cmd:
        status = status + run_cmd(ssa_global_dict, options.cmd)

    ssa_tools_utils.execute_on_remote_cleanup()

    return status
示例#5
0
def run(simulator, sim_dir='/tmp', opensm='opensm', memchk=False, osmargs=[]):

    status = 0
    '''
    rch_global_dict['sources'] = os.environ['REGRESSION_SOURCE_PATH']
    rch_global_dict['opensm'] = '%s/usr/sbin/opensm' %  rch_global_dict['sources']
    rch_global_dict['simulator'] = simulator
    rch_global_dict['osm_dir'] = sim_dir
    rch_global_dict['memchk'] = memchk  
    rch_global_dict['log_dir'] = '%s/%d' % (rch_global_dict['osm_dir'], subtest_log_dir().id)
    rch_global_dict['distrib_nodes'] = []
    rch_global_dict['acm_nodes'] = []
    '''
    tests = find_all_tests()
    rch_global_dict['log_dir'] = '%s/%s_%s' % (
        ssa_tools_utils.NFS_LOGS_DIR, time.strftime("%Y%m%d_%H%M%S"),
        os.path.basename(__file__).rstrip('.py'))
    os.mkdir(rch_global_dict['log_dir'])
    #Simulator/Real Fabric Support
    rch_global_dict.update(
        ssa_tools_utils.read_config(rch_global_dict['topology']))

    rch_global_dict['nodes'] = []
    rch_global_dict['tests_results'] = {}
    pprint(rch_global_dict)

    rch_global_dict['acm_nodes'] = list(
        set(rch_global_dict['acm_nodes']) -
        set(rch_global_dict['exclude_nodes']))

    #    rch_global_dict['pml_cfg'] = '%s/pml.cfg' % rch_global_dict['osm_dir']

    print 'The following tests will be executed', tests
    failed_tests = []
    for test in tests:
        if test == '':
            continue
        print '-I- STARTED %s' % test
        start_time = time.time()
        #        ssa_tools_utils.ssa_clean_setup(rch_global_dict)
        rc = eval(test)(None)
        total_time = round(time.time() - start_time, 2)
        if rc > 0:
            print '-I- ****************   Failed test %s **************************' % test
            rch_global_dict['tests_results'][
                test] = 'FAILED %s        %s sec' % (
                    rch_global_dict['test_description'][test], total_time)
            status += 1
            failed_tests.append(test)
        elif rc == 0:
            rch_global_dict['tests_results'][
                test] = 'PASSED %s        %s sec' % (
                    rch_global_dict['test_description'][test], total_time)
        elif rc == -1:
            rch_global_dict['tests_results'][
                test] = 'SKIPPED %s        %s sec' % (
                    rch_global_dict['test_description'][test], total_time)
        else:
            rch_global_dict['tests_results'][
                test] = 'UNKNOWN %s        %s sec' % (
                    rch_global_dict['test_description'][test], total_time)

        print '-I- FINISHED %s and %s' % (
            test, rch_global_dict['tests_results'][test])


#        ssa_tools_utils.ssa_clean_setup(rch_global_dict)

    for stat in ['PASSED', 'SKIPPED', 'FAILED']:
        for k in sorted(rch_global_dict['tests_results'].keys()):
            if rch_global_dict['tests_results'][k].find(stat) >= 0:
                print k, rch_global_dict['tests_results'][k]
    if len(failed_tests) > 0:
        print 'TEST_RUN_NOTE: Failed %s' % ','.join(failed_tests)
        print 'Test logs saved under %s' % rch_global_dict['log_dir']
    else:
        print commands.getoutput(
            'sudo -u lennyb zip %s.zip -r %s >/dev/null' %
            (rch_global_dict['log_dir'], rch_global_dict['log_dir']))
        os.system('rm -rf %s' % rch_global_dict['log_dir'])
        print 'Test logs saved under %s.zip' % rch_global_dict['log_dir']

    return status
示例#6
0
        cmd = 'nohup %s/ib_stress.sh %d > /dev/null &' % ( SSA_SCRIPTS, IB_ACME_DELAY)
        ssa_tools_utils.pdsh_run(nodes, cmd)

    return 0


def stop_ib_acme(nodes):
    ssa_tools_utils.pdsh_run(nodes, 'killall ib_stress.sh 2>/dev/null')
    return 0



if __name__ == "__main__":

    status = 0
    rch_global_dict.update(ssa_tools_utils.read_config(rch_global_dict['topology']))

    if options.node:
        nodes = options.node
    else:
        nodes = rch_global_dict['access_nodes'] + rch_global_dict['distrib_nodes'] + rch_global_dict['acm_nodes'] + rch_global_dict['core_nodes']
        if options.start == 'ib_acme' or options.stop == 'ib_acme':
            nodes = rch_global_dict['acm_nodes']

    if options.topology:
        print 'TOPO = %s' % options.topology
    if options.start:
        status = eval("start_%s" % options.start)(nodes)
    if options.stop:
        status = eval("stop_%s" % options.stop)(nodes)