示例#1
0
def check_sw_vers(swpack, ctrip):
    
    wg1 = webgui(ctrip, 'Firefox')
    wg1.webgui_logon()
    wg1.webgui_set_page("System Configuration", "Software Management", "Admin")
    check = wg1.webgui_sw_vers_match(swpack)
    wg1.webgui_logoff()
    wg1.webgui_close_connection()
    
    return check
示例#2
0
def check_alarms(ctrip):
   
    logging.info('Capturing alarms via the webgui')
    wg = webgui(ctrip, 'Firefox')
    wg.webgui_logon()
    time.sleep(5)
    wg.webgui_set_page("Status", "Alarms")
    time.sleep(5)
    alarms = wg.webgui_alarm_get_list()
    wg.webgui_logoff()
    wg.webgui_close_connection()
    
    return alarms
示例#3
0
    def set_web_rf_path(self, rfconf, prot):
        ## sets the rf path
        # @param: rfconf(dict) - the dictionary of all rfpaths
        # @param: prot(boolean) - true if its a protection setting

        logging.info("Setting all RF paths via the CSR Portal")
        for p in rfconf.keys():
            logging.info("Setting up Tx High side of radio Link")
            webgui1 = webgui(self.get_web_ip(rfconf[p]['txrx'][0]), 'Firefox')
            webgui1.webgui_rf_set_radio_link(
                rfconf[p], "high"
            )  # the rest of the work is done on the ctr8500_webgui.py
            webgui1.webgui_close_connection()
            logging.info("Setting up Tx Low side of radio Link")
            webgui2 = webgui(self.get_web_ip(rfconf[p]['txrx'][1]), 'Firefox')
            webgui2.webgui_rf_set_radio_link(
                rfconf[p],
                "low")  # the rest of the work is done on the ctr8500_webgui.py
            webgui2.webgui_close_connection()

        # put protection stuff here
        if prot:
            logging.info("Protection setup still needs to be implemented")
示例#4
0
def set_pwrlvl(ctr, ptype):

    wg = webgui(ctr.ipaddress, 'Firefox')
    wg.webgui_logon()
    time.sleep(5)
    wg.webgui_set_page('Radio Configuration', 'Radio Link Configuration')
    time.sleep(5)
    if ptype == 'max':
        pwrset = wg.webgui_rf_get_pwr_range()[1]
    elif ptype == 'min':
        pwrset = wg.webgui_rf_get_pwr_range()[0]
    else:
        wg.webgui_rf_set_high_power(True)
        wg.webgui_apply()
        time.sleep(5)
        pwrset = wg.webgui_rf_get_pwr_range()[1]
    wg.webgui_rf_apply_tx_power(pwrset)
    time.sleep(5)
    wg.webgui_logoff()
    wg.webgui_close_connection()

    return pwrset
示例#5
0
def test_template():
    
    # ========== Testrig and Testscript Initialization ==========
    # Initiate Testrig object - this handles all testrig objects as well as Topology and Config setup
    
    rig = TestRig("DVTA-CT-4", "T008.ini", "C001.ini", developmentrig, False)  # testcase ID, topology filename, config filename, developmentrig and Initialization Requirement
    
    # simple path to each of the Nodes (remove the ones that aren't needed)
    ctr1 = rig.nodes['node1']
    
    # simple path to each of the Test Equipment ((remove the ones that aren't needed)
    ss = rig.devices['SPIRENT']
    
    # logging - start of test script and other basic info
    start_sw_version = ctr1.get_sw_version()
    start_time = time.time()
    logging.info('START %s, version %s' % (test_template.__name__, VERSION))
    logging.info('Current Software Build installed = %s' % (start_sw_version))
    
    # Results - xml or excel writer (REMOVE ONE)
    results = xmlwriter("DVTA-CT-4", "T008", "Verify the date & time management features")  # testcase ID, Topology Used, Test Case Description
    
    # Initialize the required libraries
    util = utils()

    ## ========== Pre-Flow setup and checks ==========
    # Carry out all of the basic setup here which is not testable items
    
    # log the software pack to be used
    test_sw_dir = "C:/swpacks/"  # the desired test sw dir
    test_sw_vers = os.listdir(test_sw_dir)[0]  # the desired swpack
    logging.info('Current Cycle Software to be tested = %s' % (test_sw_vers))
    
    # Initialize Webgui
    wg = webgui(ctr1.ipaddress, 'Firefox')
    wg.webgui_logon()
    
    # establish a starting list of alarms and check to ensure there are no Critical alarms
    startalarms = check_alarms(wg)
    print_alarms(startalarms) 
    
    # check that we have a working rf link by passing 10sec of traffic and ensure no dropped frames check up to 3 times
    if ss.simspr_line_check('3/9', '3/10'):  # use correct ports for this
        logging.info('Spirent connection confirmed ... continuing with test script')
    else:
        # if no RF link stop script
        logging.error('Spirent connection has not been established correctly after 3 attempts.')
        end_script('error', results, rig, start_time, wg, ss)
            
    # Start a spirent outage run for outage capture    
    ss.simspir_start_outage_run('3/9', '3/10')
    logging.info('Starting Spirent Traffic for outage capture')
    
    # Check that the current software version is loaded, if not, load it.
    curr_sw_version = util.format_SWpack_str(start_sw_version)
    if not os.path.exists(os.path.join(test_sw_dir, curr_sw_version)):
        logging.info("Currently loaded Software Pack is %s. Loading the latest test build - %s." % (curr_sw_version, test_sw_vers))
        swpack = load_SWpack(os.path.join(test_sw_vers), wg)
        if swpack[0] and swpack[2]:
            # Successful downgrade - send results and clear spirent counters
            results.set_verify("LOG", util.gframe(), "%s has been upgraded to the latest test build %s" % (ctr1.name, test_sw_vers))
            results.set_verify("LOG", util.gframe(), 'RF Outage during downgrade was %s milliseconds' % str(ss.simspir_get_value_outage_run()[0]))
        else:
            # Unsuccessful downgrade - send results and end script safely
            results.set_verify("ERROR", util.gframe(), "%s has NOT been upgraded to the latest test build %s for unknown reasons" % (ctr1.name, test_sw_vers))
            end_script('error', results, rig, start_time, wg, ss)
    
    wg.webgui_logoff()
    wg.webgui_close_connection()
    
    ## ========== Test step flow ==========
    
    ## ========== Step 1 ========== 
    # Check that the currently set time is what is displayed
    logging.info("STEP 1 - Check that the currently set time is what is displayed")
    
    # go to the date time page
    wg = webgui(ctr1.ipaddress, 'Firefox')
    wg.webgui_logon()
    wg.webgui_set_page("System Configuration", "Date & Time")
    time.sleep(5)

    # ensure we are set to SNTP settings to get Network Time
    if wg.webgui_datetime_get_clock_source() != "SNTP":
        wg.webgui_datetime_set_clock_source("SNTP")
        wg.webgui_apply()
        time.sleep(30)
    
    # get the currently set system time and the displayed time for comparison
    systime = time.localtime()
    displaydt = wg.webgui_datetime_get_all_info()
    
    # capture date info
    scriptdate = time.strftime("%d %m %Y", systime)
    displaydate = time.strftime("%d %m %Y", displaydt['date'])
    
    # capture time info
    scripttime = time.strftime("%H:%M", systime)
    dtime = displaydt['time']
    displaytime = str(dtime[0]) + ":" + str(dtime[1]) 
    
    if scriptdate == displaydate:
        if scripttime == displaytime:
            # SNTP time matches system time as expected - send results and clear spirent counters
            results.set_verify("PASS", util.gframe(), "System Time and Set SNTP Time match as expected")
        else:
            results.set_verify("FAIL", util.gframe(), "System Time and Set SNTP Time do not match")
    else:
        # Unsuccessful test condition - send results and end script safely
        results.set_verify("FAIL", util.gframe(), "System Date and Set SNTP Date do not match")
    
    # check alarms on webgui (assumes webgui is open)  

    currentalarms = check_alarms(wg)
    if startalarms != currentalarms:
        print_alarms(currentalarms)
    
    ## ========== Step 2 ========== 
    # Change Date and check that it is displayed correctly
    logging.info("STEP 2 - Change Date and check that it is displayed correctly")
    
    # go to the date time page
    wg.webgui_set_page("System Configuration", "Date & Time")
    time.sleep(5)

    # ensure we are set to Local settings
    if wg.webgui_datetime_get_clock_source() != "Local":
        wg.webgui_datetime_set_clock_source("Local")
        time.sleep(5)
    
    # set Date to 01-02-03
    dateset = "01-02-03"
    wg.webgui_datetime_set_date(dateset)
    wg.webgui_apply()
    time.sleep(30)
    
    ddate = wg.webgui_datetime_get_date()
    dispdate = time.strftime("%d-%m-%Y", ddate)
    
    if dateset == dispdate:
        # Local set date matches the displayed date as expected - send results 
        results.set_verify("PASS", util.gframe(), "Set Date and Displayed Date match as expected")
    else:
        # Unsuccessful test condition - send results and end script safely
        results.set_verify("FAIL", util.gframe(), "System Date and Set Date do not match")
    
    # check alarms on webgui (assumes webgui is open)  
    currentalarms = check_alarms(wg)
    if startalarms != currentalarms:
        print_alarms(currentalarms)
    
    ## ========== Step 3 ========== 
    # Change Time and check that it is displayed correctly
    logging.info("STEP 3 - Change Time and check that it is displayed correctly")
    
    # go to the date time page
    wg.webgui_set_page("System Configuration", "Date & Time")
    time.sleep(5)

    # ensure we are set to Local settings
    if wg.webgui_datetime_get_clock_source() != "Local":
        wg.webgui_datetime_set_clock_source("Local")
        time.sleep(5)
    
    # set Time to 12:34
    timeset = "12:34"
    shours = timeset.split(':')[0]
    smins = timeset.split(':')[1]
    wg.webgui_datetime_set_time(timeset)
    wg.webgui_apply()
    time.sleep(20)
    
    # get displayed time
    dtime = wg.webgui_datetime_get_time()
    dhours = dtime[0]
    dmins = dtime[1]
    
    if shours == dhours:
        if str(smins) == str(dmins) or int(smins) == int(dmins) + 1:
            # Local set date matches the displayed date as expected - send results 
            results.set_verify("PASS", util.gframe(), "Set Time and Displayed Time match as expected")
        else:
            results.set_verify("FAIL", util.gframe(), "Set Hours and Displayed Hours match, but Minutes do NOT")
    else:
        # Unsuccessful test condition - send results and end script safely
        results.set_verify("FAIL", util.gframe(), "Set Time and Displayed Time not match")
    
    # check alarms on webgui (assumes webgui is open)  
    currentalarms = check_alarms(wg)
    if startalarms != currentalarms:
        print_alarms(currentalarms)
        
    ## ========== Step 4 ========== 
    # Change Timezone and check that it is displayed correctly
    logging.info("STEP 4 - Change Timezone and check that it is displayed correctly")
    
    # go to the date time page
    wg.webgui_set_page("System Configuration", "Date & Time")
    time.sleep(5)

    # ensure we are set to Local settings
    if wg.webgui_datetime_get_clock_source() != "Local":
        wg.webgui_datetime_set_clock_source("Local")
        time.sleep(5)
    
    # set Timezone to -11:00, -03:30 and +13:00 and check that it has been set correctly
    timezones = ["-11:00", "-03:30", "+12:00"]
    timezonecheck = 0
    for tz in timezones:
        if wg.webgui_datetime_set_timezone(tz):
            timezonecheck += 1
        time.sleep(5)
    
    if timezonecheck == 3:
            # Local set date matches the displayed date as expected - send results 
            results.set_verify("PASS", util.gframe(), "All set Timezones were set and Displayed as expected")
    elif timezonecheck == 0:
            results.set_verify("FAIL", util.gframe(), "For some reason NO Timezones were set and Displayed correctly")
    else:
        # Unsuccessful test condition - send results and end script safely
        results.set_verify("FAIL", util.gframe(), "A total of %s Timezones were set correctly. The rest were NOT!" % str(timezonecheck))
    
    # check alarms on webgui (assumes webgui is open)  
    currentalarms = check_alarms(wg)
    if startalarms != currentalarms:
        print_alarms(currentalarms)
    
    ## ========== Step 5 ========== 
    # Change Clock source to SNTP and check that the correct time is displayed
    logging.info("STEP 5 - Change Clock source to SNTP and check that the correct time is displayed")
                 
    # go to the date time page
    wg.webgui_set_page("System Configuration", "Date & Time")
    time.sleep(5)

    # ensure we are set to SNTP settings to get Network Time
    wg.webgui_datetime_set_clock_source("SNTP")
    wg.webgui_apply()
    time.sleep(90)
    
    # get the currently set system time and the displayed time for comparison
    systime = time.localtime()
    displaydt = wg.webgui_datetime_get_all_info()
    
    # capture date info
    scriptdate = time.strftime("%d %m %Y", systime)
    displaydate = time.strftime("%d %m %Y", displaydt['date'])
    
    # capture time info
    scripttime = time.strftime("%H:%M", systime)
    dtime = displaydt['time']
    displaytime = str(dtime[0]) + ":" + str(dtime[1]) 
    
    if scriptdate == displaydate:
        if scripttime == displaytime:
            # SNTP time matches system time as expected - send results and clear spirent counters
            results.set_verify("PASS", util.gframe(), "System Time and Set SNTP Time match as expected")
        else:
            results.set_verify("FAIL", util.gframe(), "System Time and Set SNTP Time do not match")
    else:
        # Unsuccessful test condition - send results and end script safely
        results.set_verify("FAIL", util.gframe(), "System Date and Set SNTP Date do not match")
    
    ## ========== Test Step rollback ==========
    # all commands to rollback the configuration that has taken place throughout this script

    # No rollback commands needed
    logging.info("TEST SETUP ROLLBACK: No rollback required")
    
    # run the end script
    end_script('Normal', results, rig, start_time, wg, ss)
    
    quit()
示例#6
0
def test_template():
    
    # ========== Testrig and Testscript Initialization ==========
    # Initiate Testrig object - this handles all testrig objects as well as Topology and Config setup
    
    rig = TestRig("DVTA-CT-6", "T008.ini", "C001.ini", developmentrig, True)  # testcase ID, topology filename, config filename, developmentrig and Initialization Requirement
    
    # simple path to each of the Nodes (remove the ones that aren't needed)
    ctr1 = rig.nodes['node1']
    rac4 = ctr1.plugin[4]
    
    # ss = rig.devices['SPIRENT']
    
    # logging - start of test script and other basic info
    start_sw_version = ctr1.get_sw_version()
    start_time = time.time()
    logging.info('START %s, version %s' % (test_template.__name__, VERSION))
    logging.info('Current Software Build installed = %s' % (start_sw_version))
    
    # Results - xml or excel writer (REMOVE ONE)
    results = xmlwriter("DVTA-CT-6", "T007", "Basic Interactions on the equipment status page")  # testcase ID, Topology Used, Test Case Description
    
    # Initialize the required libraries
    util = utils()

    ## ========== Pre-Flow setup and checks ==========
    # Carry out all of the basic setup here which is not testable items
    
    # log the software pack to be used
    test_sw_dir = "C:/swpacks/"  # the desired test sw dir
    test_sw_vers = os.listdir(test_sw_dir)[0]  # the desired swpack
    logging.info('Current Cycle Software to be tested = %s' % (test_sw_vers))
    
    # Initialize Webgui
    wg = webgui(ctr1.ipaddress, 'Firefox')
    wg.webgui_logon()
    
    # establish a starting list of alarms and check to ensure there are no Critical alarms
    startalarms = check_alarms(wg)
    print_alarms(startalarms) 
    
    # check that we have a working rf link by passing 10sec of traffic and ensure no dropped frames check up to 3 times
    # if ss.simspr_line_check('3/9', '3/10'): # use correct ports for this
        # logging.info('Spirent connection confirmed ... continuing with test script')
    # else:
        # if no RF link stop script
        # logging.error('Spirent connection has not been established correctly after 3 attempts.')
    
    # ss.simspr_release()
    
    # Check that the current software version is loaded, if not, load it.
    curr_sw_version = util.format_SWpack_str(start_sw_version)
    if not os.path.exists(os.path.join(test_sw_dir, curr_sw_version)):
        logging.info("Currently loaded Software Pack is %s. Loading the latest test build - %s." % (curr_sw_version, test_sw_vers))
        swpack = load_SWpack(os.path.join(test_sw_vers), wg)
        if swpack[0] and swpack[2]:
            # Successful downgrade - send results and clear spirent counters
            results.set_verify("LOG", util.gframe(), "%s has been upgraded to the latest test build %s" % (ctr1.name, test_sw_vers))
        else:
            # Unsuccessful downgrade - send results and end script safely
            results.set_verify("ERROR", util.gframe(), "%s has NOT been upgraded to the latest test build %s for unknown reasons" % (ctr1.name, test_sw_vers))
            end_script('error', results, rig, start_time, wg)
       
    ## ========== Test step flow ==========
    
    ## ========== Step 1-3 ========== 
    # 1. Connect to Chrome (the only browser that works with Selenium and html5 drawings)
    # 2. Select the following tooltips from the CTR display and go to their configuration pages:
    #    Fan
    #    Power
    #    Tribs 1-2 (random)
    #    Ports 1-12 (random)
    #    Plug-ins 1-4
    # 3. for each of the above items check that each opens the correct HELP tab
    
    int_array = [['fan', 'Sensors', 'Sensors', 'Sensors'],
                 ['power', 'Sensors', 'Sensors', 'Sensors'],
                 ['T', 'Diagnostics', 'Tributary Diagnostics', 'Tributary Diagnostics'],
                 ['P', 'Configure Ports', 'Port Settings', 'Port Manager'],
                 ['S4', 'Configure Radio Links', 'Radio Interface', 'Radio Link Configuration']]
    
    testcount = len(int_array)
    
    # Logon to CTR via Chrome
    wgc = webgui(ctr1.ipaddress, 'Chrome')
    wgc.webgui_logon()
    time.sleep(5)
    
    # passed test counters
    correctlinks = 0
    correcthelp = 0
    failedlinks = []
    
    # step through the different Interfaces
    for inta in int_array:
        if inta[0] == 'T':
            randy = random.Random()
            randint = randy.randint(1, 2)
            wgc.webgui_equip_click_trib(randint, inta[1])
        elif inta[0] == 'P':
            randy = random.Random()
            randint = randy.randint(1, 12)
            wgc.webgui_equip_click_port(randint, inta[1])
        elif 'S' in inta[0]:
            slotint = int(inta[0][1:])
            wgc.webgui_equip_click_slot(slotint, inta[1])
        else:
            wgc.webgui_equip_click_misc(inta[0], inta[1])
        
        time.sleep(5)
        # check that we are now on the right page
        logging.info('Checking the %s menu selection from the Equipment Status page' % inta[1])
        if inta[2] in wgc.webgui_equip_get_legend_name():
            correctlinks += 1
            
            # try to open the help menu and see if it corresponds to the previous page
            wgc.webgui_tab_set_old()
            time.sleep(1)
            logging.info('Opening the CTR Portal Online Help')
            wgc.webgui_equip_click_help()
            time.sleep(1)
            wgc.webgui_tab_set_new()
            wgc.webgui_tab_switch('new')
            time.sleep(5)
            
            logging.info('Capturing Help page title')
            if inta[3] in wgc.webgui_help_get_title():
                correcthelp += 1
            wgc.webgui_tab_switch('old')
            wgc.webgui_tab_close('new')
        else:
            failedlinks.append(inta[2])
            
        wgc.webgui_set_page("Status", "Equipment")
        time.sleep(10)
            
    time.sleep(5)
    wgc.webgui_logoff()
    wgc.webgui_close_connection()     
        
    if correctlinks == testcount:
        # Successful test condition - send results
        results.set_verify("PASS", util.gframe(), "All Equipment links to Item Configuration pages work as expected")
    else:
        # Unsuccessful test condition - send results
        results.set_verify("FAIL", util.gframe(), "The following Equipment links to Configuration pages did not work as expected: %s " % failedlinks)
    
    if correcthelp == testcount:
        # Successful test condition - send results
        results.set_verify("PASS", util.gframe(), "All Configuration page links to the CTR Portal Help pages work as expected")
    else:
        # Unsuccessful test condition - send results
        results.set_verify("FAIL", util.gframe(), "Some of the Configuration page Help links to the CTR Portal Help pages did not work as expected")
    
    ## ========== Step 4 ========== 
    #  try a search in the HELP manual and ensure it is correctly displayed
    
    # Logon to CTR via Chrome
    wgh = webgui(ctr1.ipaddress, 'Chrome')
    wgh.webgui_logon()
    time.sleep(5)
    
    # try to open the help menu and see if it corresponds to the previous page
    wgh.webgui_tab_set_old()
    time.sleep(1)
    logging.info('Opening the CTR Portal Online Help')
    wgh.webgui_equip_click_help()
    time.sleep(1)
    wgh.webgui_tab_set_new()
    wgh.webgui_tab_switch('new')
    time.sleep(5)
    
    if wgh.webgui_help_search('protection') == 'Radio Link Protection':
        # Successful test condition - send results
        results.set_verify("PASS", util.gframe(), "The CTR Portal Help search Function works as expected")
    else:
        # Unsuccessful test condition - send results
        results.set_verify("FAIL", util.gframe(), "The CTR Portal Help search Function did not work as expected")

    wgh.webgui_tab_switch('old')
    wgh.webgui_tab_close('new')
    
    # logoff and close window
    time.sleep(5)
    wgh.webgui_logoff()
    wgh.webgui_close_connection() 
    
    ## ========== Step 5 ========== 
    #  disable a Plug-in card and check that it is no longer displayed
    
    # disable plug-in 
    rac4._unset()
    time.sleep(10)
    
    # logon to CTR1 
    wgr = webgui(ctr1.ipaddress, 'Chrome')
    wgr.webgui_logon()
    time.sleep(5)
    
    # check that the plug-in slot 4 is showing empty
    menuitem = 'Set slot to detected plugin type'
    wgr.webgui_equip_click_slot(4)
    if menuitem in wgr.webgui_equip_get_menu():
        # Successful test condition - send results
        results.set_verify("PASS", util.gframe(), "CTR Portal correctly displays new or unexpected plugin types")
    else:
        # Unsuccessful test condition - send results
        results.set_verify("FAIL", util.gframe(), "CTR Portal is not displaying new or unexpected plugin types")
    
    wgr.webgui_equip_click_slot(4)
    
    ## ========== Step 6 ========== 
    # reset a plug=in card and ensure it is re-displayed
    
    wgr.webgui_equip_select_menu(menuitem)
    time.sleep(30)
    
    menua = [4, 'Configure Radio Links', 'Radio Interface']
    
    wgr.webgui_equip_click_slot(menua[0], menua[1])
    time.sleep(10)
    radiopage = wgr.webgui_equip_get_legend_name()
    if menua[2] in radiopage:
        # Successful test condition - send results
        results.set_verify("PASS", util.gframe(), "CTR Portal has correctly initiated a plugin reset")
    else:
        # Unsuccessful test condition - send results
        results.set_verify("FAIL", util.gframe(), "CTR Portal has not correctly initiated a plugin reset")
    
    # logoff and close window
    time.sleep(5)
    wgr.webgui_logoff()
    wgr.webgui_close_connection()
    
    ## ========== Step 7 ========== 
    # set a few ports to enabled with down connections
    
    alarmtagclicks = ['chassis_eth_port4', 'chassis_eth_port6']
    # logon to CTR1 
    wga = webgui(ctr1.ipaddress, 'Firefox')
    wga.webgui_logon()
    time.sleep(5)
    
    # go to the Ethernet Port Manager
    wga.webgui_set_page("Ethernet Configuration", "Port Manager")
    time.sleep(10)
    
    # enable two known disconnected ports
    wga.webgui_eth_set_port_enable(4)
    ctr1.sendcli('c t; vlan 3; ports add gi 0/4 untagged gi 0/4')
    wga.webgui_eth_set_port_enable(6)
    ctr1.sendcli('c t; vlan 3; ports add gi 0/6 untagged gi 0/6')
    time.sleep(10)
    
    # return to equipment page
    wga.webgui_set_page("Status", "Equipment")
    time.sleep(600)
    
    tagfound = 0
    # check that alarms are raised for the two disconnected ports
    for x in alarmtagclicks:
        if x in wga.webgui_equip_get_alarm_tags():
            tagfound += 1
    
    if tagfound == 2:
        # Successful test condition - send results
        results.set_verify("PASS", util.gframe(), "CTR Equipment status displays the raised Port Alarms correctly")
    else:
        # Unsuccessful test condition - send results
        results.set_verify("FAIL", util.gframe(), "CTR Equipment status is not displaying the raised Port Alarms correctly")
    
    # go to the Ethernet Port Manager
    wga.webgui_set_page("Ethernet Configuration", "Port Manager")
    time.sleep(10)
    
    # disable the two ports
    wga.webgui_eth_set_port_disable(4)
    ctr1.sendcli('c t; vlan 3; no ports gi 0/4 untagged gi 0/4')
    wga.webgui_eth_set_port_disable(6)
    ctr1.sendcli('c t; vlan 3; no ports gi 0/6 untagged gi 0/6')
    time.sleep(10)
    
    # return to equipment page
    wga.webgui_set_page("Status", "Equipment")
    time.sleep(60)
    
    # check that alarms have been dropped for the two disconnected ports
    tagfound = 0
    for x in alarmtagclicks:
        if x in wga.webgui_equip_get_alarm_tags():
            tagfound += 1
    
    if tagfound == 0:
        # Successful test condition - send results
        results.set_verify("PASS", util.gframe(), "CTR Equipment status is displaying the dropped Port Alarms correctly")
    else:
        # Unsuccessful test condition - send results
        results.set_verify("FAIL", util.gframe(), "CTR Equipment status is not displaying the dropped Port Alarms correctly") 
    
    # logoff and close window
    time.sleep(5)
    wga.webgui_logoff()
    wga.webgui_close_connection()
    
    ## ========== Step 8 ========== 
    # Validate that the Inventory(Manufacturers Details) is displayed in the System Information
    
    expectedcards = ['RACx2 plug in module', 'CTR8540 mainboard']
    correctcards = 0
    
    # open and logon web browser
    wgmd = webgui(ctr1.ipaddress, 'Firefox')
    wgmd.webgui_logon()
    time.sleep(5) 
    
    wgmd.webgui_set_page("System Configuration", "System Information")
    wgmd.webgui_set_nav_tab('MANUFACTURE DETAILS')
    
    mandetails = wgmd.webgui_systeminfo_get_mandets()
    
    for x in expectedcards:
        if x in mandetails.keys():
            correctcards += 1
    
    if correctcards == len(expectedcards):
        # Successful test condition - send results
        results.set_verify("PASS", util.gframe(), "CTR Manufacture Details is displaying the expected plugin cards")
    else:
        # Unsuccessful test condition - send results
        results.set_verify("FAIL", util.gframe(), "CTR Manufacture Details is NOT displaying the expected plugin cards") 
    
    # logoff and close window
    time.sleep(5)
    wgmd.webgui_logoff()
    wgmd.webgui_close_connection()
    
    ## ========== Test Step rollback ==========
    # all commands to rollback the configuration that has taken place throughout this script
    
    # run the end script
    end_script('Normal', results, rig, start_time, wg)
    
    quit()
