示例#1
0
    def _runtest(self, target, nclients, nconns, rate):
        self.nruns += 1
        nrun = self.nruns
        httperfs = []
        try:
            for nclient in range(nclients):
                user, host = siteconfig.site.get_load_generator()
                assert(nrun < 100 and nclient < 100)
                filename = 'httperf_run%02d_%02d.txt' % (nrun, nclient)
                logfile = open(os.path.join(self.testdir, filename), 'w')
                debug.verbose('spawning httperf on %s' % host)
                hp = HTTPerfClient(logfile, user, host, target, nconns, rate)
                httperfs.append(hp)

            # loop collecting output from all of them
            busy_httperfs = list(httperfs) # copy list
            timeout = datetime.datetime.now() + HTTPERF_TIMEOUT
            while busy_httperfs:
                (ready, _, _) = select_timeout(timeout, busy_httperfs)
                if not ready:
                    raise TimeoutError('waiting for httperfs')
                for hp in ready:
                    try:
                        hp.read()
                    except EOFError:
                        busy_httperfs.remove(hp)
        finally:
            debug.log('cleaning up httperf test...')
            for hp in httperfs:
                hp.cleanup()
示例#2
0
    def _run_ipbench(self, args, logfile):
        cmd = [siteconfig.get('IPBENCH_PATH')] + args
        firstrun = True
        for _ in range(IPBENCH_ITERATIONS):
            if firstrun:
                firstrun = False
            else:
                # sleep a moment to let things settle down between runs
                debug.verbose('sleeping between ipbench runs')
                time.sleep(IPBENCH_SLEEPTIME)

            debug.verbose('running ipbench: %s' % ' '.join(cmd))
            child = subprocess.Popen(cmd, stdout=subprocess.PIPE)
            timeout = datetime.datetime.now() + IPBENCH_TIMEOUT
            while True:
                # wait for some output
                (rlist, _, _) = select_timeout(timeout, [child.stdout])
                if not rlist:
                    debug.warning('ipbench run timed out')
                    child.terminate()
                    child.wait()
                    raise TimeoutError('waiting for ipbench')
                # read one char at a time to avoid blocking
                c = child.stdout.read(1)
                if c == '':
                    break  # EOF
                logfile.write(c)
            child.wait()
            assert (child.returncode == 0)  # check for successful exit
示例#3
0
    def _runtest(self, target, nclients, nconns, rate):
        self.nruns += 1
        nrun = self.nruns
        httperfs = []
        try:
            for nclient in range(nclients):
                user, host = siteconfig.site.get_load_generator()
                assert (nrun < 100 and nclient < 100)
                filename = 'httperf_run%02d_%02d.txt' % (nrun, nclient)
                logfile = open(os.path.join(self.testdir, filename), 'w')
                debug.verbose('spawning httperf on %s' % host)
                hp = HTTPerfClient(logfile, user, host, target, nconns, rate)
                httperfs.append(hp)

            # loop collecting output from all of them
            busy_httperfs = list(httperfs)  # copy list
            timeout = datetime.datetime.now() + HTTPERF_TIMEOUT
            while busy_httperfs:
                (ready, _, _) = select_timeout(timeout, busy_httperfs)
                if not ready:
                    raise TimeoutError('waiting for httperfs')
                for hp in ready:
                    try:
                        hp.read()
                    except EOFError:
                        busy_httperfs.remove(hp)
        finally:
            debug.log('cleaning up httperf test...')
            for hp in httperfs:
                hp.cleanup()
示例#4
0
    def _run_ipbench(self, args, logfile):
        cmd = [siteconfig.get('IPBENCH_PATH')] + args
        firstrun = True
        for _ in range(IPBENCH_ITERATIONS):
            if firstrun:
                firstrun = False
            else:
                # sleep a moment to let things settle down between runs
                debug.verbose('sleeping between ipbench runs')
                time.sleep(IPBENCH_SLEEPTIME)

            debug.verbose('running ipbench: %s' % ' '.join(cmd))
            child = subprocess.Popen(cmd, stdout=subprocess.PIPE)
            timeout = datetime.datetime.now() + IPBENCH_TIMEOUT
            while True:
                # wait for some output
                (rlist, _, _) = select_timeout(timeout, [child.stdout])
                if not rlist:
                    debug.warning('ipbench run timed out')
                    child.terminate()
                    child.wait()
                    raise TimeoutError('waiting for ipbench')
                # read one char at a time to avoid blocking
                c = child.stdout.read(1)
                if c == '':
                    break # EOF
                logfile.write(c)
            child.wait()
            assert(child.returncode == 0) # check for successful exit