Пример #1
0
    def pollLog(self, file="IxLoadLog.log", pollingInterval=0.1):
        IxLoadUtils.log("Creating the log file.")
        sleepTime = 0
        lastID = 0

        while not self.StartedLogs:
            time.sleep(1)
            sleepTime += 1
            if sleepTime > 600:
                break

        IxLoadUtils.log("Start logging.")

        try:
            while not self.StopLogs:
                logWebObject = self.connection.httpGet("%s/ixload/test/logs" % self.session_url)
                if logWebObject is None:
                    time.sleep(0.5)
                    continue
                if not any(logWebObject):
                    time.sleep(0.5)
                    continue

                with open(file, 'a+') as f:
                    time.sleep(pollingInterval)
                    f.write("".join([str(logWebObject[i].objectID) + " *" + str(logWebObject[i].severity) + " " + str(logWebObject[i].timeStamp)+ " : " + str(logWebObject[i].message) + "\n" for i in range(0, len(logWebObject)) if int(logWebObject[i].objectID) > lastID]))
                    log = ["IxLoad Log: " + str(logWebObject[i].objectID) + " *" + str(logWebObject[i].severity) + " " + str(logWebObject[i].timeStamp)+ " : " + str(logWebObject[i].message) for i in range(0, len(logWebObject)) if int(logWebObject[i].objectID) > lastID]
                    if log is not "":
                        for l in log:
                            IxLoadUtils.log(l)
                    lastID = int(logWebObject[len(logWebObject) - 1].objectID)

                    if lastID < 0:
                        time.sleep(0.1)
                        continue

        except AttributeError:
            IxLoadUtils.log("Attribute error detected!")
        except Exception, e:
            IxLoadUtils.log("The pollLog exited with the following error: %s" % e)
Пример #2
0
    rxfName = "%s.rxf" % (fileNameWithoutExtension)

    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...")
Пример #3
0
kActivities = {
    # 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
Пример #4
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)

sessionUrl = None

try:
    # create a session
    IxLoadUtils.log("Creating a new session...")
    sessionUrl = IxLoadUtils.createSession(connection, kIxLoadVersion)
    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('Editing RTSP command on RTSP client...')
    rtspCommandOptions = {
Пример #5
0
    # format: {communityName: [activityProtocolAndType1, activityProtocolAndType2]}
    'Traffic1@Network1': ['cifs Client'],
    'Traffic2@Network2': ['cifs Server']
}

# 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.')

    IxLoadUtils.log('Adding CIFS ScanAll command to CIFS client...')
Пример #6
0
        "Traffic1@Network1": [(1, 1, 1)],
        "Traffic2@Network2": [(1, 1, 2)]
    }

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

sessionUrl = None

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

    kResourcesUrl = IxLoadUtils.getResourcesUrl(connection)
    kRxfFiles = [
        '/'.join([kRxfFolderPath, f]) for f in os.listdir(kRxfFolderPath)
        if f.split(".")[1] == "rxf"
    ]

    for kRxfFile in kRxfFiles:
        kRxfRelativeUploadPath = os.path.split(kRxfFile)[1]
        kRxfAbsoluteUploadPath = kRxfFile

        if not testSettings.isLocalHost():
Пример #7
0
        "pageObject": "/8k.html",
        "arguments": kArgumentFilePath
    }]
}

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

    # Load a repository
    IxLoadUtils.log("Loading reposiory %s..." % kRxfPath)
    IxLoadUtils.loadRepository(connection, sessionUrl, kRxfPath)
    IxLoadUtils.log("Repository loaded.")

    IxLoadUtils.log("Clearing chassis list...")
    IxLoadUtils.clearChassisList(connection, sessionUrl)
    IxLoadUtils.log("Chassis list cleared.")

    IxLoadUtils.log("Adding chassis %s..." % (testSettings.chassisList))
    IxLoadUtils.addChassisList(connection, sessionUrl,
Пример #8
0
kStatSourceList = [
]  # TODO - to be changed by user if he wants statsName only for specific statSources

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

connection.setApiKey(testSettings.apiKey)

sessionUrl = None

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

    kRxfRelativeUploadPath = os.path.split(kRxfPath)[1]
    # Upload file to gateway server
    if not testSettings.isLocalHost():
        IxLoadUtils.log('Uploading file %s...' % kRxfPath)
        kResourcesUrl = IxLoadUtils.getResourcesUrl(connection)
        IxLoadUtils.uploadFile(connection, kResourcesUrl, kRxfPath,
                               kRxfRelativeUploadPath)
        IxLoadUtils.log('Upload file finished.')

    # Load a repository
    kRxfAbsoluteUploadPath = '/'.join(
Пример #9
0
                            "DNSClient": ["DNS Total Queries Sent"],
                            "DNSServer": ["DNS Total Queries Received", "TCP Retries"]
                        }

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

sessionUrl = None

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

    kRxfRelativeUploadPath = os.path.split(kRxfPath)[1]
    kRxfAbsoluteUploadPath = kRxfPath
    # Upload file to gateway server
    if not testSettings.isLocalHost():
        IxLoadUtils.log('Uploading file %s...' % kRxfPath)
        kResourcesUrl = IxLoadUtils.getResourcesUrl(connection)
        IxLoadUtils.uploadFile(connection, kResourcesUrl, kRxfPath, kRxfRelativeUploadPath)
        IxLoadUtils.log('Upload file finished.')
		kRxfAbsoluteUploadPath = '/'.join([IxLoadUtils.getSharedFolder(connection), kRxfRelativeUploadPath])

    # Load a repository
    IxLoadUtils.log("Loading repository %s..." % kRxfAbsoluteUploadPath)
Пример #10
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.")
Пример #11
0
            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.")

    def run_IxLoad(self):

        self.zip_file = self.zip_file.replace("\\", "\\\\")
        self.config_test(str(self.k_ixload_version), str(self.rxf), str(self.results_path), str(self.zip_file))


test1 = MyTest()
t1 = CustomThread(test1.run_IxLoad)
t2 = CustomThread(test1.pollLog)

t1.start()
t2.start()

t1.join()
t2.join()

IxLoadUtils.log("Test ended with status: %s" % test1.test_run_error)

if test1.error:
    exit(1)
else:
    exit(0)
Пример #12
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.")
        "commandType": "GET",
        "destination": "Traffic2_HTTPServer1:80",
        "pageObject": "/32k.html",
    }]
}

# 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.')

    # Enable SSL on clients and server
Пример #14
0
kActivities = {
    # format: {communityName: [activityProtocolAndType1, activityProtocolAndType2]}
    'Traffic1@Network1': ['FTP Client'],
    'Traffic2@Network2': ['FTP Server']
}

# 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.')

    serverIPaddress = IxLoadUtils.NetworkUtils.getIPRange(
    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)

sessionUrl = None

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

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

    IxLoadUtils.log('Deleting IP plugins...')
    IxLoadUtils.NetworkUtils.deletePlugin(connection, sessionUrl,
                                          'Traffic1@Network1', 'IP-1')
    IxLoadUtils.NetworkUtils.deletePlugin(connection, sessionUrl,
                                          'Traffic2@Network2', 'IP-2')

    IxLoadUtils.log('Adding DHCP plugins...')