def test_profile(testrig): '''main test function''' logging.info('START %s, version %s' % (test_profile.__name__, VERSION)) start_time = time.time() # Setup AttSwBoard logging.basicConfig(level=logging.DEBUG, stream=sys.stdout, format='%(asctime)s - %(levelname)s - %(module)s - %(message)s') t = AttSwBoard(testrig.config['attswboard']['address']) t.set_att(1, 5) t.set_att(2, 5) t.close() # # get nodes node1 = testrig.nodes['node1'] node2 = testrig.nodes['node2'] rac1 = node1.plugin[2] rac2 = node2.plugin[2] rac1_if = rac1.interface[1] rac2_if = rac2.interface[1] # TOPOLOGY CREATION # # create initial rf link node1.interface['cli'].send('c t; int gi 0/1; spanning-tree disable; end') node2.interface['cli'].send('c t; int gi 0/1; spanning-tree disable; end') radio_link.configure_unprotected_radio_link('rf1', testrig) eth_connection.configure_connection('rf1', testrig) eth_connection.configure_connection('eth1', testrig) eth_connection.configure_connection('eth2', testrig) spirent = testrig.devices['spirent'] # TEST FLOW config_section = testrig.config['config'] # # create Excel writer instance wb = excelwriter.ExcelWriter() # # fill out info work sheet about nodes ws = wb.add_sheet('Info') mfg_info = node1.plugin[0].get_mfg_info() print 'mfg_info = ', mfg_info lines = mfg_info.split("\n") i = 0 for line in lines: # prints each word on a line print(line) i = i + 1 info = line.split(":") if len(info) == 2: ws.write(0 + i, 0, info[0].strip(), excelwriter.TEXT, excelwriter.FONT_BOLD) ws.write(0 + i, 1, info[1].strip()) # # get RAC/ODU info rac_info = rac1_if.get_radio_capabilities() rac_info += rac2_if.get_radio_capabilities() print 'rac_info= ', rac_info lines = rac_info.split("\n") i = 0 for line in lines: # prints each word on a line print(line) i = i + 1 info = line.split(":") if len(info) == 2: ws.write(0 + i, 3, info[0].strip(), excelwriter.TEXT, excelwriter.FONT_BOLD) ws.write(0 + i, 4, info[1].strip()) # # configure spirent tc logging.info("Configuring spirent tc") port1, port2 = [port for port in spirent.ports.keys()] spirent.setResultMode({'ResultViewMode': 'LATENCY_JITTER'}) # # stream node1 -> node2 streamBlock1 = spirent.addStreamblock(port1, {'FixedFrameLength': config_section['traffic'].as_int('frame_size_bytes'), 'FillType':'PRBS'}) ethernetFrame1 = spirent.addEthernetFrameOnStreamBlock(streamBlock1) # # stream node2 -> node1 streamBlock2 = spirent.addStreamblock(port2, {'FixedFrameLength': config_section['traffic'].as_int('frame_size_bytes'), 'FillType':'PRBS'}) ethernetFrame2 = spirent.addEthernetFrameOnStreamBlock(streamBlock2) # # apply settings now. this is important step spirent.applySettings() spirent.subscribeToResults("project", "RxStreamSummaryResults") # # configure generators/analyzers generatorConfig = {'LoadUnit': 'MEGABITS_PER_SECOND', 'FixedLoad': str(10)} spirent.configGenerator(port1, generatorConfig) spirent.configGenerator(port2, generatorConfig) spirent.configAnalyzer(port1) spirent.configAnalyzer(port2) logging.info("Applying spirent tc configuration") spirent.applySettings() spirent.start() # TODO: move to rac2x plugin logging.info("Getting profile list") profile_list = rac1.get_profile_list() if config_section['profile']['bandwidth_mhz']: bandwidth_list = config_section['profile'].as_list('bandwidth_mhz') profile_list_selected = [n for p in bandwidth_list for n in [str(int(p) + 100000), str(int(p) + 200000)] if n] else: profile_list_selected = profile_list if config_section['profile']['xpic']: if config_section['profile'].as_int('xpic'): profile_list_selected = [p for p in profile_list_selected if p.startswith('2')] profile_list = [p for p in profile_list if p.startswith('2')] else: profile_list_selected = [p for p in profile_list_selected if p.startswith('1')] profile_list = [p for p in profile_list if p.startswith('1')] if profile_list_selected: profile_list = list(set(profile_list).intersection(profile_list_selected)) profile_list = sorted(profile_list) logging.info('Selected profiles: %s' % (' '.join(profile_list))) # # create excel worksheet for results ws = wb.add_sheet('Results') ws.create_table_header(TABLE_HEADER, excelwriter.STYLE0) row = 2 # # set tx power tx_power = config_section['rf'].as_float('tx_power') logging.info('Setting tx power to %.1f' % (tx_power)) rac1_if.set_tx_power(tx_power) rac2_if.set_tx_power(tx_power) # get requested rsl val = config_section['rf'].as_float('rsl_val') logging.info('running RSL to get %d', val) # print 'tune rsl value' tuneRsl(testrig, val) # # cycle profiles procount = 1 for profile in profile_list: logging.info('Setting profile to %s' % (profile)) rac1_if.set_bandwidth(config_section['profile']['regulatory'], int(profile[-2:])) rac2_if.set_bandwidth(config_section['profile']['regulatory'], int(profile[-2:])) time.sleep(5) modulation_list = rac1.get_subprofile_list(profile) modulation_list_selected = filter(None, config_section['profile'].as_list('modulation')) if modulation_list_selected: modulation_list = list(set(modulation_list).intersection(modulation_list_selected)) # # for sort using modulation_list index modulation_list = sorted(modulation_list, key=lambda a: rac1.modulation_list.index(a)) logging.info('Selected modulations: %s' % (''.join(modulation_list))) # # cycle modulations for mod in modulation_list: if '1024' in mod: mod = '1024QAM-HG' start_test_time = time.time() logging.info('Setting modulation to %s' % (mod)) # ws.write(row, 1, mod, excelwriter.TEXT) rac1_if.set_modulation_static(mod) rac2_if.set_modulation_static(mod) time.sleep(5) # # check rf link and alarms retries = 10 while retries: status1 = ['Not Locked', 'Locked'][rac1_if.get_modem_status()] status2 = ['Not Locked', 'Locked'][rac2_if.get_modem_status()] logging.info('%2d: Modem status 1:%s, 2:%s' % (retries, status1, status2)) if status1 == status2 == 'Locked': break retries -= 1 time.sleep(10) if retries == 0: logging.error('Failed to set %s modulation.' % (mod)) row += 1 continue # # check for critical/major alarms only get_alarms_per_severity = lambda a, x: ', '.join([y.description for k, v in a.items() if v and k == x for y in v if y.description]) for a in (rac1_if.get_alarms(), rac2_if.get_alarms(), \ rac1_if.radio.get_alarms(), rac2_if.radio.get_alarms()): critical_alarms = get_alarms_per_severity(a, 3) major_alarms = get_alarms_per_severity(a, 4) if critical_alarms: logging.error('Found critical alarms: %s.' % (critical_alarms)) if major_alarms: logging.error('Found major alarms: %s.' % (major_alarms)) # # get profile capacity per current profile profile_capacity = rac1_if.get_tx_capacity_mbps() ws.write(row, 0, (procount), excelwriter.TEXT) procount += 1 ws.write(row, 1, (profile[-2:], 'MHz ', mod), excelwriter.TEXT) fsArray = config_section['profile'].as_list('frameSize') for idx in range(0, len(fsArray), 2): logging.info('setting stream1 frame size to %s', fsArray[idx]) ws.write(row, 2, int(fsArray[idx]), excelwriter.TEXT) ws.write(row + 1, 2, int(fsArray[idx + 1]), excelwriter.TEXT) logging.info('setting stream2 frame size to %s', fsArray[idx + 1]) logging.info('Setting spirent load to %f' % (profile_capacity)) for port in [port1, port2]: spirent.configGenerator(port, {'LoadUnit': 'MEGABITS_PER_SECOND', 'FixedLoad': str(500)}) spirent.stc.config(streamBlock1, FixedFrameLength=fsArray[idx]) spirent.stc.config(streamBlock2, FixedFrameLength=fsArray[idx + 1]) logging.info("applying spirent tc configuration") spirent.applySettings() spirent.start() time.sleep(10) spirent.clearAllTrafficCounters() time.sleep(config_section['traffic'].as_int('traffic_time_sec')) s1ExpFrameRate_fps = (((float(profile_capacity) * 1024 * 1024) / (8 * int(fsArray[idx]))) / 100.) * 85.0 print 'profile Capacity = ', profile_capacity, 's1ExpFrameRate= ', s1ExpFrameRate_fps s2ExpFrameRate_fps = (((float(profile_capacity) * 1024 * 1024) / (8 * int(fsArray[idx + 1]))) / 100.) * 85.0 print 'profile Capacity = ', profile_capacity, 's2ExpFrameRate= ', s2ExpFrameRate_fps s1FrameRate = s2FrameRate = 0 counter = 20 while counter: time.sleep(1) results = spirent.getResults() for resultId in results: frameRate = (int(results[resultId]['results']['FrameRate'])) print 'frameRate = ', frameRate if results[resultId]['parent'] == 'streamblock1': s1DiffRate = abs(s1FrameRate - frameRate) s1FrameRate = frameRate dropped_frames1 = int(results[resultId]['results']['DroppedFrameCount']) rx_frame_count1 = int(results[resultId]['results']['FrameCount']) logging.debug('streamblock2: %d %d %d' % (frameRate, dropped_frames1, rx_frame_count1)) print 's1ExpFrameRate= ', s1ExpFrameRate_fps, 's1FrameRate= ', s1FrameRate, 's1DiffRate = ', s1DiffRate LRXBitRateL1 = ((int(fsArray[idx]) + 12 + 8) * 8 * frameRate) / 1000000.0 LRXBitRateL2 = int(fsArray[idx]) * 8 * frameRate / 1000000.0 LThrouhputL1 = (LRXBitRateL1 / profile_capacity) * 100.0 LThrouhputL2 = (LRXBitRateL2 / profile_capacity) * 100.0 logging.info('%d: %d/%d/%d/%d' % (int(fsArray[idx]), LRXBitRateL1, LRXBitRateL2, LThrouhputL1, LThrouhputL2)) if results[resultId]['parent'] == 'streamblock2': s2DiffRate = abs(s2FrameRate - frameRate) s2FrameRate = frameRate dropped_frames2 = int(results[resultId]['results']['DroppedFrameCount']) rx_frame_count2 = int(results[resultId]['results']['FrameCount']) logging.debug('streamblock2: %d %d %d' % (frameRate, dropped_frames2, rx_frame_count2)) print 's2ExpFrameRate= ', s2ExpFrameRate_fps, 's2FrameRate= ', s2FrameRate, 's2DiffRate = ', s2DiffRate RRXBitRateL1 = ((int(fsArray[idx + 1]) + 12 + 8) * 8 * frameRate) / 1000000.0 RRXBitRateL2 = int(fsArray[idx + 1]) * 8 * frameRate / 1000000. RThrouhputL1 = (RRXBitRateL1 / profile_capacity) * 100.0 RThrouhputL2 = (RRXBitRateL2 / profile_capacity) * 100.0 logging.info('%d: %d/%d/%d/%d' % (int(fsArray[idx + 1]), RRXBitRateL1, RRXBitRateL2, RThrouhputL1, RThrouhputL2)) # check for proper rate if (s1DiffRate < 100 and s2DiffRate < 100 and s1FrameRate > s1ExpFrameRate_fps and s2FrameRate > s2ExpFrameRate_fps): break logging.info('bad frame rate!') counter -= 1 print 'counter= ', counter if frameRate == 0: counter -= 1 time.sleep(5) ws.write(row, 3, (s1FrameRate), excelwriter.TEXT) ws.write(row, 4, round(LRXBitRateL1, 2), excelwriter.TEXT) ws.write(row, 5, round(LRXBitRateL2, 2), excelwriter.TEXT) ws.write(row, 6, round(LThrouhputL1, 2), excelwriter.TEXT) ws.write(row, 7, round(LThrouhputL2, 2), excelwriter.TEXT) ws.write(row + 1, 3, round(s2FrameRate, 2), excelwriter.TEXT) ws.write(row + 1, 4, round(RRXBitRateL1, 2), excelwriter.TEXT) ws.write(row + 1, 5, round(RRXBitRateL2, 2), excelwriter.TEXT) ws.write(row + 1, 6, round(RThrouhputL1, 2), excelwriter.TEXT) ws.write(row + 1, 7, round(RThrouhputL2, 2), excelwriter.TEXT) spirent.stop() # calculate new load and round it to integer s1Load = ((int(fsArray[idx]) + 20) * s1FrameRate * 8) / 1000000. s2Load = ((int(fsArray[idx + 1]) + 20) * s2FrameRate * 8) / 1000000. s1LoadReal = int((s1Load / 100.) * 80.0) s2LoadReal = int((s2Load / 100.) * 80.0) logging.info('setting stream1 load to %d%% of %d -> %d', 80.0, s1Load, s1LoadReal) logging.info('setting stream2 load to %d%% of %d -> %d', 80.0, s2Load, s2LoadReal) spirent.configGenerator(port1, {'FixedLoad': str(s1LoadReal)}) spirent.configGenerator(port2, {'FixedLoad': str(s2LoadReal)}) logging.info("applying spirent tc configuration") spirent.applySettings() spirent.start() time.sleep(5) spirent.clearAllTrafficCounters() # logging.info('started collecting counters for %d sec', testrig.config.testParams.testTime) time.sleep(5) results = spirent.getResults() for resultId in results: latency = float(results[resultId]['results']['AvgLatency']) jitter = float(results[resultId]['results']['MaxJitter']) droppedFrames = int(results[resultId]['results']['DroppedFrameCount']) if results[resultId]['parent'] == streamBlock1: ws.write(row, 8, round(latency, 2), excelwriter.TEXT) ws.write(row, 9, round(jitter, 2), excelwriter.TEXT) logging.info('%d = %.2f/%.2f/%d' % (int(fsArray[idx]), latency, jitter, droppedFrames)) if results[resultId]['parent'] == streamBlock2: ws.write(row + 1, 8, round(latency, 2), excelwriter.TEXT) ws.write(row + 1, 9, round(jitter, 2), excelwriter.TEXT) logging.info('%d = %.2f/%.2f/%d' % (int(fsArray[idx + 1]), latency, jitter, droppedFrames)) row += 2 spirent.stop() row += 1 # Spirent Calculation stops here # logging.info("Stopping spirent tc") spirent.cleanUp() # # saving results script_dir = os.path.dirname(os.path.abspath(__file__)) now = datetime.datetime.now() cur_time = now.strftime('%Y%m%d%H%M') result_file = script_dir + os.sep + 'results' + os.sep + cur_time + '_' + test_profile.__name__ + '.xls' logging.info('Writing results to %s' % (result_file)) wb.save(result_file) logging.info('Script execution time: %.1f s' % (time.time() - start_time)) logging.info('STOP %s, version %s' % (test_profile.__name__, VERSION))
def test_level3(testrig): '''main test function''' logging.info('START %s, version %s' % (test_level3.__name__, VERSION)) start_time = time.time() testrig.uut[0].discover_plugins() uut = testrig.uut[0] mb = testrig.uut[0].mb rac = testrig.uut[0].racx2[0] rac_if1 = rac.interface[0] rac_if2 = rac.interface[1] radio1 = rac_if1.radio # init Excel wb = excelwriter.ExcelWriter() # configure power meter config = [dict(testrig.config.items('powermeter'))[i] for i in ['kind', 'interface', 'address']] power_meter = PowerMeter.get_power_meter(config) power_meter.preset() power_meter.set_channel('A') power_meter.set_units('LG') power_meter.set_cal_factor(testrig.config.getfloat('powermeter', 'cal_factor')) power_meter.set_offset(testrig.config.getfloat('powermeter', 'offset')) power_meter.set_rel_mode(0) # configure attsw board config = dict(testrig.config.items('attswboard'))['address'] att_sw_board = AttSwBoard(config) # reset it att_sw_board.set_sw(1, 0) att_sw_board.set_att(1, 0) att_sw_board.set_att(2, 30) # radio configuration logging.info('configuring plugins ...') rac_tx_power_start = int(testrig.config.getfloat('test', 'tx_power_start_dbm') * 10) rac_tx_power_stop = int(testrig.config.getfloat('test', 'tx_power_stop_dbm') * 10) rac_tx_power_step = int(testrig.config.getfloat('test', 'tx_power_step_db') * 10) if rac_tx_power_step < radio1.stepTxPower: logging.warning('Selected Tx power step %d is too low. Setting to the minimum possible %d.' % (rac_tx_power_step, radio1.step_tx_power)) tx_freq = radio1.min_tx_freq_mhz + (radio1.max_tx_freq_mhz - radio1.min_tx_freq_mhz) / 2. tx_freq = float(testrig.config.get('test', 'tx_frequency_mhz')) if testrig.config.get('test', 'tx_frequency_mhz') else tx_freq txrx_spacing = float(testrig.config.getfloat('test', 'txrx_spacing_mhz')) if testrig.config.get('test', 'txrx_spacing_mhz') else radio1.txrx_spacing_mhz[0] rac_if1.set_frequency(tx_freq) rac_if1.set_spacing(txrx_spacing) rac_if2.set_frequency(rac_if1.get_rx_frequency()) rac_if2.set_spacing(txrx_spacing) rac_if1.set_tx_highpower_on() rac_if2.set_tx_highpower_on() rac_if1.set_modulation_mask('QPSK') rac_if2.set_modulation_mask('QPSK') rac_if1.set_tx_power(150) rac_if2.set_tx_power(150) rac_if1.set_tx_power_mute() rac_if2.set_tx_power_mute() mb.send('c t; line vty; exec-timeout 18000; end') logging.info("configuring gi and radio interfaces") mb.send('c t; set gvrp disable; set gmrp disable; shutdown garp; shutdown spanning-tree; end') radio_interfaces = ['gi 0/2', 'gi 0/3', 'radio 2/1', 'radio 2/2'] for interface in radio_interfaces: mb.send('c t; int ' + interface + '; no shu; map switch default; end') mb.send('c t; vlan 10; ports gi 0/2 radio 2/1 untagged radio 2/1; end') mb.send('c t; vlan 20; ports gi 0/3 radio 2/2 untagged radio 2/2; end') mb.send('c t; int gi 0/2; switchport pvid 10; end') mb.send('c t; int gi 0/3; switchport pvid 20; end') mb.send('c t; int radio 2/1; switchport pvid 10; no icf mode; end') mb.send('c t; int radio 2/2; switchport pvid 20; no icf mode; end') mb.send('c t; vlan 1; no ports; end') # fill out info about uut ws = wb.add_sheet('Info') mfg_info = mb.get_mfg_info() for i, line in enumerate(mfg_info): line = line.split(':') if len(line) == 2: ws.write(0 + i, 0, line[0].strip(), excelwriter.TEXT, excelwriter.FONT_BOLD) ws.write(0 + i, 1, line[1].strip()) # get RAC/ODU info rac_info = rac_if1.get_radio_capabilities() rac_info += rac_if2.get_radio_capabilities() for i, line in enumerate(rac_info): line = line.split(':') if len(line) == 2: ws.write(0 + i, 3, line[0].strip(), excelwriter.TEXT, excelwriter.FONT_BOLD) ws.write(0 + i, 4, line[1].strip()) logging.info("configuring spirent tc") spirent = Spirent(testrig.config.get('spirent', 'folder'), testrig.config.get('spirent', 'address')) spirent.initialization() # TODO: error check ports = testrig.config.get('spirent', 'ports').split(',') port1 = ports[0] port2 = ports[1] spirent.createProject() spirent.addPortToProject(port1) spirent.addPortToProject(port2) spirent.setResultMode({'ResultViewMode': 'LATENCY_JITTER'}) # stream for LB -> HB streamBlock1 = spirent.addStreamblock(port1, {'FixedFrameLength': 68}) ethernetFrame1 = spirent.addEthernetFrameOnStreamBlock(streamBlock1) spirent.addVlanOnEthernetFrame(ethernetFrame1, spirent.createVlanConfig(vlan_id='10')) # apply now. this is important step spirent.applySettings() spirent.subscribeToResults("project", "RxStreamSummaryResults") spirent.subscribeToResults(port1, "GeneratorPortResults") # configure generators/analyzers generatorConfig = {'LoadUnit': 'MEGABITS_PER_SECOND', 'FixedLoad': str(10)} spirent.configGenerator(port1, generatorConfig) spirent.configAnalyzer(port2) logging.info("applying spirent tc configuration") spirent.applySettings() # TODO: move to rac2x plugin logging.info("getting profile list") profile_list = rac.get_profile_list() if testrig.config.get('test', 'bandwidth_mhz'): bandwidth_list = testrig.config.get('test', 'bandwidth_mhz').split(',') profile_list_selected = [n for p in bandwidth_list for n in [str(int(p) + 100000), str(int(p) + 200000)] if n] else: profile_list_selected = profile_list if testrig.config.get('test', 'xpic').strip(): if testrig.config.getint('test', 'xpic'): profile_list_selected = [p for p in profile_list_selected if p.startswith('2')] profile_list = [p for p in profile_list if p.startswith('2')] else: profile_list_selected = [p for p in profile_list_selected if p.startswith('1')] profile_list = [p for p in profile_list if p.startswith('1')] if profile_list_selected: profile_list = list(set(profile_list).intersection(profile_list_selected)) profile_list = sorted(profile_list) logging.info('Selected profiles: %s' % (profile_list)) # create excel worksheet ws = wb.add_sheet('Results') ws.create_table_header(TABLE_HEADER, excelwriter.STYLE0) row = 1 # cycle tx powers tx_power = rac_tx_power_start while tx_power <= rac_tx_power_stop: logging.info('tx power -> %.2f' % (tx_power / 10.)) rac_if1.set_tx_power_override(tx_power) # cycle profiles for profile in profile_list: logging.info('profile -> %s' % (profile)) ws.write(row, 1, int(profile), excelwriter.TEXT) rac_if1.set_bandwidth(testrig.config.get('test', 'regulatory'), int(profile[-2:])) rac_if2.set_bandwidth(testrig.config.get('test', 'regulatory'), int(profile[-2:])) time.sleep(5) modulation_list = rac.get_subprofile_list(profile) modulation_list_selected = filter(None, testrig.config.get('test', 'modulation').split(',')) if modulation_list_selected: modulation_list = list(set(modulation_list).intersection(modulation_list_selected)) # for sort using modulation_list index modulation_list = sorted(modulation_list, key=lambda a: rac.modulation_list.index(a)) logging.info('Selected modulations: %s' % (modulation_list)) # cycle modulations for mod in modulation_list: start_test_time = time.time() logging.info('modulation -> %s' % (mod)) ws.write(row, 2, mod, excelwriter.TEXT) rac_if1.set_modulation_static(mod) rac_if2.set_modulation_static(mod) time.sleep(10) rac_if1.set_tx_power_unmute() # check rf link if not if_rf_link_up(rac): logging.error('Failed to set %s modulation.' % (mod)) row += 1 continue # one time attenuator calibration if tx_power == rac_tx_power_start and \ profile_list.index(profile) == 0 and \ modulation_list.index(mod) == 0: # calibrate one attenuator logging.info('setting rx level to -21dBm ...') tune_rsl(att_sw_board, power_meter, 2, -21.) logging.info('calibrating attenuator 1 ...') att_calibration_table = calibrate_attenuator(testrig, att_sw_board, power_meter, 1) if modulation_list.index(mod) == 0: logging.info('setting rx level to -50dBm ...') real_rsl = float(tune_rsl(att_sw_board, power_meter, 2, -50.)) else: logging.info('getting rx level from power meter ...') real_rsl = float(tune_rsl(att_sw_board, power_meter, 2, 0.)) rslB = rac_if2.get_avg_rsl(5) logging.info('rsl %.2f ~ %.2f measured rsl' % (float(rslB), float(real_rsl))) profile_capacity = (rac_if1.get_tx_capacity_mbps() * 90.) / 100. logging.info('setting spirent load to %d', profile_capacity) spirent.configGenerator(port1, {'LoadUnit': 'MEGABITS_PER_SECOND', 'FixedLoad': str(profile_capacity)}) spirent.applySettings() spirent.startGenerator(port1) time.sleep(10) ipber = find_ipber(att_sw_board, spirent, 1.E-3) astep = .8 atten = float(att_sw_board.get_att(1)) while True: # print '%5.2f (%.3f): ' % (float(atten), astep), start_test_time = time.time() spirent.clearAllTrafficCounters() time.sleep(5) while True: time.sleep(1) results = spirent.getResults() for resultId in results: if results[resultId]['parent'] == 'generator1': tx_frame_count = int(results[resultId]['results']['TotalFrameCount']) if results[resultId]['parent'] == 'streamblock1': dropped_frames = int(results[resultId]['results']['DroppedFrameCount']) rx_frame_count = int(results[resultId]['results']['FrameCount']) ipber = dropped_frames / (tx_frame_count * 8. * 68) elapsed_time = time.time() - start_test_time sys.stdout.write("\r %5.2f (%.3f): %d -> %d [%d] %.2e\t%ds " % (float(atten), astep, tx_frame_count, rx_frame_count, dropped_frames, ipber, elapsed_time)) if 1E-8 <= ipber and dropped_frames > 1000 and elapsed_time > 180: astep = .4 break if 1E-9 <= ipber <= 1E-8 and dropped_frames > 500: astep = .2 break if 1E-10 <= ipber <= 1E-9 and dropped_frames > 100: astep = .1 break if ipber <= 1E-10 and dropped_frames > 50: break print '' # reconnect if iss/klish interfaces are lost uut.check_interfaces() # reconnect if connection to att/sw board is lost att_sw_board.check() # att_value = att_sw_board.get_att(1) mrsl = real_rsl + get_real_atten_value(att_calibration_table, float(atten)) rsl = rac_if2.get_avg_rsl(10) snr = rac_if2.get_avg_snr(10) ldpc = rac_if2.get_ldpc_stress() # writing to excel ws.write(row, 3, tx_power / 10., excelwriter.NUM1) ws.write(row, 4, mrsl, excelwriter.NUM1) ws.write(row, 5, snr, excelwriter.NUM1) ws.write(row, 6, ldpc, excelwriter.NUM2) ws.write(row, 7, ipber, excelwriter.NUM2) ws.write(row, 8, tx_frame_count, excelwriter.NUM0) ws.write(row, 9, tx_frame_count, excelwriter.NUM0) ws.write(row, 10, dropped_frames, excelwriter.NUM0) ws.write(row, 11, elapsed_time, excelwriter.NUM0) logging.info('ipber/mrsl/rsl/snr/ldpc = %.2e %.2f %.2f %.2f %.2e'\ % (ipber, mrsl, rsl, snr, ldpc)) row += 1 if ipber < 1E-10: break att_sw_board.set_att_fade(1, atten - astep, 100) atten = atten - astep atten = 0 if atten < 0 else atten # spirent.stop() att_sw_board.set_att_fade(1, 0) print '' row += 1 # disable power override before setting new profile # rac_if1.set_tx_power_override_disable() # empty line b/w tx powers row += 1 # before setting new profile rac_if1.set_tx_power_mute() # empty line b/w profiles row += 1 tx_power += rac_tx_power_step # stopping spirent logging.info("stopping spirent tc") spirent.cleanUp() # finally save result file script_dir = os.path.dirname(os.path.abspath(__file__)) now = datetime.datetime.now() cur_time = now.strftime('%Y%m%d%H%M') result_file = script_dir + os.sep + 'results' + os.sep + cur_time + '_' + test_level3.__name__ + '.xls' logging.info('writing results to %s' % (result_file)) wb.save(result_file) logging.info('script execution time: %.1f s' % (time.time() - start_time)) logging.info('STOP %s, version %s' % (test_level3.__name__, VERSION))
def test_level0(testrig): '''main test function''' logging.info('START %s, version %s' % (test_level0.__name__, VERSION)) start_time = time.time() testrig.uut[0].discover_plugins() mb = testrig.uut[0].mb rac = testrig.uut[0].racx2[0] rac_if1 = rac.interface[0] rac_if2 = rac.interface[1] radio1 = rac_if1.radio # init Excel wb = excelwriter.ExcelWriter(2) # configure attsw board config = dict(testrig.config.items('attswboard'))['address'] att_sw_board = AttSwBoard(config) att_sw_board.set_att(2, 0) # radio configuration logging.info('configuring plugins ...') rac_tx_power_start = int( testrig.config.getfloat('test', 'tx_power_start_dbm') * 10) rac_tx_power_stop = int( testrig.config.getfloat('test', 'tx_power_stop_dbm') * 10) rac_tx_power_step = int( testrig.config.getfloat('test', 'tx_power_step_db') * 10) if rac_tx_power_step < radio1.stepTxPower: logging.warning( 'Selected Tx power step %d is too low. Setting to the minimum possible %d.' % (rac_tx_power_step, radio1.step_tx_power)) tx_freq = radio1.min_tx_freq_mhz + (radio1.max_tx_freq_mhz - radio1.min_tx_freq_mhz) / 2. tx_freq = float(testrig.config.get( 'test', 'tx_frequency_mhz')) if testrig.config.get( 'test', 'tx_frequency_mhz') else tx_freq txrx_spacing = float(testrig.config.getfloat( 'test', 'txrx_spacing_mhz')) if testrig.config.get( 'test', 'txrx_spacing_mhz') else radio1.txrx_spacing_mhz[0] rac_if1.set_frequency(tx_freq) rac_if1.set_spacing(txrx_spacing) rac_if2.set_frequency(rac_if1.get_rx_frequency()) rac_if2.set_spacing(txrx_spacing) rac_if1.set_tx_highpower_on() rac_if2.set_tx_highpower_on() rac_if1.set_modulation_mask('QPSK') rac_if2.set_modulation_mask('QPSK') rac_if1.set_tx_power(150) rac_if2.set_tx_power(150) rac_if1.set_tx_power_unmute() rac_if2.set_tx_power_unmute() # fill out info about the uut ws = wb.add_sheet('Info') mfg_info = mb.get_mfg_info() for i, line in enumerate(mfg_info): line = line.split(':') if len(line) == 2: ws.write(0 + i, 0, line[0].strip(), excelwriter.TEXT, excelwriter.FONT_BOLD) ws.write(0 + i, 1, line[1].strip()) # get RAC/ODU info rac_info = rac_if1.get_radio_capabilities() rac_info += rac_if2.get_radio_capabilities() for i, line in enumerate(rac_info): line = line.split(':') if len(line) == 2: ws.write(0 + i, 3, line[0].strip(), excelwriter.TEXT, excelwriter.FONT_BOLD) ws.write(0 + i, 4, line[1].strip()) # TODO: move to rac2x plugin logging.info("getting profile list") profile_list = rac.get_profile_list() if testrig.config.get('test', 'bandwidth_mhz'): bandwidth_list = testrig.config.get('test', 'bandwidth_mhz').split(',') profile_list_selected = [ n for p in bandwidth_list for n in [str(int(p) + 100000), str(int(p) + 200000)] if n ] else: profile_list_selected = profile_list if testrig.config.get('test', 'xpic').strip(): if testrig.config.getint('test', 'xpic'): profile_list_selected = [ p for p in profile_list_selected if p.startswith('2') ] profile_list = [p for p in profile_list if p.startswith('2')] else: profile_list_selected = [ p for p in profile_list_selected if p.startswith('1') ] profile_list = [p for p in profile_list if p.startswith('1')] if profile_list_selected: profile_list = list( set(profile_list).intersection(profile_list_selected)) profile_list = sorted(profile_list) logging.info('Selected profiles: %s' % (profile_list)) row = 2 # cycle tx powers tx_power = rac_tx_power_start while tx_power <= rac_tx_power_stop: logging.info('tx power -> %.2f' % (tx_power / 10.)) # create excel worksheet ws = wb.add_sheet(str(tx_power / 10.)) ws.create_table_header(TABLE_HEADER, excelwriter.STYLE0) rac_if1.set_tx_power_override(tx_power) rac_if2.set_tx_power_override(tx_power) ws.write(row, 3, tx_power / 10., excelwriter.NUM1) ws.write(row, 4, tx_power / 10., excelwriter.NUM1) # cycle profiles for profile in profile_list: logging.info('profile -> %s' % (profile)) ws.write(row, 1, int(profile), excelwriter.TEXT) # rac_if1.set_tx_power_mute() # rac_if2.set_tx_power_mute() rac_if1.set_bandwidth(testrig.config.get('test', 'regulatory'), int(profile[-2:])) rac_if2.set_bandwidth(testrig.config.get('test', 'regulatory'), int(profile[-2:])) time.sleep(5) modulation_list = rac.get_subprofile_list(profile) modulation_list_selected = filter( None, testrig.config.get('test', 'modulation').split(',')) if modulation_list_selected: modulation_list = list( set(modulation_list).intersection( modulation_list_selected)) # for sort using modulation_list index modulation_list = sorted( modulation_list, key=lambda a: rac.modulation_list.index(a)) logging.info('Selected modulations: %s' % (modulation_list)) # cycle modulations for mod in modulation_list: start_test_time = time.time() logging.info('modulation -> %s' % (mod)) ws.write(row, 2, mod, excelwriter.TEXT) rac_if1.set_modulation_static(mod) rac_if2.set_modulation_static(mod) time.sleep(10) # rac_if1.set_tx_power_unmute() # rac_if2.set_tx_power_unmute() for atten in range(0, 80, 1): att_sw_board.set_att_fade(2, atten, 100) logging.info(atten) if rac_if1.get_snr() == 0 and rac_if2.get_snr() == 0: if atten > 50.: break continue for i in range(0, 2): snr = vars()['rac_if' + str(i + 1)].get_avg_snr(5, .1) rsl = vars()['rac_if' + str(i + 1)].get_avg_rsl(5, .1) ber = vars()['rac_if' + str(i + 1)].get_avg_ber(5, .1) ldpc = vars()['rac_if' + str(i + 1)].get_ldpc_stress( 5, .01) logging.info('rsl/snr/ber/ldpc = %d:%.2f %.2f %.2e %.2e' % \ (i + 1, rsl, snr, ber, ldpc)) # writing to excel ws.write(row, 5 + i, rsl, excelwriter.NUM1) ws.write(row, 7 + i, snr, excelwriter.NUM1) ws.write(row, 9 + i, ber, excelwriter.NUM2, \ excelwriter.FONT_GREEN if ber == 0 else excelwriter.FONT_RED) ws.write(row, 11 + i, ldpc, excelwriter.NUM2) ws.write(row, 13, time.time() - start_test_time, excelwriter.NUM0) row += 1 att_sw_board.set_att(2, 0) time.sleep(3) print '' row += 1 # disable power override before setting new profile # rac_if1.set_tx_power_override_disable() # empty line b/w tx powers row += 1 # empty line b/w profiles row += 1 tx_power += rac_tx_power_step # finally save result file script_dir = os.path.dirname(os.path.abspath(__file__)) now = datetime.datetime.now() cur_time = now.strftime('%Y%m%d%H%M') result_file = script_dir + os.sep + 'results' + os.sep + cur_time + '_' + test_level0.__name__ + '.xls' logging.info('writing results to %s' % (result_file)) wb.save(result_file) logging.info('script execution time: %.1f s' % (time.time() - start_time)) logging.info('STOP %s, version %s' % (test_level0.__name__, VERSION))
def test_profile(testrig): '''main test function''' logging.info('START %s, version %s' % (test_profile.__name__, VERSION)) start_time = time.time() # # get nodes node1 = testrig.nodes['node1'] node2 = testrig.nodes['node2'] cli1 = node1.interface['cli'] cli2 = node2.interface['cli'] rac1 = node1.plugin[2] rac2 = node2.plugin[2] rac1_if = rac1.interface[1] rac2_if = rac2.interface[1] # TOPOLOGY CREATION # # create initial rf link cli1.send('c t; int gi 0/1; spanning-tree disable; end') cli2.send('c t; int gi 0/1; spanning-tree disable; end') radio_link.configure_unprotected_radio_link('rf1', testrig) # # create ethernet connections eth_connection.configure_connection('eth1', testrig) eth_connection.configure_connection('eth2', testrig) vlan.configure_vlan('vlan1', testrig) spirent = testrig.devices['spirent'] # TEST FLOW config_section = testrig.config['config'] # # create Excel writer instance wb = excelwriter.ExcelWriter() # # fill out info work sheet about nodes ws = wb.add_sheet('Info') for i, node in enumerate((node1, node2)): mfg_info = node.plugin[0].get_mfg_info().split('\n') ws.write(0, 0 + 2 * i, node.plugin[0].get_sw_version(), excelwriter.TEXT, excelwriter.FONT_BOLD) for j, line in enumerate(mfg_info): line = line.split(' : ') if len(line) == 2: ws.write(1 + j, 0 + 2 * i, line[0].strip(), excelwriter.TEXT, excelwriter.FONT_BOLD) ws.write(1 + j, 1 + 2 * i, line[1].strip()) # # get RAC/ODU info rac_info = '' for rac_if in (rac1_if, rac2_if): rac_info = rac_if.get_radio_capabilities().split('\n') for i, line in enumerate(rac_info): line = line.split(' ') if len(line) == 2: ws.write(0 + i, 5, line[0].strip(), excelwriter.TEXT, excelwriter.FONT_BOLD) ws.write(0 + i, 6, line[1].strip()) if len(line) == 1: ws.write(0 + i, 6, line[0].strip()) # # configure spirent tc logging.info("Configuring spirent tc") port1, port2 = [port for port in spirent.ports.keys()] spirent.setResultMode({'ResultViewMode': 'LATENCY_JITTER'}) # # stream node1 -> node2 streamBlock1 = spirent.addStreamblock( port1, { 'FixedFrameLength': config_section['traffic'].as_int('frame_size_bytes'), 'FillType': 'PRBS' }) spirent.addEthernetFrameOnStreamBlock(streamBlock1, { 'srcMac': '00:00:00:00:00:01', 'dstMac': '00:00:00:00:00:02' }) # spirent.addVlanOnEthernetFrame(ethernetFrame1, spirent.createVlanConfig(vlan_id = testrig.topology['vlan1']['id'])) # # stream node2 -> node1 streamBlock2 = spirent.addStreamblock( port2, { 'FixedFrameLength': config_section['traffic'].as_int('frame_size_bytes'), 'FillType': 'PRBS' }) spirent.addEthernetFrameOnStreamBlock(streamBlock2, { 'srcMac': '00:00:00:00:00:02', 'dstMac': '00:00:00:00:00:01' }) # spirent.addVlanOnEthernetFrame(ethernetFrame2, spirent.createVlanConfig(vlan_id = testrig.topology['vlan1']['id'])) # # apply settings now. this is important step spirent.applySettings() spirent.subscribeToResults("project", "RxStreamSummaryResults") spirent.subscribeToResults(port1, "GeneratorPortResults") spirent.subscribeToResults(port2, "GeneratorPortResults") # # configure generators/analyzers generatorConfig = {'LoadUnit': 'MEGABITS_PER_SECOND', 'FixedLoad': str(10)} spirent.configGenerator(port1, generatorConfig) spirent.configGenerator(port2, generatorConfig) spirent.configAnalyzer(port1) spirent.configAnalyzer(port2) logging.info("Applying spirent tc configuration") spirent.applySettings() spirent.start() # # create excel worksheet for results ws = wb.add_sheet('Results') ws.create_table_header(TABLE_HEADER, excelwriter.STYLE0) row = 2 # # set tx power tx_power = config_section['rf'].as_float('tx_power') logging.info('Setting tx power to %.1f' % (tx_power)) rac1_if.set_tx_power(tx_power) rac2_if.set_tx_power(tx_power) # # cycle profiles profile_list = radio_link.get_bandwidth_list(rac1, testrig) for profile in profile_list: logging.info('Setting profile to %s' % (profile)) ws.write(row, 1, int(profile), excelwriter.TEXT) rac1_if.set_bandwidth(config_section['profile']['regulatory'], int(profile[-2:])) rac2_if.set_bandwidth(config_section['profile']['regulatory'], int(profile[-2:])) time.sleep(5) # # cycle modulations modulation_list = radio_link.get_modulation_list( profile, rac1, testrig) for mod in modulation_list: start_test_time = time.time() logging.info('Setting modulation to %s' % (mod)) ws.write(row, 2, mod, excelwriter.TEXT) rac1_if.set_modulation_fixed(mod) rac2_if.set_modulation_fixed(mod) time.sleep(5) # # check rf link and alarms logging.info('Checking if modems locked up.') retries = 10 while retries: status1 = ['Not Locked', 'Locked'][rac1_if.get_modem_status()] status2 = ['Not Locked', 'Locked'][rac2_if.get_modem_status()] logging.info('%2d: Modem status 1:%s, 2:%s' % (retries, status1, status2)) if status1 == status2 == 'Locked': break retries -= 1 time.sleep(3) if retries == 0: logging.error('Failed to set %s modulation.' % (mod)) row += 1 continue # give enough time for alarms to settle down time.sleep(10) logging.info('Checking for alarms.') found_alarms = False for plugin in (rac1_if, rac2_if, rac1_if.radio, rac2_if.radio): print plugin alarms = plugin.get_alarms() for severity in alarms.keys(): if alarms[severity]: print severity, ' - ', alarms[severity] # critical(3) or major(4) if severity in (3, 4): found_alarms = True if found_alarms: logging.error( 'Found Critical or Major alarms. Skipping this profile.') row += 1 continue logging.error('No Critical or Major alarms found.') # # get profile capacity per current profile profile_capacity = ( rac1_if.get_tx_capacity_mbps() * config_section['traffic'].as_float('max_capacity_rate')) / 100. logging.info('Setting spirent load to %f' % (profile_capacity)) spirent.configGenerator( port1, { 'LoadUnit': 'MEGABITS_PER_SECOND', 'FixedLoad': str(profile_capacity) }) spirent.configGenerator( port2, { 'LoadUnit': 'MEGABITS_PER_SECOND', 'FixedLoad': str(profile_capacity) }) spirent.applySettings() # spirent.start() time.sleep(10) spirent.clearAllTrafficCounters() time.sleep(config_section['traffic'].as_int('traffic_time_sec')) results = spirent.getResults() for resultId in results: if results[resultId]['parent'] == 'generator1': tx_frame_count1 = int( results[resultId]['results']['TotalFrameCount']) if results[resultId]['parent'] == 'generator2': tx_frame_count2 = int( results[resultId]['results']['TotalFrameCount']) if results[resultId]['parent'] == 'streamblock1': dropped_frames1 = int( results[resultId]['results']['DroppedFrameCount']) # rx_frame_count1 = int(results[resultId]['results']['FrameCount']) if results[resultId]['parent'] == 'streamblock2': dropped_frames2 = int( results[resultId]['results']['DroppedFrameCount']) # rx_frame_count2 = int(results[resultId]['results']['FrameCount']) ipber = (dropped_frames1 / (tx_frame_count1 * 8. * config_section['traffic'].as_int('frame_size_bytes')), \ dropped_frames2 / (tx_frame_count2 * 8. * config_section['traffic'].as_int('frame_size_bytes'))) power = (rac1_if.get_tx_power(), rac2_if.get_tx_power()) rsl = (rac1_if.get_avg_rsl(10), rac2_if.get_avg_rsl(10)) snr = (rac1_if.get_avg_snr(10), rac2_if.get_avg_snr(10)) ldpc = (rac1_if.get_ldpc_stress(), rac2_if.get_ldpc_stress()) ber = (rac1_if.get_ber(), rac2_if.get_ber()) # # writing to excel for i in range(0, 2): ws.write( row, 3 + i, power[i], excelwriter.NUM1, excelwriter.FONT_GREEN if (abs(power[i] - tx_power) < 1.) else excelwriter.FONT_RED) ws.write(row, 5 + i, rsl[i], excelwriter.NUM1) ws.write(row, 7 + i, snr[i], excelwriter.NUM1, \ excelwriter.FONT_GREEN if (snr[i] > 32.) else excelwriter.FONT_RED) ws.write(row, 9 + i, ber[i], excelwriter.NUM2, \ excelwriter.FONT_GREEN if (ber[i] == 0) else excelwriter.FONT_RED) ws.write(row, 11 + i, ldpc[i], excelwriter.NUM2) ws.write(row, 13 + i, ipber[i], excelwriter.NUM2, \ excelwriter.FONT_GREEN if (ipber[i] == 0) else excelwriter.FONT_RED) logging.info('%d: txpower/rsl/snr/ber/ldpc/ipber = %.2f %.2f %.2f %.2e %.2e %.2e' % \ (i + 1, power[i], rsl[i], snr[i], ber[i], ldpc[i], ipber[i])) ws.write(row, 15, time.time() - start_test_time, excelwriter.NUM0) row += 1 # # empty line b/w tx powers row += 1 # # empty line b/w profiles row += 1 # # stop spirent spirent.stop() logging.info("Stopping spirent tc") spirent.cleanUp() # CONFIGURATION ROLLBACK vlan.delete_vlan('vlan1', testrig) # RESULT WRITER # # saving results script_dir = os.path.dirname(os.path.abspath(__file__)) now = datetime.datetime.now() cur_time = now.strftime('%Y%m%d%H%M') result_file = script_dir + os.sep + 'results' + os.sep + cur_time + '_' + test_profile.__name__ + '.xls' logging.info('Writing results to %s' % (result_file)) wb.save(result_file) logging.info('Script execution time: %.1f s' % (time.time() - start_time)) logging.info('STOP %s, version %s' % (test_profile.__name__, VERSION))
def test_level1(testrig): '''main test function''' logging.info('START %s, version %s' % (test_level1.__name__, VERSION)) start_time = time.time() testrig.uut[0].discover_plugins() mb = testrig.uut[0].mb rac = testrig.uut[0].racx2[0] rac_if1 = rac.interface[0] rac_if2 = rac.interface[1] radio1 = rac_if1.radio # init Excel wb = excelwriter.ExcelWriter() # radio configuration logging.info('configuring plugins ...') rac_tx_power_start = int( testrig.config.getfloat('test', 'tx_power_start_dbm') * 10) rac_tx_power_stop = int( testrig.config.getfloat('test', 'tx_power_stop_dbm') * 10) rac_tx_power_step = int( testrig.config.getfloat('test', 'tx_power_step_db') * 10) if rac_tx_power_step < radio1.stepTxPower: logging.warning( 'Selected Tx power step %d is too low. Setting to the minimum possible %d.' % (rac_tx_power_step, radio1.step_tx_power)) tx_freq = radio1.min_tx_freq_mhz + (radio1.max_tx_freq_mhz - radio1.min_tx_freq_mhz) / 2. tx_freq = float(testrig.config.get( 'test', 'tx_frequency_mhz')) if testrig.config.get( 'test', 'tx_frequency_mhz') else tx_freq txrx_spacing = float(testrig.config.getfloat( 'test', 'txrx_spacing_mhz')) if testrig.config.get( 'test', 'txrx_spacing_mhz') else radio1.txrx_spacing_mhz[0] rac_if1.set_frequency(tx_freq) rac_if1.set_spacing(txrx_spacing) rac_if2.set_frequency(rac_if1.get_rx_frequency()) rac_if2.set_spacing(txrx_spacing) rac_if1.set_tx_highpower_on() rac_if2.set_tx_highpower_on() rac_if1.set_modulation_mask('QPSK') rac_if1.set_modulation_mask('QPSK') rac_if1.set_tx_power(150) rac_if2.set_tx_power(150) rac_if1.set_tx_power_unmute() rac_if2.set_tx_power_unmute() # fill out info about uut ws = wb.add_sheet('Info') mfg_info = mb.get_mfg_info() for i, line in enumerate(mfg_info): line = line.split(':') if len(line) == 2: ws.write(0 + i, 0, line[0].strip(), excelwriter.TEXT, excelwriter.FONT_BOLD) ws.write(0 + i, 1, line[1].strip()) # get RAC/ODU info rac_info = rac_if1.get_radio_capabilities() rac_info += rac_if2.get_radio_capabilities() for i, line in enumerate(rac_info): line = line.split(':') if len(line) == 2: ws.write(0 + i, 3, line[0].strip(), excelwriter.TEXT, excelwriter.FONT_BOLD) ws.write(0 + i, 4, line[1].strip()) # TODO: move to rac2x plugin profile_list = rac.get_profile_list() if testrig.config.get('test', 'bandwidth_mhz'): bandwidth_list = testrig.config.get('test', 'bandwidth_mhz').split(',') profile_list_selected = [ n for p in bandwidth_list for n in [str(int(p) + 100000), str(int(p) + 200000)] if n ] else: profile_list_selected = profile_list if testrig.config.get('test', 'xpic').strip(): if testrig.config.getint('test', 'xpic'): profile_list_selected = [ p for p in profile_list_selected if p.startswith('2') ] profile_list = [p for p in profile_list if p.startswith('2')] else: profile_list_selected = [ p for p in profile_list_selected if p.startswith('1') ] profile_list = [p for p in profile_list if p.startswith('1')] if profile_list_selected: profile_list = list( set(profile_list).intersection(profile_list_selected)) logging.info('Selected profiles: %s' % (profile_list)) # create excel worksheet ws = wb.add_sheet('Results') ws.create_table_header(TABLE_HEADER, excelwriter.STYLE0) row = 2 # cycle profiles for profile in sorted(profile_list): logging.info('profile -> %s' % (profile)) ws.write(row, 1, int(profile), excelwriter.TEXT) rac_if1.set_bandwidth(testrig.config.get('test', 'regulatory'), int(profile[-2:])) rac_if2.set_bandwidth(testrig.config.get('test', 'regulatory'), int(profile[-2:])) time.sleep(5) modulation_list = rac.get_subprofile_list(profile) modulation_list_selected = filter( None, testrig.config.get('test', 'modulation').split(',')) if modulation_list_selected: modulation_list = list( set(modulation_list).intersection(modulation_list_selected)) # for sort using modulation_list index modulation_list = sorted(modulation_list, key=lambda a: rac.modulation_list.index(a)) logging.info('Selected modulations: %s' % (modulation_list)) # cycle modulations for mod in modulation_list: logging.info('modulation -> %s' % (mod)) ws.write(row, 2, mod, excelwriter.TEXT) rac_if1.set_modulation_static(mod) rac_if2.set_modulation_static(mod) time.sleep(10) # check rf link if not if_rf_link_up(rac): logging.error('Failed to set %s modulation.' % (mod)) row += 1 continue current_modulation = rac_if1.get_modulation() logging.info('1: Tx/Rx ACM Profiles = %s/%s' % (current_modulation[0], current_modulation[1])) current_modulation = rac_if2.get_modulation() logging.info('2: Tx/Rx ACM Profiles = %s/%s' % (current_modulation[0], current_modulation[1])) # measure loopback snr only once per profile if asked if testrig.config.getint( 'test', 'loopback_test') and modulation_list.index(mod) == 0: rac_if1.enable_loopback() rac_if2.enable_loopback() time.sleep(10) snrA = rac_if1.get_avg_snr(5) snrB = rac_if2.get_avg_snr(5) print '{0:>8} {1:>8} {2:>8}'.format('lb snr:', snrA, snrB) # write to result file ws.write(row, 11, snrA, excelwriter.NUM1) ws.write(row, 12, snrB, excelwriter.NUM1) rac_if1.disable_loopback() rac_if2.disable_loopback() time.sleep(5) # cycle tx powers tx_power = rac_tx_power_start while tx_power <= rac_tx_power_stop: # TODO: do handle alarms rac_if1.set_tx_power_override(tx_power) rac_if2.set_tx_power_override(tx_power) # rac_if1.set_tx_power(tx_power) # rac_if2.set_tx_power(tx_power) time.sleep(15) txpowerA = rac_if1.get_tx_power() txpowerB = rac_if2.get_tx_power() rslA = rac_if1.get_avg_rsl(5) rslB = rac_if2.get_avg_rsl(5) snrA = rac_if1.get_avg_snr(5) snrB = rac_if2.get_avg_snr(5) ldpcA = rac_if1.get_ldpc_stress(10) ldpcB = rac_if2.get_ldpc_stress(10) # write to console print '{0:>8} {1:>8} {2:>8}'.format('ch:', 'A', 'B') print '{0:>8} {1:>8} {2:>8}'.format('txpower:', txpowerA, txpowerB) print '{0:>8} {1:>8} {2:>8}'.format('rsl:', rslA, rslB) print '{0:>8} {1:>8} {2:>8}'.format('snr:', snrA, snrB) print '{0:>8} {1:>8.2e} {2:>8.2e}'.format( 'ldpc:', ldpcA, ldpcB) print '' # write to result file ws.write(row, 3, txpowerA, excelwriter.NUM1) ws.write(row, 4, txpowerB, excelwriter.NUM1) ws.write(row, 5, rslA, excelwriter.NUM1) ws.write(row, 6, rslB, excelwriter.NUM1) ws.write(row, 7, snrA, excelwriter.NUM1) ws.write(row, 8, snrB, excelwriter.NUM1) ws.write(row, 9, ldpcA, excelwriter.NUM2) ws.write(row, 10, ldpcB, excelwriter.NUM2) tx_power += rac_tx_power_step row += 1 # disable power override before setting new profile rac_if1.set_tx_power_override_disable() rac_if2.set_tx_power_override_disable() time.sleep(1) logging.debug('%s %s' % (rac_if1.get_tx_power(), rac_if2.get_tx_power())) row += 1 # finally save result file script_dir = os.path.dirname(os.path.abspath(__file__)) now = datetime.datetime.now() cur_time = now.strftime('%Y%m%d%H%M') result_file = script_dir + os.sep + 'results' + os.sep + cur_time + '_' + test_level1.__name__ + '.xls' logging.info('writing results to %s' % (result_file)) wb.save(result_file) logging.info('script execution time: %.1f s' % (time.time() - start_time)) logging.info('STOP %s, version %s' % (test_level1.__name__, VERSION))