Exemple #1
0
	def beginStatThread(self):
		'''This thread receives messages from LCMThread every 
		time there is a new message.  Each 	message is stored 
		in this thread. This thread will compute statistics 
		about the messages, such as frequency.'''

		self.statThread = statThread.statThread()
		self.lcmThread.sigNewMsg.connect( self.statThread.newMsg )
		#self.lcmThread.sigNewChannel.connect( self.statThread.newChannel )
		self.lcmThread.sigTakeAttDict.connect( self.statThread.newAttDict )
		self.lcmThread.refreshAttDict()
		self.statThread.start()
Exemple #2
0
    def runTheTest(self, bptName, **opts):
        self.bps.runCustomCommand(
            "/api/v1/bps/ports/operations/reserve",
            "post",
            slot=self.slot,
            portList=self.portList,
            group=self.group,
            force=self.forceful,
        )

        response = self.bps.getResponse()
        if response:
            print "Operation = %s" % response["Operation"]
            print "response Code = %s" % response["responseCode"]
            print "Response Text = %s" % response["responseText"]

        if not response["responseCode"] == 200:
            print "Port reservation unsuccessful"
            return -1

        self.bps.runCustomCommand("/api/v1/bps/upload", "post", "uploadBpt", filePath=bptName, force="true")
        response = self.bps.getResponse()
        if response:
            print "Operation = %s" % response["Operation"]
            print "response Code = %s" % response["responseCode"]
            print "Response Text = %s" % response["responseText"]

        if not response["responseCode"] == 200:
            print "Bpt upload unsuccessful"
            return -1

        # Get & Patch testing.
        self.bps.runCustomCommand(
            "/api/v1/bps/workingmodel", "patch", template=os.path.splitext(os.path.basename(bptName))[0]
        )
        response = self.bps.getResponse()
        if response:
            print "Operation = %s" % response["Operation"]
            print "response Code = %s" % response["responseCode"]
            print "Response Text = %s" % response["responseText"]

        # View the settings
        self.bps.runCustomCommand("/api/v1/bps/workingmodel/settings", "get")
        response = self.bps.getResponse()
        if response:
            print "Operation = %s" % response["Operation"]
            print "response Code = %s" % response["responseCode"]
            print "Response Text = %s" % response["responseText"]

        if len(opts.keys()) > 0:
            self.bps.runCustomCommand("/api/v1/bps/workingmodel", "patch", newParams=opts)
            response = self.bps.getResponse()
            if response:
                print "Operation = %s" % response["Operation"]
                print "response Code = %s" % response["responseCode"]
                print "Response Text = %s" % response["responseText"]

            self.bps.runCustomCommand("/api/v1/bps/workingmodel/operations/save", "post")
            response = self.bps.getResponse()
            if response:
                print "Operation = %s" % response["Operation"]
                print "response Code = %s" % response["responseCode"]
                print "Response Text = %s" % response["responseText"]

        # self.bps.runCustomCommand("/api/v1/bps/workingmodel","patch",newParams={"componentId":"appsim_1","elementId":"rampDist","paramId":"steady","value":"24:01:10"})
        # response = self.bps.getResponse()
        # if response:
        #   print "Operation = %s" %response["Operation"]
        #   print "response Code = %s" %response["responseCode"]
        #   print "Response Text = %s" %response["responseText"]

        self.statsObj = statThread.statThread(os.path.splitext(os.path.basename(bptName))[0], self.statQueue)
        self.statsObj.kickStart(1)
        self.statsObj.setDaemon(True)
        self.statsObj.start()

        self.bps.runCustomCommand(
            "/api/v1/bps/tests/operations/start",
            "post",
            modelname=os.path.splitext(os.path.basename(bptName))[0],
            group=self.group,
            neighborhood=None,
        )
        response = self.bps.getResponse()
        if response and response["responseCode"] == 200:
            runId = response["responseText"].get("testid")
            self.test_id = runId
            print "Test Id = %s" % runId
            self.updateTestResults(run_id=runId, end_result="RUNNING")

        progress = 0
        while True:
            groupDetailStats = {}
            for groupStats in [
                "summary",
                "iface",
                "l4Stats",
                "sslStats",
                "ipsecStats",
                "l7Stats",
                "clientStats",
                "attackStats",
                "gtp",
                "resource",
            ]:
                self.bps.runCustomCommand(
                    "/api/v1/bps/tests/operations/getRTS", "post", runid=runId, statsGroup=groupStats
                )
                response = self.bps.getResponse()
                if response and response["responseCode"] == 200:
                    progress = response["responseText"].get("progress")
                    rts = response["responseText"].get("rts")
                    groupDetailStats[groupStats] = rts

                    print "RTS == %s" % rts

                else:
                    print "Coming out"

            self.statQueue.put(groupDetailStats)

            self.updateTestResults(progress=progress)

            if progress >= 100:
                print "Test done"
                self.updateTestResults(progress=progress, end_result="FINISHED")
                self.statQueue.put("QUIT")
                break
            time.sleep(2)

        self.statsObj.join()
        self.bps.exportTestReport(
            runId, "%s.pdf" % os.path.splitext(os.path.basename(bptName))[0], self.statsObj.getResultLocation()
        )
        self.bps.exportTestBPT(os.path.basename(bptName), testId=runId, location=self.statsObj.getResultLocation())

        self.bps.runCustomCommand(
            "/api/v1/bps/ports/operations/unreserve",
            "post",
            "createResult",
            slot=self.slot,
            portList=self.portList,
            group=self.group,
        )
        response = self.bps.getResponse()

        self.updateTestResults(result_path=self.statsObj.getResultLocation())
