def CASE4(self, main): """ Deletion of Node """ import os, sys import re import time main.case("TestCase 4: Deletion of Node from existing Topology") try: from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs except ImportError: main.log.exception( "Something wrong with import file or code error.") main.log.info("Import Error, please check!") main.cleanup() main.exit() bgplsConfig = BgpLs() Ne_id = bgplsConfig.Constants() app = bgplsConfig.apps() main.CLIs = [] main.nodes = [] main.numCtrls = 1 bgplsConfig.Comments() main.log.info("Blocked due to this defect : ONOS-3920 ") bgplsConfig.Comments() '''
def CASE2(self, main): """ Discovery the topology using BGPLS """ import os import sys import re import time main.case("Testcase 2 : Discovery the Network Topology using BGPLS") main.Cluster.active(0).CLI.log("\"testcase2 start\"") try: from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs except ImportError: main.log.exception( "Something wrong with import file or code error.") main.log.info("Import Error, please check!") main.cleanAndExit() bgplsConfig = BgpLs() Ne_id = bgplsConfig.Constants() app = bgplsConfig.apps() httpport = main.params['HTTP']['port'] path = main.params['HTTP']['path'] bgplsConfig.ipValue(main.ipList, main.scapy_ip) bgplsConfig.Comments() main.log.info("Sending BGPLS information") bgplsConfig.Comments() main.Scapy1.handle.sendline( "sudo python OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/\ dependencies/Scapyfiles/Topo_discovery.py") bgplsConfig.Comments() main.log.info("Enable BGPlS plugin in ONOS") bgplsConfig.Comments() main.testSetUp.startOnosClis(main.Cluster) installResults = main.Cluster.active(0).CLI.activateApp(app[0]) main.step("Install onos-app-bgp") utilities.assert_equals(expect=main.TRUE, actual=installResults, onpass="******", onfail="Install onos-app-bgp failed") bgpls_post = bgplsConfig.DictoJson() bgplsConfig.Comments() main.log.info("BGPLS RestConf input") bgplsConfig.Comments() print(bgpls_post) Poststatus, result = main.Cluster.active(0).REST.send( '/network/configuration/', method="POST", data=bgpls_post) main.step("Configure BGP through RESTCONF") utilities.assert_equals(expect='200', actual=Poststatus, onpass="******", onfail="Post Port Failed " + str(Poststatus) + "," + str(result)) bgplsConfig.Comments() main.step("Check Network devices are Updated in ONOS ") bgplsConfig.Comments() time.sleep(15) response = main.Cluster.active(0).CLI.devices() responseCheck = main.FALSE if response: responseCheck = main.TRUE utilities.assert_equals( expect=main.TRUE, actual=responseCheck, onpass="******", onfail="Network Devices update in ONOS failed") main.step("Check the nodes are discovered") if response.find(Ne_id[1][0]) and response.find( Ne_id[1][1]) and response.find(Ne_id[1][2]) != -1: stepResult = main.TRUE else: stepResult = main.FALSE utilities.assert_equals(expect=main.TRUE, actual=stepResult, onpass="******" + str(Ne_id[1][0]) + (Ne_id[1][1]) + (Ne_id[1][2]) + " sucess", onfail="Node " + str(Ne_id[1][0]) + (Ne_id[1][1]) + (Ne_id[1][2]) + " failed") main.Cluster.active(0).CLI.log("\"testcase2 end\"") main.step("Check for Errors or Exception in testcase2") startStr = "testcase2 start" endStr = "testcase2 end" errorLog = main.ONOSbench.logReport( main.Cluster.active(0).ipAddress, ["ERROR", "EXCEPT"], "s", startStr, endStr) utilities.assert_equals( expect=0, actual=errorLog, onpass="******", onfail="Exception or Error occured in testcase2") bgplsConfig.Comments() main.log.info("Kill Scapy process") bgplsConfig.Comments() main.Scapy1.handle.send("\x03") time.sleep(90) # This Sleep time gives time for the socket to close.
def CASE3(self, main): """ Addition of new Node to existing topology """ import os import sys import re import time main.case("Testcase 3: Addition of New Node to existing topology") main.Cluster.active(0).CLI.log("\"testcase3 start\"") try: from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs except ImportError: main.log.exception( "Something wrong with import file or code error.") main.log.info("Import Error, please check!") main.cleanAndExit() bgplsConfig = BgpLs() Ne_id = bgplsConfig.Constants() app = bgplsConfig.apps() httpport = main.params['HTTP']['port'] path = main.params['HTTP']['path'] bgplsConfig.ipValue(main.ipList, main.scapy_ip) bgplsConfig.Comments() main.log.info("Sending BGPLS Packet ") bgplsConfig.Comments() main.Scapy1.handle.sendline( "sudo python OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/\ dependencies/Scapyfiles/Update_Node.py") bgplsConfig.Comments() main.log.info("Enable BGPlS plugin in ONOS") bgplsConfig.Comments() main.step("UnInstall onos-app-bgp") installResults = main.Cluster.active(0).CLI.deactivateApp(app[0]) utilities.assert_equals(expect=main.TRUE, actual=installResults, onpass="******", onfail="Uninstall onos-app-bgp failed") installResults = main.Cluster.active(0).CLI.activateApp(app[0]) main.step("Install onos-app-bgp") utilities.assert_equals(expect=main.TRUE, actual=installResults, onpass="******", onfail="Install onos-app-bgp failed") bgpls_post = bgplsConfig.DictoJson() bgplsConfig.Comments() main.log.info("BGPLS RestConf input") bgplsConfig.Comments() bgplsConfig.Comments() main.step("Check Network devices are Updated in ONOS") bgplsConfig.Comments() time.sleep(120) response = main.Cluster.active(0).CLI.devices() responseCheck = main.FALSE if response: responseCheck = main.TRUE utilities.assert_equals( expect=main.TRUE, actual=responseCheck, onpass="******", onfail="Network Devices update in ONOS failed") main.step("Check Newly added Node is getting updated") if response.find(Ne_id[1][3]) != -1: stepResult = main.TRUE else: stepResult = main.FALSE utilities.assert_equals( expect=main.TRUE, actual=stepResult, onpass="******" + str(Ne_id[1][3]) + " update sucess", onfail="Node " + str(Ne_id[1][3]) + " update failed") main.Cluster.active(0).CLI.log("\"testcase3 end\"") main.step("Check for Errors or Exception in testcase3") startStr = "testcase3 start" endStr = "testcase3 end" errorLog = main.ONOSbench.logReport( main.Cluster.active(0).ipAddress, ["ERROR", "EXCEPT"], "s", startStr, endStr) utilities.assert_equals( expect=0, actual=errorLog, onpass="******", onfail="Exception or Error occured in testcase3") bgplsConfig.Comments() main.log.info("Kill Scapy process") bgplsConfig.Comments() main.Scapy1.handle.send("\x03") time.sleep(90) # This Sleep time gives time for the socket to close.
def CASE3(self, main): """ Addition of new Node to existing topology """ import os, sys import re import time main.case("Testcase 3: Addition of New Node to existing topology") try: from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs except ImportError: main.log.exception( "Something wrong with import file or code error.") main.log.info("Import Error, please check!") main.cleanup() main.exit() bgplsConfig = BgpLs() Ne_id = bgplsConfig.Constants() app = bgplsConfig.apps() main.CLIs = [] main.nodes = [] main.numCtrls = 1 ipList = os.getenv(main.params['CTRL']['ip1']) scapy_ip = os.getenv(main.params['SCAPY']['HOSTNAMES']) cellName = main.params['ENV']['cellName'] cellAppString = main.params['ENV']['cellApps'] httpport = main.params['HTTP']['port'] path = main.params['HTTP']['path'] bgplsConfig.ipValue(ipList, scapy_ip) for i in range(1, main.numCtrls + 1): try: main.CLIs.append(getattr(main, 'ONOScli' + str(i))) main.nodes.append(getattr(main, 'ONOS' + str(i))) ipList.append(main.nodes[-1].ip_address) except AttributeError: break bgplsConfig.Comments() main.log.info("Sending BGPLS Packet ") bgplsConfig.Comments() main.Scapy1.handle.sendline( "sudo python OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/\ dependencies/Scapyfiles/Update_Node.py") bgplsConfig.Comments() main.log.info("Enable BGPlS plugin in ONOS") bgplsConfig.Comments() main.step("UnInstall onos-app-bgp") installResults = main.ONOScli1.deactivateApp(app[0]) utilities.assert_equals(expect=main.TRUE, actual=installResults, onpass="******", onfail="Uninstall onos-app-bgp failed") installResults = main.ONOScli1.activateApp(app[0]) main.step("Install onos-app-bgp") utilities.assert_equals(expect=main.TRUE, actual=installResults, onpass="******", onfail="Install onos-app-bgp failed") bgpls_post = bgplsConfig.DictoJson() bgplsConfig.Comments() main.log.info("BGPLS RestConf input") bgplsConfig.Comments() bgplsConfig.Comments() main.log.info("Check Network devices are Updated in ONOS ") bgplsConfig.Comments() time.sleep(120) response = main.ONOScli1.devices() main.step("Check Newly added Node is getting updated") if response.find(Ne_id[1][3]) != -1: stepResult = main.TRUE else: stepResult = main.FALSE utilities.assert_equals( expect=main.TRUE, actual=stepResult, onpass="******" + str(Ne_id[1][3]) + " update sucess", onfail="Node " + str(Ne_id[1][3]) + " update failed") bgplsConfig.Comments() main.log.info("Kill Scapy process") bgplsConfig.Comments() main.Scapy1.handle.sendline("\x03")
def CASE2(self, main): """ Discovery the topology using BGPLS """ import os, sys import re import time main.case("Testcase 2 : Discovery the Network Topology using BGPLS") try: from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs except ImportError: main.log.exception( "Something wrong with import file or code error.") main.log.info("Import Error, please check!") main.cleanup() main.exit() bgplsConfig = BgpLs() Ne_id = bgplsConfig.Constants() app = bgplsConfig.apps() main.CLIs = [] main.nodes = [] main.numCtrls = 1 ipList = os.getenv(main.params['CTRL']['ip1']) scapy_ip = os.getenv(main.params['SCAPY']['HOSTNAMES']) httpport = main.params['HTTP']['port'] path = main.params['HTTP']['path'] bgplsConfig.ipValue(ipList, scapy_ip) for i in range(1, main.numCtrls + 1): try: main.CLIs.append(getattr(main, 'ONOScli' + str(i))) main.nodes.append(getattr(main, 'ONOS' + str(i))) ipList.append(main.nodes[-1].ip_address) except AttributeError: break main.step("Apply cell to environment") bgplsConfig.Comments() bgplsConfig.Comments() main.log.info("Sending BGPLS information ") bgplsConfig.Comments() main.Scapy1.handle.sendline( "sudo python OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/\ dependencies/Scapyfiles/Topo_discovery.py") bgplsConfig.Comments() main.log.info("Enable BGPlS plugin in ONOS") bgplsConfig.Comments() cliResults = main.ONOScli1.startOnosCli(main.nodes[0].ip_address) main.step("Getting connected to ONOS") utilities.assert_equals(expect=main.TRUE, actual=cliResults, onpass="******", onfail="ONOS cli startup failed") installResults = main.ONOScli1.activateApp(app[0]) main.step("Install onos-app-bgp") utilities.assert_equals(expect=main.TRUE, actual=installResults, onpass="******", onfail="Install onos-app-bgp failed") bgpls_post = bgplsConfig.DictoJson() bgplsConfig.Comments() main.log.info("BGPLS RestConf input") bgplsConfig.Comments() print(bgpls_post) main.ONOSrest.user_name = "karaf" main.ONOSrest.pwd = "karaf" Poststatus, result = main.ONOSrest.send('/network/configuration/', method="POST", data=bgpls_post) main.step("Configure BGP through RESTCONF") utilities.assert_equals(expect='200', actual=Poststatus, onpass="******", onfail="Post Port Failed " + str(Poststatus) + "," + str(result)) bgplsConfig.Comments() main.log.info("Check Network devices are Updated in ONOS ") bgplsConfig.Comments() time.sleep(15) response = main.ONOScli1.devices() main.step("Check the nodes are discovered") if response.find(Ne_id[1][0]) and response.find( Ne_id[1][1]) and response.find(Ne_id[1][2]) != -1: stepResult = main.TRUE else: stepResult = main.FALSE utilities.assert_equals(expect=main.TRUE, actual=stepResult, onpass="******" + str(Ne_id[1][0]) + (Ne_id[1][1]) + (Ne_id[1][2]) + " sucess", onfail="Node " + str(Ne_id[1][0]) + (Ne_id[1][1]) + (Ne_id[1][2]) + " failed") bgplsConfig.Comments() main.log.info("Kill Scapy process") bgplsConfig.Comments() main.Scapy1.handle.sendline("\x03") time.sleep(90) #This Sleep time gives time for the socket to close.