示例#7
0
def test_template():
    
    # ========== Testrig and Testscript Initialization ==========
    # Initiate Testrig object - this handles all testrig objects as well as Topology and Config setup
    
    rig = TestRig("DVTA-CT-7-A", "T008.ini", "C001.ini", developmentrig, True)  # testcase ID, topology filename, config filename, developmentrig and Initialization Requirement
    
    # simple path to each of the Nodes (remove the ones that aren't needed)
    ctr1 = rig.nodes['node1']
    ctr2 = rig.nodes['node2']
    # ctr3 = rig.nodes['node3']
    # ctr4 = rig.nodes['node4']
   
    # simple path to each of the Test Equipment ((remove the ones that aren't needed)
    # mrv = rig.devices['MRV']
    matrix = rig.devices['MATRIX']
    ss = rig.devices['SPIRENT']
    
    # logging - start of test script and other basic info
    start_sw_version = ctr1.get_sw_version()
    start_time = time.time()
    logging.info('START %s, version %s' % (test_template.__name__, VERSION))
    logging.info('Current Software Build installed = %s' % (start_sw_version))
    
    # Results - xml or excel writer (REMOVE ONE)
    results = xmlwriter("DVTA-CT-7-A", "T008", "Basic RF Frequency and power configuration functions of CraftTool")  # testcase ID, Topology Used, Test Case Description
    # results = ExcelWriter() 
    
    # Initialize the required libraries
    util = utils()

    ## ========== Pre-Flow setup and checks ==========
    # Carry out all of the basic setup here which is not testable items
    
    # log the software pack to be used
    test_sw_dir = "C:/swpacks/"  # the desired test sw dir
    test_sw_vers = os.listdir(test_sw_dir)[0]  # the desired swpack
    logging.info('Current Cycle Software to be tested = %s' % (test_sw_vers))

    # Check that the current software version is loaded, if not, load it.
    curr_sw_version = util.format_SWpack_str(start_sw_version)
    if not os.path.exists(os.path.join(test_sw_dir, curr_sw_version)):
        logging.info("Currently loaded Software Pack is %s. Loading the latest test build - %s." % (curr_sw_version, test_sw_vers))
        for ct in [ctr1, ctr2]:
            wgc = webgui(ct.ipaddress, 'Firefox') 
            wgc.webgui_logon()
            swpack = load_SWpack(os.path.join(test_sw_vers), wgc)
            if swpack[0] and swpack[2]:
                # Successful upgrade - send results and clear Spirent counters
                results.set_verify("LOG", util.gframe(), "%s has been upgraded to the latest test build %s" % (ct.name, test_sw_vers))
                results.set_verify("LOG", util.gframe(), 'RF Outage during downgrade was %s milliseconds' % str(ss.simspir_get_value_outage_run()[0]))
            else:
                # Unsuccessful upgrade - send results and end script safely
                results.set_verify("ERROR", util.gframe(), "%s has NOT been upgraded to the latest test build %s for unknown reasons" % (ct.name, test_sw_vers))
                end_script('error', results, rig, start_time, wgc, ss)
                quit()
    
    # Initialize Webgui
    wg1 = webgui(ctr1.ipaddress, 'Firefox')
    wg1.webgui_logon()
    
    # establish a starting list of alarms and check to ensure there are no Critical alarms
    startalarms_ctr1 = check_alarms(ctr1.ipaddress)
    print_alarms(startalarms_ctr1) 
    
    # check that we have a working rf link by passing 10sec of traffic and ensure no dropped frames check up to 3 times
    if ss.simspr_line_check('3/9', '3/10'):  # use correct ports for this
        logging.info('Spirent connection confirmed ... continuing with test script')
    else:
        # if no RF link stop script
        logging.error('Spirent connection has not been established correctly after 3 attempts.')
        end_script('error', results, rig, start_time, wg1, ss)
        quit()
    
    # Start a spirent outage run for outage capture    
    # ss.simspir_start_outage_run('3/9', '3/10')
    # logging.info('Starting Spirent Traffic for outage capture')
    
    time.sleep(10)
            
    ## ========== Test step flow ==========
    
    ## ========== Step 1 ========== 
    # Disable RAC Interface and ensure Traffic drops and Alarms are raised
    
    # go to radio page and disable RAC interface
    logging.info("Disable RAC Interface and ensure Traffic drops and Alarms are raised")
    wg1.webgui_set_page('Radio Configuration', 'Radio Link Configuration')
    time.sleep(5)
    wg1.webgui_rf_set_radio_int('RADIO INT 1/4/1')
    time.sleep(2)
    wg1.webgui_rf_disable_interface()
    wg1.webgui_apply()
    
    time.sleep(10)
    
    if not ss.simspr_line_check('3/9', '3/10'):
        # Successful test condition - send results and clear spirent counters
        print "Traffic Stopped"
        results.set_verify("PASS", util.gframe(), "Disabling of the RAC Interface Port stops Traffic Flowing as expected")
    else:
        print "Traffic flowing"
        # Unsuccessful test condition - send results and end script safely
        results.set_verify("FAIL", util.gframe(), "Disabling of the RAC Interface Port did NOT stop Traffic Flowing")
    
    # check alarms on webgui (assumes webgui is open)  
    currentalarms = check_alarms(ctr1.ipaddress)
    if startalarms_ctr1 != currentalarms:
        print_alarms(currentalarms)
        results.set_verify("PASS", util.gframe(), "Radio Interface Alarm has been raised as expected")
    else:
        # Unsuccessful test condition - send results and end script safely
        results.set_verify("FAIL", util.gframe(), "Radio Interface Alarm has not been raised")
    
    ## ========== Step 2 ========== 
    # Enable RAC Interface and ensure Traffic resumes and Alarms are dropped
    
    # go to radio page and enable RAC interface
    logging.info("Enable RAC Interface and ensure Traffic resumes and Alarms are dropped")
    wg1.webgui_set_page('Radio Configuration', 'Radio Link Configuration')
    time.sleep(5)
    wg1.webgui_rf_set_radio_int('RADIO INT 1/4/1')
    time.sleep(2)
    wg1.webgui_rf_enable_interface()
    wg1.webgui_apply()
    
    time.sleep(10)
    
    if ss.simspr_line_check('3/9', '3/10'):
        # Successful test condition - send results and clear spirent counters
        results.set_verify("PASS", util.gframe(), "Enabling of the RAC Interface Port allowed the Traffic to Flow as expected")
    else:
        # Unsuccessful test condition - send results and end script safely
        results.set_verify("FAIL", util.gframe(), "Enabling of the RAC Interface Port did NOT allow the Traffic to Flow")
    
    # check alarms to see whether Interface Alarm has been dropped
    currentalarms = check_alarms(ctr1.ipaddress)
    if startalarms_ctr1 == currentalarms:
        results.set_verify("PASS", util.gframe(), "Radio Interface Alarm has been dropped as expected")
    else:
        # Unsuccessful test condition - send results and end script safely
        print_alarms(currentalarms)
        results.set_verify("FAIL", util.gframe(), "Radio Interface Alarm has not been dropped")
    
    # Close webgui connection ready for next part
    wg1.webgui_logoff()
    wg1.webgui_close_connection()
    
    ## ========== Step 2 ========== 
    # RF Frequency Parameter Validation:
    #    A. set the bandwidth to ETSI 7MHz and change frequency to lowest possible 
    #    B. ensure traffic flows without any errors or alarms
    #    C. set frequency to highest possible
    #    D. Repeat step B
    #    E. set BW to ETSI 7MHz and set the largest Tx/Rx Spacing available (ie lowest Rx Freq highest Tx Freq)
    #    F. Repeat step B
    #    G. Set BW to ETSI 55MHz and ensure frequency not valid warning is displayed 
    
    logging.info("RF Frequency Parameter Validation")   
    
    #    A. set the bandwidth to ETSI 7MHz and change frequency to lowest possible
    logging.info("Check ODU operation at the lowest frequency possible")
    for ctrip in [ctr1.ipaddress, ctr2.ipaddress]:
        logging.info('Setting CTR %s to 7MHz BW, with frequencies set to lowest possible' % ctrip)
        
        # log on and go to the Radio configuration Page
        wgl = webgui(ctrip, 'Firefox')
        wgl.webgui_logon()
        time.sleep(5)
        wgl.webgui_set_page('Radio Configuration', 'Radio Link Configuration')
        time.sleep(5)
        
        # set BW to 7 MHz
        wgl.webgui_rf_set_bandwidth('7 MHz')
        wgl.webgui_apply()
        time.sleep(5)
        
        # get and set the required freq's
        txlowfreq = wgl.webgui_rf_get_freq_range('tx')[0]
        wgl.webgui_rf_set_frequency('tx', txlowfreq)
        wgl.webgui_apply()
        time.sleep(5)
        rxlowfreq = wgl.webgui_rf_get_freq_range('rx')[0]
        wgl.webgui_rf_set_frequency('rx', rxlowfreq)
        wgl.webgui_apply()
        time.sleep(5)
        
        logging.info('CTR %s has been setup at 7 MHz BW, with freq set to tx = %s and rx = %s' % (ctrip, txlowfreq, rxlowfreq))
        wgl.webgui_logoff()
        wgl.webgui_close_connection()
    
    #    B. ensure traffic flows without any errors or alarms 
    if ss.simspr_line_check('3/9', '3/10'):
        # Successful test condition - send results and clear spirent counters
        results.set_verify("PASS", util.gframe(), "Traffic is flowing as expected for lowest Possible Frequency")
    else:
        # Unsuccessful test condition - send results and end script safely
        results.set_verify("FAIL", util.gframe(), "Traffic is NOT flowing for lowest Possible Frequency")
    
    # ensure no extra alarms have been raised
    currentalarms = check_alarms(ctr1.ipaddress)
    if startalarms_ctr1 == currentalarms:
        results.set_verify("PASS", util.gframe(), "No alarms have been raised due to change of BW or low frequency")
    else:
        # Unsuccessful test condition - send results and end script safely
        print_alarms(currentalarms)
        results.set_verify("FAIL", util.gframe(), "Alarms have been raised due to change of BW or low frequency")   
    
    #    C. set frequency to highest possible
    logging.info("Check ODU operation at the highest frequency possible")
    for ctrip in [ctr1.ipaddress, ctr2.ipaddress]:
        logging.info('Setting CTR %s to 7MHz BW, with frequencies set to highest possible' % ctrip)
        
        # log on and go to the Radio configuration Page
        wgh = webgui(ctrip, 'Firefox')
        wgh.webgui_logon()
        time.sleep(5)
        wgh.webgui_set_page('Radio Configuration', 'Radio Link Configuration')
        time.sleep(5)
        
        # get and set the required freq's
        txhighfreq = wgh.webgui_rf_get_freq_range('tx')[1]
        wgh.webgui_rf_set_frequency('tx', txhighfreq)
        wgh.webgui_apply()
        time.sleep(5)
        rxhighfreq = wgh.webgui_rf_get_freq_range('rx')[1]
        wgh.webgui_rf_set_frequency('rx', rxhighfreq)
        wgh.webgui_apply()
        time.sleep(5)
        
        logging.info('CTR %s has been setup at 7 MHz BW, with freq set to tx = %s and rx = %s' % (ctrip, txhighfreq, rxhighfreq))
        wgh.webgui_logoff()
        wgh.webgui_close_connection()  
        
    #    D. ensure traffic flows without any errors or alarms 
    if ss.simspr_line_check('3/9', '3/10'):
        # Successful test condition - send results and clear spirent counters
        results.set_verify("PASS", util.gframe(), "Traffic is flowing as expected for the highest possible Frequency")
    else:
        # Unsuccessful test condition - send results and end script safely
        results.set_verify("FAIL", util.gframe(), "Traffic is NOT flowing for the highest possible Frequency")
    
    # ensure no extra alarms have been raised
    currentalarms = check_alarms(ctr1.ipaddress)
    if startalarms_ctr1 == currentalarms:
        results.set_verify("PASS", util.gframe(), "No alarms have been raised due to change of BW or high frequency")
    else:
        # Unsuccessful test condition - send results and end script safely
        print_alarms(currentalarms)
        results.set_verify("FAIL", util.gframe(), "Alarms have been raised due to change of BW or high frequency")   
    
    #    E. set BW to ETSI 7MHz and set the largest Tx/Rx Spacing available (ie lowest Rx Freq highest Tx Freq)
    logging.info("Check ODU operation at the largest Tx-Rx Spacing available (ie lowest Rx Freq highest Tx Freq)")
    highfreq = 1
    lowfreq = 0
    for ctrip in [ctr1.ipaddress, ctr2.ipaddress]:
        logging.info('Setting CTR %s with frequencies set to the largest Tx-Rx Spacing available' % ctrip)
        
        # log on and go to the Radio configuration Page
        wgs = webgui(ctrip, 'Firefox')
        wgs.webgui_logon()
        time.sleep(5)
        wgs.webgui_set_page('Radio Configuration', 'Radio Link Configuration')
        time.sleep(5)
        
        # get and set the required freq's
        txfreq = wgs.webgui_rf_get_freq_range('tx')[highfreq]
        wgs.webgui_rf_set_frequency('tx', txfreq)
        wgs.webgui_apply()
        time.sleep(5)
        rxfreq = wgs.webgui_rf_get_freq_range('rx')[lowfreq]
        wgs.webgui_rf_set_frequency('rx', rxfreq)
        wgs.webgui_apply()
        time.sleep(5)
        
        logging.info('CTR %s has been setup with freq set to tx = %s and rx = %s' % (ctrip, txfreq, rxfreq))
        wgs.webgui_logoff()
        wgs.webgui_close_connection()
        
        # Needed to set the correct frequencies
        highfreq = 0
        lowfreq = 1
    
    #    F. ensure traffic flows without any errors or alarms 
    if ss.simspr_line_check('3/9', '3/10'):
        # Successful test condition - send results and clear spirent counters
        results.set_verify("PASS", util.gframe(), "Traffic is flowing as expected for the largest Tx-Rx Spacing available")
    else:
        # Unsuccessful test condition - send results and end script safely
        results.set_verify("FAIL", util.gframe(), "Traffic is NOT flowing for the largest Tx-Rx Spacing available")
    
    # ensure no extra alarms have been raised
    currentalarms = check_alarms(ctr1.ipaddress)
    if startalarms_ctr1 == currentalarms:
        results.set_verify("PASS", util.gframe(), "No alarms have been raised due to change of BW or frequencies")
    else:
        # Unsuccessful test condition - send results and end script safely
        print_alarms(currentalarms)
        results.set_verify("FAIL", util.gframe(), "Alarms have been raised due to change of BW or frequencies")   
    
    # G. Set BW to ETSI 55MHz and ensure frequency not valid warning is displayed
    logging.info("Set BW to ETSI 55MHz and ensure frequency not valid warning is displayed")
    
    # login to ctr1
    wgw = webgui(ctr1.ipaddress, 'Firefox')
    wgw.webgui_logon()
    time.sleep(5)
    wgw.webgui_set_page('Radio Configuration', 'Radio Link Configuration')
    time.sleep(5)
    
    # set BW to 55 MHz
    wgw.webgui_rf_set_bandwidth('55 MHz')
    wgw.webgui_apply()
    time.sleep(5)
    
    freqwarnings = 0
    # warnings should be raised - capture and check for 
    for x in wgw.webgui_rf_get_entry_errors():
        if 'Tx Frequency must be within' in x:
            freqwarnings += 1
        if 'Rx Frequency must be within' in x:
            freqwarnings += 1
    
    wgw.webgui_logoff()
    wgw.webgui_close_connection()
    
    if freqwarnings == 2:
        # Successful test condition - send results and clear spirent counters
        results.set_verify("PASS", util.gframe(), "Setting warning was displayed for the incorrect Tx and Rx Frequencies")
    else:
        # Unsuccessful test condition - send results and end script safely
        results.set_verify("FAIL", util.gframe(), "Setting warning was NOT displayed for the incorrect Tx and Rx Frequencies")
    
    ## ========== Step 3 ========== 
    # RF Power Parameter Validation:  
    # A. Set RF Frequency to mid range, Capacity to QPSK 40MHz, RF Power to 20dBm
    # B. adjust MATRIX to give -45dBm RSL
    # C. adjust Power to the following conditions, ensure RSL adjusts within spec, traffic flows and no errors or alarms are raised
    #     i. Max with NO High Power
    #     ii. Max with High Power
    #     iii. Min
    
    # A. Set RF Frequency to mid range, Capacity to QPSK 40MHz, RF Power to 20dBm
    logging.info("Setting RF Frequency to mid range, Capacity to QPSK 40MHz, RF Power to 20dBm")
    for ctrip in [ctr1.ipaddress, ctr2.ipaddress]:
        # log on and go to the Radio configuration Page
        wgpi = webgui(ctrip, 'Firefox')
        wgpi.webgui_logon()
        time.sleep(5)
        wgpi.webgui_set_page('Radio Configuration', 'Radio Link Configuration')
        time.sleep(5)
    
        # set BW to 7 MHz
        wgpi.webgui_rf_set_bandwidth('40 MHz')
        wgpi.webgui_apply()
        time.sleep(2)
        
        # set modulation to QPSK
        wgpi.webgui_rf_set_modulation(['QPSK'])
        wgpi.webgui_apply()
        time.sleep(2)
        
        # set frequency to mid band
        for rf in ['tx', 'rx']:
            frange = wgpi.webgui_rf_get_freq_range(rf)
            totfreq = float(frange[0]) + float(frange[1])
            txfreq = str(totfreq / 2)
            wgpi.webgui_rf_set_frequency(rf, txfreq)
            wgpi.webgui_apply()
            time.sleep(2)
            
        wgpi.webgui_rf_apply_tx_power(['20'])
        
        wgpi.webgui_logoff()
        wgpi.webgui_close_connection()
    
    time.sleep(10)
    
    # ensure traffic flows without any errors or alarms 
    if ss.simspr_line_check('3/9', '3/10'):
        # Successful test condition - send results and clear spirent counters
        results.set_verify("PASS", util.gframe(), "Traffic is flowing as expected for the initial RF Power configuration")
    else:
        # Unsuccessful test condition - send results and end script safely
        results.set_verify("FAIL", util.gframe(), "Traffic is NOT flowing as expected for the initial RF Power configuration")
    
    # ensure no extra alarms have been raised
    currentalarms = check_alarms(ctr1.ipaddress)
    if startalarms_ctr1 == currentalarms:
        results.set_verify("PASS", util.gframe(), "No alarms have been raised due to changes for the initial RF Power configuration")
    else:
        # Unsuccessful test condition - send results and end script safely
        print_alarms(currentalarms)
        results.set_verify("FAIL", util.gframe(), "Alarms have been raised due to changes for the initial RF Power configuration")   
    
    # B. adjust MATRIX to give -45dBm RSL
    logging.info('B. adjust MATRIX to give -45dBm RSL')
    
    # get the current RSL Level
    # log on and go to the radio config page
    wgrsl2 = webgui(ctr2.ipaddress, 'Firefox')
    wgrsl2.webgui_logon()
    time.sleep(5)
    wgrsl2.webgui_set_page('Radio Configuration', 'Radio Link Configuration')
    time.sleep(5)
    
    if set_matrix(wgrsl2, matrix):
        results.set_verify("PASS", util.gframe(), "RSL figures have been correctly set to -45dB")
    else:
        # Unsuccessful test condition - send results and end script safely
        results.set_verify("ERROR", util.gframe(), "RSL figures have not been correctly set to -45dB. Ending Testscript")
        end_script('error', results, rig, start_time, wgrsl2, ss)
        quit()
    
    wgrsl2.webgui_logoff()
    wgrsl2.webgui_close_connection()
    
    # ensure traffic flows without any errors or alarms 
    if ss.simspr_line_check('3/9', '3/10'):
        # Successful test condition - send results and clear spirent counters
        results.set_verify("PASS", util.gframe(), "Traffic is flowing as expected with RSL level of -45dB")
    else:
        # Unsuccessful test condition - send results and end script safely
        results.set_verify("FAIL", util.gframe(), "Traffic is NOT flowing as expected with RSL level of -45dB")
    
    # ensure no extra alarms have been raised
    currentalarms = check_alarms(ctr1.ipaddress)
    if startalarms_ctr1 == currentalarms:
        results.set_verify("PASS", util.gframe(), "No alarms have been raised due to change to a RSL level of -45dB")
    else:
        # Unsuccessful test condition - send results and end script safely
        print_alarms(currentalarms)
        results.set_verify("FAIL", util.gframe(), "Alarms have been raised due to change to a RSL level of -45dB")
    
    # C. adjust Power to the following conditions, ensure RSL adjusts within spec, traffic flows and no errors or alarms are raised
    #     i. Max with NO High Power
    #     ii. Max with High Power
    #     iii. Min
    logging.info('C. adjust Power to the following conditions, ensure RSL adjusts within spec, traffic flows and no errors or alarms are raised')
    
    # open the FAR END Node and check that the starting RSL level
    wgrsl2 = webgui(ctr2.ipaddress, 'Firefox')
    wgrsl2.webgui_logon()
    time.sleep(5)
    wgrsl2.webgui_set_page('Radio Configuration', 'Radio Link Configuration')
    time.sleep(5)
    startrsl = float(wgrsl2.webgui_rf_get_rsl().replace(' dBm', ''))
    startingpwr = 20
    
    for ptype in ['max', 'min', 'high-max']:
        logging.info('Setting %s Power Level' % ptype)
        setlvl = set_pwrlvl(ctr1, ptype)
        print "Set Level = " + setlvl
        # get and compare rsl levels
        dBchange = float(setlvl) - float(startingpwr)
        expectedrsl = startrsl + dBchange
        print "Expected RSL = " + str(expectedrsl)
        time.sleep(10)
        currrsl = float(wgrsl2.webgui_rf_get_rsl().replace(' dBm', ''))
        print 'Current RSL = ' + str(currrsl)
        # check change of RSL level
        if currrsl >= expectedrsl - 1 and currrsl <= expectedrsl + 1:
            results.set_verify("PASS", util.gframe(), "RSL level has changed to the expected value of %s after changing to %s power level of %s" % (str(currrsl), ptype, str(setlvl)))
        else:
            # Unsuccessful test condition - send results and end script safely
            results.set_verify("FAIL", util.gframe(), "RSL level has NOT changed to the expect value of %s after changing to %s power level of %s" % (str(currrsl), ptype, str(setlvl)))
            
        # ensure traffic flows without any errors or alarms 
        if ss.simspr_line_check('3/9', '3/10'):
            # Successful test condition - send results and clear spirent counters
            results.set_verify("PASS", util.gframe(), "Traffic is flowing as expected for the %s RF Power configuration" % ptype)
        else:
            # Unsuccessful test condition - send results and end script safely
            results.set_verify("FAIL", util.gframe(), "Traffic is NOT flowing as expected for the %s RF Power configuration" % ptype)
            
        # ensure no extra alarms have been raised
        currentalarms = check_alarms(ctr1.ipaddress)
        if startalarms_ctr1 == currentalarms:
            results.set_verify("PASS", util.gframe(), "No alarms have been raised due to change of Power levels")
        else:
            # Unsuccessful test condition - send results and end script safely
            print_alarms(currentalarms)
            results.set_verify("FAIL", util.gframe(), "Alarms have been raised due to change of Power levels")
    
    wgrsl2.webgui_logoff()
    wgrsl2.webgui_close_connection() 
    
    ## ========== Step 4 ========== 
    # RF Tx Mute Diagnostics
    logging.info('RF Tx Mute Diagnostics')
    
    # set TX Mute for the current rf link
    wgtxm = webgui(ctr1.ipaddress, 'Firefox')
    wgtxm.webgui_logon()
    time.sleep(5)
    wgtxm.webgui_set_page('Radio Configuration', 'Radio Link Diagnostics')
    time.sleep(5)
    wgtxm.webgui_rf_set_tx_mute('1/4/1', True)
    time.sleep(20)
    
    # check that the Tx mute alarm is raised
    txmute_alarm_chk = check_alarms(ctr1.ipaddress)
    alarmfound = 0
    print_alarms(txmute_alarm_chk)
    for al in txmute_alarm_chk:
        for x in al:
            if 'transmitter mute diagnostic' in x:
                results.set_verify("LOG", util.gframe(), 'The expected Tx Mute alarm was raised')
                alarmfound += 1
            if 'Transmit path has been lost' in x:
                results.set_verify("LOG", util.gframe(), 'The expected Transmit Path failure alarm was raised')
                alarmfound += 1
            if 'Radio traffic path' in x:
                results.set_verify("LOG", util.gframe(), 'The expected Radio traffic path alarm was raised')
                alarmfound += 1 
    
    if alarmfound == 3:
        results.set_verify("PASS", util.gframe(), 'All of the expected alarms were raised as expected')
    else:
        results.set_verify("FAIL", util.gframe(), 'All of the expected alarms were NOT raised as expected')
        
    # check that the Detected Tx Power is Muted
    wgtxm.webgui_set_page('Radio Configuration', 'Radio Link Configuration')
    time.sleep(5)
    currtxpwr = wgtxm.webgui_rf_get_detected_power()
    if currtxpwr == 'Muted':
        results.set_verify("PASS", util.gframe(), 'Detected Tx Power is displaying Muted as expected')
    else:
        results.set_verify("FAIL", util.gframe(), 'Detected Tx Power is NOT displaying Muted')
    
    # check that the rf link is not transmitting and not passing Traffic    
    if ss.simspr_line_check('3/9', '3/10'):  # use correct ports for this
        results.set_verify("FAIL", util.gframe(), 'Spirent connection is up even though Tx Mute is set')
    else:
        results.set_verify("PASS", util.gframe(), 'Spirent connection down as expected for the Tx muted RF Link.')
    
    # turn off the Diagnostic function 
    wgtxm.webgui_set_page('Radio Configuration', 'Radio Link Diagnostics')
    time.sleep(5)
    wgtxm.webgui_rf_set_tx_mute('1/4/1', False)
    time.sleep(5)
    wgtxm.webgui_logoff()
    wgtxm.webgui_close_connection()
    
    ## ========== Step 5 ========== 
    # IF Loopback Diagnostics
    logging.info('IF Loopback Diagnostics')
    
    # set IF loopback for the current rf link
    wgiflb = webgui(ctr1.ipaddress, 'Firefox')
    wgiflb.webgui_logon()
    time.sleep(5)
    wgiflb.webgui_set_page('Radio Configuration', 'Radio Link Diagnostics')
    time.sleep(5)
    wgiflb.webgui_rf_set_if_lb_dura('1/4/1', True)
    time.sleep(20)
    
    # check that the IF loopback alarm is raised
    iflb_alarm_chk = check_alarms(ctr1.ipaddress)
    print_alarms(iflb_alarm_chk)
    for al in iflb_alarm_chk:
        for x in al:
            if 'IF loopback diagnostic' in x:
                results.set_verify("PASS", util.gframe(), 'The expected IF loopback diagnostic alarm was raised')
            if 'Transmit path has been lost' in x:
                results.set_verify("FAIL", util.gframe(), 'The Transmit Path failure alarm was raised')
            if 'Radio traffic path' in x:
                results.set_verify("FAIL", util.gframe(), 'The Radio traffic path alarm was raised')

    # check that the Detected Tx Power is Muted
    wgiflb.webgui_set_page('Radio Configuration', 'Radio Link Configuration')
    time.sleep(5)
    currtxpwr = wgiflb.webgui_rf_get_detected_power()
    if currtxpwr == 'Muted':
        results.set_verify("PASS", util.gframe(), 'Detected Tx Power is displaying Muted as expected')
    else:
        results.set_verify("FAIL", util.gframe(), 'Detected Tx Power is NOT displaying Muted')
    
    # check that the rf link is not transmitting and not passing Traffic    
    if ss.simspr_line_check('3/9', '3/10'):  # use correct ports for this
        results.set_verify("FAIL", util.gframe(), 'Spirent connection is up even though IF loopback is set')
    else:
        results.set_verify("PASS", util.gframe(), 'Spirent connection down as expected for the IF loopback RF Link.')
    
    # turn off the Diagnostic function
    wgiflb.webgui_set_page('Radio Configuration', 'Radio Link Diagnostics')
    time.sleep(5)
    wgiflb.webgui_rf_set_if_lb_dura('1/4/1', False)
    time.sleep(5)
    wgiflb.webgui_logoff()
    wgiflb.webgui_close_connection() 
    
    wgrsl1 = webgui(ctr1.ipaddress, 'Firefox')
    wgrsl1.webgui_logon()
    time.sleep(5)
    
    ## ========== Test Step rollback ==========
    # all commands to rollback the configuration that has taken place throughout this script
    
    logging.info('Rollback Not needed all settings will be reset during next testscript configuration')
    
    # run the end script
    end_script('Normal', results, rig, start_time, wgrsl1, ss)
    quit()
