コード例 #1
0
ファイル: test_qclient.py プロジェクト: tobgu/qcache-client
def test_one_node_unavailable_then_appears(qcache_factory):
    names1 = qcache_factory.spawn_caches('2222')
    nodes = ['http://localhost:2222', 'http://localhost:2223']
    client = QClient(nodes)
    key = _get_key_on_node(nodes, 'http://localhost:2223')

    content = data_source('foo')
    client.post(key, content, content_type='application/json')

    # Verify that the data is indeed available even though the primary destination node
    # was not available.
    assert client.get(key, q={}) is not None

    # Now start the server that the key is destined for and re-post the data
    # a number of times until it is moved to the destination node.
    qcache_factory.spawn_caches('2223')
    for _ in range(10):
        client.post(key, content, content_type='application/json')

    # Kill the first server to make sure that no stale data exists
    # and perform a get to verify that the data has indeed been moved to
    # the original destination node.
    qcache_factory.kill_caches(*names1)
    assert client.get(key, q={}) is not None
    assert client.statistics['http://localhost:2223']['resurrections']
コード例 #2
0
ファイル: test_qclient.py プロジェクト: tobgu/qcache-client
def xtest_repeated_posts_on_small_dataset():
    client = QClient(['http://localhost:8882'])
    content = data_source('foo')

    for x in range(1000):
        t0 = time.time()
        client.post(id_generator(), content, content_type='application/json')
        print("Loop: {num}, duration: {dur}".format(num=x, dur=time.time() - t0))
コード例 #3
0
ファイル: test_qclient.py プロジェクト: tobgu/qcache-client
def test_https_with_basic_auth(qcache_factory):
    qcache_factory.spawn_caches('2222', certfile='host.pem', auth='abc:123')
    nodes = ['https://localhost:2222']
    client = QClient(nodes, verify='tests/rootCA.crt', auth=('abc', '123'))
    content = data_source('foo')
    key = '12345'

    client.post(key, content, content_type='application/json')
    assert client.get(key, q={}) is not None

    client.delete(key)
    assert client.get(key, q={}) is None
コード例 #4
0
ファイル: test_qclient.py プロジェクト: tobgu/qcache-client
def test_delete(qcache_factory):
    qcache_factory.spawn_caches('2222')
    nodes = ['http://localhost:2222']
    client = QClient(nodes)
    content = data_source('foo')
    key = '12345'

    client.post(key, content, content_type='application/json')
    assert client.get(key, q={}) is not None

    client.delete(key)
    assert client.get(key, q={}) is None
コード例 #5
0
ファイル: io_test.py プロジェクト: tobgu/qocache
    args = parser.parse_args()

    input_string = "a,b,c,d,e,f,g,h\n"
    input_string += "\n".join(
        args.line_count *
        ["1200,456,123.12345,a string,another string,9877654.2,1234567.12,77"])
    print("Size of input = {}".format(len(input_string)))

    c = QClient(node_list=["http://localhost:8888"], read_timeout=10.0)

    frame_uploads = max(args.lz4_frame_uploads,
                        int(args.lz4_frame_queries > 0))
    for _ in range(frame_uploads):
        t0 = time.time()
        c.post("key_lz4_frame",
               frame_lz4er(input_string),
               post_headers={"Content-Encoding": "lz4-frame"})
        print("LZ4 frame upload time: {} s".format(time.time() - t0))

    for _ in range(args.lz4_frame_queries):
        t0 = time.time()
        r = c.get("key_lz4_frame", {},
                  query_headers={"Accept-Encoding": "lz4-frame"})
        qt = time.time() - t0
        t0 = time.time()
        dr = lz4.frame.decompress(r.content)
        print(
            "LZ4 frame query time: {} s, decompress time: {}, comp size: {}, uncomp size: {}"
            .format(qt,
                    time.time() - t0, len(r.content), len(dr)))
コード例 #6
0
ファイル: traffic.py プロジェクト: tobgu/qocache
from qclient import QClient
import time

inputS = "a,b,c,d,e,f,g,h\n"
inputS += "\n".join(5000 * ["1200,456,123.12345,a string,another string,9877654.2,1234567.12,77"])

print("Size of input = {}".format(len(inputS)))

c = QClient(node_list=["http://localhost:8888"], read_timeout=10.0)

t0 = time.time()
for x in range(100000000):
    c.post("key{}".format(x), inputS)
    if x % 100 == 0:
        avg_ms = round(1000*(time.time()-t0) / 100, 2)
        print("Total count: {}, mean req time: {} ms".format(x, avg_ms))
        t0 = time.time()