예제 #1
0
def main(path):

    if not os.path.exists(path):
        print("Path {0} doesn't exists".format(path))
        sys.exit(1)

    akumulid = att.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:
        for ix in range(0, len(MSG)):
            result = send_malicious_message(ix)
            if not result.startswith('-ERR'):
                print("Error at {0}".format(ix))
                print("Message:\n{0}".format(MSG[ix]))
                print("Response:\n{0}".format(result))
                raise ValueError("Bad response")
    except:
        traceback.print_exc()
        sys.exit(1)
    finally:
        print("Stopping server...")
        akumulid.stop()
        time.sleep(5)
예제 #2
0
def main(path, debug=False):
    if not os.path.exists(path):
        print("Path {0} doesn't exists".format(path))
        sys.exit(1)

    akumulid = att.Akumulid(path)
    if not debug:
        # Reset database
        akumulid.delete_database()
        akumulid.create_database()
        # start ./akumulid server
        print("Starting server...")
        akumulid.serve()
        time.sleep(5)
    else:
        print("Akumulid should be started first")
    try:

        dt = datetime.datetime.utcnow()
        delta = datetime.timedelta(milliseconds=1)
        nmsgs = 1000000

        rproc = multiprocessing.Process(name='Reader', target=reader, args=[dt, delta, nmsgs])
        rproc.start()
        rproc.join()

    except:
        traceback.print_exc()
        raise
    finally:
        if not debug:
            print("Stopping server...")
            akumulid.stop()
            time.sleep(5)
예제 #3
0
def main(path, protocol):

    if not os.path.exists(path):
        print("Path {0} doesn't exists".format(path))
        sys.exit(1)

    akumulid = att.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 it in att.generate_messages(dt, delta, nmsgs, 'temp', tag='test'):
            chan.send(it)

        # check stats
        httpport = 8181
        statsurl = "http://{0}:{1}/stats".format(host, httpport)
        rawstats = urllib.urlopen(statsurl).read()
        stats = json.loads(rawstats)

        # some space should be used
        volume0space = stats["volume_0"]["free_space"]
        volume1space = stats["volume_1"]["free_space"]
        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)
예제 #4
0
def main(path, debug=False):
    if not os.path.exists(path):
        print("Path {0} doesn't exists".format(path))
        sys.exit(1)

    akumulid = att.Akumulid(path)
    if not debug:
        # Reset database
        akumulid.delete_database()
        akumulid.create_database()
        # start ./akumulid server
        print("Starting server...")
        akumulid.serve()
        time.sleep(5)
    else:
        print("Akumulid should be started first")
    try:

        chan = att.TCPChan(HOST, TCPPORT)

        # fill data in
        dt = datetime.datetime.utcnow().replace(second=0, microsecond=0)
        delta = datetime.timedelta(milliseconds=1)
        nmsgs = 100000
        print("Sending {0} messages through TCP...".format(nmsgs))
        tags = {
            "tag1": ['A'],
            "tag2": ['B', 'C'],
            "tag3": ['D', 'E', 'F', 'G', 'H'],
        }

        def getval(ix):
            return float(ix % (nmsgs * 10))

        for it in att.generate_messages2(dt, delta, nmsgs, 'test', getval,
                                         **tags):
            chan.send(it)
        time.sleep(5)  # wait untill all messagess will be processed

        test_sax_in_backward_direction(dt, delta, nmsgs)
    except:
        traceback.print_exc()
        sys.exit(1)
    finally:
        if not debug:
            print("Stopping server...")
            akumulid.stop()
            time.sleep(5)