示例#8
0
def test_template():

    # ========== Testrig and Testscript Initialization ==========
    # Initiate Testrig object - this handles all testrig objects as well as Topology and Config setup

    rig = TestRig(
        "DVTA-CT-7-B", "T008.ini", "C001.ini", developmentrig, True
    )  # testcase ID, topology filename, config filename, developmentrig and Initialization Requirement

    # simple path to each of the Nodes (remove the ones that aren't needed)
    ctr1 = rig.nodes['node1']
    ctr2 = rig.nodes['node2']
    # ctr3 = rig.nodes['node3']
    # ctr4 = rig.nodes['node4']

    # simple path to each of the Test Equipment ((remove the ones that aren't needed)
    # mrv = rig.devices['MRV']
    matrix = rig.devices['MATRIX']
    ss = rig.devices['SPIRENT']

    # logging - start of test script and other basic info
    start_sw_version = ctr1.get_sw_version()
    start_time = time.time()
    logging.info('START %s, version %s' % (test_template.__name__, VERSION))
    logging.info('Current Software Build installed = %s' % (start_sw_version))

    # Results - xml or excel writer (REMOVE ONE)
    results = xmlwriter(
        "DVTA-CT-7-B", "T008",
        "Basic RF Capacity configuration functions of CraftTool"
    )  # testcase ID, Topology Used, Test Case Description
    # results = ExcelWriter()

    # Initialize the required libraries
    util = utils()

    ## ========== Pre-Flow setup and checks ==========
    # Carry out all of the basic setup here which is not testable items

    # log the software pack to be used
    test_sw_dir = "C:/swpacks/"  # the desired test sw dir
    test_sw_vers = os.listdir(test_sw_dir)[0]  # the desired swpack
    logging.info('Current Cycle Software to be tested = %s' % (test_sw_vers))

    # Check that the current software version is loaded, if not, load it.
    curr_sw_version = util.format_SWpack_str(start_sw_version)
    if not os.path.exists(os.path.join(test_sw_dir, curr_sw_version)):
        logging.info(
            "Currently loaded Software Pack is %s. Loading the latest test build - %s."
            % (curr_sw_version, test_sw_vers))
        for ct in [ctr1, ctr2]:
            wgc = webgui(ct.ipaddress, 'Firefox')
            wgc.webgui_logon()
            swpack = load_SWpack(os.path.join(test_sw_vers), wgc)
            if swpack[0] and swpack[2]:
                # Successful upgrade - send results and clear Spirent counters
                results.set_verify(
                    "LOG", util.gframe(),
                    "%s has been upgraded to the latest test build %s" %
                    (ct.name, test_sw_vers))
                results.set_verify(
                    "LOG", util.gframe(),
                    'RF Outage during downgrade was %s milliseconds' %
                    str(ss.simspir_get_value_outage_run()[0]))
            else:
                # Unsuccessful upgrade - send results and end script safely
                results.set_verify(
                    "ERROR", util.gframe(),
                    "%s has NOT been upgraded to the latest test build %s for unknown reasons"
                    % (ct.name, test_sw_vers))
                end_script('error', results, rig, start_time, wgc, ss)
                quit()

    # Initialize Webgui
    wg1 = webgui(ctr1.ipaddress, 'Firefox')
    wg1.webgui_logon()

    # establish a starting list of alarms and check to ensure there are no Critical alarms
    startalarms_ctr1 = check_alarms(wg1)
    print_alarms(startalarms_ctr1)

    # check that we have a working rf link by passing 10sec of traffic and ensure no dropped frames check up to 3 times
    if ss.simspr_line_check('3/9', '3/10'):  # use correct ports for this
        logging.info(
            'Spirent connection confirmed ... continuing with test script')
    else:
        # if no RF link stop script
        logging.error(
            'Spirent connection has not been established correctly after 3 attempts.'
        )
        end_script('error', results, rig, start_time, wg1, ss)
        quit()

    # Start a spirent outage run for outage capture
    # ss.simspir_start_outage_run('3/9', '3/10')
    # logging.info('Starting Spirent Traffic for outage capture')

    time.sleep(10)

    ## ========== Test step flow ==========

    ## ========== Step 1 ==========
    # Check that the preset RF link is up (and Displayed) and traffic is flowing
    wg1.webgui_set_page('Radio Configuration', 'Radio Link Configuration')
    time.sleep(5)

    protset = wg1.webgui_rf_is_prot_set()
    linkup = wg1.webgui_rf_is_link_up('RADIO INT 1/4/1')

    if not protset and linkup:
        results.set_verify(
            "PASS", util.gframe(),
            "The Radio Interface Page is displaying the correct non-protected links as expected"
        )
    else:
        # Unsuccessful test condition - send results and end script safely
        results.set_verify(
            "ERROR", util.gframe(),
            "The Radio Interface Page is NOT displaying the correct non-protected links as expected"
        )

    wg1.webgui_logoff()
    wg1.webgui_close_connection()

    ## ========== Step 2 ==========
    # Set RF Frequency to mid range, RF Power to 20dBm, Capacity to QPSK 40MHz then adjust MATRIX to give -45dBm RSL
    # A. Set RF Frequency to mid range, Capacity to QPSK 40MHz, RF Power to 20dBm
    logging.info(
        "Setting RF Frequency to mid range, Capacity to QPSK 40MHz, RF Power to 20dBm"
    )
    for ctrip in [ctr1.ipaddress, ctr2.ipaddress]:
        # log on and go to the Radio configuration Page
        wgpi = webgui(ctrip, 'Firefox')
        wgpi.webgui_logon()
        time.sleep(5)
        wgpi.webgui_set_page('Radio Configuration', 'Radio Link Configuration')
        time.sleep(5)

        # set BW to 7 MHz
        wgpi.webgui_rf_set_bandwidth('40 MHz')
        wgpi.webgui_apply()
        time.sleep(2)

        # set modulation to QPSK
        wgpi.webgui_rf_set_modulation(['QPSK'])
        wgpi.webgui_apply()
        time.sleep(2)

        # set capacity to 1000
        wgpi.webgui_rf_set_link_capacity('1000')
        wgpi.webgui_apply()
        time.sleep(2)

        # set frequency to mid band
        for rf in ['tx', 'rx']:
            frange = wgpi.webgui_rf_get_freq_range(rf)
            totfreq = float(frange[0]) + float(frange[1])
            txfreq = str(totfreq / 2)
            wgpi.webgui_rf_set_frequency(rf, txfreq)
            wgpi.webgui_apply()
            time.sleep(2)

        wgpi.webgui_rf_apply_tx_power(['20'])

        if ctrip == ctr1.ipaddress:
            wgpi.webgui_logoff()
            wgpi.webgui_close_connection()

    time.sleep(10)

    # B. adjust MATRIX to give -45dBm RSL
    logging.info('B. adjust MATRIX to give -45dBm RSL')

    # get the current RSL Level
    if set_matrix(wgpi, matrix):
        results.set_verify("PASS", util.gframe(),
                           "RSL figures have been correctly set to -45dB")
    else:
        # Unsuccessful test condition - send results and end script safely
        results.set_verify(
            "ERROR", util.gframe(),
            "RSL figures have not been correctly set to -45dB. Ending Testscript"
        )
        end_script('error', results, rig, start_time, wgpi, ss)
        quit()

    wgpi.webgui_logoff()
    wgpi.webgui_close_connection()

    # ensure traffic flows without any errors or alarms
    if ss.simspr_line_check('3/9', '3/10'):
        # Successful test condition - send results and clear spirent counters
        results.set_verify(
            "PASS", util.gframe(),
            "Traffic is flowing as expected with RSL level of -45dB")
    else:
        # Unsuccessful test condition - send results and end script safely
        results.set_verify(
            "FAIL", util.gframe(),
            "Traffic is NOT flowing as expected with RSL level of -45dB")

    # ensure no extra alarms have been raised
    wga = webgui(ctr1.ipaddress, 'Firefox')
    wga.webgui_logon()
    time.sleep(5)
    currentalarms = check_alarms(wga)
    if startalarms_ctr1 == currentalarms:
        results.set_verify(
            "PASS", util.gframe(),
            "No alarms have been raised due to change to a RSL level of -45dB")
    else:
        # Unsuccessful test condition - send results and end script safely
        print_alarms(currentalarms)
        results.set_verify(
            "FAIL", util.gframe(),
            "Alarms have been raised due to change to a RSL level of -45dB")

    wga.webgui_logoff()
    wga.webgui_close_connection()

    ## ========== Step 3 ==========
    # For each BW check:
    #    A. Link is up with no alarms
    #    B. Traffic is flowing at the given Max Capacity
    #    C. SNR is at an expected level

    bandwidths = ['7', '14', '28', '40', '55']
    logging.info(
        "Testing all Bandwidths for correct operation, SNR and Throughput")

    for bws in bandwidths:
        logging.info("Testing %s MHz Bandwidth" % bws)
        # open webgui and set BW
        for ctrip in [ctr1.ipaddress, ctr2.ipaddress]:

            wgbw = webgui(ctrip, 'Firefox')
            wgbw.webgui_logon()
            time.sleep(5)
            wgbw.webgui_set_page('Radio Configuration',
                                 'Radio Link Configuration')
            time.sleep(5)
            wgbw.webgui_rf_set_bandwidth(bws + ' MHz')
            time.sleep(2)
            wgbw.webgui_apply()
            time.sleep(2)
            wgbw.webgui_logoff()
            wgbw.webgui_close_connection()

        # A. Link is up with no alarms
        time.sleep(10)
        wgbw = webgui(ctr1.ipaddress, 'Firefox')
        wgbw.webgui_logon()
        time.sleep(5)
        wgbw.webgui_set_page('Radio Configuration', 'Radio Link Configuration')
        time.sleep(5)

        # check link is up
        logging.info("Checking Link is up with %s MHz Bandwidth" % bws)
        linkup = False
        for x in range(5):
            if wgbw.webgui_rf_is_link_up('RADIO INT 1/4/1'):
                linkup = True
                break
            else:
                time.sleep(5)
                logging.info('Waiting for Link to establish %s' % str(x))

        if linkup:
            results.set_verify(
                "PASS", util.gframe(),
                "The RF link is up with a bandwidth setting of %s" % bws)
        else:
            results.set_verify(
                "FAIL", util.gframe(),
                "The RF link has NOT come up with a bandwidth setting of %s" %
                bws)

        # check alarms
        logging.info(
            "Checking no Alarms have been raised with %s MHz Bandwidth" % bws)
        currentalarms = check_alarms(wgbw)
        if startalarms_ctr1 == currentalarms:
            results.set_verify(
                "PASS", util.gframe(),
                "No alarms have been raised due to a set bandwidth of %s" %
                bws)
        else:
            results.set_verify(
                "FAIL", util.gframe(),
                "Alarms have been raised due to a set bandwidth of %s" % bws)

        # B. Traffic is flowing at the given Max Capacity
        logging.info("Checking Throughput for %s MHz Bandwidth" % bws)
        wgbw.webgui_set_page('Radio Configuration', 'Radio Link Configuration')
        time.sleep(5)
        maxcap = float(wgbw.webgui_rf_get_max_capacity().replace(' Mbps', ''))
        maxthru = float(ss.simspr_get_max_throughput('3/9',
                                                     '3/10')[0]) / 1000000

        if maxthru >= maxcap - 1 and maxthru <= maxcap:
            results.set_verify(
                "PASS", util.gframe(),
                "Maximum RF Link Throughput of %s due to a bandwidth of %s has been achieved"
                % (maxthru, bws))
        else:
            results.set_verify(
                "FAIL", util.gframe(),
                "Maximum RF Link Throughput of %s due to a bandwidth of %s has NOT been achieved"
                % (maxthru, bws))

        #  C. SNR is at an expected level
        logging.info("Checking SNR levels for %s MHz Bandwidth" % bws)
        linksnr = float(wgbw.webgui_rf_get_snr().replace(' dB', ''))
        if linksnr >= 32:
            results.set_verify(
                "PASS", util.gframe(),
                "RF Link SNR is %s with a bandwidth of %s" %
                (str(linksnr), bws))
        else:
            results.set_verify(
                "FAIL", util.gframe(),
                "RF Link SNR is %s with a bandwidth of %s" %
                (str(linksnr), bws))

        wgbw.webgui_logoff()
        wgbw.webgui_close_connection()

    ## ========== Step 4 ==========
    # Set BW to 55MHz QPSK and adjust MATRIX to give -45dBm RSL level
    logging.info("Unit should already be set for 55MHz Bandwidth and QPSK")
    logging.info("Adjusting MATRIX box for RSL of -45 dB")

    wgrsl = webgui(ctr2.ipaddress, 'Firefox')
    wgrsl.webgui_logon()
    time.sleep(5)
    wgrsl.webgui_set_page('Radio Configuration', 'Radio Link Configuration')
    time.sleep(5)

    # get the current RSL Level
    if set_matrix(wgrsl, matrix):
        results.set_verify("PASS", util.gframe(),
                           "RSL figures have been correctly set to -45dB")
    else:
        # Unsuccessful test condition - send results and end script safely
        results.set_verify(
            "ERROR", util.gframe(),
            "RSL figures have not been correctly set to -45dB. Ending Testscript"
        )
        end_script('error', results, rig, start_time, wgrsl, ss)
        quit()

    wgrsl.webgui_logoff()
    wgrsl.webgui_close_connection()

    ## ========== Step 5 ==========
    # For each Modulation check:
    #    A. Link is up with no alarms
    #    B. Traffic is flowing at the given Max Capacity
    #    C. SNR is at an expected level

    modulations = [
        'QPSK', '16QAM', '32QAM', '64QAM', '128QAM', '256QAM', '512QAM',
        '1024QAM HIGH GAIN'
    ]
    logging.info(
        "Testing all Modulations for correct operation, SNR and Throughput")

    for mods in modulations:
        logging.info("Testing %s Fixed Modulation" % mods)
        # open webgui and set BW
        for ctrip in [ctr1.ipaddress, ctr2.ipaddress]:

            wgbw = webgui(ctrip, 'Firefox')
            wgbw.webgui_logon()
            time.sleep(5)
            wgbw.webgui_set_page('Radio Configuration',
                                 'Radio Link Configuration')
            time.sleep(5)
            wgbw.webgui_rf_set_modulation([mods])
            time.sleep(2)
            wgbw.webgui_apply()
            time.sleep(2)
            wgbw.webgui_logoff()
            wgbw.webgui_close_connection()
            time.sleep(2)

        # A. Link is up with no alarms
        time.sleep(10)
        wgbw = webgui(ctr1.ipaddress, 'Firefox')
        wgbw.webgui_logon()
        time.sleep(5)
        wgbw.webgui_set_page('Radio Configuration', 'Radio Link Configuration')
        time.sleep(5)

        # check link is up
        logging.info("Checking Link is up with %s Modulation" % mods)
        linkup = False
        for x in range(5):
            if wgbw.webgui_rf_is_link_up('RADIO INT 1/4/1'):
                linkup = True
                break
            else:
                time.sleep(5)
                logging.info('Waiting for Link to establish %s' % str(x))

        if linkup:
            results.set_verify(
                "PASS", util.gframe(),
                "The RF link is up with a modulation setting of %s" % mods)
        else:
            results.set_verify(
                "FAIL", util.gframe(),
                "The RF link has NOT come up with a modulation setting of %s" %
                mods)

        # check alarms
        logging.info("Checking no Alarms have been raised with %s Modulation" %
                     mods)
        currentalarms = check_alarms(wgbw)
        if startalarms_ctr1 == currentalarms:
            results.set_verify(
                "PASS", util.gframe(),
                "No alarms have been raised due to a set bandwidth of %s" %
                mods)
        else:
            results.set_verify(
                "FAIL", util.gframe(),
                "Alarms have been raised due to a set bandwidth of %s" % mods)

        # B. Traffic is flowing at the given Max Capacity
        logging.info("Checking Throughput for %s Modulation" % mods)
        wgbw.webgui_set_page('Radio Configuration', 'Radio Link Configuration')
        time.sleep(5)
        maxcap = float(wgbw.webgui_rf_get_max_capacity().replace(' Mbps', ''))
        maxthru = float(ss.simspr_get_max_throughput('3/9',
                                                     '3/10')[0]) / 1000000

        # should be greater than 95% of Max Capacity
        maxcapmin = maxcap * 0.95
        if maxthru >= maxcapmin and maxthru <= maxcap:
            results.set_verify(
                "PASS", util.gframe(),
                "Maximum RF Link Throughput of %s due to a modulation of %s has been achieved"
                % (maxthru, mods))
        else:
            results.set_verify(
                "FAIL", util.gframe(),
                "Maximum RF Link Throughput of %s due to a modulation of %s has NOT been achieved"
                % (maxthru, mods))

        #  C. SNR is at an expected level
        logging.info("Checking SNR levels for %s Modulation" % mods)
        linksnr = float(wgbw.webgui_rf_get_snr().replace(' dB', ''))
        if linksnr >= 32:
            results.set_verify(
                "PASS", util.gframe(),
                "RF Link SNR is %s with a modulation of %s" %
                (str(linksnr), mods))
        else:
            results.set_verify(
                "FAIL", util.gframe(),
                "RF Link SNR is %s with a modulation of %s" %
                (str(linksnr), mods))

        wgbw.webgui_logoff()
        wgbw.webgui_close_connection()

    ## ========== Step 6 ==========
    # Set ACM 55MHz with Max Mod = 1024QAM and Base Mod = QPSK - Also set ATPC
    logging.info('Set Nodes for: 55MHz ACM QPSK to 1024QAM with ATPC')

    for ctrip in [ctr1.ipaddress, ctr2.ipaddress]:

        wgacm = webgui(ctrip, 'Firefox')
        wgacm.webgui_logon()
        time.sleep(5)
        wgacm.webgui_set_page('Radio Configuration',
                              'Radio Link Configuration')
        time.sleep(5)
        # set ACM modulation
        wgacm.webgui_rf_set_modulation(
            ['QPSK', '1024QAM HIGH GAIN', '1024QAM HIGH GAIN'])
        time.sleep(2)
        wgacm.webgui_apply()
        time.sleep(2)
        # set ATPC
        wgacm.webgui_rf_set_atpc(True)
        pwrnge = wgacm.webgui_rf_get_pwr_range()
        wgacm.webgui_rf_apply_tx_power([pwrnge[0], pwrnge[1]], fade='10')
        time.sleep(2)

        wgacm.webgui_logoff()
        wgacm.webgui_close_connection()

    logging.info("MATRIX box should already be set for an RSL of -45 dB")
    logging.info("Checking for Traffic Flow and Alarms")

    # login to Node
    wgacm = webgui(ctr1.ipaddress, 'Firefox')
    wgacm.webgui_logon()
    time.sleep(5)
    wgacm.webgui_set_page('Radio Configuration', 'Radio Link Configuration')
    time.sleep(5)

    # ensure traffic is flowing
    if ss.simspr_line_check('3/9', '3/10'):  # use correct ports for this
        results.set_verify("PASS", util.gframe(),
                           "Traffic is still flowing after ACM being set")
    else:
        # if no RF link stop script
        results.set_verify("FAIL", util.gframe(),
                           "Traffic is NOT flowing after ACM being set")
        end_script('error', results, rig, start_time, wgacm, ss)
        quit()

    # check for alarms
    currentalarms = check_alarms(wgacm)
    if startalarms_ctr1 == currentalarms:
        results.set_verify("PASS", util.gframe(),
                           "No alarms have been raised due to ACM being set")
    else:
        results.set_verify("FAIL", util.gframe(),
                           "Alarms have been raised due to ACM being set")

    wgacm.webgui_logoff()
    wgacm.webgui_close_connection()

    ## ========== Step 6 ==========
    # Create a very slow fade and capture all changes in Modulation due to fade
    logging.info(
        'Create a very slow fade and capture all changes in Modulation due to fade'
    )

    wgfade = webgui(ctr1.ipaddress, 'Firefox')
    wgfade.webgui_logon()
    time.sleep(5)
    wgfade.webgui_set_page('Statistics', 'Radio Link')
    time.sleep(5)

    # get current radio link values
    initial_att = float(matrix.get_att(11))
    rlstats = wgfade.webgui_stat_get_radio_links()
    initial_mod = str(
        rlstats['Radio Interface 1/4/1']['Current Rx Modulation'])
    initial_pwr = str(rlstats['Radio Interface 1/4/1']['Tx Power'])
    logging.info(
        "Current Settings are %s at %s with %s dB attenuation in the path" %
        (initial_mod, initial_pwr, str(initial_att)))

    shifted_mod = initial_mod
    atpc = False
    acm = 0
    # recursive loop
    logging.info('Fading attenuator to get change of Modulation')
    for x in range(1, 45, 2):
        # fade attenuator by 1dB
        matrix.set_att_fade(11, initial_att + x, 1)
        time.sleep(1)
        curstats = wgfade.webgui_stat_get_radio_links()
        cur_mod = str(
            curstats['Radio Interface 1/4/1']['Current Rx Modulation'])
        cur_pwr = str(curstats['Radio Interface 1/4/1']['Tx Power'])
        if cur_mod != shifted_mod:
            acm += 1
            logging.info(
                'A change of Modulation has taken place. From %s to %s' %
                (shifted_mod, cur_mod))
            shifted_mod = cur_mod
        if float(cur_pwr.replace(' dBm', '')) >= float(
                initial_pwr.replace(' dBm', '')) + 5 or float(
                    cur_pwr.replace(' dBm', '')) <= float(
                        initial_pwr.replace(' dBm', '')) - 5:
            if not atpc:
                logging.info(
                    "A change of Tx Power of more than 5dB has shown ATPC works as expected"
                )
                atpc = True

    if atpc:
        results.set_verify(
            "PASS", util.gframe(),
            "Changes in Tx Power of more than 5dB have shown that ATPC is working as expected"
        )
    else:
        results.set_verify(
            "FAIL", util.gframe(),
            "Changes in Tx Power of more than 5dB have NOT been seen indicating that ATPC is NOT working as expected"
        )

    if acm >= 1:
        results.set_verify(
            "PASS", util.gframe(),
            "Modulation changes due to an RF fade has shown ACM is working as expected"
        )
    else:
        results.set_verify(
            "FAIL", util.gframe(),
            "Modulation changes due to an RF fade have NOT been seen indicating that ACM is NOT working as expected"
        )

    ## ========== Step 7 ==========
    # Unfade link and ensure Modulation is restored to 1024QAM
    logging.info("Unfade link and ensure Modulation is restored to 1024QAM")

    matrix.set_att_fade(11, initial_att, 5)
    time.sleep(10)

    curstats = wgfade.webgui_stat_get_radio_links()
    cur_mod = str(curstats['Radio Interface 1/4/1']['Current Rx Modulation'])
    if cur_mod == initial_mod:
        results.set_verify(
            "PASS", util.gframe(),
            "Modulation has returned to its Maximum setting after an RF Unfade"
        )
    else:
        results.set_verify(
            "FAIL", util.gframe(),
            "Modulation has NOT returned to its Maximum setting after an RF Unfade"
        )

    wgfade.webgui_logoff()
    wgfade.webgui_close_connection()

    ## ========== Test Step rollback ==========
    # all commands to rollback the configuration that has taken place throughout this script

    logging.info(
        'Rollback Not needed all settings will be reset during next testscript configuration'
    )

    wg1 = webgui(ctr1.ipaddress, 'Firefox')
    wg1.webgui_logon()
    time.sleep(5)
    # run the end script
    end_script('Normal', results, rig, start_time, wg1, ss)
    quit()
