예제 #1
0
    def run_client(self, cmd):
        client = ShellProcess(cmd)
        try:
            client.wait()
        except OSError as e:
            # we got interrupted, let's gather data
            if e.errno == errno.EINTR:
                client.kill()

        output = client.read_nonblocking()

        if re.search("connect failed:", output):
            logging.info("Iperf connection failed!")
            return (False, "Iperf connection failed!")

        m = re.search("\[[^0-9]*[0-9]*\]\s*0.0+-\s*\d*\.\d+\s*sec\s*\d*(\.\d*){0,1}\s*[ kGMT]Bytes\s*(\d*(\.\d*){0,1}\s*[ kGMT]bits\/sec)", output, re.IGNORECASE)
        if m is None:
            logging.info("Could not get performance throughput!")
            return (False, "Could not get performance throughput!")

        rate = m.group(2)
        if self.threshold is not None:
            # check if expected threshold is reached
            result = self._rate_over_threshold(rate)
            if result:
                return (True, "Measured rate (%s) is over threshold (%s)." %
                        (rate, self.threshold))
            else:
                return (False, "Measured rate (%s) is below threshold (%s)!" %
                        (rate, self.threshold))
        else:
            return True, "Measured rate: %s" % rate
예제 #2
0
 def _run_server(self, cmd):
     logging.debug("running as server...")
     server = ShellProcess(cmd)
     try:
         server.wait()
     except OSError as e:
         if e.errno == errno.EINTR:
             server.kill()
예제 #3
0
파일: Netperf.py 프로젝트: jpirko/lnst
 def _run_server(self, cmd):
     logging.debug("running as server...")
     server = ShellProcess(cmd)
     try:
         server.wait()
     except OSError as e:
         if e.errno == errno.EINTR:
             server.kill()
예제 #4
0
    def run_server(self, cmd):
        server = ShellProcess(cmd)

        if not self._keep_server_running:
            time.sleep(float(self.duration))
            server.read_nonblocking()
            server.kill()
        else:
            try:
                server.wait()
            except OSError as e:
                if e.errno == errno.EINTR:
                     server.kill()

            server.read_nonblocking()
예제 #5
0
파일: Netperf.py 프로젝트: wngjan/lnst
 def _run_client(self, cmd):
     logging.debug("running as client...")
     client = ShellProcess(cmd)
     try:
         rv = client.wait()
     except OSError as e:
         if e.errno == errno.EINTR:
             client.kill()
     output = client.read_nonblocking()
     if rv != 0:
         logging.info("Could not get performance throughput! Are you sure "
                      "netperf is installed on both machines and machines "
                      "are mutually accessible?")
         return (False, "Could not get performance throughput! Are you "
                        "sure netperf is installed on both machines and "
                        "machines are mutually accessible?")
     return self._parse_output(self.get_opt("threshold"), output)
예제 #6
0
파일: TestNetCat.py 프로젝트: pazdera/lnst
    def run(self):
        nc = ShellProcess(self._compose_nc_cmd())

        # check whether anything is being sent over the line
        td = ShellProcess(self._compose_tcpdump_cmd())

        try:
            td.read_until_output_matches("10 packets captured", timeout=5)
        except ShellProcess.ProcessTerminatedError:
            return self.set_fail("tcpdump process died unexpectedly!")
        except ShellProcess.ProcessTimeoutError:
            return self.set_fail("No stream detected!")

        td.kill()

        duration = self.get_opt("duration", default=30)
        time.sleep(duration)

        nc.kill()

        logging.info("nc stream with duration of %s secs" % duration)
        return self.set_pass()