示例#1
0
def test_late_write(dtstart, delta, N, chan):
    """Read data in forward direction"""
    ts = dtstart
    message = att.msg(ts, 1.0, 'test', tag1='A', tag2='B', tag3='D')
    chan.send(message)
    resp = chan.recv().strip()
    if resp != '-DB late write':
        print(resp)
        raise ValueError("Late write not detected")
示例#2
0
def main(path, protocol):
    akumulid = att.create_akumulid(path)
    # delete database
    akumulid.delete_database()
    # create empty database
    akumulid.create_database()
    # start ./akumulid server
    print("Starting server...")
    akumulid.serve()
    time.sleep(5)
    try:
        # fill data in
        host = '127.0.0.1'
        udpport = 8383
        tcpport = 8282
        if protocol == 'TCP':
            chan = TCPChan(host, tcpport)
        elif protocol == 'UDP':
            chan = UDPChan(host, udpport)
        else:
            print('Unknown protocol "{0}"'.format(protocol))
        dt = datetime.datetime.utcnow()
        delta = datetime.timedelta(milliseconds=1)
        nmsgs = 1000000
        print("Sending {0} messages through {1}...".format(nmsgs, protocol))
        for ix, it in enumerate(att.generate_messages(dt, delta, nmsgs, 'temp', tag='test')):
            if protocol == 'UDP' and ix == 2:
                msg = att.msg(dt, 0.1, 'temp', tag='test')
                chan.send(msg)
            chan.send(it)
        # check stats
        httpport = 8181
        statsurl = "http://{0}:{1}/api/stats".format(host, httpport)
        rawstats = urllib.urlopen(statsurl).read()
        stats = json.loads(rawstats)

        # some space should be used
        volume0space = stats["volume_0"]["free_space"]
        if "volume_1" in stats:
            volume1space = stats["volume_1"]["free_space"]
        else:
            volume1space = 0
        if volume0space == volume1space:
            print("Test #1 failed. Nothing was written to disk, /stats:")
            print(rawstats)
            sys.exit(10)
        else:
            print("Test #1 passed")
    except:
        traceback.print_exc()
        sys.exit(1)
    finally:
        print("Stopping server...")
        akumulid.stop()
        time.sleep(5)
示例#3
0
def test_late_write(dtstart, delta, N, chan):
    """Read data in forward direction"""
    print("Test #7 - late write")
    window = att.get_window_width()
    ts = dtstart + delta * (N - 1) - 2 * window
    message = att.msg(ts, 1.0, 'test', key='value')
    chan.send(message)
    resp = chan.recv().strip()
    if resp != '-DB late write':
        print(resp)
        raise ValueError("Late write not detected")
    print("Test #7 passed")
示例#4
0
def test_late_write(dtstart, delta, N, chan):
    """Read data in forward direction"""
    print("Test #7 - late write")
    window = att.get_window_width()
    ts = dtstart + delta*(N-1) - 2*window
    message = att.msg(ts, 1.0, 'test', key='value')
    chan.send(message)
    resp = chan.recv().strip()
    if resp != '-DB late write':
        print(resp)
        raise ValueError("Late write not detected")
    print("Test #7 passed")