예제 #5
0
def main(path, debug=False):
    if not os.path.exists(path):
        print("Path {0} doesn't exists".format(path))
        sys.exit(1)

    akumulid = att.Akumulid(path)
    if not debug:
        # Reset database
        akumulid.delete_database()
        akumulid.create_database()
        # start ./akumulid server
        print("Starting server...")
        akumulid.serve()
        time.sleep(5)
    else:
        print("Akumulid should be started first")
    try:

        chan = att.TCPChan(HOST, TCPPORT)

        # fill data in
        dt = datetime.datetime.utcnow().replace(second=0, microsecond=0)
        delta = datetime.timedelta(milliseconds=1)
        nmsgs = 100000
        print("Sending {0} messages through TCP...".format(nmsgs))
        tags = {
            "tag1": ['A'],
            "tag2": ['B', 'C'],
            "tag3": ['D', 'E', 'F', 'G', 'H'],
        }
        for it in att.generate_messages(dt, delta, nmsgs, 'test', **tags):
            chan.send(it)
        time.sleep(5)  # wait untill all messagess will be processed

        test_read_all_in_backward_direction(dt, delta, nmsgs)
        test_group_by_tag_in_backward_direction(dt, delta, nmsgs)
        test_where_clause_in_backward_direction(dt, delta, nmsgs)
        test_where_clause_with_groupby_in_backward_direction(dt, delta, nmsgs)
        test_metadata_query(tags)
        test_read_in_forward_direction(dt, delta, nmsgs)
        test_late_write(dt, delta, nmsgs, chan)
        test_paa_in_backward_direction("Test #8 - PAA", dt, delta, nmsgs,
                                       lambda buf: float(sum(buf)) / len(buf),
                                       "paa")
        test_paa_in_backward_direction("Test #9 - median PAA", dt, delta,
                                       nmsgs, med, "median-paa")
        test_paa_in_backward_direction("Test #10 - max PAA", dt, delta, nmsgs,
                                       max, "max-paa")
        test_paa_in_backward_direction("Test #11 - min PAA", dt, delta, nmsgs,
                                       min, "min-paa")
        test_paa_in_backward_direction("Test #12 - first wins PAA", dt, delta,
                                       nmsgs, lambda buf: buf[0], "first-paa")
        test_paa_in_backward_direction("Test #13 - last wins PAA", dt, delta,
                                       nmsgs, lambda buf: buf[-1], "last-paa")
    except:
        traceback.print_exc()
        sys.exit(1)
    finally:
        if not debug:
            print("Stopping server...")
            akumulid.stop()
            time.sleep(5)
예제 #6
0
def main(path):
    if not os.path.exists(path):
        print("Path {0} doesn't exists".format(path))
        sys.exit(1)

    akumulid = att.Akumulid(path)
    # Reset database
    akumulid.delete_database()
    akumulid.create_database()
    # start ./akumulid server
    print("Starting server...")
    akumulid.serve()
    time.sleep(5)

    nmsgs = 100000
    tags = [
        {
            "tag3": "D",
            "tag2": "B",
            "tag1": "A"
        },
        {
            "tag3": "E",
            "tag2": "B",
            "tag1": "A"
        },
        {
            "tag3": "F",
            "tag2": "B",
            "tag1": "A"
        },
        {
            "tag3": "G",
            "tag2": "B",
            "tag1": "A"
        },
        {
            "tag3": "H",
            "tag2": "B",
            "tag1": "A"
        },
        {
            "tag3": "D",
            "tag2": "C",
            "tag1": "A"
        },
        {
            "tag3": "E",
            "tag2": "C",
            "tag1": "A"
        },
        {
            "tag3": "F",
            "tag2": "C",
            "tag1": "A"
        },
        {
            "tag3": "G",
            "tag2": "C",
            "tag1": "A"
        },
        {
            "tag3": "H",
            "tag2": "C",
            "tag1": "A"
        },
    ]
    dt = datetime.datetime.utcnow() - (datetime.timedelta(milliseconds=1) *
                                       nmsgs)
    delta = datetime.timedelta(milliseconds=1)
    try:
        chan = att.TCPChan(HOST, TCPPORT)

        # fill data in
        print("Sending {0} messages through TCP...".format(nmsgs))

        for it in att.generate_messages3(dt, delta, nmsgs, 'test', tags):
            chan.send(it)

        # kill process
        akumulid.terminate()
    except:
        traceback.print_exc()
        sys.exit(1)
    finally:
        print("Server terminated")

    print("Starting server...")
    akumulid.serve()
    time.sleep(5)
    print("Server started")
    try:
        test_read_all(tags, dt, delta, nmsgs)

        # Try to write some data
        chan = att.TCPChan(HOST, TCPPORT)
        dt = datetime.datetime.utcnow()

        print("Sending {0} messages through TCP...".format(nmsgs))
        for it in att.generate_messages3(dt, delta, nmsgs, 'test', tags):
            chan.send(it)

        time.sleep(5)  # wait untill all messagess will be processed
        print("Trying to close channel")
        chan.close()

        test_read_all(tags, dt, delta, nmsgs)
    finally:
        print("Stopping server...")
        akumulid.stop()
        time.sleep(5)