Exemple #3
0
    def runLab(self, bptName):
        self.bps.runCustomCommand(
            "/api/v1/bps/ports/operations/reserve",
            "post",
            slot=self.slot,
            portList=self.portList,
            group=self.group,
            force=self.forceful,
        )
        response = self.bps.getResponse()
        if response:
            print "Operation = %s" % response["Operation"]
            print "response Code = %s" % response["responseCode"]
            print "Response Text = %s" % response["responseText"]

        if not response["responseCode"] == 200:
            print "Port reservation unsuccessful"
            return -1

        self.statsObj = statThread.statThread(os.path.splitext(os.path.basename(bptName))[0], self.statQueue)
        self.statsObj.kickStart(1)
        self.statsObj.setDaemon(True)
        self.statsObj.start()

        self.bps.runCustomCommand(
            "/api/v1/bps/tests/operations/start",
            "post",
            modelname=os.path.splitext(os.path.basename(bptName))[0],
            group=self.group,
            neighborhood=None,
        )
        response = self.bps.getResponse()
        if response and response["responseCode"] == 200:
            runId = response["responseText"].get("testid")
            self.test_id = runId
            print "Test Id = %s" % runId

        while True:
            groupDetailStats = {}
            for groupStats in [
                "summary",
                "iface",
                "l4Stats",
                "sslStats",
                "ipsecStats",
                "l7Stats",
                "clientStats",
                "attackStats",
                "gtp",
                "resource",
            ]:
                self.bps.runCustomCommand(
                    "/api/v1/bps/tests/operations/getRTS", "post", runid=runId, statsGroup=groupStats
                )
                response = self.bps.getResponse()
                if response and response["responseCode"] == 200:
                    progress = response["responseText"].get("progress")
                    rts = response["responseText"].get("rts")
                    groupDetailStats[groupStats] = rts

                    print "RTS == %s" % rts

                else:
                    print "Coming out"

            self.statQueue.put(groupDetailStats)

            if progress == 100:
                print "Test done"
                self.statQueue.put("QUIT")
                break
            time.sleep(2)

        self.statsObj.join()
        self.bps.exportTestReport(
            runId, "%s.pdf" % os.path.splitext(os.path.basename(bptName))[0], self.statsObj.getResultLocation()
        )
        self.bps.exportTestBPT(os.path.basename(bptName), testId=runId, location=self.statsObj.getResultLocation())

        self.bps.runCustomCommand(
            "/api/v1/bps/ports/operations/unreserve",
            "post",
            "createResult",
            slot=self.slot,
            portList=self.portList,
            group=self.group,
        )
        response = self.bps.getResponse()