예제 #1
0
kDutType = {"type": "ExternalServer"}

kDutConfig = {"ipAddress": "10.10.10.10"}

# Create a connection to the gateway
connection = IxRestUtils.getConnection(testSettings.gatewayServer,
                                       testSettings.gatewayPort,
                                       httpRedirect=testSettings.httpRedirect,
                                       version=testSettings.apiVersion)

sessionUrl = None

try:
    # Create a session
    IxLoadUtils.log("Creating a new session...")
    sessionUrl = IxLoadUtils.createSession(connection,
                                           testSettings.ixLoadVersion)
    IxLoadUtils.log("Session created.")

    # Create nettraffics (communities)
    IxLoadUtils.log('Creating communities...')
    IxLoadUtils.addCommunities(connection, sessionUrl, kCommunities)
    IxLoadUtils.log('Communities created.')

    # Create activities
    IxLoadUtils.log('Creating activities...')
    IxLoadUtils.addActivities(connection, sessionUrl, kActivities)
    IxLoadUtils.log('Activities created.')

    IxLoadUtils.log('Adding DNS command to DNS client...')
    dnsCommandOptions = {'commandType': 'DnsQuery', "dnsServer": "DUT1"}
    IxLoadUtils.DnsUtils.addDnsCommand(connection, sessionUrl,
예제 #2
0
    rxfDirPath = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))

    return os.path.join(rxfDirPath, rxfName)
################


#create a connection to the gateway
connection = IxRestUtils.getConnection(kGatewayServer, kGatewayPort, httpRedirect=kHttpRedirect)
connection.setApiKey(kApiKey)

sessionUrl = None
#create a session
try:
    IxLoadUtils.log("Creating a new session...")
    sessionUrl = IxLoadUtils.createSession(connection, kIxLoadVersion)
    IxLoadUtils.log("Session created.")

    # upload file to gateway server
    IxLoadUtils.log('Uploading file %s...' % kRxfPath)
    kResourcesUrl = IxLoadUtils.getResourcesUrl(connection)
    IxLoadUtils.uploadFile(connection, kResourcesUrl, kRxfPath, kRxfRelativeUploadPath)
    IxLoadUtils.log('Upload file finished.')

    # load a repository
    IxLoadUtils.log("Loading repository %s..." % kRxfAbsoluteUploadPath)
    IxLoadUtils.loadRepository(connection, sessionUrl, kRxfAbsoluteUploadPath)
    IxLoadUtils.log("Repository loaded.")

    IxLoadUtils.log("Clearing chassis list...")
    IxLoadUtils.clearChassisList(connection, sessionUrl)
예제 #3
0
    def config_test(self, build_version, rxf_name, csv_path, zip_file):
        self.k_rxf_path = rxf_name

        # Create a connection to the gateway
        self.connection = IxRestUtils.getConnection(self.k_gateway_server, self.k_gateway_port)

        # Create a session
        IxLoadUtils.log("Creating a new session...")
        self.session_url = IxLoadUtils.createSession(self.connection, self.k_ixload_version)
        IxLoadUtils.log("Session created.")

        try:
            # Load a repository
            IxLoadUtils.log("Loading repository %s..." % self.k_rxf_path)
            IxLoadUtils.loadRepository(self.connection, self.session_url, self.k_rxf_path)
            IxLoadUtils.log("Repository loaded.")

            # Modify CSVs results path
            load_test_url = "%s/ixload/test/" % self.session_url
            payloadDict = {"outputDir" : "true", "runResultDirFull" : csv_path}
            IxLoadUtils.log("Perform CSVs results path modification.")
            IxLoadUtils.performGenericPatch(self.connection, load_test_url, payloadDict)

            # Enable Capture on both ports
            communtiyListUrl = "%s/ixload/test/activeTest/communityList" % self.session_url
            communityList = self.connection.httpGet(url=communtiyListUrl)

            for community in communityList:
                portListUrl = "%s/%s/network/portList" % (communtiyListUrl, community.objectID)
                payloadDict = {"enableCapture" : "true"}
                IxLoadUtils.log("Perform enable capture on port : %s." % str(community.objectID))
                IxLoadUtils.performGenericPatch(self.connection, portListUrl, payloadDict)
                IxLoadUtils.log("Enabled capture on port : %s." % str(community.objectID))

            # Save repository
            IxLoadUtils.log("Saving repository %s..." % (rxf_name.split(".")[0]))
            IxLoadUtils.saveRxf(self.connection, self.session_url, rxf_name.split(".")[0]+"save")
            IxLoadUtils.log("Repository saved.")

            self.StartedLogs = True

            # Start test
            IxLoadUtils.log("Starting the test...")
            IxLoadUtils.runTest(self.connection, self.session_url)
            IxLoadUtils.log("Test started.")

            testIsRunning = True
            while testIsRunning:
                time.sleep(2)
                testIsRunning = IxLoadUtils.getTestCurrentState(self.connection, self.session_url) == "Running"

            # Test ended
            IxLoadUtils.log("Test finished.")

            # Get test error
            IxLoadUtils.log("Checking test status...")
            self.test_run_error = IxLoadUtils.getTestRunError(self.connection, self.session_url)

            if self.test_run_error:
                IxLoadUtils.log("The test exited with the following error: %s" % self.test_run_error)
                self.error = True
                self.diag = True
            else:
                IxLoadUtils.log("The test completed successfully.")
                self.error = False
                self.diag = False

            IxLoadUtils.log("Waiting for test to clean up and reach 'Unconfigured' state...")
            IxLoadUtils.waitForTestToReachUnconfiguredState(self.connection, self.session_url)
            IxLoadUtils.log("Test is back in 'Unconfigured' state.")

            time.sleep(1)
            self.StopLogs = True

            # Collect Diagnostics
            if self.diag:
                IxLoadUtils.log("Collecting diagnostics...")
                collectDiagnosticsUrl = "%s/ixload/test/activeTest/operations/collectDiagnostics" % (self.session_url)
                data = {"zipFileLocation": zip_file}
                IxLoadUtils.performGenericOperation(self.connection, collectDiagnosticsUrl, data)

        finally:
            self.StopLogs = True
            self.StartedLogs = True
            IxLoadUtils.log("Closing IxLoad session...")

            if self.connection is not None and self.session_url is not None:
                IxLoadUtils.deleteSession(self.connection, self.session_url)
            IxLoadUtils.log("IxLoad session closed.")