예제 #7
0
def main(path):
    if not os.path.exists(path):
        print("Path {0} doesn't exists".format(path))
        sys.exit(1)

    akumulid = att.Akumulid(path)
    # Reset database
    akumulid.delete_database()
    akumulid.create_database()
    # start ./akumulid server
    print("Starting server...")
    akumulid.serve()
    time.sleep(5)

    nmsgs = 100000
    tags = [
        {
            "tag3": "D",
            "tag2": "B",
            "tag1": "A"
        },
        {
            "tag3": "E",
            "tag2": "B",
            "tag1": "A"
        },
        {
            "tag3": "F",
            "tag2": "B",
            "tag1": "A"
        },
        {
            "tag3": "G",
            "tag2": "B",
            "tag1": "A"
        },
        {
            "tag3": "H",
            "tag2": "B",
            "tag1": "A"
        },
        {
            "tag3": "D",
            "tag2": "C",
            "tag1": "A"
        },
        {
            "tag3": "E",
            "tag2": "C",
            "tag1": "A"
        },
        {
            "tag3": "F",
            "tag2": "C",
            "tag1": "A"
        },
        {
            "tag3": "G",
            "tag2": "C",
            "tag1": "A"
        },
        {
            "tag3": "H",
            "tag2": "C",
            "tag1": "A"
        },
    ]

    dt = datetime.datetime.utcnow() - (datetime.timedelta(milliseconds=1) *
                                       nmsgs)
    delta = datetime.timedelta(milliseconds=1)
    try:
        chan = att.TCPChan(HOST, TCPPORT)

        print("Sending {0} messages through TCP...".format(nmsgs))

        # Send 1 message for each series in rare set
        for it in att.generate_messages3(dt, delta, 10, 'rare', tags):
            chan.send(it)

        # Send a lot of other messages to ensure that the raer set is on disk
        for it in att.generate_messages3(dt, delta, 1000, 'bulk', tags):
            chan.send(it)

        chan.close()

        time.sleep(1)

        # kill process
        akumulid.terminate()
    except:
        traceback.print_exc()
        sys.exit(1)
    finally:
        print("Server terminated")

    print("Starting server...")
    akumulid.serve()
    time.sleep(5)
    print("Server started")
    try:
        test_select('rare', tags, dt, delta, 10)
        test_select('bulk', tags, dt, delta, 1000)
    finally:
        print("Stopping server...")
        akumulid.stop()
        time.sleep(5)
