示例#1
0
    def CASE2(self, main):
        """
        Load and test vpls configurations from json configuration file
        """
        import os.path
        from tests.USECASE.VPLS.dependencies import vpls

        main.vpls = vpls
        pprint = main.Cluster.active(0).REST.pprint
        hosts = int(main.params['vpls']['hosts'])
        main.step("Discover hosts using pings")
        for i in range(1, hosts + 1):
            src = "h" + str(i)
            for j in range(1, hosts + 1):
                if j == i:
                    continue
                dst = "h" + str(j)
            pingResult = main.Mininet1.pingHost(SRC=src, TARGET=dst)

        main.step("Load VPLS configurations")
        fileName = main.params['DEPENDENCY']['topology']
        app = main.params['vpls']['name']

        loadVPLSResult = main.ONOSbench.onosNetCfg(
            main.Cluster.active(0).ipAddress, "", fileName)
        utilities.assert_equals(expect=main.TRUE,
                                actual=loadVPLSResult,
                                onpass="******",
                                onfail="Failed to load vpls configuration.")

        # Time for netcfg to load data
        time.sleep(main.sleep)
        # 'Master' copy of test configuration

        try:
            with open(os.path.expanduser(fileName)) as dataFile:
                originalCfg = json.load(dataFile)
                main.vplsConfig = originalCfg['apps'].get(app).get('vpls').get(
                    'vplsList')
        except Exception as e:
            main.log.error("Error loading config file: {}".format(e))
        if main.vplsConfig:
            result = True
        else:
            result = False
        utilities.assert_equals(expect=True,
                                actual=result,
                                onpass="******",
                                onfail="Failed to load vpls configuration")

        main.step("Check interface configurations")
        result = False
        getPorts = utilities.retry(f=main.Cluster.active(0).REST.getNetCfg,
                                   retValue=False,
                                   kwargs={"subjectClass": "ports"},
                                   sleep=main.sleep)
        onosCfg = pprint(getPorts)
        sentCfg = pprint(originalCfg.get("ports"))

        if onosCfg == sentCfg:
            main.log.info("ONOS interfaces NetCfg matches what was sent")
            result = True
        else:
            main.log.error(
                "ONOS interfaces NetCfg doesn't match what was sent")
            main.log.debug("ONOS config: {}".format(onosCfg))
            main.log.debug("Sent config: {}".format(sentCfg))
        utilities.assert_equals(expect=True,
                                actual=result,
                                onpass="******",
                                onfail="Net Cfg not added for interfaces")

        # Run a bunch of checks to verify functionality based on configs
        vpls.verify(main)

        main.step(
            "Loading vpls configuration in case any configuration was missed.")
        loadVPLSResult = main.ONOSbench.onosNetCfg(
            main.Cluster.active(0).ipAddress, "", fileName)
        utilities.assert_equals(expect=main.TRUE,
                                actual=loadVPLSResult,
                                onpass="******",
                                onfail="Failed to load vpls configuration.")
示例#2
0
    def CASE2(self, main):
        """
        Load and test vpls configurations from json configuration file
        """
        import os.path
        from tests.USECASE.VPLS.dependencies import vpls

        pprint = main.ONOSrest1.pprint
        hosts = int(main.params['vpls']['hosts'])
        SLEEP = int(main.params['SLEEP']['netcfg'])

        main.step("Discover hosts using pings")
        for i in range(1, hosts + 1):
            src = "h" + str(i)
            for j in range(1, hosts + 1):
                if j == i:
                    continue
                dst = "h" + str(j)
            pingResult = main.Mininet1.pingHost(SRC=src, TARGET=dst)

        main.step("Load VPLS configurations")
        # TODO: load from params
        fileName = main.params['DEPENDENCY']['topology']
        app = main.params['vpls']['name']
        # TODO make this a function?
        main.ONOSbench.handle.sendline("onos-netcfg $OC1 " + fileName)
        # Time for netcfg to load data
        time.sleep(SLEEP)
        # 'Master' copy of test configuration
        try:
            with open(os.path.expanduser(fileName)) as dataFile:
                originalCfg = json.load(dataFile)
                main.vplsConfig = originalCfg['apps'].get(app).get('vpls').get(
                    'vplsList')
        except Exception as e:
            main.log.error("Error loading config file: {}".format(e))
        if main.vplsConfig:
            result = True
        else:
            result = False
        utilities.assert_equals(expect=True,
                                actual=result,
                                onpass="******",
                                onfail="Failed to load vpls configuration")

        main.step("Check interface configurations")
        result = False
        getPorts = main.ONOSrest1.getNetCfg(subjectClass="ports")
        onosCfg = pprint(getPorts)
        sentCfg = pprint(originalCfg.get("ports"))

        if onosCfg == sentCfg:
            main.log.info("ONOS interfaces NetCfg matches what was sent")
            result = True
        else:
            main.log.error(
                "ONOS interfaces NetCfg doesn't match what was sent")
            main.log.debug("ONOS config: {}".format(onosCfg))
            main.log.debug("Sent config: {}".format(sentCfg))
        utilities.assert_equals(expect=True,
                                actual=result,
                                onpass="******",
                                onfail="Net Cfg not added for interfaces")

        # Run a bunch of checks to verify functionality based on configs
        vpls.verify(main)
