class SDNIPperf:

    def __init__( self ):
        self.default = ''
        global branchName

    # This case is to setup ONOS
    def CASE100( self, main ):
        """
           CASE100 is to compile ONOS and push it to the test machines
           Startup sequence:
           cell <name>
           onos-verify-cell
           git pull
           mvn clean install
           onos-package
           onos-install -f
           onos-wait-for-start
        """
        main.case( "Setting up test environment" )

        cellName = main.params[ 'ENV' ][ 'cellName' ]
        ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]

        main.step( "Applying cell variable to environment" )
        cellResult = main.ONOSbench.setCell( cellName )
        verifyResult = main.ONOSbench.verifyCell()

        branchName = main.ONOSbench.getBranchName()
        main.log.info( "ONOS is on branch: " + branchName )

        main.log.report( "Uninstalling ONOS" )
        main.ONOSbench.onosUninstall( ONOS1Ip )

        cleanInstallResult = main.TRUE
        gitPullResult = main.TRUE

        main.step( "Git pull" )
        gitPullResult = main.FALSE
        #Need to push some new code to ONOS before using the git pull
        #gitPullResult = main.ONOSbench.gitPull()

        main.step( "Using mvn clean & install" )
        if gitPullResult == main.TRUE:
            cleanInstallResult = main.ONOSbench.cleanInstall()
        else:
             main.log.warn( "Did not pull new code so skipping mvn " +
                             "clean install" )
        cleanInstallResult = main.ONOSbench.cleanInstall( mciTimeout= 300 )
        main.ONOSbench.getVersion( report=True )

        main.step( "Creating ONOS package" )
        packageResult = main.ONOSbench.onosPackage( opTimeout=500 )

        main.step( "Installing ONOS package" )
        onos1InstallResult = main.ONOSbench.onosInstall( options="-f",
                                                           node=ONOS1Ip )

        main.step( "Checking if ONOS is up yet" )
        for i in range( 2 ):
            onos1Isup = main.ONOSbench.isup( ONOS1Ip, timeout=420 )
            if onos1Isup:
                break
        if not onos1Isup:
            main.log.report( "ONOS1 didn't start!" )

        cliResult = main.ONOScli.startOnosCli( ONOS1Ip,
                commandlineTimeout=100, onosStartTimeout=600)

        case1Result = ( cleanInstallResult and packageResult and
                        cellResult and verifyResult and
                        onos1InstallResult and
                        onos1Isup and cliResult )

        utilities.assert_equals( expect=main.TRUE, actual=case1Result,
                                 onpass="ONOS startup successful",
                                 onfail="ONOS startup NOT successful" )

        if case1Result == main.FALSE:
            main.cleanup()
            main.exit()

    def CASE9( self, main ):
        """
        Test the SDN-IP Performance
        Test whether SDN-IP can boot with 600,000 routes from an external peer.
        Since our goal for SDN-IP is to handle 600,000 routes, in this test case
        we statically configure an external peer Quagga with 655360 routes.
        Thus, we pre-know the routes and intents it should be, and then boot the
        whole system and check whether the numbers of routes and intents from
        ONOS CLI are correct.
        """
        import time
        import json
        from operator import eq
        from time import localtime, strftime

        # We configured one external BGP peer with 655360 routes
        routeNumberExpected = 655360
        m2SIntentsNumberExpected = 655360

        main.case("This case is to testing the performance of SDN-IP with \
        single ONOS instance" )
        time.sleep( 10 )

        main.step( "Get devices in the network" )
        listResult = main.ONOScli.devices( jsonFormat=False )
        main.log.info( listResult )

        main.step( "Get links in the network" )
        listResult = main.ONOScli.links ( jsonFormat=False )
        main.log.info( listResult )

        main.log.info( "Activate sdn-ip application" )
        main.ONOScli.activateApp( "org.onosproject.sdnip" )

        main.step("Sleep 1200 seconds")
        # wait until SDN-IP receives all routes and ONOS installs all intents
        time.sleep( main.params[ 'timers' ][ 'SystemBoot' ] )

        main.step( "Checking routes installed" )

        main.log.info( "Total route number expected is:" )
        main.log.info( routeNumberExpected )

        routeNumberActual = main.ONOScli.ipv4RouteNumber()
        main.log.info("Total route  number actual is: ")
        main.log.info(routeNumberActual)

        utilities.assertEquals(
            expect=routeNumberExpected, actual=routeNumberActual,
            onpass="***Routes in SDN-IP are correct!***",
            onfail="***Routes in SDN-IP are wrong!***" )


        main.step( "Checking MultiPointToSinglePointIntent intents installed" )

        main.log.info( "MultiPointToSinglePoint intent number expected is:" )
        main.log.info( m2SIntentsNumberExpected )

        m2SIntentsNumberActual = main.ONOScli.m2SIntentInstalledNumber()
        main.log.info( "MultiPointToSinglePoint intent number actual is:" )
        main.log.info(m2SIntentsNumberActual)

        utilities.assertEquals(
            expect=True,
            actual=eq( m2SIntentsNumberExpected, m2SIntentsNumberActual ),
            onpass="***MultiPointToSinglePoint intent number is correct!***",
            onfail="***MultiPointToSinglePoint intent number is wrong!***" )