示例#9
0
def test_template():
    
    # ========== Testrig and Testscript Initialization ==========
    # Initiate Testrig object - this handles all testrig objects as well as Topology and Config setup
    
    rig = TestRig("DVTA-CT-8", "T008.ini", "C001.ini", developmentrig, True)  # testcase ID, topology filename, config filename, developmentrig and Initialization Requirement
    
    # simple path to each of the Nodes (remove the ones that aren't needed)
    ctr1 = rig.nodes['node1']
    ctr2 = rig.nodes['node2']
    # ctr3 = rig.nodes['node3']
    # ctr4 = rig.nodes['node4']
    
    # simple path to each of the Test Equipment ((remove the ones that aren't needed)
    # mrv = rig.devices['MRV']
    matrix = rig.devices['MATRIX']
    ss = rig.devices['SPIRENT']
    
    # logging - start of test script and other basic info
    start_sw_version = ctr1.get_sw_version()  # rig.nodes['node1'].get_sw_version()
    start_time = time.time()
    logging.info('START %s, version %s' % (test_template.__name__, VERSION))
    logging.info('Current Software Build installed = %s' % (start_sw_version))
    
    # Results - xml or excel writer (REMOVE ONE)
    results = xmlwriter("DVTA-CT-8", "T007", "Verify that the RF Monitoring features are available via the CraftTool")  # testcase ID, Topology Used, Test Case Description
    # results = ExcelWriter() 
    
    # Initialize the required libraries
    util = utils()

    ## ========== Pre-Flow setup and checks ==========
    # Carry out all of the basic setup here which is not testable items
    
    # log the software pack to be used
    test_sw_dir = "C:/swpacks/"  # the desired test sw dir
    test_sw_vers = os.listdir(test_sw_dir)[0]  # the desired swpack
    logging.info('Current Cycle Software to be tested = %s' % (test_sw_vers))
    
    # Initialize Webgui
    wg = webgui(ctr1.ipaddress, 'Firefox')
    wg.webgui_logon()
    
    # establish a starting list of alarms and check to ensure there are no Critical alarms
    startalarms = check_alarms(wg)
    print_alarms(startalarms) 
    
    # check that we have a working rf link by passing 10sec of traffic and ensure no dropped frames check up to 3 times
    if ss.simspr_line_check('3/9', '3/10'):  # use correct ports for this
        logging.info('Spirent connection confirmed ... continuing with test script')
    else:
        # if no RF link stop script
        logging.error('Spirent connection has not been established correctly after 3 attempts.')
        end_script('error', results, rig, start_time, wg, ss)
            
    # Start a spirent outage run for outage capture    
    ss.simspir_start_outage_run('3/9', '3/10')
    logging.info('Starting Spirent Traffic for outage capture')
    
    # Check that the current software version is loaded, if not, load it.
    curr_sw_version = util.format_SWpack_str(start_sw_version)
    if not os.path.exists(os.path.join(test_sw_dir, curr_sw_version)):
        logging.info("Currently loaded Software Pack is %s. Loading the latest test build - %s." % (curr_sw_version, test_sw_vers))
        swpack = load_SWpack(os.path.join(test_sw_vers), wg)
        if swpack[0] and swpack[2]:
            # Successful downgrade - send results and clear spirent counters
            results.set_verify("LOG", util.gframe(), "%s has been upgraded to the latest test build %s" % (ctr2.name, test_sw_vers))
            results.set_verify("LOG", util.gframe(), 'RF Outage during downgrade was %s milliseconds' % str(ss.simspir_get_value_outage_run()[0]))
            wg = webgui(ctr2.ipaddress, 'Firefox')
            wg.webgui_logon()
        else:
            # Unsuccessful downgrade - send results and end script safely
            results.set_verify("ERROR", util.gframe(), "%s has NOT been upgraded to the latest test build %s for unknown reasons" % (ctr2.name, test_sw_vers))
            end_script('error', results, rig, start_time, wg, ss)
            
    ## ========== Test step flow ==========
    
    ## ========== Step 1 ========== 
    # Capture RF performance results from RF link
    
    # Open webgui and capture results
    wg = webgui(ctr2.ipaddress, 'Firefox')
    wg.webgui_logon()
    time.sleep(5)
    wg.webgui_set_page('Statistics', 'Radio Link')
    time.sleep(5)
    rflinkstats = wg.webgui_stat_get_radio_links()
    uplink = rflinkstats['Radio Interface 1/3/1']
    logging.info(uplink)
    results.set_verify("VALUE", util.gframe(), [['BER', uplink['Current BER']], ['Remote RSL', uplink['Remote RSL']], ['Remote SNR', uplink['Remote SNR']],
                                                ['Local RSL', uplink['Local RSL']], ['Local SNR', uplink['Local SNR']], ['Tx Power', uplink['Tx Power']]])
    
    # extract local RSL
    initialRSL = rflinkstats['Radio Interface 1/3/1']['Local RSL'][:-3]
    
    ## ========== Step 2 ========== 
    # fade link by 10dB
    matrix.set_att(11, 10)
    
    ## ========== Step 3 ========== 
    # capture new results and ensure that they are different from the initial ones
    
    change_expected = True
    for x in range(5):
        rflinkstats = wg.webgui_stat_get_radio_links()
        uplink = rflinkstats['Radio Interface 1/3/1']
        logging.info(uplink)
        results.set_verify("VALUE", util.gframe(), [['BER', uplink['Current BER']], ['Remote RSL', uplink['Remote RSL']], ['Remote SNR', uplink['Remote SNR']],
                                                ['Local RSL', uplink['Local RSL']], ['Local SNR', uplink['Local SNR']], ['Tx Power', uplink['Tx Power']]])
    
        # extract local RSL
        finalRSL = rflinkstats['Radio Interface 1/3/1']['Local RSL'][:-3]
        if float(finalRSL) <= float(initialRSL) - 9:
            # Successful test condition - send results and clear spirent counters
            results.set_verify("PASS", util.gframe(), "Radio Link Statistics are working as expected ")
            change_expected = False
            break
        else:
            time.sleep(1)
            
    if change_expected:
        results.set_verify("FAIL", util.gframe(), "There was no change in Local RSL")
    
    # check alarms on webgui (assumes webgui is open)  
    currentalarms = check_alarms(wg)
    if startalarms != currentalarms:
        print_alarms(currentalarms)
        
    ## ========== Step 4 ========== 
    # go to the radio link performance page and capture the current RSL 
    
    wg.webgui_set_page('Statistics', 'Radio Link Performance')
    time.sleep(5)

    curRSL = wg.webgui_rlp_get_rsl('Radio Interface 1/3/1')
    time.sleep(2)
    
    # check that the RSL value is the same as the one captured just before
    if float(curRSL) <= float(finalRSL) + 1 and float(curRSL) >= float(finalRSL) - 1:
        results.set_verify("PASS", util.gframe(), "The RSL displayed on the Radio Link Performance page is within 1dB of previously recorded values as expected")
    else:
        results.set_verify("FAIL", util.gframe(), "The RSL displayed on the Radio Link Performance page is NOT within 1dB of previously recorded values")
        
    # unfade link by 10dB
    matrix.set_att(11, 0)
    time.sleep(5)
    
    wg.webgui_set_page('Statistics', 'Radio Link Performance')
    time.sleep(5)
    
    endRSL = wg.webgui_rlp_get_rsl('Radio Interface 1/3/1')
    time.sleep(2)
    
    if float(endRSL) >= float(curRSL) + 9:
        results.set_verify("PASS", util.gframe(), "The RSL displayed on the Radio Link Performance page has changed to the expected value")
    else:
        results.set_verify("FAIL", util.gframe(), "The RSL displayed on the Radio Link Performance page has NOT changed to the expected value")
    
    ## ========== Step 5 ========== 
    # go to the sensors page and capture all information
    
    wg.webgui_set_page('Status', 'Sensors')
    time.sleep(5)
    firstsensors = wg.webgui_sensor_get_info()
    logging.info(firstsensors)
    time.sleep(2)
    if 'FAN Tray 1/1' in firstsensors:
        results.set_verify("PASS", util.gframe(), "Sensors Page is displaying information as expected")
    else:
        results.set_verify("FAIL", util.gframe(), "Sensors Page is NOT displaying information as expected")
        
    ## ========== Step 6 ========== 
    # wait several seconds and then ensure results have changed
    secondsensors = wg.webgui_sensor_get_info()
    logging.info(secondsensors)
    
    if not firstsensors == secondsensors:
        results.set_verify("PASS", util.gframe(), "Sensors Page is updating the information as expected")
    else:
        results.set_verify("FAIL", util.gframe(), "Sensors Page is NOT updating the information as expected")
    
    ## ========== Test Step rollback ==========
    # all commands to rollback the configuration that has taken place throughout this script

    # run the end script
    end_script('Normal', results, rig, start_time, wg, ss)
    
    quit()
