# format: {communityName: [activityProtocolAndType1, activityProtocolAndType2]} 'Traffic1@Network1': ['stateless Peer'], 'Traffic2@Network2': ['stateless Peer'] } # 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.createNewSession(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.') # Generate IP Stream command IxLoadUtils.log('Adding Generate IP Stream command to StatelessPeer2...') IxLoadUtils.log('IP in IP encapsulation ...')
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.")