예제 #8
0
def main(path):
    if not os.path.exists(path):
        print("Path {0} doesn't exists".format(path))
        sys.exit(1)

    akumulid = att.Akumulid(path)
    # Reset database
    akumulid.delete_database()
    akumulid.create_database()
    # start ./akumulid server
    print("Starting server...")
    akumulid.serve()
    time.sleep(5)

    nmsgs = 100000
    tags = [
        {
            "tag3": "D",
            "tag2": "B",
            "tag1": "A"
        },
        {
            "tag3": "E",
            "tag2": "B",
            "tag1": "A"
        },
        {
            "tag3": "F",
            "tag2": "B",
            "tag1": "A"
        },
        {
            "tag3": "G",
            "tag2": "B",
            "tag1": "A"
        },
        {
            "tag3": "H",
            "tag2": "B",
            "tag1": "A"
        },
        {
            "tag3": "D",
            "tag2": "C",
            "tag1": "A"
        },
        {
            "tag3": "E",
            "tag2": "C",
            "tag1": "A"
        },
        {
            "tag3": "F",
            "tag2": "C",
            "tag1": "A"
        },
        {
            "tag3": "G",
            "tag2": "C",
            "tag1": "A"
        },
        {
            "tag3": "H",
            "tag2": "C",
            "tag1": "A"
        },
    ]

    dt = datetime.datetime.utcnow() - (datetime.timedelta(milliseconds=1) *
                                       nmsgs)
    delta = datetime.timedelta(milliseconds=1)
    try:
        chan = att.TCPChan(HOST, TCPPORT)

        print("Sending {0} messages through TCP...".format(nmsgs))

        for it in att.generate_messages3(dt, delta, 100, 'test', tags):
            chan.send(it)

        chan.close()

        test_select('test', tags, dt, delta, 100)

        time.sleep(5)

        # kill process
        akumulid.terminate()
    except:
        traceback.print_exc()
        sys.exit(1)
    finally:
        print("Server terminated")

    try:
        statinfo = os.stat(os.path.expanduser("~/.akumuli/inputlog0_0.ils"))
        print("inputlog0_0.ils size is {0}".format(statinfo.st_size))
        statinfo = os.stat(os.path.expanduser("~/.akumuli/inputlog0_1.ils"))
        print("inputlog0_1.ils size is {0}".format(statinfo.st_size))
    except:
        pass

    print("Starting server...")
    akumulid.serve()
    time.sleep(5)
    print("Server started")
    try:
        require_empty('test', dt, delta, 100)
    finally:
        print("Stopping server...")
        akumulid.stop()
        time.sleep(5)
예제 #9
0
def main(path):
    if not os.path.exists(path):
        print("Path {0} doesn't exists".format(path))
        sys.exit(1)

    akumulid = att.Akumulid(path)
    # Reset database
    akumulid.delete_database()
    akumulid.create_database()
    # start ./akumulid server
    print("Starting server...")
    akumulid.serve()
    time.sleep(5)

    nmsgs = 100000
    dt = datetime.datetime.utcnow() - (datetime.timedelta(milliseconds=1) *
                                       nmsgs)
    delta = datetime.timedelta(milliseconds=1)
    try:
        chan = att.TCPChan(HOST, TCPPORT)

        # fill data in
        print("Sending {0} messages through TCP...".format(nmsgs))
        tags = {
            "tag1": ['A'],
            "tag2": ['B', 'C'],
            "tag3": ['D', 'E', 'F', 'G', 'H'],
        }
        for it in att.generate_messages(dt, delta, nmsgs, 'test', **tags):
            chan.send(it)

        time.sleep(5)  # wait untill all messagess will be processed
        print("Trying to close channel")
        chan.close()

        test_read_all(dt, delta, nmsgs)
    except:
        traceback.print_exc()
        sys.exit(1)
    finally:
        print("Stopping server...")
        akumulid.stop()
        time.sleep(5)
        print("Server stopped")

    print("Starting server...")
    akumulid.serve()
    time.sleep(5)
    print("Server started")
    try:
        test_read_all(dt, delta, nmsgs)

        # Try to write new data
        dt = datetime.datetime.utcnow()
        chan = att.TCPChan(HOST, TCPPORT)

        # fill data in
        print("Sending {0} messages through TCP second time...".format(nmsgs))
        tags = {
            "tag1": ['A'],
            "tag2": ['B', 'C'],
            "tag3": ['D', 'E', 'F', 'G', 'H'],
        }
        for it in att.generate_messages(dt, delta, nmsgs, 'test', **tags):
            chan.send(it)
        time.sleep(5)
        test_read_all(dt, delta, nmsgs)
    finally:
        print("Stopping server...")
        akumulid.stop()
        time.sleep(5)