示例#10
0
def test_template():
    
    # ========== Testrig and Testscript Initialization ==========
    # Initiate Testrig object - this handles all testrig objects as well as Topology and Config setup
    
    rig = TestRig("DVTA-CT-9", "T008.ini", "C001.ini", developmentrig, True)  # testcase ID, topology filename, config filename, developmentrig and Initialization Requirement
    
    # simple path to each of the Nodes (remove the ones that aren't needed)
    ctr1 = rig.nodes['node1']
    ctr2 = rig.nodes['node2']
    # ctr3 = rig.nodes['node3']
    # ctr4 = rig.nodes['node4']
    
    # simple path to each of the Test Equipment ((remove the ones that aren't needed)
    # mrv = rig.devices['MRV']
    # matrix = rig.devices['MATRIX']
    ss = rig.devices['SPIRENT']
    
    # logging - start of test script and other basic info
    start_sw_version = ctr1.get_sw_version()  # rig.nodes['node1'].get_sw_version()
    start_time = time.time()
    logging.info('START %s, version %s' % (test_template.__name__, VERSION))
    logging.info('Current Software Build installed = %s' % (start_sw_version))
    
    # Results - xml or excel writer (REMOVE ONE)
    results = xmlwriter("DVTA-CT-9", "T008", "Basic Alarm and Event Logging functions of CraftTool")  # testcase ID, Topology Used, Test Case Description
    # results = ExcelWriter() 
    
    # Initialize the required libraries
    util = utils()

    ## ========== Pre-Flow setup and checks ==========
    # Carry out all of the basic setup here which is not testable items
    
    # log the software pack to be used
    test_sw_dir = "C:/swpacks/"  # the desired test sw dir
    test_sw_vers = os.listdir(test_sw_dir)[0]  # the desired swpack
    logging.info('Current Cycle Software to be tested = %s' % (test_sw_vers))
    
    # Initialize Webgui
    wg = webgui(ctr1.ipaddress, 'Firefox')
    wg.webgui_logon()
    
    # establish a starting list of alarms and check to ensure there are no Critical alarms
    startalarms = check_alarms(wg)
    print_alarms(startalarms) 
    
    # check that we have a working rf link by passing 10sec of traffic and ensure no dropped frames check up to 3 times
    if ss.simspr_line_check('3/9', '3/10'):  # use correct ports for this
        logging.info('Spirent connection confirmed ... continuing with test script')
    else:
        # if no RF link stop script
        logging.error('Spirent connection has not been established correctly after 3 attempts.')
        end_script('error', results, rig, start_time, wg, ss)
            
    # Start a spirent outage run for outage capture    
    ss.simspir_start_outage_run('3/9', '3/10')
    logging.info('Starting Spirent Traffic for outage capture')
    
    # Check that the current software version is loaded, if not, load it.
    curr_sw_version = util.format_SWpack_str(start_sw_version)
    if not os.path.exists(os.path.join(test_sw_dir, curr_sw_version)):
        logging.info("Currently loaded Software Pack is %s. Loading the latest test build - %s." % (curr_sw_version, test_sw_vers))
        swpack = load_SWpack(os.path.join(test_sw_vers), wg)
        if swpack[0] and swpack[2]:
            # Successful downgrade - send results and clear spirent counters
            results.set_verify("LOG", util.gframe(), "%s has been upgraded to the latest test build %s" % (ctr2.name, test_sw_vers))
            results.set_verify("LOG", util.gframe(), 'RF Outage during downgrade was %s milliseconds' % str(ss.simspir_get_value_outage_run()[0]))
            wg = webgui(ctr2.ipaddress, 'Firefox')
            wg.webgui_logon()
        else:
            # Unsuccessful downgrade - send results and end script safely
            results.set_verify("ERROR", util.gframe(), "%s has NOT been upgraded to the latest test build %s for unknown reasons" % (ctr2.name, test_sw_vers))
            end_script('error', results, rig, start_time, wg, ss)
            
    ## ========== Test step flow ==========
    
    ## ========== Step 1 ========== 
    # go to the port Manager page and enable a disconnected port
    logging.info('Go to the Port Manager page and enable a disconnected port')
    
    wg.webgui_set_page('Ethernet Configuration', 'Port Manager')
    time.sleep(5)
    wg.webgui_eth_set_port_enable(5)
    
    # wait for 5 minutes to ensure the alarm is raised (there is an existing JIRA for this)
    time.sleep(300)
    
    # go to the Alarms page and ensure the that the Alarm has been raised
    currentalarms = check_alarms(wg)
    print_alarms(currentalarms) 
    
    foundalarm = False
    for x in currentalarms:
        if 'Ethernet port link down' in x[3]:
            foundalarm = True
            
    if foundalarm:
        # Successful test condition - send results and clear spirent counters
        results.set_verify("PASS", util.gframe(), "The Ethernet port link down Alarm was raised as expected")
    else:
        # Unsuccessful test condition - send results and end script safely
        results.set_verify("FAIL", util.gframe(), "The Ethernet port link down Alarm was not raised as expected")

    ## ========== Step 2 ========== 
    # ensure that the ALarm has a history tag attached to it
    logging.info('Ensure that the ALarm has a history tag attached to it')
    
    historyalarms = wg.webgui_alarm_get_history()
    print_alarms(historyalarms)
    
    foundalarm = False
    for x in currentalarms:
        if 'Ethernet port link down' in x[3]:
            foundalarm = True
            
    if foundalarm:
        results.set_verify("PASS", util.gframe(), "The Ethernet port link down Alarm is displayed as recently raised ... as expected")
    else:
        results.set_verify("FAIL", util.gframe(), "The Ethernet port link down Alarm was not  displayed as recently raised")

    wg.webgui_set_page('Ethernet Configuration', 'Port Manager')
    time.sleep(5)
    wg.webgui_eth_set_port_disable(5)
    time.sleep(10)
    
    ## ========== Step 3 ========== 
    # This is where Log Event testing will go however this needs work and will be done in the future
    
    ## ========== Test Step rollback ==========
    # all commands to rollback the configuration that has taken place throughout this script

    # run the end script
    end_script('Normal', results, rig, start_time, wg, ss)
    
    quit()
示例#11
0
def test_template():

    # ========== Testrig and Testscript Initialization ==========
    # Initiate Testrig object - this handles all testrig objects as well as Topology and Config setup

    rig = testrig.TestRig(
        "DVTA-CT-5", "T008.ini", "C001.ini", developmentrig, False
    )  # testcase ID, topology filename, config filename, developmentrig and Initialization Requirement

    # simple path to each of the Nodes (remove the ones that aren't needed)
    ctr1 = rig.nodes['node1']

    # logging - start of test script and other basic info
    start_sw_version = ctr1.get_sw_version()
    start_time = time.time()
    logging.info('START %s, version %s' % (test_template.__name__, VERSION))
    logging.info('Current Software Build installed = %s' % (start_sw_version))

    # Results - xml or excel writer (REMOVE ONE)
    results = xmlwriter(
        "DVTA-CT-1", "T007",
        "Basic Software Loading and Configuration functions of CraftTool"
    )  # testcase ID, Topology Used, Test Case Description
    # results = ExcelWriter()

    # Initialize the required libraries
    util = utils()

    ## ========== Pre-Flow setup and checks ==========
    # Carry out all of the basic setup here which is not testable items

    # log the software pack to be used
    test_sw_dir = "C:/swpacks/"  # the desired test sw dir
    test_sw_vers = os.listdir(test_sw_dir)[0]  # the desired swpack
    logging.info('Current Cycle Software to be tested = %s' % (test_sw_vers))

    # Initialize Webgui
    wg = ctr8500_webgui.webgui(ctr1.ipaddress, 'Firefox')
    wg.webgui_logon()

    # establish a starting list of alarms and check to ensure there are no Critical alarms
    startalarms = check_alarms(wg)
    print_alarms(startalarms)

    # Check that the current software version is loaded, if not, load it.
    curr_sw_version = util.format_SWpack_str(start_sw_version)
    if not os.path.exists(os.path.join(test_sw_dir, curr_sw_version)):
        logging.info(
            "Currently loaded Software Pack is %s. Loading the latest test build - %s."
            % (curr_sw_version, test_sw_vers))
        swpack = load_SWpack(os.path.join(test_sw_vers), wg)
        if swpack[0] and swpack[2]:
            # Successful downgrade - send results and clear spirent counters
            results.set_verify(
                "LOG", util.gframe(),
                "%s has been upgraded to the latest test build %s" %
                (ctr1.name, test_sw_vers))
        else:
            # Unsuccessful downgrade - send results and end script safely
            results.set_verify(
                "ERROR", util.gframe(),
                "%s has NOT been upgraded to the latest test build %s for unknown reasons"
                % (ctr1.name, test_sw_vers))
            end_script('error', results, rig, start_time, wg)

    wg.webgui_logoff()
    wg.webgui_close_connection()

    ## ========== Test step flow ==========

    ## ========== Step 1 to 3 ==========
    # Connect to Node with Chrome, IE and Firefox and ensure correct Host and User name are displayed - check that progress indicator is "available"

    browsers = ['Chrome', 'IE', 'Firefox']
    for brow in browsers:
        # open new browser window
        wgbr = ctr8500_webgui.webgui(ctr1.ipaddress, brow)
        wgbr.webgui_logon()
        time.sleep(1)

        # check for progress indicator
        if wgbr.webgui_progress_indicator():
            logging.info(
                'Progress Indicator was shown before page load was completed as expected'
            )
            results.set_verify(
                "PASS", util.gframe(),
                "Progress Indicator was shown before page load was completed as expected"
            )
        else:
            logging.info(
                'Progress Indicator was NOT shown during the capture time')
            results.set_verify(
                "LOG", util.gframe(),
                "Progress Indicator was NOT shown during the capture time")

        try:
            # check for correct CTR Host Name and User Name
            if wgbr.webgui_systeminfo_get_nodename() == 'CTR8540-211':
                if wgbr.webgui_systeminfo_get_username() == 'root':
                    # Successful test condition - send results and clear spirent counters
                    results.set_verify(
                        "PASS", util.gframe(),
                        "Successful Logon to CTR8540-211 via the %s web browser. Host and User Name were displayed correctly"
                        % brow)
                else:
                    results.set_verify(
                        "FAIL", util.gframe(),
                        "Successful Logon to CTR8540-211 via the %s web browser. However, User Name was not displayed correctly"
                        % brow)
            else:
                results.set_verify(
                    "FAIL", util.gframe(),
                    "Successful Logon to CTR8540-211 via the %s web browser. However, Host Name was not displayed correctly"
                    % brow)
        except:
            results.set_verify(
                "FAIL", util.gframe(),
                "UnSuccessful Logon to CTR8540-211 via the %s web browser." %
                brow)
            end_script('error', results, rig, start_time, wg)

        # logoff and close browser
        wgbr.webgui_logoff()
        wgbr.webgui_close_connection()

    ## ========== Step 4 - 5 ==========
    # STEP 4 -Connect to Node with 4 separate Browsers (should be able to log into 4)

    logincount = 0

    # LOGIN 1 - IE
    wg1 = ctr8500_webgui.webgui(ctr1.ipaddress, 'IE')
    wg1.webgui_logon()
    time.sleep(1)
    if wg1.webgui_check_login_error() == 'Logged In':
        logincount += 1

    # LOGIN 2 - Firefox 1
    wg2 = ctr8500_webgui.webgui(ctr1.ipaddress, 'Firefox')
    wg2.webgui_logon()
    time.sleep(1)
    if wg2.webgui_check_login_error() == 'Logged In':
        logincount += 1

    # LOGIN 3 - Firefox 2
    wg3 = ctr8500_webgui.webgui(ctr1.ipaddress, 'Firefox')
    wg3.webgui_logon()
    time.sleep(1)
    if wg3.webgui_check_login_error() == 'Logged In':
        logincount += 1

    # LOGIN 4 - Firefox 3
    wg4 = ctr8500_webgui.webgui(ctr1.ipaddress, 'Firefox')
    wg4.webgui_logon()
    time.sleep(1)
    if wg4.webgui_check_login_error() == 'Logged In':
        logincount += 1

    if logincount == 4:
        results.set_verify(
            "PASS", util.gframe(),
            "Successfully logged into %s 4 times via browser" % ctr1.name)
    else:
        results.set_verify(
            "FAIL", util.gframe(),
            "Unsuccessfully logged into %s 4 times via browser. Only %s logins were successful"
            % (ctr1.name, str(logincount)))

    ## ========== Step 5 ==========
    # Try to connect with a fifth browser and ensure user is not allowed access

    # LOGIN 5 - Firefox 4
    rejectuser = True
    wg5 = ctr8500_webgui.webgui(ctr1.ipaddress, 'Firefox')
    wg5.webgui_logon()
    time.sleep(1)
    if wg5.webgui_check_login_error() == 'Logged In':
        rejectuser = False
        wg5.webgui_logoff()
    wg5.webgui_close_connection()

    if rejectuser:
        results.set_verify(
            "PASS", util.gframe(),
            "5th Login Attempt to %s was unsuccessful as expected." %
            ctr1.name)
    else:
        results.set_verify(
            "FAIL", util.gframe(),
            "5th Login Attempt to %s was Successful. Should of been rejected" %
            (ctr1.name, str(logincount)))

    ## ========== Step 6 ==========
    # Edit Host name on one browser and ensure (once a refresh is done) that the name change is now shown on all browsers correctly

    teststr = 'DTVA-UI-Test'
    wg4.webgui_set_page("System Configuration", "System Information")
    time.sleep(10)
    wg4.webgui_systeminfo_nodename(teststr)
    time.sleep(5)

    nodenamecheck = 0
    for wnode in [wg1, wg2, wg3]:
        wnode.webgui_refresh()
        if wnode.webgui_systeminfo_get_nodename() == teststr:
            nodenamecheck += 1

    if nodenamecheck == 3:
        results.set_verify(
            "PASS", util.gframe(),
            "The Host Name change has been distributed correctly to all logged in users on %s"
            % ctr1.name)
    else:
        results.set_verify(
            "FAIL", util.gframe(),
            "The Host Name change has not been successfully executed on %s" %
            ctr1.name)

    wg4.webgui_set_page("System Configuration", "System Information")
    time.sleep(5)
    wg4.webgui_systeminfo_nodename('CTR8540-211')
    time.sleep(5)

    ## ========== Step 7 ==========
    # Try to connect via CLI (should work and change host name)

    # Try to log on to the node via the CLI - and set a new node name
    if ctr1.sendcli(['c t', 'set switch-name ' + teststr]) == '':
        results.set_verify(
            "PASS", util.gframe(),
            "With 4 logged on webgui users, connection was still possible on %s via CLI"
            % ctr1.name)
        time.sleep(5)
    else:
        results.set_verify(
            "FAIL", util.gframe(),
            "With 4 logged on webgui users, connection was NOT possible on %s via CLI"
            % ctr1.name)

    # check that this test node name has been distributed to all logged on users
    nodenamecheck = 0
    for wnode in [wg1, wg2, wg3, wg4]:
        wnode.webgui_refresh()
        if wnode.webgui_systeminfo_get_nodename() == teststr:
            nodenamecheck += 1

    if nodenamecheck == 4:
        results.set_verify(
            "PASS", util.gframe(),
            "The Host Name change has been distributed correctly from CLI to all logged in users on %s"
            % ctr1.name)
    else:
        results.set_verify(
            "FAIL", util.gframe(),
            "The Host Name change has not been successfully executed from CLI on %s"
            % ctr1.name)

    # change node name back to default name
    wg4.webgui_set_page("System Configuration", "System Information")
    wg4.webgui_systeminfo_nodename('CTR8540-211')
    time.sleep(5)

    ## ========== Step 8 ==========
    # close all browsers

    for wnode in [wg4, wg3, wg2, wg1]:
        wnode.webgui_logoff()
        wnode.webgui_close_connection()

    ## ========== Step 9 ==========
    # Log in as Guest and check that editing ability is not available

    # set the list of pages to check
    pagelist = [["System Configuration", "System Information"],
                ["System Configuration", "Date & Time"],
                ["System Configuration", "PoE Configuration"],
                ["System Configuration", "Backup Power"],
                ["Ethernet Configuration", "Port Manager"],
                ["Radio Configuration", "Radio Link Configuration"],
                ["TDM Configuration", "Tributary Diagnostics"]]

    # the list of expected outcomes
    setlist = [["System Information", 0], ["Date & Time", 0],
               ["PoE Configuration", 0], ["Backup Power", 0],
               ["Port Manager", 0], ["Radio Link Configuration", 0],
               ["Tributary Diagnostics", 0]]

    wg1 = ctr8500_webgui.webgui(ctr1.ipaddress, 'Firefox')
    wg1.webgui_logon('guest', 'guest123')
    time.sleep(5)

    inputlist = wg1.webgui_guestuser_check(pagelist)

    if inputlist == setlist:
        results.set_verify(
            "PASS", util.gframe(),
            "The Guest User was restricted in the configuration of %s as expected"
            % ctr1.name)
    else:
        results.set_verify(
            "FAIL", util.gframe(),
            "The Guest User was able to configure parts of %s they are not authorised to"
            % ctr1.name)

    wg1.webgui_logoff()
    wg1.webgui_close_connection()

    ## ========== Step 10 ==========
    # Try connecting via https

    wgs = ctr8500_webgui.webgui('https://' + ctr1.ipaddress, 'Firefox')
    wgs.webgui_logon()
    time.sleep(5)

    if wgs.webgui_check_login_error() == 'Logged In':
        results.set_verify(
            "PASS", util.gframe(),
            "Successful entry into %s via a secure path (https)" % ctr1.name)
    else:
        results.set_verify(
            "FAIL", util.gframe(),
            "Unsuccessful entry into %s via a secure path (https)" % ctr1.name)

    ## ========== Test Step rollback ==========
    # all commands to rollback the configuration that has taken place throughout this script

    # Nothing to rollback

    # run the end script
    end_script('Normal', results, rig, start_time, wgs)

    quit()
示例#12
0
def test_template():

    # ========== Testrig and Testscript Initialization ==========
    # Initiate Testrig object - this handles all testrig objects as well as Topology and Config setup

    rig = TestRig(
        "DVTA-CT-7-D", "T009.ini", "C003.ini", developmentrig, True
    )  # testcase ID, topology filename, config filename, developmentrig and Initialization Requirement

    # simple path to each of the Nodes (remove the ones that aren't needed)
    ctr1 = rig.nodes['node1']
    ctr2 = rig.nodes['node2']
    # ctr3 = rig.nodes['node3']
    # ctr4 = rig.nodes['node4']

    # simple path to each of the Test Equipment ((remove the ones that aren't needed)
    # mrv = rig.devices['MRV']
    matrix = rig.devices['MATRIX']
    ss = rig.devices['SPIRENT']

    # logging - start of test script and other basic info
    start_sw_version = ctr1.get_sw_version(
    )  # rig.nodes['node1'].get_sw_version()
    start_time = time.time()
    logging.info('START %s, version %s' % (test_template.__name__, VERSION))
    logging.info('Current Software Build installed = %s' % (start_sw_version))

    # Results - xml or excel writer (REMOVE ONE)
    results = xmlwriter(
        "DVTA-CT-7-C", "T009",
        "Basic Software Loading and Configuration functions of CraftTool"
    )  # testcase ID, Topology Used, Test Case Description
    # results = ExcelWriter()

    # Initialize the required libraries
    util = utils()

    ## ========== Pre-Flow setup and checks ==========
    # Carry out all of the basic setup here which is not testable items

    # log the software pack to be used
    test_sw_dir = "C:/swpacks/"  # the desired test sw dir
    test_sw_vers = os.listdir(test_sw_dir)[0]  # the desired swpack
    logging.info('Current Cycle Software to be tested = %s' % (test_sw_vers))

    # establish a starting list of alarms and check to ensure there are no Critical alarms
    startalarms = check_alarms(ctr1.ipaddress)
    print_alarms(startalarms)

    # Initialize Webgui
    wg = webgui(ctr2.ipaddress, 'Firefox')
    wg.webgui_logon()
    # Check that the current software version is loaded, if not, load it.
    curr_sw_version = util.format_SWpack_str(start_sw_version)
    if not os.path.exists(os.path.join(test_sw_dir, curr_sw_version)):
        logging.info(
            "Currently loaded Software Pack is %s. Loading the latest test build - %s."
            % (curr_sw_version, test_sw_vers))
        swpack = load_SWpack(os.path.join(test_sw_vers), wg)
        if swpack[0] and swpack[2]:
            # Successful downgrade - send results and clear spirent counters
            results.set_verify(
                "LOG", util.gframe(),
                "%s has been upgraded to the latest test build %s" %
                (ctr1.name, test_sw_vers))
            results.set_verify(
                "LOG", util.gframe(),
                'RF Outage during downgrade was %s milliseconds' %
                str(ss.simspir_get_value_outage_run()[0]))
            wg = webgui(ctr2.ipaddress, 'Firefox')
            wg.webgui_logon()
        else:
            # Unsuccessful downgrade - send results and end script safely
            results.set_verify(
                "ERROR", util.gframe(),
                "%s has NOT been upgraded to the latest test build %s for unknown reasons"
                % (ctr2.name, test_sw_vers))
            end_script('error', results, rig, start_time, wg, ss)
            quit()

    ## ========== Test step flow ==========

    ## ========== Step 1 ==========
    # adjust the individual RF Links for -45dBm RSL

    logging.info('adjust the individual RF Links for -45dBm RSL')

    rslattens = []
    # A. set each link to -45dBm RSL and capture this value for future reference
    for rfint in [['1/3/1', 11], ['1/3/2', 21]]:
        wgrsl = webgui(ctr2.ipaddress, 'Firefox')
        wgrsl.webgui_logon()
        time.sleep(5)
        wgrsl.webgui_set_page('Radio Configuration',
                              'Radio Link Configuration')
        time.sleep(2)
        wgrsl.webgui_rf_set_radio_int('RADIO INT ' + rfint[0])
        time.sleep(2)
        if set_matrix(wgrsl, matrix, rfint[1]):
            rslattens.append(matrix.get_att(rfint[1]))
        else:
            logging.error(
                'RSL has not been set to -45dBm correctly of RADIO INT %s. Quitting testscript'
                % rfint[0])
            end_script('error', results, rig, start_time, wgrsl, ss)
            quit()

        wgrsl.webgui_logoff()
        wgrsl.webgui_close_connection()

    # B. send traffic on these ports and check for correct link
    logging.info('Checking RF Paths are still connected as expected')

    # check that we have a working primary rf link by passing 10sec of traffic and ensure no dropped frames check up to 3 times
    if ss.simspr_line_check('3/9', '3/10'):  # use correct ports for this
        logging.info(
            'Spirent connection confirmed for Primary RF Link ... continuing with test script'
        )
    else:
        # if no RF link stop script
        logging.error(
            'Spirent connection has not been established correctly after 3 attempts.'
        )
        end_script('error', results, rig, start_time, wg, ss)
        quit()

    # send traffic down secondary Link
    ctr1.sendcli('c t; vlan 1; no ports ra 4/1 untagged ra 4/1')
    ctr1.sendcli('c t; vlan 1; ports add ra 4/2 untagged ra 4/2')
    ctr2.sendcli('c t; vlan 1; no ports ra 3/1 untagged ra 3/1')
    ctr2.sendcli('c t; vlan 1; ports add ra 3/2 untagged ra 3/2')
    ctr2.sendcli('c t; int gi 0/1; spanning-tree disable; end')

    # check that we have a working primary rf link by passing 10sec of traffic and ensure no dropped frames check up to 3 times
    if ss.simspr_line_check('3/9', '3/10'):  # use correct ports for this
        logging.info(
            'Spirent connection confirmed for Secondary RF Link ... continuing with test script'
        )
    else:
        # if no RF link stop script
        logging.error(
            'Spirent connection has not been established correctly after 3 attempts.'
        )
        end_script('error', results, rig, start_time, wg, ss)
        quit()

    # send traffic down primary Link
    ctr1.sendcli('c t; vlan 1; no ports ra 4/2 untagged ra 4/2')
    ctr1.sendcli('c t; vlan 1; ports add ra 4/1 untagged ra 4/1')
    ctr2.sendcli('c t; vlan 1; no ports ra 3/2 untagged ra 3/2')
    ctr2.sendcli('c t; vlan 1; ports add ra 3/1 untagged ra 3/1')
    ctr2.sendcli('c t; int ra 3/1; spanning-tree disable; end')

    # C. check to see whether any new alarms have been raised
    currentalarms = check_alarms(ctr1.ipaddress)
    if startalarms != currentalarms:
        print_alarms(currentalarms)
        logging.error('Differences in alarms have been found, not as expected')
        end_script('error', results, rig, start_time, wg, ss)
        quit()
    else:
        logging.info('No Alarms have been raised ... as expected')

    ## ========== Step 2 ==========
    # Set MATRIX to a XPIC Configuration
    logging.info('Set MATRIX to a XPIC Configuration')

    matrix.set_xpic()

    ## ========== Step 3 ==========
    # Create a XPIC RF Link
    logging.info('Create a XPIC RF Link')

    for ctr in [ctr1, ctr2]:
        logging.info('Setting XPIC config on %s' % ctr.name)
        wgxpic = webgui(ctr.ipaddress, 'Firefox')
        wgxpic.webgui_logon()
        time.sleep(5)
        wgxpic.webgui_set_page('Radio Configuration',
                               'Radio Link Configuration')
        time.sleep(2)
        wgxpic.webgui_rf_set_xpic(True)
        time.sleep(2)
        wgxpic.webgui_apply()
        time.sleep(2)
        wgxpic.webgui_logoff()
        wgxpic.webgui_close_connection()

    ## ========== Step 4 ==========
    # Check that XPIC is displayed correctly
    logging.info('Check that XPIC is displayed correctly')

    wgxpic2 = webgui(ctr1.ipaddress, 'Firefox')
    wgxpic2.webgui_logon()
    time.sleep(5)
    wgxpic2.webgui_set_page('Radio Configuration', 'Radio Link Configuration')
    time.sleep(2)
    if wgxpic2.webgui_rf_is_xpic_set():
        results.set_verify("PASS", util.gframe(),
                           'CTR Portal is displaying XPIC as expected')
    else:
        results.set_verify("FAIL", util.gframe(),
                           'CTR Portal is NOT displaying XPIC as expected')
    wgxpic2.webgui_logoff()
    wgxpic2.webgui_close_connection()

    ## ========== Step 5 ==========
    # Ensure that traffic flows on both paths and no alarms or errors are recorded
    logging.info(
        'Ensure that traffic flows on both paths and no alarms or errors are recorded'
    )

    # setup vlans to send traffic down vertical Link only
    ctr1.sendcli('c t; vlan 1; no ports')
    ctr1.sendcli('c t; vlan 1; ports add gi 0/2 ra 4/1 untagged gi 0/2 ra 4/1')
    ctr1.sendcli('sh vlan')
    ctr2.sendcli('c t; vlan 1; no ports')
    ctr2.sendcli('c t; vlan 1; ports add gi 0/2 ra 3/1 untagged gi 0/2 ra 3/1')
    ctr2.sendcli('sh vlan')

    if ss.simspr_line_check('3/9', '3/10'):  # use correct ports for this
        results.set_verify(
            "PASS", util.gframe(),
            'Spirent connection confirmed for Vertical XPIC RF Link ... continuing with test script'
        )
    else:
        # if no RF link stop script
        results.set_verify(
            "FAIL", util.gframe(),
            'Spirent connection has not been confirmed for the Vertical XPIC RF Link correctly after 3 attempts.'
        )

    # setup vlans to send traffic down vertical Link only
    ctr1.sendcli('c t; vlan 1; no ports')
    ctr1.sendcli('c t; vlan 1; ports add gi 0/2 ra 4/2 untagged gi 0/2 ra 4/2')
    ctr1.sendcli('sh vlan')
    ctr2.sendcli('c t; vlan 1; no ports')
    ctr2.sendcli('c t; vlan 1; ports add gi 0/2 ra 3/2 untagged gi 0/2 ra 3/2')
    ctr2.sendcli('sh vlan')

    if ss.simspr_line_check('3/9', '3/10'):  # use correct ports for this
        results.set_verify(
            "PASS", util.gframe(),
            'Spirent connection confirmed for Horizontal XPIC RF Link ... continuing with test script'
        )
    else:
        # if no RF link stop script
        results.set_verify(
            "FAIL", util.gframe(),
            'Spirent connection has not been confirmed for the Horizontal XPIC RF Link correctly after 3 attempts.'
        )

    # check alarmson webgui (assumes webgui is open)
    currentalarms = check_alarms(ctr1.ipaddress)
    if startalarms == currentalarms:
        results.set_verify("PASS", util.gframe(), 'Alarms are as expected.')
        print_alarms(currentalarms)
    else:
        results.set_verify("FAIL", util.gframe(), 'Alarms are NOT as expected')

    ## ========== Step 6 ==========
    # Check that the XPD on BNC is available and selectable

    wgxpd = webgui(ctr1.ipaddress, 'Firefox')
    wgxpd.webgui_logon()
    time.sleep(5)
    wgxpd.webgui_set_page('Radio Configuration', 'Radio Link Diagnostics')
    time.sleep(5)
    wgxpd.webgui_rf_set_xpd_bnc_dura('1/4/1', True)
    time.sleep(15)

    ## ========== Step 7 ==========
    # Ensure Alarm is raised then remove XPD on BNC

    xpd_alarm_chk = check_alarms(ctr1.ipaddress)
    alarmfound = False
    print_alarms(xpd_alarm_chk)
    for al in xpd_alarm_chk:
        for x in al:
            if 'XPD output on BNC' in x:
                results.set_verify("PASS", util.gframe(),
                                   'The expected XPD on BNC alarm was raised')
                alarmfound = True

    if not alarmfound:
        results.set_verify("FAIL", util.gframe(),
                           'The expected XPD on BNC alarm was NOT raised')

    wgxpd.webgui_rf_set_xpd_bnc_dura('1/4/1', False)
    time.sleep(5)
    wgxpd.webgui_logoff()
    wgxpd.webgui_close_connection()

    ## ========== Test Step rollback ==========
    # all commands to rollback the configuration that has taken place throughout this script

    # run the end script
    end_script('Normal', results, rig, start_time, wg, ss)

    quit()
