示例#1
0
def main():
    '''main test entry point'''
    args = parse_args()
    aconn = iorio.Connection(args.host, args.port)
    uconn = iorio.Connection(args.host, args.port)
    log("authenticating", args.username)
    auth_ok, _result = aconn.authenticate(args.username, args.password)

    assert auth_ok

    test_all_authenticate(args)
    test_all_create_user(aconn, args)
    auth_ok, _result = uconn.authenticate(args.tempuser, args.temppass)

    assert auth_ok
    test_all_send_event(aconn, uconn, args)

    test_all_patch(uconn, args)
示例#2
0
 def __init__(self, token, generators, args):
     threading.Thread.__init__(self)
     self.token = token
     self.generators = generators
     self.args = args
     self.count = 0
     self.errors = 0
     self.t_diff = 0
     self.conn = iorio.Connection(args.host, args.port)
     self.conn.token = token
示例#3
0
def test_all_authenticate(args):
    '''all auth tests'''
    log('Testing Auth')
    conn = iorio.Connection(args.host, args.port)

    auth_ok, resp = conn.authenticate('someuser', 'some password')
    expect_val('auth_ok', auth_ok, False)
    expect_json_error(resp, 401, 'unauthorized')

    auth_ok, resp = conn.authenticate(args.username, 'some password')
    expect_json_error(resp, 401, 'unauthorized')
示例#4
0
 def __init__(self, host, port, token=None):
     threading.Thread.__init__(self)
     self.daemon = True
     self.host = host
     self.port = port
     self.stop = False
     self.errors = 0
     self.query_count = 0
     self.max_sleep_secs = 5
     self.conn = iorio.Connection(host, port)
     self.conn.token = token
示例#5
0
    def __init__(self, generators, listener_count, host, port, token, args):
        threading.Thread.__init__(self)
        self.stop = False
        self.host = host
        self.port = port
        self.token = token
        self.generators = generators
        self.subs = iorio.Subscriptions()

        for i in range(listener_count):
            generator_i = (i - 1) % len(generators)
            bucket, stream, _data = generators[generator_i].generate()
            self.subs.add(bucket, stream)

        self.args = args
        self.count = 0
        self.errors = 0
        self.t_diff = 0
        self.conn = iorio.Connection(host, port)
        self.conn.token = token
示例#6
0
def do_when_authenticated(args, fun, conn=None):
    '''if auth works run fun'''
    if conn is None:
        conn = iorio.Connection(args.host, args.port)

    auth_t1 = time.time()
    auth_ok, auth_resp = conn.authenticate(args.username, args.password)
    auth_t2 = time.time()

    if args.verbose and args.verbose > 1:
        print("Auth request time", (auth_t2 - auth_t1) * 1000, "ms")

    if auth_ok:
        req_t1 = time.time()
        response = fun(conn)
        req_t2 = time.time()

        if args.verbose and args.verbose > 1:
            print("Request time", (req_t2 - req_t1) * 1000, "ms")

        print(response)
    else:
        print("Auth Failed")
        print(auth_resp)
示例#7
0
def main():
    args = parse_args()
    log('using seed', args.seed)
    random.seed(args.seed)

    conn = iorio.Connection(args.host, args.port)
    ok, _response = conn.authenticate(args.username, args.password)

    if not ok:
        log('authentication failed')
        return
    else:
        token = conn.token
        log("token", conn.token)

    generators = [Generator(i, randint(), args.streams) \
            for i in range(args.buckets)]

    inserters = []
    patchers = []
    requesters = []
    listers = []
    listeners = []

    for _ in range(args.inserters):
        inserter = Inserter(token, generators, args)
        inserter.start()
        inserters.append(inserter)

    for _ in range(args.patchers):
        patcher = Patcher(token, generators, args)
        patcher.start()
        patchers.append(patcher)

    for _ in range(args.requesters):
        requester = QueryRequester(generators, args.host, args.port, token)
        requester.start()
        requesters.append(requester)

    for _ in range(args.listers):
        bucket_lister = BucketLister(generators, args.host, args.port, token)
        bucket_lister.start()
        listers.append(bucket_lister)

    for i in range(args.listeners):
        listener = Listener(generators, i + 1, args.host, args.port, token,
                            args)
        listener.start()
        listeners.append(listener)

    for inserter in inserters:
        inserter.join()
        log(inserter.format_summary())

    for patcher in patchers:
        patcher.join()
        log(patcher.format_summary())

    for requester in requesters:
        requester.stop = True
        requester.join()
        log(requester.format_summary())

    for bucket_lister in listers:
        bucket_lister.stop = True
        bucket_lister.join()
        log(bucket_lister.format_summary())

    log('waiting for listeners to timeout, this may take a while')
    for listener in listeners:
        listener.stop = True
        listener.join()
        log(listener.format_summary())