示例#3
0
    def CASE3(self, main):
        """
        Test VPLS cli commands
        High level steps:
            remove interface from a network
            Clean configs
            create vpls network
            add interfaces to a network
            add encap
            change encap
            remove encap
            list?
        """
        from tests.USECASE.VPLS.dependencies import vpls
        SLEEP = int(main.params['SLEEP']['netcfg'])
        pprint = main.ONOSrest1.pprint

        main.step("Remove an interface from a vpls network")
        main.CLIs[0].vplsRemIface('VPLS1', 'h1')
        time.sleep(SLEEP)
        #update master config json
        for network in main.vplsConfig:
            if network.get('name') == 'VPLS1':
                ifaces = network.get('interfaces')
                ifaces.remove('h1')
        vpls.verify(main)

        main.step("Clean all vpls configurations")
        main.CLIs[0].vplsClean()
        time.sleep(SLEEP)
        main.vplsConfig = []
        vpls.verify(main)

        main.step("Create a new vpls network")
        name = "Network1"
        main.CLIs[0].vplsCreate(name)
        time.sleep(SLEEP)
        network1 = {'name': name, 'interfaces': [], 'encapsulation': 'NONE'}
        main.vplsConfig.append(network1)
        vpls.verify(main)

        main.step("Add interfaces to the network")
        main.CLIs[0].vplsAddIface(name, "h1")
        main.CLIs[0].vplsAddIface(name, "h5")
        main.CLIs[0].vplsAddIface(name, "h4")
        time.sleep(SLEEP)
        for network in main.vplsConfig:
            if network.get('name') == name:
                ifaces = network.get('interfaces')
                ifaces.append('h1')
                ifaces.append('h4')
                ifaces.append('h5')
                network['interfaces'] = ifaces
        vpls.verify(main)

        main.step("Add MPLS encapsulation to a vpls network")
        encapType = "MPLS"
        main.CLIs[0].vplsSetEncap(name, encapType)
        for network in main.vplsConfig:
            if network.get('name') == name:
                network['encapsulation'] = encapType
        time.sleep(SLEEP)
        vpls.verify(main)

        main.step("Change an encapsulation type")
        encapType = "VLAN"
        main.CLIs[0].vplsSetEncap(name, encapType)
        for network in main.vplsConfig:
            if network.get('name') == name:
                network['encapsulation'] = encapType
        time.sleep(SLEEP)
        vpls.verify(main)

        main.step("Remove encapsulation")
        encapType = "NONE"
        main.CLIs[0].vplsSetEncap(name, encapType)
        for network in main.vplsConfig:
            if network.get('name') == name:
                network['encapsulation'] = encapType
        time.sleep(SLEEP)
        vpls.verify(main)

        main.step("Clean all vpls configurations")
        main.CLIs[0].vplsClean()
        time.sleep(SLEEP)
        main.vplsConfig = []
        vpls.verify(main)
示例#4
0
    def CASE2( self, main ):
        """
        Load and test vpls configurations from json configuration file
        """
        import os.path
        from tests.USECASE.VPLS.dependencies import vpls

        main.vpls = vpls
        pprint = main.Cluster.active( 0 ).REST.pprint
        hosts = int( main.params[ 'vpls' ][ 'hosts' ] )
        main.step( "Discover hosts using pings" )
        for i in range( 1, hosts + 1 ):
            src = "h" + str( i )
            for j in range( 1, hosts + 1 ):
                if j == i:
                    continue
                dst = "h" + str( j )
            pingResult = main.Mininet1.pingHost( SRC=src, TARGET=dst )

        main.step( "Load VPLS configurations" )
        fileName = main.params[ 'DEPENDENCY' ][ 'topology' ]
        app = main.params[ 'vpls' ][ 'name' ]

        loadVPLSResult = main.ONOSbench.onosNetCfg( main.Cluster.active( 0 ).ipAddress, "", fileName )
        utilities.assert_equals( expect=main.TRUE,
                                 actual=loadVPLSResult,
                                 onpass="******",
                                 onfail="Failed to load vpls configuration." )

        # Time for netcfg to load data
        time.sleep( main.sleep )
        # 'Master' copy of test configuration

        try:
            with open( os.path.expanduser( fileName ) ) as dataFile:
                originalCfg = json.load( dataFile )
                main.vplsConfig = originalCfg[ 'apps' ].get( app ).get( 'vpls' ).get( 'vplsList' )
        except Exception as e:
            main.log.error( "Error loading config file: {}".format( e ) )
        if main.vplsConfig:
            result = True
        else:
            result = False
        utilities.assert_equals( expect=True,
                                 actual=result,
                                 onpass="******",
                                 onfail="Failed to load vpls configuration" )

        main.step( "Check interface configurations" )
        result = False
        getPorts = utilities.retry( f=main.Cluster.active( 0 ).REST.getNetCfg,
                                    retValue=False,
                                    kwargs={ "subjectClass": "ports" },
                                    sleep=main.sleep )
        onosCfg = pprint( getPorts )
        sentCfg = pprint( originalCfg.get( "ports" ) )

        if onosCfg == sentCfg:
            main.log.info( "ONOS interfaces NetCfg matches what was sent" )
            result = True
        else:
            main.log.error( "ONOS interfaces NetCfg doesn't match what was sent" )
            main.log.debug( "ONOS config: {}".format( onosCfg ) )
            main.log.debug( "Sent config: {}".format( sentCfg ) )
        utilities.assert_equals( expect=True,
                                 actual=result,
                                 onpass="******",
                                 onfail="Net Cfg not added for interfaces" )

        # Run a bunch of checks to verify functionality based on configs
        vpls.verify( main )

        main.step( "Loading vpls configuration in case any configuration was missed." )
        loadVPLSResult = main.ONOSbench.onosNetCfg( main.Cluster.active( 0 ).ipAddress, "", fileName )
        utilities.assert_equals( expect=main.TRUE,
                                 actual=loadVPLSResult,
                                 onpass="******",
                                 onfail="Failed to load vpls configuration." )