示例#13
0
def sw_management():
    
    # ========== Testrig and Testscript Initialization ==========
    # Initiate Testrig object - this handles all testrig objects as well as Topology and Config setup
    results = xmlwriter("DVTA-CT-1", "T007", "Basic Software Loading and Configuration functions of CraftTool")  # testcase ID, Topology Used, Test Case Description
    rig = TestRig("DVTA-CT-1", "T008.ini", "C001.ini", developmentrig, True)  # testcase ID, topology filename, config filename, developmentrig and Initialization Requirement
    
    # simple path to each of the Nodes (remove the ones that aren't needed)
    ctr1 = rig.nodes['node1']
    ss = rig.devices['SPIRENT']
    start_sw_version = ctr1.get_sw_version()
    
    # logging - start of test script and other basic info
    start_time = time.time()
    logging.info('START %s, version %s' % (sw_management.__name__, VERSION))
    logging.info('Current Software Build installed = %s' % (start_sw_version))
    
    # Results - xml or excel writer (REMOVE ONE)
    # results = xmlwriter.__init__("DVTA-CT-1", "T007", "Basic Software Loading and Configuration functions of CraftTool") # testcase ID, Topology Used, Test Case Description
    
    # Initialize the required libraries
    util = utils()
    
    # set the software pack variables
    test_sw_dir = "C:/swpacks/"  # the desired test sw dir
    test_sw_vers = os.listdir(test_sw_dir)[0]  # the desired swpack
    GA_sw_dir = "C:/GA_swpack/"  # GA swpack directory
    faulty_sw_dir = "C:/swpack_faulty/"  # faulty swpack directory
    sw_repos = "http://192.168.77.1/CTR8540/swpacks/" + util.format_swpack_dir(test_sw_vers)  # swpack remote repository
    
    logging.info('Current Cycle Software to be tested = %s' % (test_sw_vers))
    
    ## ========== Pre-Flow setup and checks ==========
    # 
    
    # Initialize Webgui
    wg = ctr8500_webgui.webgui(ctr1.ipaddress, 'Firefox')
    wg.webgui_logon()
    
    # establish a starting list of alarms and check to ensure there are no Critical alarms
    startalarms = check_alarms(wg)
    print_alarms(startalarms) 
    
    # check that we have a working rf link by passing 10sec of traffic and ensure no dropped frames check up to 3 times
    if ss.simspr_line_check('3/9', '3/10'):
        logging.info('Spirent connection confirmed ... continuing with test script')
    else:
        logging.error('Spirent connection has not been established correctly after 3 attempts.')
        end_script('error', results, rig, start_time, wg, ss)
    
    # Start a spirent outage run     
    ss.simspir_start_outage_run('3/9', '3/10')
    logging.info('Starting Spirent Traffic for outage capture')
    
    ## ========== Test step flow ==========
    
    ## ========== Step 1 ========== 
    # Check that the GA software version is loaded, if not reload it.
    
    curr_sw_version = util.format_SWpack_str(start_sw_version)
    if not os.path.exists(os.path.join(GA_sw_dir, curr_sw_version)):
        logging.info("Currently loaded Software Pack is not the latest GA release. Loading GA Release.")
        gaswpack = load_SWpack(os.path.join(GA_sw_dir, os.listdir(GA_sw_dir)[0]), wg)
        if gaswpack[0]:
            # Successful downgrade - send results and clear spirent counters
            results.set_verify("LOG", util.gframe(), "%s has been downgraded to GA release %s" % (ctr1.name, os.listdir(GA_sw_dir)[0]))
            results.set_verify("LOG", util.gframe(), 'RF Outage during downgrade was %s milliseconds' % str(ss.simspir_get_value_outage_run()[0]))
            wg = ctr8500_webgui.webgui(ctr1.ipaddress, 'Firefox')
            wg.webgui_logon()
        else:
            # Unsuccessful downgrade - send results and end script safely
            results.set_verify("ERROR", util.gframe(), "%s has NOT been downgraded to GA release %s for unknown reasons" % (ctr1.name, os.listdir(GA_sw_dir)[0]))
            end_script('error', results, rig, start_time, wg, ss)
    
    # clear spirent counters and check alarms    
    ss.simspr_clear_counters()
    currentalarms = check_alarms(wg)
    if startalarms != currentalarms:
        print_alarms(currentalarms)
    
    ## ========== Step 2 ==========     
    # Ensure Transfer Error is raised if a faulty swpack is set to be downloaded
    
    if load_SWpack(os.path.join(faulty_sw_dir, os.listdir(faulty_sw_dir)[0]), wg) == "Transfer Error":
        # Successful catch of faulty swpack - send results and report and clear spirent results if required
        results.set_verify("PASS", util.gframe(), "%s has rejected the faulty swpack - Tranfer Error raised as expected" % ctr1.name)
        droppedframes = ss.simspir_get_value_outage_run()[0]
        if droppedframes != 0:    
            results.set_verify("LOG", util.gframe(), 'ISSUE: RF Outage during downgrade was %s milliseconds' % str(droppedframes))
    else:
        # Unsuccessful catch of faulty swpack - send results 
        results.set_verify("FAIL", util.gframe(), "%s has NOT rejected the faulty swpack as expected" % ctr1.name)
        
    wg.webgui_close_connection()
    time.sleep(5)
    
    wg = ctr8500_webgui.webgui(ctr1.ipaddress, 'Firefox')
    wg.webgui_logon()
    
    # clear spirent counters and check alarms  
    ss.simspr_clear_counters()
    currentalarms = check_alarms(wg)
    if startalarms != currentalarms:
        print_alarms(currentalarms)
    
    ## ========== Step 3 ========== 
    # Ensure upgrading to current Swpack is available from the remote repository using a delayed activation time of 4 mins
    
    reposload = load_SWpack(sw_repos + test_sw_vers, wg, "T", 4)
    if reposload[0]:
        if reposload[1] and reposload[2]:
            # Successful upgrade of swpack after a delayed start - send results and report and clear spirent results
            results.set_verify("PASS", util.gframe(), "%s has been upgraded to %s from the remote repository with a delayed activation time set" % (ctr1.name, test_sw_vers))
            results.set_verify("LOG", util.gframe(), 'RF Outage during upgrade was %s milliseconds' % str(ss.simspir_get_value_outage_run()[0]))
        else:
            # Successful upgrade BUT delayed time did not work - send results but carry on
            results.set_verify("FAIL", util.gframe(), "%s has upgraded to %s from the remote repository. However the delayed activation time did not work" % (ctr1.name, test_sw_vers))
    else:
        # Unsuccessful upgrade from repository - send results and end script safely
        results.set_verify("FAIL", util.gframe(), "%s has NOT been upgraded to %s from the remote repository with a delayed activation time set" % (ctr1.name, test_sw_vers))
        end_script('error', results, rig, start_time, wg, ss)
    
    wg = ctr8500_webgui.webgui(ctr1.ipaddress, 'Firefox')
    wg.webgui_logon()
    
    # clear spirent counters and check alarms   
    ss.simspr_clear_counters()
    currentalarms = check_alarms(wg)
    if startalarms != currentalarms:
        print_alarms(currentalarms)
    
    ## ========== Step 4 ==========     
    # Rollback sw to GA version
    
    wg.webgui_set_page("System Configuration", "Software Management", "Admin")
    rollback = wg.webgui_sw_rollback()
    if 'PASS' in rollback:
        if check_sw_vers(os.path.join(GA_sw_dir, os.listdir(GA_sw_dir)[0]), ctr1.ipaddress):
            # successful rollback - send results and report and clear spirent results 
            rollback.replace("PASS - ", "")
            results.set_verify("PASS", util.gframe(), rollback)
            results.set_verify("LOG", util.gframe(), 'RF Outage during rollback was %s milliseconds' % str(ss.simspir_get_value_outage_run()[0]))
        else:
            rollback.replace("FAIL - ", "")
            results.set_verify("FAIL", util.gframe(), "Unsuccessfull rollback to GA swpack is not actively set to the GA build")
    else:
        # Unsuccessful rollback of software - send results and try to carry on
        rollback.replace("FAIL - ", "")
        results.set_verify("FAIL", util.gframe(), "Unsuccessfull rollback to GA swpack due to %s" % rollback)
    
    wg.webgui_close_connection()
    time.sleep(5)
    
    wg = ctr8500_webgui.webgui(ctr1.ipaddress, 'Firefox')
    wg.webgui_logon()
    
    # clear spirent counters and check alarms   
    ss.simspr_clear_counters()    
    currentalarms = check_alarms(wg)
    if startalarms != currentalarms:
        print_alarms(currentalarms)   
    
    ## ========== Step 5 ==========
    # Upgrade sw to Testable version via Local file using Transfer and Activate method
    
    if load_SWpack(os.path.join(test_sw_dir, test_sw_vers), wg)[0]:
        # Successful Upgrade to current Software version - send results and report and clear spirent results
        results.set_verify("PASS", util.gframe(), "%s has been upgraded to Current Build release %s" % (ctr1.name, test_sw_vers))
        results.set_verify("LOG", util.gframe(), 'RF Outage during upgrade was %s milliseconds' % str(ss.simspir_get_value_outage_run()[0]))
    else:
        # Unsuccessful upgrade of software - send results and try to carry on
        results.set_verify("FAIL", util.gframe(), "Unsuccessfull rollback to GA swpack due to %s" % test_sw_vers)
    
    wg = ctr8500_webgui.webgui(ctr1.ipaddress, 'Firefox')
    wg.webgui_logon()
    
    # clear spirent counters and check alarms     
    currentalarms = check_alarms(wg)
    if startalarms != currentalarms:
        print_alarms(currentalarms)
    
    ## ========== Test Step rollback ==========
    # No major rollback of settings required
    
    # run the end script
    end_script('Normal', results, rig, start_time, wg, ss)
    
    quit()
