Esempio n. 1
0
 def _t():
     client = Client()
     for i in range(_ONE):
         try:
             client.execute(str(i))
         except:
             print 'error'
Esempio n. 2
0
 def _t():
     client = Client()
     for i in range(_ONE):
         try:
             client.execute(str(i))
         except:
             print 'error'
Esempio n. 3
0
class TestClient():

    def __init__(self, config=None):
        self.client = Client(frontend=config.FRONTEND)

    def fetch(self, addr):
        return json.loads(self.client.execute(addr))
import time
from powerhose.client import Client
from powerhose.exc import TimeoutError
from random import randrange

client = Client(frontend='ipc:///tmp/geo_front',
                timeout=100,
                timeout_max_overflow=1,
                timeout_overflows=1)

n = 1000
start = time.time()
try:
    for num in xrange(n):
        ip = '%s.%s.%s.%s' % (randrange(0, 255), randrange(
            0, 255), randrange(0, 255), randrange(0, 255))
        raw = client.execute('GET %s' % ip)
        reply = json.loads(raw)
        if 'success' in reply and reply['success']['addr'] != ip:
            print "FAIL!\n%s\n%s" % (ip, json.dumps(reply))
    secs = time.time() - start
    print "Time: %s\n RpS: %s\n" % (secs, n / secs)
except ValueError as e:
    print "FAIL\n%s\n%s" % (str(e), raw)
except TimeoutError as e:
    print """ A timeout occured trying to process the request.
    Please make sure that the broker and workers are running.
    """

client.close()
Esempio n. 5
0
import random
import sys
import time

from powerhose.client import Client
from powerhose.job import Job
from powerhose.util import set_logger


set_logger(True)
client = Client()

print 'Running 100 echo'

start = time.time()

for i in range(2000):
    data = str(random.randint(1, 1000))
    job = Job(data)
    res = client.execute(job)
    assert res == data
    sys.stdout.write('.')
    sys.stdout.flush()

print 'Done in %.2f' % (time.time() - start)
import pdb; pdb.set_trace()
Esempio n. 6
0
import random
import sys
import time

from powerhose.client import Client
from powerhose.job import Job
from powerhose.util import set_logger

set_logger(True)
client = Client()

print 'Running 100 echo'

start = time.time()

for i in range(2000):
    data = str(random.randint(1, 1000))
    job = Job(data)
    res = client.execute(job)
    assert res == data
    sys.stdout.write('.')
    sys.stdout.flush()

print 'Done in %.2f' % (time.time() - start)
import pdb
pdb.set_trace()
Esempio n. 7
0
from powerhose.exc import TimeoutError
from random import randrange

client = Client(frontend='ipc:///tmp/geo_front', timeout=100,
                timeout_max_overflow=1, timeout_overflows=1)

n = 1000
start = time.time()
try:
    for num in xrange(n):
        ip = '%s.%s.%s.%s' % (
            randrange(0, 255),
            randrange(0, 255),
            randrange(0, 255),
            randrange(0, 255)
        )
        raw = client.execute('GET %s' % ip)
        reply = json.loads(raw)
        if 'success' in reply and reply['success']['addr'] != ip:
            print "FAIL!\n%s\n%s" % (ip, json.dumps(reply))
    secs = time.time() - start
    print "Time: %s\n RpS: %s\n" % (secs, n/secs)
except ValueError as e:
    print "FAIL\n%s\n%s" % (str(e), raw)
except TimeoutError as e:
    print """ A timeout occured trying to process the request.
    Please make sure that the broker and workers are running.
    """

client.close()
from powerhose import get_cluster
from powerhose.client import Client


cluster = get_cluster('echo_worker.echo', background=True)
cluster.start()

client = Client()

for i in range(10):
    print client.execute(str(i))

cluster.stop()