예제 #1
0
def setUpWithCrateLayer(test):
    test.globs['HttpClient'] = http.Client
    test.globs['crate_host'] = crate_host
    test.globs['pprint'] = pprint
    test.globs['print'] = cprint

    conn = connect(crate_host)
    cursor = conn.cursor()

    def refresh(table):
        cursor.execute("refresh table %s" % table)
    test.globs["refresh"] = refresh

    with open(docs_path('testing/testdata/mappings/locations.sql')) as s:
        stmt = s.read()
        cursor.execute(stmt)
        stmt = ("select count(*) from information_schema.tables "
                "where table_name = 'locations'")
        cursor.execute(stmt)
        assert cursor.fetchall()[0][0] == 1

    data_path = docs_path('testing/testdata/data/test_a.json')
    # load testing data into crate
    cursor.execute("copy locations from ?", (data_path,))
    # refresh location table so imported data is visible immediately
    refresh("locations")

    # create blob table
    cursor.execute("create blob table myfiles clustered into 1 shards " +
                   "with (number_of_replicas=0)")
예제 #2
0
def setUpWithCrateLayer(test):
    test.globs['HttpClient'] = http.Client
    test.globs['crate_host'] = crate_host
    test.globs['pprint'] = pprint
    test.globs['print'] = cprint

    conn = connect(crate_host)
    cursor = conn.cursor()

    def refresh(table):
        cursor.execute("refresh table %s" % table)

    test.globs["refresh"] = refresh

    with open(docs_path('testing/testdata/mappings/locations.sql')) as s:
        stmt = s.read()
        cursor.execute(stmt)
        stmt = ("select count(*) from information_schema.tables "
                "where table_name = 'locations'")
        cursor.execute(stmt)
        assert cursor.fetchall()[0][0] == 1

    data_path = docs_path('testing/testdata/data/test_a.json')
    # load testing data into crate
    cursor.execute("copy locations from ?", (data_path, ))
    # refresh location table so imported data is visible immediately
    refresh("locations")

    # create blob table
    cursor.execute(
        "create blob table myfiles clustered into 1 shards with (number_of_replicas=0)"
    )