示例#14
0
def test_template():

    # ========== Testrig and Testscript Initialization ==========
    # Initiate Testrig object - this handles all testrig objects as well as Topology and Config setup

    rig = TestRig(
        "DVTA-CT-2", "T008.ini", "C001.ini", developmentrig, False
    )  # testcase ID, topology filename, config filename, developmentrig and Initialization Requirement

    # simple path to each of the Nodes (remove the ones that aren't needed)
    ctr1 = rig.nodes['node1']

    # simple path to each of the Test Equipment ((remove the ones that aren't needed)
    ss = rig.devices['SPIRENT']

    # logging - start of test script and other basic info
    start_sw_version = ctr1.get_sw_version()
    start_time = time.time()
    logging.info('START %s, version %s' % (test_template.__name__, VERSION))
    logging.info('Current Software Build installed = %s' % (start_sw_version))

    # Results - xml or excel writer (REMOVE ONE)
    results = xmlwriter(
        "DVTA-CT-2", "T008",
        "Verify the Configuration Functions of CraftTool as well as the Revert/Restore Timer"
    )  # testcase ID, Topology Used, Test Case Description

    # Initialize the required libraries
    util = utils()

    ## ========== Pre-Flow setup and checks ==========
    # Carry out all of the basic setup here which is not testable items
    # 1. Ensure Testrig is correctly setup with no alarms present (NOTE: compare results after each step)
    # 2. Start a spirent run to calculate outage times (NOTE: gather results after each step)

    # log the software pack to be used
    test_sw_dir = "C:/swpacks/"  # the desired test sw dir
    test_sw_vers = os.listdir(test_sw_dir)[0]  # the desired swpack
    test_dl_dir = "C:/ctrdownloads/"  # the desired test sw dir
    faulty_dir = "C:/config_faulty/"
    sw_repos = "192.168.77.1/CTR8540/config/"

    logging.info('Current Cycle Software to be tested = %s' % (test_sw_vers))

    # Initialize Webgui
    wg = webgui(ctr1.ipaddress, 'Firefox', True)
    wg.webgui_logon()

    # establish a starting list of alarms and check to ensure there are no Critical alarms
    startalarms = check_alarms(wg)
    print_alarms(startalarms)

    # check that we have a working rf link by passing 10sec of traffic and ensure no dropped frames check up to 3 times
    if ss.simspr_line_check('3/9', '3/10'):  # use correct ports for this
        logging.info(
            'Spirent connection confirmed ... continuing with test script')
    else:
        # if no RF link stop script
        logging.error(
            'Spirent connection has not been established correctly after 3 attempts.'
        )
        end_script('error', results, rig, start_time, wg, ss)

    # Start a spirent outage run for outage capture
    ss.simspir_start_outage_run('3/9', '3/10')
    logging.info('Starting Spirent Traffic for outage capture')

    # Check that the current software version is loaded, if not, load it.
    curr_sw_version = util.format_SWpack_str(start_sw_version)
    if not os.path.exists(os.path.join(test_sw_dir, curr_sw_version)):
        logging.info(
            "Currently loaded Software Pack is %s. Loading the latest test build - %s."
            % (curr_sw_version, test_sw_vers))
        swpack = load_SWpack(os.path.join(test_sw_vers), wg)
        if swpack[0] and swpack[2]:
            # Successful downgrade - send results and clear spirent counters
            results.set_verify(
                "LOG", util.gframe(),
                "%s has been upgraded to the latest test build %s" %
                (ctr1.name, test_sw_vers))
            results.set_verify(
                "LOG", util.gframe(),
                'RF Outage during downgrade was %s milliseconds' %
                str(ss.simspir_get_value_outage_run()[0]))
            wg = webgui(ctr1.ipaddress, 'Firefox')
            wg.webgui_logon()
        else:
            # Unsuccessful downgrade - send results and end script safely
            results.set_verify(
                "ERROR", util.gframe(),
                "%s has NOT been upgraded to the latest test build %s for unknown reasons"
                % (ctr1.name, test_sw_vers))
            end_script('error', results, rig, start_time, wg, ss)

    ## ========== Test step flow ==========

    ## ========== Step 1 ==========
    # Backup the current configuration to file and ensure this was done correctly.

    # start by ensuring the current config is correct
    wg.webgui_set_page("System Configuration", "System Information")
    wg.webgui_systeminfo_nodename('CTR8540-211')
    wg.webgui_config_save()
    time.sleep(10)

    configfile = True
    wg.webgui_set_page("System Configuration", "Configuration Management",
                       "Admin")
    # Create backup file and ensure file has been placed in the ctrdownloads folder
    logging.info("Backup Current Configuration and Check file correct")
    if wg.webgui_config_backup():
        results.set_verify(
            "PASS", util.gframe(),
            "aos.conf file was succcessfully saved to download folder")
        # wait till the file is available
        time.sleep(10)
        while not os.path.exists(os.path.join(test_dl_dir, 'aos.conf')):
            time.sleep(5)
        # check to ensure this file is actually the correct one
        if ctr1.ipaddress in open(os.path.join(test_dl_dir,
                                               'aos.conf')).read():
            results.set_verify(
                "PASS", util.gframe(),
                "aos.conf contained the correct ipaddress for this Node")
        else:
            results.set_verify(
                "FAIL", util.gframe(),
                "aos.conf did NOT contain the correct ipaddress for this Node")
            configfile = False
    else:
        results.set_verify(
            "FAIL", util.gframe(),
            "aos.conf file was NOT succcessfully saved to download folder")
        configfile = False

    ## ========== Step 2 ==========
    # Change some obvious settings and commit

    # only do this step if the config file had been saved successfully before
    restoreconfig = False
    if configfile:
        logging.info("Change Node Name for config restore reference")
        # change the name of the ctr and save configuration
        wg.webgui_set_page("System Configuration", "System Information")
        if wg.webgui_systeminfo_nodename('CONFIG-TEST'):
            wg.webgui_config_save()
            results.set_verify(
                "PASS", util.gframe(),
                "The Node Name has been successfully changed and committed")
            restoreconfig = True
        else:
            results.set_verify(
                "FAIL", util.gframe(),
                "The Node Name has NOT been successfully changed and committed"
            )

    ## ========== Step 3 ==========
    # Setup Revert Timer and validate correct range of time

    passvalues = 0
    nonrevertvalues = [20, 299, 3601, 9999]
    revertvalues = [300, random.randint(301, 3599), 3600]
    restorevalues = False
    if restoreconfig:
        logging.info("Validate Revert Timer Values - Good and Bad")
        # step through all non allowable values and ensure each is correctly handled
        for x in nonrevertvalues:
            if wg.webgui_revert_set_timer(x):
                results.set_verify(
                    "FAIL", util.gframe(),
                    "The Revert Timer accepted a value (%s) outside its parameters"
                    % str(x))
            else:
                results.set_verify(
                    "PASS", util.gframe(),
                    "The Revert Timer rejected a value (%s) outside its parameters"
                    % str(x))
                passvalues += 1
            wg.webgui_revert_disable()
        # step through all allowed values (including 1 random one) and ensure it is correctly handled
        for x in revertvalues:
            if wg.webgui_revert_set_timer(x):
                results.set_verify(
                    "PASS", util.gframe(),
                    "The Revert Timer accepted a valid value (%s) and started its run"
                    % str(x))
                passvalues += 1
            else:
                results.set_verify(
                    "FAIL", util.gframe(),
                    "The Revert Timer rejected a valid value (%s)" % str(x))
            wg.webgui_revert_disable()

    if passvalues == 7:
        results.set_verify(
            "PASS", util.gframe(),
            "The Revert Timer accepted all valid values and rejected all invalid values"
        )
        restorevalues = True
    else:
        results.set_verify(
            "FAIL", util.gframe(),
            "The Revert Timer correctly handled %s values, but incorrectly handled %s values"
            % (str(passvalues), str(7 - passvalues)))

    ## ========== Step 4 ==========
    # checks to see whether the config load will handle a load with no revert Timer
    configwarn = False
    if restorevalues:
        logging.info("Config File Restore - No Revert Timer Warning Check")
        wg.webgui_set_page("System Configuration", "Configuration Management",
                           "Admin")
        reverterrorcheck = wg.webgui_config_restore(
            'local', os.path.join(test_dl_dir, 'aos.conf'))
        if type(reverterrorcheck) != bool:
            results.set_verify("INFO", util.gframe(), reverterrorcheck)
            results.set_verify(
                "PASS", util.gframe(),
                "The Config load error warning was displayed as expected with no revert timer set"
            )
            configwarn = True
        else:
            results.set_verify(
                "FAIL", util.gframe(),
                "The Config load error warning was NOT displayed with no revert timer set"
            )

    ## ========== Step 5 ==========
    # Restore config from Local File, confirm restore successful and then wait for restore timer to kick in and rollback to previous config.

    if configwarn:
        logging.info("Restoring Config file from Local Source")
        time.sleep(5)
        # config should already be loaded and ready to got so set revert timer
        for x in range(3):
            if wg.webgui_revert_set_timer(300):
                logging.info("revert timer set and now restoring config file")
                break
            else:
                logging.error(
                    "revert Timer not set correctly ... trying again")
        time.sleep(2)
        # Start the Configuration Restore
        wg.webgui_config_restore_click()
        # Wait for system reboot
        time.sleep(120)
        # open new window and logon
        wg.webgui_close_connection()
        wg2 = webgui(ctr1.ipaddress, 'Firefox', True)
        wg2.webgui_logon()

        # check for change in node name and remaining revert timer
        nodename = wg2.webgui_systeminfo_get_nodename()
        timeremaining = wg2.webgui_revert_get_time_remaining()
        if "CONFIG-TEST" in nodename or timeremaining == 'Disabled':
            logging.error("Configuration File has not loaded correctly")
            results.set_verify(
                "FAIL", util.gframe(),
                "The Configuration has not been restored correctly")
        else:
            results.set_verify(
                "PASS", util.gframe(),
                "The Configuration has been restored correctly")
            results.set_verify(
                "LOG", util.gframe(),
                'RF Outage during upgrade was %s milliseconds' %
                str(ss.simspir_get_value_outage_run()[0]))

        ss.simspr_clear_counters()
        currentalarms = check_alarms(wg2)
        if startalarms != currentalarms:
            print_alarms(currentalarms)
        # wait for remaining time and then check that the node reverts back
        time.sleep(420)
        wg2.webgui_close_connection()
        wg3 = webgui(ctr1.ipaddress, 'Firefox', True)
        wg3.webgui_logon()

        nodename2 = wg3.webgui_systeminfo_get_nodename()
        timeremaining2 = wg3.webgui_revert_get_time_remaining()
        if "CONFIG-TEST" in nodename2 and timeremaining2 == 'Disabled':
            results.set_verify(
                "PASS", util.gframe(),
                "The Revert Timer has caused the Configuration rolled back correctly"
            )
            results.set_verify(
                "LOG", util.gframe(),
                'RF Outage during upgrade was %s milliseconds' %
                str(ss.simspir_get_value_outage_run()[0]))
        else:
            results.set_verify(
                "FAIL", util.gframe(),
                "The Configuration has not been rolled back correctly")
            logging.error(
                "The Configuration has not been rolled back correctly")

        ss.simspr_clear_counters()
        currentalarms = check_alarms(wg3)
        if startalarms != currentalarms:
            print_alarms(currentalarms)

        wg3.webgui_close_connection()

    ## ========== Step 6 ==========
    # Try to load faulty config file and ensure alarms are raised etc

    wg = webgui(ctr1.ipaddress, 'Firefox', True)
    wg.webgui_logon()
    wg.webgui_set_page("System Configuration", "Configuration Management",
                       "Admin")

    logging.info("Trying to load faulty Config File")
    wg.webgui_revert_set_timer(300)
    wg.webgui_config_restore_enter_path('local',
                                        os.path.join(faulty_dir, 'aos.conf'))
    wg.webgui_config_restore_click()

    # refresh the page stop the revert timer and then check for a "checksum verification" event
    time.sleep(60)
    wg.webgui_refresh()
    time.sleep(5)
    if wg.webgui_revert_disable() == 'Disabled':
        results.set_verify("PASS", util.gframe(),
                           "The CTR handled a faulty configuration file")
    else:
        results.set_verify(
            "FAIL", util.gframe(),
            "The CTR did NOT handle a faulty configuration file")
        end_script('error', results, rig, start_time, wg, ss)

    wg.webgui_set_page("Status", "Event Log")
    time.sleep(5)

    if wg.webgui_event_recent_check("Checksum verification failed"):
        results.set_verify(
            "PASS", util.gframe(),
            "The CTR raised a checksum failed Event as expected")
    else:
        results.set_verify("FAIL", util.gframe(),
                           "The CTR did NOT display a checksum failed event")

    wg.webgui_close_connection()
    wg1 = webgui(ctr1.ipaddress, 'Firefox', True)
    wg1.webgui_logon()

    ss.simspr_clear_counters()
    currentalarms = check_alarms(wg1)
    if startalarms != currentalarms:
        print_alarms(currentalarms)

    ## ========== Step 7 ==========
    # Config Restore from a remote repository and ensure it is successful and then cancel restore timer

    logging.info("Config File Restore from Remote repository")
    logging.info(
        "as per JIRA CSR-6154 config restore from remote repository not fix until master(14.1949)"
    )
    # change the node name as an update reference
    wg1.webgui_set_page("System Configuration", "System Information")
    if wg1.webgui_systeminfo_nodename('CONFIG-TEST'):
        wg1.webgui_config_save()
    # goto configuration management page and restore config from remote repository
    wg1.webgui_set_page("System Configuration", "Configuration Management",
                        "Admin")
    if wg1.webgui_config_restore('remote', sw_repos + 'dvta-ctr1.conf', 450):
        nodename = wg1.webgui_systeminfo_get_nodename()
        if nodename == 'CTR8540-211':
            results.set_verify(
                "PASS", util.gframe(),
                "The CTR restored its config from a remote repository")
            results.set_verify(
                "LOG", util.gframe(),
                'RF Outage during upgrade was %s milliseconds' %
                str(ss.simspir_get_value_outage_run()[0]))
        else:
            results.set_verify(
                "FAIL", util.gframe(),
                "The CTR did NOT restore its config from a remote repository - nodename unchanged"
            )
    else:
        results.set_verify(
            "FAIL", util.gframe(),
            "The CTR did NOT restore its config from a remote repository - load not successful"
        )
        # end_script('error', results, rig, start_time, wg1, ss)

    ss.simspr_clear_counters()
    currentalarms = check_alarms(wg1)
    if startalarms != currentalarms:
        print_alarms(currentalarms)

    ## ========== Step 8 ==========
    # Capture Helpdesk report and ensure it is as expected

    wg1.webgui_close_connection()
    wg2 = webgui(ctr1.ipaddress, 'Firefox', True)
    wg2.webgui_logon()

    if wg2.webgui_revert_get_time_remaining() != 'Disabled':
        wg2.webgui_revert_disable()

    wg2.webgui_set_page('Status', 'Reports')
    time.sleep(2)

    if wg2.webgui_report_generate():
        wg2.webgui_report_download()

    time.sleep(30)  # windows OS takes some time to update its listings

    if os.path.exists('C:/hdtest'):
        shutil.rmtree('C:/hdtest')

    os.mkdir('C:/hdtest')

    hdfiles = tarfile.TarFile.open(os.path.join(test_dl_dir, "helpdesk.tar"))
    hdfiles.extractall('C:/hdtest')

    issdir = ('C:/hdtest/tmp/helpdeskFiles/')
    if 'CTR8540-211' and test_sw_vers[-14:-7] in open(
            os.path.join(issdir, 'issInfo.txt')).read():
        results.set_verify(
            "PASS", util.gframe(),
            "The %s downloaded the helpdesk file correctly" % ctr1.name)
    else:
        results.set_verify(
            "FAIL", util.gframe(),
            "The %s did NOT download the helpdesk file correctly" % ctr1.name)

    shutil.rmtree('C:/hdtest')

    ## ========== Test Step rollback ==========
    # all commands to rollback the configuration that has taken place throughout this script

    ## ========== Run Test End Script ==========
    # run the end script
    end_script('Normal', results, rig, start_time, wg2, ss)

    quit()
示例#15
0
def test_template():

    # ========== Testrig and Testscript Initialization ==========
    # Initiate Testrig object - this handles all testrig objects as well as Topology and Config setup

    rig = TestRig(
        "DVTA-CT-7-C", "T009.ini", "C003.ini", developmentrig, True
    )  # testcase ID, topology filename, config filename, developmentrig and Initialization Requirement

    # simple path to each of the Nodes (remove the ones that aren't needed)
    ctr1 = rig.nodes['node1']
    ctr2 = rig.nodes['node2']
    # ctr3 = rig.nodes['node3']
    # ctr4 = rig.nodes['node4']

    # simple path to each of the Test Equipment ((remove the ones that aren't needed)
    # mrv = rig.devices['MRV']
    matrix = rig.devices['MATRIX']
    ss = rig.devices['SPIRENT']

    # logging - start of test script and other basic info
    start_sw_version = ctr1.get_sw_version(
    )  # rig.nodes['node1'].get_sw_version()
    start_time = time.time()
    logging.info('START %s, version %s' % (test_template.__name__, VERSION))
    logging.info('Current Software Build installed = %s' % (start_sw_version))

    # Results - xml or excel writer (REMOVE ONE)
    results = xmlwriter(
        "DVTA-CT-7-C", "T009",
        "Basic Software Loading and Configuration functions of CraftTool"
    )  # testcase ID, Topology Used, Test Case Description
    # results = ExcelWriter()

    # Initialize the required libraries
    util = utils()

    ## ========== Pre-Flow setup and checks ==========
    # Carry out all of the basic setup here which is not testable items

    # log the software pack to be used
    test_sw_dir = "C:/swpacks/"  # the desired test sw dir
    test_sw_vers = os.listdir(test_sw_dir)[0]  # the desired swpack
    logging.info('Current Cycle Software to be tested = %s' % (test_sw_vers))

    # establish a starting list of alarms and check to ensure there are no Critical alarms
    startalarms = check_alarms(ctr1.ipaddress)
    print_alarms(startalarms)

    # Initialize Webgui
    wg = webgui(ctr2.ipaddress, 'Firefox')
    wg.webgui_logon()
    # Check that the current software version is loaded, if not, load it.
    curr_sw_version = util.format_SWpack_str(start_sw_version)
    if not os.path.exists(os.path.join(test_sw_dir, curr_sw_version)):
        logging.info(
            "Currently loaded Software Pack is %s. Loading the latest test build - %s."
            % (curr_sw_version, test_sw_vers))
        swpack = load_SWpack(os.path.join(test_sw_vers), wg)
        if swpack[0] and swpack[2]:
            # Successful downgrade - send results and clear spirent counters
            results.set_verify(
                "LOG", util.gframe(),
                "%s has been upgraded to the latest test build %s" %
                (ctr1.name, test_sw_vers))
            results.set_verify(
                "LOG", util.gframe(),
                'RF Outage during downgrade was %s milliseconds' %
                str(ss.simspir_get_value_outage_run()[0]))
            wg = webgui(ctr2.ipaddress, 'Firefox')
            wg.webgui_logon()
        else:
            # Unsuccessful downgrade - send results and end script safely
            results.set_verify(
                "ERROR", util.gframe(),
                "%s has NOT been upgraded to the latest test build %s for unknown reasons"
                % (ctr2.name, test_sw_vers))
            end_script('error', results, rig, start_time, wg, ss)
            quit()

    ## ========== Test step flow ==========

    ## ========== Step 1 ==========
    # adjust the individual RF Links for -45dBm RSL

    logging.info('adjust the individual RF Links for -45dBm RSL')

    rslattens = []
    # A. set each link to -45dBm RSL and capture this value for future reference
    for rfint in [['1/3/1', 11], ['1/3/2', 21]]:
        wgrsl = webgui(ctr2.ipaddress, 'Firefox')
        wgrsl.webgui_logon()
        time.sleep(5)
        wgrsl.webgui_set_page('Radio Configuration',
                              'Radio Link Configuration')
        time.sleep(2)
        wgrsl.webgui_rf_set_radio_int('RADIO INT ' + rfint[0])
        time.sleep(2)
        if set_matrix(wgrsl, matrix, rfint[1]):
            rslattens.append(matrix.get_att(rfint[1]))
        else:
            logging.error(
                'RSL has not been set to -45dBm correctly of RADIO INT %s. Quitting testscript'
                % rfint[0])
            end_script('error', results, rig, start_time, wgrsl, ss)
            quit()

        wgrsl.webgui_logoff()
        wgrsl.webgui_close_connection()

    # B. send traffic on these ports and check for correct link
    logging.info('Checking RF Paths are still connected as expected')

    # check that we have a working primary rf link by passing 10sec of traffic and ensure no dropped frames check up to 3 times
    if ss.simspr_line_check('3/9', '3/10'):  # use correct ports for this
        logging.info(
            'Spirent connection confirmed for Primary RF Link ... continuing with test script'
        )
    else:
        # if no RF link stop script
        logging.error(
            'Spirent connection has not been established correctly after 3 attempts.'
        )
        end_script('error', results, rig, start_time, wg, ss)
        quit()

    # send traffic down secondary Link
    ctr1.sendcli('c t; vlan 1; no ports ra 4/1 untagged ra 4/1')
    ctr1.sendcli('c t; vlan 1; ports add ra 4/2 untagged ra 4/2')
    ctr2.sendcli('c t; vlan 1; no ports ra 3/1 untagged ra 3/1')
    ctr2.sendcli('c t; vlan 1; ports add ra 3/2 untagged ra 3/2')
    ctr2.sendcli('c t; int gi 0/1; spanning-tree disable; end')

    # check that we have a working primary rf link by passing 10sec of traffic and ensure no dropped frames check up to 3 times
    if ss.simspr_line_check('3/9', '3/10'):  # use correct ports for this
        logging.info(
            'Spirent connection confirmed for Secondary RF Link ... continuing with test script'
        )
    else:
        # if no RF link stop script
        logging.error(
            'Spirent connection has not been established correctly after 3 attempts.'
        )
        end_script('error', results, rig, start_time, wg, ss)
        quit()

    # send traffic down primary Link
    ctr1.sendcli('c t; vlan 1; no ports ra 4/2 untagged ra 4/2')
    ctr1.sendcli('c t; vlan 1; ports add ra 4/1 untagged ra 4/1')
    ctr2.sendcli('c t; vlan 1; no ports ra 3/2 untagged ra 3/2')
    ctr2.sendcli('c t; vlan 1; ports add ra 3/1 untagged ra 3/1')
    ctr2.sendcli('c t; int ra 3/1; spanning-tree disable; end')

    # C. check to see whether any new alarms have been raised
    currentalarms = check_alarms(ctr1.ipaddress)
    if startalarms != currentalarms:
        print_alarms(currentalarms)
        logging.error('Differences in alarms have been found, not as expected')
        end_script('error', results, rig, start_time, wg, ss)
        quit()
    else:
        logging.info('No Alarms have been raised ... as expected')

    ## ========== Step 2 ==========
    # Set MATRIX to a Protected Configuration

    logging.info('Set MATRIX to a Protected Configuration')
    matrix.set_protected()

    # A. set the "individual" links to the predetermined RSL values
    attidx = 11
    for attval in rslattens:
        matrix.set_att(attidx, float(attval))
        attidx = attidx + 10

    ## ========== Step 3 ==========
    # Configure a Protected RF Link

    logging.info('Configure a Protected RF Link')

    # Set a Protected link
    pri = ['1/4/1', '1/3/1']
    sec = ['1/4/2', '1/3/2']
    idp = 0

    for ctr in [ctr1, ctr2]:
        wgprot = webgui(ctr.ipaddress, 'Firefox')
        wgprot.webgui_logon()
        time.sleep(5)
        wgprot.webgui_set_page('Radio Configuration',
                               'Radio Link Configuration')
        time.sleep(2)
        wgprot.webgui_rf_add_protection(1, pri[idp], sec[idp], 'Hot-Standby',
                                        'Equal', ['0'], 'No Revert')
        time.sleep(10)
        wgprot.webgui_set_nav_tab('RADIO LINKS')
        time.sleep(10)
        wgprot.webgui_rf_enable_interface()
        time.sleep(2)
        wgprot.webgui_apply()
        time.sleep(5)
        wgprot.webgui_logoff()
        wgprot.webgui_close_connection()
        time.sleep(10)
        idp = 1

    time.sleep(20)

    # check that the VLANs and Port connections are ready for Traffic flow
    vlantext = ctr1.sendcli('show vlan')
    if 'Prot1' in vlantext:
        results.set_verify(
            "PASS", util.gframe(),
            "The Prot1 VLAN is now configured correctly and ready for traffic to flow"
        )
    else:
        results.set_verify("FAIL", util.gframe(),
                           "The Prot1 VLAN is NOT configured correctly")
        end_script('error', results, rig, start_time, wg, ss)
        quit()

    ## ========== Step 4 ==========
    # Check that Protection is displayed correctly
    logging.info('Check that Protection is displayed correctly')

    # Check for the correct Protection display on the Radio Link configuration page
    wgdisp = webgui(ctr1.ipaddress, 'Firefox')
    wgdisp.webgui_logon()
    time.sleep(5)
    wgdisp.webgui_set_page('Radio Configuration', 'Radio Link Configuration')
    time.sleep(5)
    if wgdisp.webgui_rf_is_prot_set():
        results.set_verify(
            "PASS", util.gframe(),
            "The Protected RF link is now Displayed correctly, and ready for traffic to flow"
        )
    else:
        results.set_verify("FAIL", util.gframe(),
                           "The Protected RF link is NOT Displayed correctly")
        end_script('error', results, rig, start_time, wgdisp, ss)
        quit()

    time.sleep(2)

    ## ========== Step 5 ==========
    # ensure that the Primary RFU is up and transmitting

    if wgdisp.webgui_rf_is_link_up('RADIO INT 1/4/1'):
        logging.info('Primary RFU is up and Transmitting')
        onlinetx = 'pri'
    else:
        logging.info('Secondary RFU is up and Transmitting')
        onlinetx = 'sec'

    ## ========== Step 6 ==========
    # Check that the Online Tx Lock Diagnostics is working
    logging.info('Checking Online Tx Lock Diagnostics')
    wgdisp.webgui_set_page('Radio Configuration', 'Radio Link Diagnostics')
    time.sleep(5)
    wgdisp.webgui_set_nav_tab('RADIO LINK PROTECTION DIAGNOSTICS')
    time.sleep(5)

    if onlinetx == 'sec':
        logging.info('Switching Online RFU to Primary')
        wgdisp.webgui_rf_set_lock_tx_path('prot 1', True,
                                          'Radio Interface 1/4/1 (pri)')
        time.sleep(5)
        wgdisp.webgui_rf_set_lock_tx_path('prot 1')
        time.sleep(5)

    logging.info('Switching Online RFU to Secondary for 2 minutes')
    wgdisp.webgui_rf_set_lock_tx_path('prot 1', True,
                                      'Radio Interface 1/4/2 (sec)',
                                      '00:00:02')
    time.sleep(5)
    txlockalarms = check_alarms(ctr1.ipaddress)
    alarmfound = False
    print_alarms(txlockalarms)
    for al in txlockalarms:
        for x in al:
            if 'transmitter lock diagnostic' in x:
                results.set_verify(
                    "PASS", util.gframe(),
                    'The expected transmitter lock diagnostic alarm was raised'
                )
                alarmfound = True

    if not alarmfound:
        results.set_verify(
            "FAIL", util.gframe(),
            'The expected  transmitter lock diagnostic alarm was NOT raised')

    wgdisp.webgui_set_page('Radio Configuration', 'Radio Link Configuration')
    time.sleep(5)
    if wgdisp.webgui_rf_is_link_up('RADIO INT 1/4/2'):
        results.set_verify(
            "PASS", util.gframe(),
            'The secondary RFU is now Transmitting as expected')
    else:
        results.set_verify(
            "FAIL", util.gframe(),
            'The Primary RFU is still Transmitting NOT as expected')

    # wait 2 minutes then check to see that alarm has dropped
    time.sleep(120)

    txlockalarms = check_alarms(ctr1.ipaddress)
    alarmfound = False
    print_alarms(txlockalarms)
    for al in txlockalarms:
        for x in al:
            if 'transmitter lock diagnostic' in x:
                results.set_verify(
                    "FAIL", util.gframe(),
                    'The transmitter lock diagnostic alarm was still raised')
                alarmfound = True

    if not alarmfound:
        results.set_verify(
            "PASS", util.gframe(),
            'The transmitter lock diagnostic alarm was dropped as expected')

    # switch back to Primary RFU
    wgdisp.webgui_set_page('Radio Configuration', 'Radio Link Diagnostics')
    time.sleep(5)
    wgdisp.webgui_set_nav_tab('RADIO LINK PROTECTION DIAGNOSTICS')
    time.sleep(5)
    wgdisp.webgui_rf_set_lock_tx_path('prot 1', True,
                                      'Radio Interface 1/4/1 (pri)')
    time.sleep(5)
    wgdisp.webgui_rf_set_lock_tx_path('prot 1')
    time.sleep(5)

    wgdisp.webgui_logoff()
    wgdisp.webgui_close_connection()

    ## ========== Step 6 ==========
    # Ensure that traffic flows and no alarms or errors are recorded

    logging.info(
        'Ensure that traffic flows and no alarms or errors are recorded')

    # check that we have a working protected rf link by passing 10sec of traffic and ensure no dropped frames check up to 3 times
    if ss.simspr_line_check('3/9', '3/10'):  # use correct ports for this
        results.set_verify(
            "PASS", util.gframe(),
            'Spirent connection confirmed for Protected RF Link')
    else:
        # if no RF link stop script
        results.set_verify(
            "FAIL", util.gframe(),
            'Spirent connection has not been established correctly after 3 attempts.'
        )
        end_script('error', results, rig, start_time, wg, ss)
        quit()

    # C. check to see whether any new alarms have been raised
    currentalarms = check_alarms(ctr1.ipaddress)
    if startalarms != currentalarms:
        print_alarms(currentalarms)
        results.set_verify(
            "FAIL", util.gframe(),
            'Differences in alarms have been found, not as expected')
        end_script('error', results, rig, start_time, wg, ss)
        quit()
    else:
        results.set_verify("PASS", util.gframe(),
                           'No Alarms have been raised ... as expected')

    ## ========== Step 7 ==========
    # drop the Primary Path and ensure secondary takes over - record the drop time

    logging.info(
        'drop the Primary Path and ensure secondary takes over - record the drop time'
    )

    # check that the Primary Path is up
    wgpri = webgui(ctr1.ipaddress, 'Firefox')
    wgpri.webgui_logon()
    time.sleep(5)
    wgpri.webgui_set_page('Radio Configuration', 'Radio Link Configuration')
    time.sleep(5)
    if wgpri.webgui_rf_is_link_up('RADIO INT 1/4/1'):
        pripath = True
        logging.info(
            'RADIO INT 1/4/1 (Primary) is up and transmitting from %s' %
            ctr1.name)
        results.set_verify(
            "LOG", util.gframe(),
            'RADIO INT 1/4/1 (Primary) is up and transmitting from %s' %
            ctr1.name)
    else:
        pripath = False
        logging.info(
            'RADIO INT 1/4/2 (Secondary) is up and transmitting from %s' %
            ctr1.name)
        results.set_verify(
            "LOG", util.gframe(),
            'RADIO INT 1/4/2 (Secondary) is up and transmitting from %s' %
            ctr1.name)

    # start a spirent outage run for outage capture
    ss.simspir_start_outage_run('3/9', '3/10')
    logging.info('Starting Spirent Traffic for outage capture')
    time.sleep(10)

    # kill the Up and transmitting RFU.
    if pripath:
        ctr1.sendcli('c t; int ra 4/1; diag rfu ind')
    else:
        ctr1.sendcli('c t; int ra 4/2; diag rfu ind')

    time.sleep(20)

    # ensure standby RF Path takes over
    if wgpri.webgui_rf_is_link_up('RADIO INT 1/4/1'):
        stdbypath = False
        logging.info(
            'RADIO INT 1/4/1 (Primary) is up and transmitting from %s' %
            ctr1.name)
        results.set_verify(
            "LOG", util.gframe(),
            'RADIO INT 1/4/1 (Primary) is up and transmitting from %s' %
            ctr1.name)
    else:
        stdbypath = True
        logging.info(
            'RADIO INT 1/4/2 (Secondary) is up and transmitting from %s' %
            ctr1.name)
        results.set_verify(
            "LOG", util.gframe(),
            'RADIO INT 1/4/2 (Secondary) is up and transmitting from %s' %
            ctr1.name)

    if pripath == stdbypath:
        results.set_verify(
            "PASS", util.gframe(),
            "Protection has correctly switched to the alternate RF path")
    else:
        results.set_verify(
            "FAIL", util.gframe(),
            "Protection has NOT correctly switched to the alternate RF path")

    # D. Ensure correct alarms are raised
    currentalarms = check_alarms(ctr1.ipaddress)
    if startalarms == currentalarms:
        results.set_verify(
            "FAIL", util.gframe(),
            'No Extra Alarms have been raised ... not as expected')
        print_alarms(currentalarms)
    else:
        results.set_verify(
            "PASS", util.gframe(),
            'Differences in alarms have been found, as expected')
        print_alarms(currentalarms)

    # E. Record Traffic Outage
    rfout = ss.simspir_get_value_outage_run()[0]
    results.set_verify(
        "LOG", util.gframe(),
        'RF Outage during Protection Switch was %s milliseconds' % str(rfout))
    if int(rfout) <= 50:
        results.set_verify(
            "PASS", util.gframe(),
            'RF Outage due to the Protection Switch was less than 50 milliseconds'
        )
    else:
        results.set_verify(
            "FAIL", util.gframe(),
            'RF Outage due to the Protection Switch was greater than 50 milliseconds'
        )

    ## ========== Step 8 ==========
    # restore the Primary Path and ensure link is restored as expected

    logging.info(
        'restore the Primary Path and ensure link is restored as expected')

    # A. start a Traffic Outage Spirent flow
    ss.simspr_clear_counters()

    # B. restore the Primary RFU.
    # kill the Up and transmitting RFU.
    if pripath:
        ctr1.sendcli('c t; int ra 4/1; no diag rfu')
    else:
        ctr1.sendcli('c t; int ra 4/2; no diag rfu')

    # C. ensure RF Link remains
    if wgpri.webgui_rf_is_link_up('RADIO INT 1/4/1'):
        currpath = True
        logging.info(
            'RADIO INT 1/4/1 (Primary) is up and transmitting from %s' %
            ctr1.name)
        results.set_verify(
            "LOG", util.gframe(),
            'RADIO INT 1/4/1 (Primary) is up and transmitting from %s' %
            ctr1.name)
    else:
        currpath = False
        logging.info(
            'RADIO INT 1/4/2 (Secondary) is up and transmitting from %s' %
            ctr1.name)
        results.set_verify(
            "LOG", util.gframe(),
            'RADIO INT 1/4/2 (Secondary) is up and transmitting from %s' %
            ctr1.name)

    if pripath == currpath:
        results.set_verify(
            "FAIL", util.gframe(),
            "Protection has switched to the Original RF path when not needed")
    else:
        results.set_verify(
            "PASS", util.gframe(),
            "Protection has NOT switched to the Original RF path as expected")

    # D. Ensure correct alarms are raised / dropped
    currentalarms = check_alarms(ctr1.ipaddress)
    if startalarms == currentalarms:
        results.set_verify(
            "PASS", util.gframe(),
            'Differences in alarms have been found, not as expected')
    else:
        results.set_verify("PASS", util.gframe(),
                           'No Alarms have been raised ... as expected')
        print_alarms(currentalarms)

    # E. Record Traffic Outage if any
    rfout = ss.simspir_get_value_outage_run()[0]
    results.set_verify(
        "LOG", util.gframe(),
        'RF Outage during condition was %s milliseconds' % str(rfout))
    if int(rfout) <= 50:
        results.set_verify(
            "PASS", util.gframe(),
            'RF Outage due to the Protection Switch was less than 50 milliseconds'
        )
    else:
        results.set_verify(
            "FAIL", util.gframe(),
            'RF Outage due to the Protection Switch was greater than 50 milliseconds'
        )

    wgpri.webgui_logoff()
    wgpri.webgui_close_connection()

    # stop current spirent run
    ss.simspir_stop_outage_run()
    ss.simspr_release()

    ## ========== Step 8 ==========
    # check that the Rx Diversity source lock diagnostics is working as expected
    logging.info(
        'check that the Rx Diversity source lock diagnostics is working as expected'
    )

    wgrxlock = webgui(ctr1.ipaddress, 'Firefox')
    wgrxlock.webgui_logon()
    time.sleep(5)
    wgrxlock.webgui_set_page('Radio Configuration', 'Radio Link Diagnostics')
    time.sleep(5)
    wgrxlock.webgui_set_nav_tab('RADIO LINK PROTECTION DIAGNOSTICS')
    time.sleep(5)

    # lock Primary RFU RX and check for alarm and traffic flow
    wgrxlock.webgui_rf_set_lock_rx_path('prot 1', True,
                                        'Radio Interface 1/4/1 (pri)')
    time.sleep(10)
    rxlockalarms = check_alarms(ctr1.ipaddress)
    alarmfound = False
    print_alarms(rxlockalarms)
    for al in rxlockalarms:
        for x in al:
            if 'Rx-source lock diagnostic' in x:
                results.set_verify(
                    "PASS", util.gframe(),
                    'The expected Rx-source lock diagnostic alarm was raised for Primary RFU'
                )
                alarmfound = True

    if not alarmfound:
        results.set_verify(
            "FAIL", util.gframe(),
            'The expected Rx-source lock diagnostic alarm was NOT raised for Primary RFU'
        )

    if ss.simspr_line_check('3/9', '3/10'):  # use correct ports for this
        logging.info(
            'Spirent connection confirmed for Primary Rx Lock ... continuing with test script'
        )
        results.set_verify(
            "PASS", util.gframe(),
            'Spirent connection confirmed for Primary Rx Lock ... continuing with test script'
        )
    else:
        # if no RF link stop script
        logging.error(
            'Spirent connection has not been established correctly after 3 attempts.'
        )
        results.set_verify(
            "FAIL", util.gframe(),
            'Spirent connection has not been established correctly after 3 attempts.'
        )

    wgrxlock.webgui_rf_set_lock_rx_path('prot 1', True,
                                        'Radio Interface 1/4/2 (sec)')
    time.sleep(10)
    rxlockalarms = check_alarms(ctr1.ipaddress)
    alarmfound = False
    print_alarms(rxlockalarms)
    for al in rxlockalarms:
        for x in al:
            if 'Rx-source lock diagnostic' in x:
                results.set_verify(
                    "PASS", util.gframe(),
                    'The expected Rx-source lock diagnostic alarm was raised for Secondary RFU'
                )
                alarmfound = True

    if not alarmfound:
        results.set_verify(
            "FAIL", util.gframe(),
            'The expected Rx-source lock diagnostic alarm was NOT raised for Secondary RFU'
        )

    if ss.simspr_line_check('3/9', '3/10'):  # use correct ports for this
        logging.info(
            'Spirent connection confirmed for Secondary Rx Lock ... continuing with test script'
        )
        results.set_verify(
            "PASS", util.gframe(),
            'Spirent connection confirmed for Secondary Rx Lock ... continuing with test script'
        )
    else:
        # if no RF link stop script
        logging.error(
            'Spirent connection has not been established correctly after 3 attempts.'
        )
        results.set_verify(
            "FAIL", util.gframe(),
            'Spirent connection has not been established correctly after 3 attempts.'
        )

    wgrxlock.webgui_rf_set_lock_rx_path('prot 1')
    wgrxlock.webgui_logoff()
    wgrxlock.webgui_close_connection()

    ## ========== Step 9 ==========
    # remove the protected configuration from the CTRs and MATRIX
    logging.info('Remove the protected configuration from the CTRs')

    # A. set MATRIX Box to nonprotected setup
    matrix.set_nonprotected()

    # B. delete the Protection configuration from the Nodes
    for ctr in [ctr1, ctr2]:
        logging.info('Removing Protection from %s' % ctr.name)
        wgunprot = webgui(ctr.ipaddress, 'Firefox')
        wgunprot.webgui_logon()
        time.sleep(5)
        wgunprot.webgui_set_page('Radio Configuration',
                                 'Radio Link Configuration')
        time.sleep(2)
        wgunprot.webgui_set_nav_tab("RADIO LINK PROTECTION")
        time.sleep(5)
        wgunprot.webgui_rf_remove_protection(1)
        time.sleep(2)
        wgunprot.webgui_apply()
        time.sleep(2)
        wgunprot.webgui_logoff()
        wgunprot.webgui_close_connection()

    ## ========== Test Step rollback ==========
    # all commands to rollback the configuration that has taken place throughout this script

    # run the end script
    end_script('Normal', results, rig, start_time, wg, ss)

    quit()
