Beispiel #1
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()
Beispiel #2
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
Beispiel #3
0
 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)