Exemplo n.º 1
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.")
Exemplo n.º 2
0
    IxLoadUtils.log("Ports assigned.")

    IxLoadUtils.log("Saving repository %s..." % (getRxfName()))
    IxLoadUtils.saveRxf(connection, sessionUrl, getRxfName())
    IxLoadUtils.log("Repository saved.")

    IxLoadUtils.log("Starting the test...")
    IxLoadUtils.runTest(connection, sessionUrl)
    IxLoadUtils.log("Test started.")

    IxLoadUtils.log("Polling values for stats %s..." % (kStatsToDisplayDict))
    IxLoadUtils.pollStats(connection, sessionUrl, kStatsToDisplayDict)

    IxLoadUtils.log("Test finished.")

    IxLoadUtils.log("Checking test status...")
    testRunError = IxLoadUtils.getTestRunError(connection, sessionUrl)
    if testRunError:
        IxLoadUtils.log("The test exited with the following error: %s" % testRunError)
    else:
        IxLoadUtils.log("The test completed successfully.")

    IxLoadUtils.log("Waiting for test to clean up and reach 'Unconfigured' state...")
    IxLoadUtils.waitForTestToReachUnconfiguredState(connection, sessionUrl)
    IxLoadUtils.log("Test is back in 'Unconfigured' state.")
finally:
    if sessionUrl is not None:
        IxLoadUtils.log("Closing IxLoad session...")
        IxLoadUtils.deleteSession(connection, sessionUrl)
        IxLoadUtils.log("IxLoad session closed.")
Exemplo n.º 3
0
    def config_test(self, build_version, rxf_name, csv_path, zip_file, gateway_file):

        location=inspect.getfile(inspect.currentframe())
        kStatsToDisplayDict =   {
                            #format: { statSource : [stat name list] }
                            "HTTPClient": ["HTTP Simulated Users"],
                            "HTTPServer": ["HTTP Requests Received"]
                        }
        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.createNewSession(self.connection, self.k_ixload_version)
        IxLoadUtils.log("Session created.")

        try:
            # Upload file to gateway server
            kRxfRelativeUploadPath = os.path.split(self.k_rxf_path)[1]
            kRxfAbsoluteUploadPath = self.k_rxf_path
            if self.k_gateway_server not in ["127.0.0.1", "localhost", "::1"]:
                IxLoadUtils.log('Uploading file %s...' % self.k_rxf_path)
                kResourcesUrl = IxLoadUtils.getResourcesUrl(self.connection)
                IxLoadUtils.uploadFile(self.connection, kResourcesUrl, self.k_rxf_path, kRxfRelativeUploadPath)
                IxLoadUtils.log('Upload file finished.')
                kRxfAbsoluteUploadPath = '/'.join([IxLoadUtils.getSharedFolder(self.connection), kRxfRelativeUploadPath])

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

            # Modify CSVs results path
            IxLoadUtils.log("Perform CSVs results path modification.")
            IxLoadUtils.changeRunResultDir(self.connection,self.session_url, csv_path)

            IxLoadUtils.log("Refresh all chassis...")
            IxLoadUtils.refreshAllChassis(self.connection, self.session_url)
            IxLoadUtils.log("All chassis refreshed...")

            # Enable Capture on assigned ports
            IxLoadUtils.enableAnalyzerOnAssignedPorts(self.connection, self.session_url)

            # Save repository
            result = time.localtime()
            kRxfName = kRxfRelativeUploadPath.split(".")[0] + "%s-%s-%s-%s:%s" % (result.tm_mday, result.tm_mon, result.tm_year, result.tm_hour, result.tm_min) + '.rxf'
            IxLoadUtils.log("Saving repository %s..." % (kRxfName))
            IxLoadUtils.saveRxf(self.connection, self.session_url, kRxfName)
            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.")

            IxLoadUtils.log("Polling values for stats %s..." % (kStatsToDisplayDict))
            IxLoadUtils.pollStats(self.connection, self.session_url, kStatsToDisplayDict)

            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.")

            IxLoadUtils.log("Retrieving capture for assisgned ports..." )
            IxLoadUtils.retrieveCaptureFileForAssignedPorts(self.connection, self.session_url, os.path.dirname(self.rxf))

            time.sleep(1)
            self.StopLogs = True

            # Collect Diagnostics
            if self.diag:
                IxLoadUtils.log("Collecting diagnostics...")
                IxLoadUtils.collectDiagnostics(self.connection, self.session_url, zip_file)
                IxLoadUtils.collectGatewayDiagnostics(self.connection, gateway_file)
                IxLoadUtils.log("Collecting diagnostics operation is successful...")

        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.")