示例#16
0
def test_template():
    
    # ========== Testrig and Testscript Initialization ==========
    # Initiate Testrig object - this handles all testrig objects as well as Topology and Config setup
    
    rig = TestRig("DVTA-CT-3", "T008.ini", "C001.ini", developmentrig, False)  # testcase ID, topology filename, config filename, developmentrig and Initialization Requirement
    
    # simple path to each of the Nodes (remove the ones that aren't needed)
    # ctr1 = rig.nodes['node1']
    ctr2 = rig.nodes['node2']
    # ctr3 = rig.nodes['node3']
    # ctr4 = rig.nodes['node4']
    
    # simple path to each of the Test Equipment ((remove the ones that aren't needed)
    # mrv = rig.devices['MRV']
    # matrix = rig.devices['MATRIX']
    ss = rig.devices['SPIRENT']
    
    # logging - start of test script and other basic info
    start_sw_version = ctr2.get_sw_version()
    start_time = time.time()
    logging.info('START %s, version %s' % (test_template.__name__, VERSION))
    logging.info('Current Software Build installed = %s' % (start_sw_version))
    
    # Results - xml or excel writer (REMOVE ONE)
    results = xmlwriter("DVTA-CT-1", "T007", "Basic Software Loading and Configuration functions of CraftTool")  # testcase ID, Topology Used, Test Case Description
    # results = ExcelWriter() 
    
    # Initialize the required libraries
    util = utils()
    bsys = basicsys(rig)
    
    ## ========== Pre-Flow setup and checks ==========
    # Carry out all of the basic setup here which are not testable items
    logging.info("Starting the Pre-Test Setup")
    
    # log the software pack to be used
    test_sw_dir = "C:/swpacks/"  # the desired test sw dir
    test_sw_vers = os.listdir(test_sw_dir)[0]  # the desired swpack
    logging.info('Current Cycle Software to be tested = %s' % (test_sw_vers))
    
    # Initialize Webgui
    wg = webgui(ctr2.ipaddress, 'Firefox')
    wg.webgui_logon()
    
    # establish a starting list of alarms and check to ensure there are no Critical alarms
    startalarms = check_alarms(wg)
    print_alarms(startalarms) 
    
    # check that we have a working rf link by passing 10sec of traffic and ensure no dropped frames check up to 3 times
    if ss.simspr_line_check('3/9', '3/10'):  # use correct ports for this
        logging.info('Spirent connection confirmed ... continuing with test script')
    else:
        # if no RF link stop script
        logging.error('Spirent connection has not been established correctly after 3 attempts.')
        end_script('error', results, rig, start_time, wg, ss)
            
    # Start a spirent outage run for outage capture    
    ss.simspir_start_outage_run('3/9', '3/10')
    logging.info('Starting Spirent Traffic for outage capture')
    
    # Check that the current software version is loaded, if not, load it.
    curr_sw_version = util.format_SWpack_str(start_sw_version)
    if not os.path.exists(os.path.join(test_sw_dir, curr_sw_version)):
        logging.info("Currently loaded Software Pack is %s. Loading the latest test build - %s." % (curr_sw_version, test_sw_vers))
        swpack = load_SWpack(os.path.join(test_sw_vers), wg)
        if swpack[0] and swpack[2]:
            # Successful downgrade - send results and clear spirent counters
            results.set_verify("LOG", util.gframe(), "%s has been upgraded to the latest test build %s" % (ctr2.name, test_sw_vers))
            results.set_verify("LOG", util.gframe(), 'RF Outage during downgrade was %s milliseconds' % str(ss.simspir_get_value_outage_run()[0]))
            wg = webgui(ctr2.ipaddress, 'Firefox')
            wg.webgui_logon()
        else:
            # Unsuccessful downgrade - send results and end script safely
            results.set_verify("ERROR", util.gframe(), "%s has NOT been upgraded to the latest test build %s for unknown reasons" % (ctr2.name, test_sw_vers))
            end_script('error', results, rig, start_time, wg, ss)
    
    ## ========== Test step flow ==========
    
    ## ========== Step 1 ========== 
    # ensure all ethernet ports are licensed as a base check
    logging.info("STEP 1: ensure all ethernet ports are licensed as a base check")
    
    if count_licensed_ports(wg) == 12:
        results.set_verify("LOG", util.gframe(), "Super License is currently loaded and all ports are Available as expected")
    else:
        results.set_verify("LOG", util.gframe(), "The Super License is not currently loaded ... script should still run OK")
    
    ## ========== Step 2 ========== 
    # remove all licenses from the node via cli except for -basic
    logging.info("STEP 2: remove all licenses from the node via cli except for -basic")
    
    # close the webgui to avoid issues when reload happens
    wg.webgui_logoff()
    wg.webgui_close_connection()
    
    if bsys.basicsys_remove_licenses(ctr2):
        # Successful test condition - send results and clear spirent counters
        results.set_verify("PASS", util.gframe(), "Removal of all licenses except the basic license was successful")
        results.set_verify("LOG", util.gframe(), 'RF Outage during license removal (and reload) was %s milliseconds' % str(ss.simspir_get_value_outage_run()[0]))
    else:
        # Unsuccessful test condition - send results and end script safely
        results.set_verify("FAIL", util.gframe(), "Removal of all licenses except the basic license was unsuccessful")
        end_script('error', results, rig, start_time, wg, ss)
    
    # clear spirent counters and check alarms on webgui (assumes webgui is open)  
    ss.simspr_clear_counters()
    
    wg = webgui(ctr2.ipaddress, 'Firefox')
    wg.webgui_logon()
    
    currentalarms = check_alarms(wg)
    if startalarms != currentalarms:
        print_alarms(currentalarms)
    
    ## ========== Step 3 ========== 
    # check for correct display on license page and ensure only 4 eth ports are available
    logging.info("STEP 3: check for correct display on license page and ensure only 4 eth ports are available")
    
    features = count_licensed_features(wg, 'lic')
    if features[0] == 6:
        results.set_verify("PASS", util.gframe(), "The Licensed Feature count of 6 is as expected")
    else:
        results.set_verify("FAIL", util.gframe(), "The Licensed Feature count does not appear to be correct")
        
    # Log the Licensed and unlicensed features    
    results.set_verify("LOG", util.gframe(), "Licensed Features are: %s" % features[1])
    unfeatures = count_licensed_features(wg, 'unlic')
    results.set_verify("LOG", util.gframe(), "Unlicensed Features are: %s" % unfeatures[1])
    
    ports = count_licensed_ports(wg) 
    if ports[0] == 4:
        results.set_verify("PASS", util.gframe(), "Only the 4 Ethernet Ports are available as expected")
    else:
        results.set_verify("FAIL", util.gframe(), "There should be 4 Ethernet Ports available, however %s are shown as licensed" % str(ports[0]))
        
    # Log the Licensed ports    
    results.set_verify("LOG", util.gframe(), "Licensed Ports are: %s" % ports[1])
    
    ## ========== Step 4 ========== 
    # add the -sfp license
    logging.info("STEP 4: add the -sfp license")
    
    # close the webgui to avoid connection issues 
    wg.webgui_logoff()
    wg.webgui_close_connection()
    
    if bsys.basicsys_add_license_path(ctr2, 'http://192.168.77.1/CTR8540/licenses/212/LKA14020131-sfp.LIC'):
        results.set_verify("PASS", util.gframe(), "Adding of the sfp license has been successful")
        results.set_verify("LOG", util.gframe(), 'RF Outage during license addition was %s milliseconds' % str(ss.simspir_get_value_outage_run()[0]))
    else:
        # Unsuccessful test condition - send results and end script safely
        results.set_verify("FAIL", util.gframe(), "Adding of the sfp license has been unsuccessful")
        end_script('error', results, rig, start_time, wg, ss)
    
    # clear spirent counters and check alarms on webgui 
    ss.simspr_clear_counters()
    
    wg = webgui(ctr2.ipaddress, 'Firefox')
    wg.webgui_logon()
    
    currentalarms = check_alarms(wg)
    if startalarms != currentalarms:
        print_alarms(currentalarms)
        
    ## ========== Step 5 ========== 
    # check for correct display on license page and ensure the sfp ports are now available
    logging.info("STEP 5: check for correct display on license page and ensure the sfp ports are now available")
    
    features = count_licensed_features(wg, 'lic')
    if features[0] == 7:
        results.set_verify("PASS", util.gframe(), "The Licensed Feature count of 7 is as expected")
    else:
        results.set_verify("FAIL", util.gframe(), "The Licensed Feature count does not appear to be correct")
        
    # Log the Licensed and unlicensed features    
    results.set_verify("LOG", util.gframe(), "Licensed Features are: %s" % features[1])
    unfeatures = count_licensed_features(wg, 'unlic')
    results.set_verify("LOG", util.gframe(), "Unlicensed Features are: %s" % unfeatures[1])
    
    ports = count_licensed_ports(wg) 
    if ports[0] == 8:
        results.set_verify("PASS", util.gframe(), "8 Ports (4 electrical and 4 sfp) are available as expected")
    else:
        results.set_verify("FAIL", util.gframe(), "There should be 8 Ports available, however %s are shown as licensed" % str(ports[0]))
        
    # Log the Licensed ports    
    results.set_verify("LOG", util.gframe(), "Licensed Ports are: %s" % ports[1])
    
    ## ========== Step 6 ========== 
    # add the -super license
    logging.info("STEP 6: add the -super license")
    
    # close the webgui to avoid connection issues 
    wg.webgui_logoff()
    wg.webgui_close_connection()
    
    if bsys.basicsys_add_license_path(ctr2, 'http://192.168.77.1/CTR8540/licenses/212/LKA14020131-super.LIC'):
        results.set_verify("PASS", util.gframe(), "Adding of the super license has been successful")
        results.set_verify("LOG", util.gframe(), 'RF Outage during license addition was %s milliseconds' % str(ss.simspir_get_value_outage_run()[0]))
    else:
        # Unsuccessful test condition - send results and end script safely
        results.set_verify("FAIL", util.gframe(), "Adding of the super license has been unsuccessful")
        end_script('error', results, rig, start_time, wg, ss)
    
    # clear spirent counters and check alarms on webgui (assumes webgui is open)  
    ss.simspr_clear_counters()
    
    wg = webgui(ctr2.ipaddress, 'Firefox')
    wg.webgui_logon()
    
    currentalarms = check_alarms(wg)
    if startalarms != currentalarms:
        print_alarms(currentalarms)
    
    ## ========== Step 7 ========== 
    # check for correct display on license page and ensure all ports are now available
    logging.info("STEP 7: check for correct display on license page and ensure all ports are now available")
    
    features = count_licensed_features(wg, 'lic')
    if features[0] == 15:
        results.set_verify("PASS", util.gframe(), "The Licensed Feature, for the super license, count of 7 is as expected")
    else:
        results.set_verify("FAIL", util.gframe(), "The Licensed Feature, for the super license, count does not appear to be correct")
        
    # Log the Licensed and unlicensed features    
    results.set_verify("LOG", util.gframe(), "Licensed Features are: %s" % features[1])
    unfeatures = count_licensed_features(wg, 'unlic')
    results.set_verify("LOG", util.gframe(), "Unlicensed Features are: %s" % unfeatures[1])
    
    ports = count_licensed_ports(wg) 
    if ports[0] == 12:
        results.set_verify("PASS", util.gframe(), "All Ports (8 electrical and 4 sfp) are available as expected")
    else:
        results.set_verify("FAIL", util.gframe(), "There should be all 12 Ports available, however %s are shown as licensed" % str(ports[0]))
        
    # Log the Licensed ports    
    results.set_verify("LOG", util.gframe(), "Licensed Ports are: %s" % ports[1])
    
    ## ========== Test Step rollback ==========
    # all commands to rollback the configuration that has taken place throughout this script
    # No rollback required
    logging.info("TEST SETUP ROLLBACK: No rollback required")
    
    # run the end script
    end_script('Normal', results, rig, start_time, wg, ss)
    
    quit()