def setup(self, uut1): logger.info(banner("Verify connectivity on LIIN interface")) logger.info("Verify connectivity on LIIN interface") logger.info(title('Setup')) uut1_config = ''' service internal ip vrf internal ''' uut1.configure(uut1_config)
def section_test(self, uut1, rtr1, rtr2): logger.info(banner("Verify iP Connectivity before QoS test")) logger.info("Verifying ping before QoS configuration") logger.info(title('Setup')) # Verify IP connectivity between routers if not ping_test(rtr1, rtr2IP, ipv6 = False): self.failed('Connectivity failure between rtr1 and rtr2') else: logger.info('Ping successfull')
def test(self, uut1): logger.info(banner("Generic Interface check")) logger.info("Verify that all interfaces are present") logger.info(title('Setup')) uut1.execute("show plat soft peer for fp act | incl updates") intf_output = uut1.execute("show ip interface brief") intf_count = 0 #interface count for lines in intf_output.splitlines()[1:]: intf_count = intf_count + 1 logger.info("Interface count is {}".format(intf_count))
def test(self, uut1): logger.info(banner("Verify the bootflash can be accessed")) logger.info("Verify the bootflash can be accessed") logger.info(title('Setup')) #Get dir output dir_output = uut1.execute("dir bootflash:mcp_crashinfo*") check_status = re.findall("(Error|Invalid|Incomplete|bytes free)", dir_output) if "Error" or "Invalid" or "Incomplete" in check_status: logger.info( "Failed to access the bootflash {}".format(check_status)) elif "bytes free" in check_status: logger.info(banner("The bootflash can be accessed"))
def test(self, uut1): logger.info(banner("Check GigE SPA status")) logger.info("Check if GigE SPA is online") logger.info(title('Setup')) #Get status output_sh_pl = uut1.execute("show platform") check_status = re.search("SPA-\dX1GE...\s+(ok)\s+", output_sh_pl) #check fp status if check_status.group(1) == "ok": logger.info( banner("GigE SPA is up status {}".format( check_status.group(1)))) else: self.failed("GigE SPA is NOT up")
def test(self, uut1): logger.info(banner("Check CC1 status")) logger.info("Check if CC1 is online") logger.info(title('Setup')) #Get status output_sh_pl = uut1.execute("show platform") check_status = re.search("0\s+(MCP-CC|ASR\d+-SIP\d+)\s+(ok)\s+", output_sh_pl) #check fp status if check_status.group(2) == "ok": logger.info( banner("CC1 is up status {}".format(check_status.group(2)))) else: self.failed("CC1 is NOT up")
def test(self, uut1): logger.info(banner("Check standby FP status")) logger.info("Check if standby FP reaches ok state") logger.info(title('Setup')) #Get status output_sh_pl = uut1.execute("show platform") check_status = re.search("F\d\s+[^\s]+\s+(ok)\,\s+standby", output_sh_pl) #check fp status if check_status.group(1) == "ok": logger.info( banner("Standby FP is status {}".format( check_status.group(1)))) else: self.failed("Standby FP failed to reach ok state")
def test(self, uut1): logger.info(banner("Check active FP status")) logger.info("Check if active FP is online") logger.info(title('Setup')) #Get status output_sh_pl = uut1.execute("show platform") check_status = re.search("F\d\s+[^\s]+\s+(ok)\,\s+active", output_sh_pl) #check fp status if check_status.group(1) == "ok": logger.info( banner("Active FP is up status {}".format( check_status.group(1)))) else: self.failed("Active FP is NOT up")
def test(self, uut1): logger.info(banner("Check standby RP status")) logger.info("Check if standby RP is online") logger.info(title('Setup')) #Get status output_sh_pl = uut1.execute("show platform") check_status = re.search("R\d\s+[^\s]+\s+(ok)\,\s+standby", output_sh_pl) #check rp status if check_status.group(1) == "ok": logger.info( banner("Standby RP is up status {}".format( check_status.group(1)))) else: self.failed("Standby RP is NOT up") #redundancy check logger.info("Display the output of show redundancy history") uut1.execute("show redundancy history")
def test(self, uut1): logger.info(banner("Interactive test command to all online FRUs")) logger.info("Interactive test command to all online FRUs") logger.info(title('Setup')) numFRUs = 0 passCount = 0 showResult = uut1.execute("show platform | incl ESP|RP") for fru in showResult.splitlines(): matchs = re.search("([RF]\d)\s+\S+\s+(ok)", fru) if (matchs.group(1))[0] == "R": type_rp = "RP" numFRUs = numFRUs + 1 rp_ok = matchs.group(2) if rp_ok: passCount = passCount + 1 elif (matchs.group(1))[0] == "F": typ_fp = "FP" numFRUs = numFRUs + 1 fp_ok = matchs.group(2) if fp_ok: passCount = passCount + 1 status_match = (matchs.group(1)) if numFRUs == passCount: try: output_inter = uut1.execute( "test platform software shell command infrastructure interactive {}" .format(status_match)) self.failed("fail") except Exception as e: logger.info( "Interactive test command did not succeed to some of the online FRUs" )
from ats.log import ScreenHandler from ats.log.utils import banner from ats.log.utils import title import time # get the root logger logger = logging.getLogger(__name__) # create handler (defaults to STDOUT) handler = ScreenHandler() # or, if you want to output to STDERR, use below instead handler = ScreenHandler(sys.stderr) # add handler to logger logger.addHandler(handler) # now try logging :) logger.critical('A critical message') logger.error(banner('an error message\nwith newline')) time.sleep(1) msg = banner('Something Done Wrong', v_margin='~', h_margin='~') print(msg) msg = banner('a banner message') print(msg) print(banner('Another Text Message', width=80)) msg = title('a title message') print(msg)
def section_test(self, uut1, rtr1, rtr2, uutInt1, uutInt2, rtr2Int): logger.info(banner("QoS classification and marking - multiple service-policies")) logger.info("Verify ip precedence and dscp classification and marking") logger.info(title('Setup')) precValue = "1" dscpValue = "34" #configuring access list try: uut1_config = ''' access-list 103 permit ip any any ! class-map match-all acl103 match access-group 103 ! class-map match-all prec1 match ip precedence {} ! policy-map inputPolicy class acl103 set ip prec {} ! policy-map outputPolicy class prec1 set ip dscp {} ! interface {} service-policy input inputPolicy '''.format((precValue),(precValue),(dscpValue),(uutInt1)) uut1.configure(uut1_config) #FIXME - Temporarily put a 10 second sleep between configuring input and output serive-policies time.sleep(10) uut1_config = ''' interface {} service-policy output outputPolicy '''.format((uutInt2)) uut1.configure(uut1_config) rtr2_config =''' access-list 121 permit ip any any dscp {} ! interface {} ip access-group 121 in '''.format((dscpValue),(rtr2Int)) rtr2.configure(rtr2_config) logger.info(banner("acl configuration successfull")) except Exception as e: self.failed("acl configuration error") #Verifying ping goes through to rtr2IP if not ping_test(rtr1, rtr2IP, count = '10', ipv6 = False): self.failed("Test failed: Packet marking not working") else: logger.info("Packets getting classified and marked correctly") uut1.execute("show policy-map interface " + uutInt1) uut1.execute("show policy-map interface " + uutInt2) #unconfiguring the policy map and access lists try: uut1_config =''' interface {} no service-policy input inputPolicy ! interface {} no service-policy output outputPolicy ! no policy-map outputPolicy no policy-map inputPolicy no class-map prec1 no class-map acl103 ! no access-list 103 '''.format((uutInt1),(uutInt2)) uut1.configure(uut1_config) rtr2_config =''' interface {} no ip access-group 121 in ! no access-list 121 '''.format((rtr2Int)) rtr2.configure(rtr2_config) logger.info("Unconfiguration scuccessfull") except Exception as e: self.failed("Unconfiguration error")
def section_test(self, uut1, rtr1, rtr2, uutInt2, rtr2Int): logger.info(banner("QoS output classification and marking")) logger.info("Verify output acl classification and dscp marking") logger.info(title('Setup')) dscpValue = "46" #configuring access list try: uut1_config = ''' access-list 103 permit ip any any ! class-map match-all acl103 match access-group 103 ! policy-map outputPolicy class acl103 set ip dscp {} ! interface {} service-policy output outputPolicy '''.format((dscpValue),(uutInt2)) uut1.configure(uut1_config) rtr2_config = ''' access-list 121 permit ip any any dscp {} ! interface {} ip access-group 121 in '''.format((dscpValue),(rtr2Int)) rtr2.configure(rtr2_config) logger.info(banner("acl configuration successfull")) except Exception as e: self.failed("acl configuration error") #Verifying ping goes through to rtr2IP if not ping_test(rtr1, rtr2IP, count = '10', ipv6 = False): self.failed("Test failed: Packet marking not working") else: logger.info("Packets getting classified and marked correctly") #unconfiguring the policy map and access lists try: uut1_config = ''' interface {} no service-policy output outputPolicy ! no policy-map outputPolicy no class-map acl103 ! no access-list 103 '''.format((uutInt2)) uut1.configure(uut1_config) rtr2_config = ''' interface {} no ip access-group 121 in ! no access-list 121 '''.format((rtr2Int)) rtr2.configure(rtr2_config) logger.info(banner("Unconfiguring the policy map and access lists scuccessfull")) except Exception as e: self.failed("Unconfiguring error")
def setup(self, uut1, rtr1, rtr2): logger.info(banner("Overall IOS punt ICMP test")) logger.info( "Verify interface bring up, presense of routes and ping UUT") logger.info(title('Setup'))