2022-01-14 17:58:56 +00:00
|
|
|
import json
|
|
|
|
import os
|
|
|
|
from time import sleep
|
|
|
|
import meilisearch
|
2022-01-27 16:22:05 +00:00
|
|
|
from pymysql import NULL
|
2022-01-14 17:58:56 +00:00
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
from helpers.cluster import ClickHouseCluster
|
|
|
|
|
|
|
|
SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
|
2022-05-13 13:55:42 +00:00
|
|
|
|
2022-01-14 17:58:56 +00:00
|
|
|
@pytest.fixture(scope="module")
|
|
|
|
def started_cluster(request):
|
|
|
|
try:
|
|
|
|
cluster = ClickHouseCluster(__file__)
|
2022-05-13 13:55:42 +00:00
|
|
|
node = cluster.add_instance(
|
|
|
|
"meili", main_configs=["configs/named_collection.xml"], with_meili=True
|
|
|
|
)
|
2022-01-14 17:58:56 +00:00
|
|
|
cluster.start()
|
|
|
|
yield cluster
|
|
|
|
finally:
|
|
|
|
cluster.shutdown()
|
|
|
|
|
|
|
|
|
|
|
|
def get_meili_client(started_cluster):
|
2022-05-13 13:55:42 +00:00
|
|
|
connection_str = "http://localhost:{}".format(started_cluster.meili_port)
|
2022-01-14 17:58:56 +00:00
|
|
|
return meilisearch.Client(connection_str)
|
|
|
|
|
2022-05-13 13:55:42 +00:00
|
|
|
|
2022-01-14 17:58:56 +00:00
|
|
|
def get_meili_secure_client(started_cluster):
|
2022-05-13 13:55:42 +00:00
|
|
|
connection_str = "http://localhost:{}".format(started_cluster.meili_secure_port)
|
2022-01-14 17:58:56 +00:00
|
|
|
return meilisearch.Client(connection_str, "password")
|
|
|
|
|
2022-05-13 13:55:42 +00:00
|
|
|
|
2022-01-14 17:58:56 +00:00
|
|
|
def push_data(client, table, documents):
|
|
|
|
ans = table.add_documents(documents)
|
2022-05-13 13:55:42 +00:00
|
|
|
client.wait_for_task(ans["uid"])
|
|
|
|
|
2022-01-14 17:58:56 +00:00
|
|
|
|
|
|
|
def push_movies(client):
|
2022-05-13 13:55:42 +00:00
|
|
|
print(SCRIPT_DIR + "/movies.json")
|
|
|
|
json_file = open(SCRIPT_DIR + "/movies.json")
|
2022-01-14 17:58:56 +00:00
|
|
|
movies = json.load(json_file)
|
2022-05-13 13:55:42 +00:00
|
|
|
ans = client.index("movies").add_documents(movies)
|
|
|
|
client.wait_for_task(ans["uid"], 100000)
|
2022-01-14 17:58:56 +00:00
|
|
|
|
|
|
|
|
2022-05-13 13:55:42 +00:00
|
|
|
@pytest.mark.parametrize("started_cluster", [False], indirect=["started_cluster"])
|
2022-01-14 17:58:56 +00:00
|
|
|
def test_simple_select(started_cluster):
|
|
|
|
client = get_meili_client(started_cluster)
|
|
|
|
table = client.index("new_table")
|
|
|
|
data = []
|
|
|
|
for i in range(0, 100):
|
2022-05-13 13:55:42 +00:00
|
|
|
data.append({"id": i, "data": hex(i * i)})
|
2022-01-14 17:58:56 +00:00
|
|
|
|
|
|
|
push_data(client, table, data)
|
|
|
|
|
2022-05-13 13:55:42 +00:00
|
|
|
node = started_cluster.instances["meili"]
|
2023-02-20 13:29:04 +00:00
|
|
|
node.query("DROP TABLE IF EXISTS simple_meili_table")
|
2022-01-14 17:58:56 +00:00
|
|
|
node.query(
|
2022-05-13 13:55:42 +00:00
|
|
|
"CREATE TABLE simple_meili_table(id UInt64, data String) ENGINE = MeiliSearch('http://meili1:7700', 'new_table', '')"
|
|
|
|
)
|
|
|
|
|
|
|
|
assert node.query("SELECT COUNT() FROM simple_meili_table") == "100\n"
|
|
|
|
assert (
|
|
|
|
node.query("SELECT sum(id) FROM simple_meili_table")
|
|
|
|
== str(sum(range(0, 100))) + "\n"
|
|
|
|
)
|
|
|
|
|
|
|
|
assert (
|
|
|
|
node.query("SELECT data FROM simple_meili_table WHERE id = 42")
|
|
|
|
== hex(42 * 42) + "\n"
|
|
|
|
)
|
2022-01-14 17:58:56 +00:00
|
|
|
node.query("DROP TABLE simple_meili_table")
|
|
|
|
table.delete()
|
|
|
|
|
|
|
|
|
2022-05-13 13:55:42 +00:00
|
|
|
@pytest.mark.parametrize("started_cluster", [False], indirect=["started_cluster"])
|
2022-01-14 17:58:56 +00:00
|
|
|
def test_insert(started_cluster):
|
|
|
|
client = get_meili_client(started_cluster)
|
|
|
|
new_table = client.index("new_table")
|
|
|
|
big_table = client.index("big_table")
|
|
|
|
|
2022-05-13 13:55:42 +00:00
|
|
|
node = started_cluster.instances["meili"]
|
2023-02-20 13:29:04 +00:00
|
|
|
node.query("DROP TABLE IF EXISTS new_table")
|
2022-05-13 13:55:42 +00:00
|
|
|
node.query(
|
|
|
|
"CREATE TABLE new_table(id UInt64, data String) ENGINE = MeiliSearch('http://meili1:7700', 'new_table', '')"
|
|
|
|
)
|
|
|
|
|
|
|
|
node.query(
|
|
|
|
"INSERT INTO new_table (id, data) VALUES (1, '1') (2, '2') (3, '3') (4, '4') (5, '5') (6, '6') (7, '7')"
|
|
|
|
)
|
2023-02-20 13:29:04 +00:00
|
|
|
sleep(5)
|
2022-01-14 17:58:56 +00:00
|
|
|
assert len(new_table.get_documents()) == 7
|
|
|
|
|
2023-02-20 13:29:04 +00:00
|
|
|
node.query("DROP TABLE IF EXISTS big_table")
|
2022-05-13 13:55:42 +00:00
|
|
|
node.query(
|
|
|
|
"CREATE TABLE big_table(id UInt64, data String) ENGINE = MeiliSearch('http://meili1:7700', 'big_table', '')"
|
|
|
|
)
|
2022-01-14 17:58:56 +00:00
|
|
|
|
|
|
|
values = ""
|
|
|
|
for i in range(1, 40001):
|
2022-05-13 13:55:42 +00:00
|
|
|
values += "(" + str(i) + ", " + "'" + str(i) + "'" + ") "
|
|
|
|
|
2022-01-14 17:58:56 +00:00
|
|
|
node.query("INSERT INTO big_table (id, data) VALUES " + values)
|
|
|
|
sleep(5)
|
2022-05-13 13:55:42 +00:00
|
|
|
ans = big_table.update_sortable_attributes(["id"])
|
|
|
|
client.wait_for_task(ans["uid"])
|
|
|
|
docs = big_table.get_documents({"limit": 40010})
|
2022-01-14 17:58:56 +00:00
|
|
|
assert len(docs) == 40000
|
|
|
|
|
|
|
|
node.query("DROP TABLE new_table")
|
|
|
|
node.query("DROP TABLE big_table")
|
|
|
|
new_table.delete()
|
|
|
|
big_table.delete()
|
|
|
|
|
|
|
|
|
2022-05-13 13:55:42 +00:00
|
|
|
@pytest.mark.parametrize("started_cluster", [False], indirect=["started_cluster"])
|
2022-01-14 17:58:56 +00:00
|
|
|
def test_meilimatch(started_cluster):
|
|
|
|
client = get_meili_client(started_cluster)
|
|
|
|
table = client.index("movies")
|
2022-05-13 13:55:42 +00:00
|
|
|
table.update_sortable_attributes(["release_date"])
|
|
|
|
table.update_filterable_attributes(["release_date"])
|
2022-01-14 17:58:56 +00:00
|
|
|
|
|
|
|
push_movies(client)
|
|
|
|
|
2022-05-13 13:55:42 +00:00
|
|
|
node = started_cluster.instances["meili"]
|
2023-02-20 13:29:04 +00:00
|
|
|
node.query("DROP TABLE IF EXISTS movies_table")
|
2022-05-13 13:55:42 +00:00
|
|
|
node.query(
|
|
|
|
"CREATE TABLE movies_table(id String, title String, release_date Int64) ENGINE = MeiliSearch('http://meili1:7700', 'movies', '')"
|
|
|
|
)
|
|
|
|
|
|
|
|
assert node.query("SELECT COUNT() FROM movies_table") == "19546\n"
|
|
|
|
|
|
|
|
real_json = table.search(
|
|
|
|
"abaca",
|
|
|
|
{"attributesToRetrieve": ["id", "title", "release_date"], "limit": 20000},
|
|
|
|
)["hits"]
|
|
|
|
click_ans = (
|
|
|
|
"["
|
|
|
|
+ ", ".join(
|
|
|
|
node.query(
|
|
|
|
'SELECT * FROM movies_table WHERE \
|
|
|
|
meiliMatch(\'"q"="abaca"\') \
|
|
|
|
format JSONEachRow settings output_format_json_quote_64bit_integers=0'
|
|
|
|
).split("\n")[:-1]
|
|
|
|
)
|
|
|
|
+ "]"
|
|
|
|
)
|
2022-01-14 17:58:56 +00:00
|
|
|
click_json = json.loads(click_ans)
|
|
|
|
assert real_json == click_json
|
|
|
|
|
2022-05-13 13:55:42 +00:00
|
|
|
real_json = table.search(
|
|
|
|
"abaca",
|
|
|
|
{
|
|
|
|
"attributesToRetrieve": ["id", "title", "release_date"],
|
|
|
|
"limit": 20000,
|
|
|
|
"sort": ["release_date:asc"],
|
|
|
|
},
|
|
|
|
)["hits"]
|
|
|
|
click_ans = (
|
|
|
|
"["
|
|
|
|
+ ", ".join(
|
|
|
|
node.query(
|
|
|
|
'SELECT * FROM movies_table WHERE \
|
|
|
|
meiliMatch(\'"q"="abaca"\', \'"sort"=["release_date:asc"]\') \
|
|
|
|
format JSONEachRow settings output_format_json_quote_64bit_integers=0'
|
|
|
|
).split("\n")[:-1]
|
|
|
|
)
|
|
|
|
+ "]"
|
|
|
|
)
|
2022-01-14 17:58:56 +00:00
|
|
|
click_json = json.loads(click_ans)
|
|
|
|
assert real_json == click_json
|
|
|
|
|
2022-05-13 13:55:42 +00:00
|
|
|
real_json = table.search(
|
|
|
|
"abaca",
|
|
|
|
{
|
|
|
|
"attributesToRetrieve": ["id", "title", "release_date"],
|
|
|
|
"limit": 20000,
|
|
|
|
"sort": ["release_date:desc"],
|
|
|
|
"filter": "release_date < 700000000",
|
|
|
|
},
|
|
|
|
)["hits"]
|
|
|
|
click_ans = (
|
|
|
|
"["
|
|
|
|
+ ", ".join(
|
|
|
|
node.query(
|
|
|
|
'SELECT * FROM movies_table WHERE \
|
|
|
|
meiliMatch(\'"q"="abaca"\', \'"sort"=["release_date:asc"]\', \'"filter"="release_date < 700000000"\') \
|
|
|
|
format JSONEachRow settings output_format_json_quote_64bit_integers=0'
|
|
|
|
).split("\n")[:-1]
|
|
|
|
)
|
|
|
|
+ "]"
|
|
|
|
)
|
2022-01-14 17:58:56 +00:00
|
|
|
click_json = json.loads(click_ans)
|
|
|
|
assert real_json == click_json
|
|
|
|
|
|
|
|
node.query("DROP TABLE movies_table")
|
|
|
|
table.delete()
|
|
|
|
|
|
|
|
|
2022-05-13 13:55:42 +00:00
|
|
|
@pytest.mark.parametrize("started_cluster", [False], indirect=["started_cluster"])
|
2022-01-14 17:58:56 +00:00
|
|
|
def test_incorrect_data_type(started_cluster):
|
|
|
|
client = get_meili_client(started_cluster)
|
|
|
|
table = client.index("new_table")
|
|
|
|
data = []
|
|
|
|
for i in range(0, 100):
|
2022-05-13 13:55:42 +00:00
|
|
|
data.append({"id": i, "data": hex(i * i), "aaaa": "Hello"})
|
|
|
|
|
|
|
|
push_data(client, table, data)
|
2022-01-14 17:58:56 +00:00
|
|
|
|
2022-05-13 13:55:42 +00:00
|
|
|
node = started_cluster.instances["meili"]
|
2023-02-20 13:29:04 +00:00
|
|
|
node.query("DROP TABLE IF EXISTS strange_meili_table")
|
2022-05-13 13:55:42 +00:00
|
|
|
node.query(
|
|
|
|
"CREATE TABLE strange_meili_table(id UInt64, data String, bbbb String) ENGINE = MeiliSearch('http://meili1:7700', 'new_table', '')"
|
|
|
|
)
|
2022-01-14 17:58:56 +00:00
|
|
|
|
2022-01-27 16:22:05 +00:00
|
|
|
error = node.query_and_get_error("SELECT bbbb FROM strange_meili_table")
|
2022-05-13 13:55:42 +00:00
|
|
|
assert "MEILISEARCH_MISSING_SOME_COLUMNS" in error
|
2022-01-14 17:58:56 +00:00
|
|
|
|
|
|
|
node.query("DROP TABLE strange_meili_table")
|
|
|
|
table.delete()
|
|
|
|
|
|
|
|
|
2022-05-13 13:55:42 +00:00
|
|
|
@pytest.mark.parametrize("started_cluster", [False], indirect=["started_cluster"])
|
2022-01-14 17:58:56 +00:00
|
|
|
def test_simple_select_secure(started_cluster):
|
|
|
|
client = get_meili_secure_client(started_cluster)
|
|
|
|
table = client.index("new_table")
|
|
|
|
data = []
|
|
|
|
for i in range(0, 100):
|
2022-05-13 13:55:42 +00:00
|
|
|
data.append({"id": i, "data": hex(i * i)})
|
2022-01-14 17:58:56 +00:00
|
|
|
|
|
|
|
push_data(client, table, data)
|
|
|
|
|
2022-05-13 13:55:42 +00:00
|
|
|
node = started_cluster.instances["meili"]
|
2023-02-20 13:29:04 +00:00
|
|
|
node.query("DROP TABLE IF EXISTS simple_meili_table")
|
2022-01-14 17:58:56 +00:00
|
|
|
node.query(
|
2022-05-13 13:55:42 +00:00
|
|
|
"CREATE TABLE simple_meili_table(id UInt64, data String) ENGINE = MeiliSearch('http://meili_secure:7700', 'new_table', 'password')"
|
|
|
|
)
|
2022-01-14 17:58:56 +00:00
|
|
|
|
2023-02-20 13:29:04 +00:00
|
|
|
node.query("DROP TABLE IF EXISTS wrong_meili_table")
|
2022-01-14 17:58:56 +00:00
|
|
|
node.query(
|
2022-05-13 13:55:42 +00:00
|
|
|
"CREATE TABLE wrong_meili_table(id UInt64, data String) ENGINE = MeiliSearch('http://meili_secure:7700', 'new_table', 'wrong_password')"
|
|
|
|
)
|
|
|
|
|
|
|
|
assert node.query("SELECT COUNT() FROM simple_meili_table") == "100\n"
|
|
|
|
assert (
|
|
|
|
node.query("SELECT sum(id) FROM simple_meili_table")
|
|
|
|
== str(sum(range(0, 100))) + "\n"
|
|
|
|
)
|
|
|
|
assert (
|
|
|
|
node.query("SELECT data FROM simple_meili_table WHERE id = 42")
|
|
|
|
== hex(42 * 42) + "\n"
|
|
|
|
)
|
2022-01-14 17:58:56 +00:00
|
|
|
|
2022-01-27 16:22:05 +00:00
|
|
|
error = node.query_and_get_error("SELECT COUNT() FROM wrong_meili_table")
|
2022-05-13 13:55:42 +00:00
|
|
|
assert "MEILISEARCH_EXCEPTION" in error
|
2022-01-14 17:58:56 +00:00
|
|
|
|
2022-01-27 16:22:05 +00:00
|
|
|
error = node.query_and_get_error("SELECT sum(id) FROM wrong_meili_table")
|
2022-05-13 13:55:42 +00:00
|
|
|
assert "MEILISEARCH_EXCEPTION" in error
|
2022-01-14 17:58:56 +00:00
|
|
|
|
2022-01-27 16:22:05 +00:00
|
|
|
error = node.query_and_get_error("SELECT data FROM wrong_meili_table WHERE id = 42")
|
2022-05-13 13:55:42 +00:00
|
|
|
assert "MEILISEARCH_EXCEPTION" in error
|
2022-01-14 17:58:56 +00:00
|
|
|
|
|
|
|
node.query("DROP TABLE simple_meili_table")
|
|
|
|
node.query("DROP TABLE wrong_meili_table")
|
|
|
|
table.delete()
|
|
|
|
|
|
|
|
|
2022-05-13 13:55:42 +00:00
|
|
|
@pytest.mark.parametrize("started_cluster", [False], indirect=["started_cluster"])
|
2022-01-14 17:58:56 +00:00
|
|
|
def test_meilimatch_secure(started_cluster):
|
|
|
|
client = get_meili_secure_client(started_cluster)
|
|
|
|
table = client.index("movies")
|
2022-05-13 13:55:42 +00:00
|
|
|
table.update_sortable_attributes(["release_date"])
|
|
|
|
table.update_filterable_attributes(["release_date"])
|
2022-01-14 17:58:56 +00:00
|
|
|
|
|
|
|
push_movies(client)
|
|
|
|
|
2022-05-13 13:55:42 +00:00
|
|
|
node = started_cluster.instances["meili"]
|
2023-02-20 13:29:04 +00:00
|
|
|
node.query("DROP TABLE IF EXISTS movies_table")
|
2022-05-13 13:55:42 +00:00
|
|
|
node.query(
|
|
|
|
"CREATE TABLE movies_table(id String, title String, release_date Int64) ENGINE = MeiliSearch('http://meili_secure:7700', 'movies', 'password')"
|
|
|
|
)
|
|
|
|
|
|
|
|
assert node.query("SELECT COUNT() FROM movies_table") == "19546\n"
|
|
|
|
|
|
|
|
real_json = table.search(
|
|
|
|
"abaca",
|
|
|
|
{"attributesToRetrieve": ["id", "title", "release_date"], "limit": 20000},
|
|
|
|
)["hits"]
|
|
|
|
click_ans = (
|
|
|
|
"["
|
|
|
|
+ ", ".join(
|
|
|
|
node.query(
|
|
|
|
'SELECT * FROM movies_table WHERE \
|
|
|
|
meiliMatch(\'"q"="abaca"\') \
|
|
|
|
format JSONEachRow settings output_format_json_quote_64bit_integers=0'
|
|
|
|
).split("\n")[:-1]
|
|
|
|
)
|
|
|
|
+ "]"
|
|
|
|
)
|
2022-01-14 17:58:56 +00:00
|
|
|
click_json = json.loads(click_ans)
|
|
|
|
assert real_json == click_json
|
|
|
|
|
2022-05-13 13:55:42 +00:00
|
|
|
real_json = table.search(
|
|
|
|
"abaca",
|
|
|
|
{
|
|
|
|
"attributesToRetrieve": ["id", "title", "release_date"],
|
|
|
|
"limit": 20000,
|
|
|
|
"sort": ["release_date:asc"],
|
|
|
|
},
|
|
|
|
)["hits"]
|
|
|
|
click_ans = (
|
|
|
|
"["
|
|
|
|
+ ", ".join(
|
|
|
|
node.query(
|
|
|
|
'SELECT * FROM movies_table WHERE \
|
|
|
|
meiliMatch(\'"q"="abaca"\', \'"sort"=["release_date:asc"]\') \
|
|
|
|
format JSONEachRow settings output_format_json_quote_64bit_integers=0'
|
|
|
|
).split("\n")[:-1]
|
|
|
|
)
|
|
|
|
+ "]"
|
|
|
|
)
|
2022-01-14 17:58:56 +00:00
|
|
|
click_json = json.loads(click_ans)
|
|
|
|
assert real_json == click_json
|
|
|
|
|
2022-05-13 13:55:42 +00:00
|
|
|
real_json = table.search(
|
|
|
|
"abaca",
|
|
|
|
{
|
|
|
|
"attributesToRetrieve": ["id", "title", "release_date"],
|
|
|
|
"limit": 20000,
|
|
|
|
"sort": ["release_date:desc"],
|
|
|
|
"filter": "release_date < 700000000",
|
|
|
|
},
|
|
|
|
)["hits"]
|
|
|
|
click_ans = (
|
|
|
|
"["
|
|
|
|
+ ", ".join(
|
|
|
|
node.query(
|
|
|
|
'SELECT * FROM movies_table WHERE \
|
|
|
|
meiliMatch(\'"q"="abaca"\', \'"sort"=["release_date:asc"]\', \'"filter"="release_date < 700000000"\') \
|
|
|
|
format JSONEachRow settings output_format_json_quote_64bit_integers=0'
|
|
|
|
).split("\n")[:-1]
|
|
|
|
)
|
|
|
|
+ "]"
|
|
|
|
)
|
2022-01-14 17:58:56 +00:00
|
|
|
click_json = json.loads(click_ans)
|
|
|
|
assert real_json == click_json
|
|
|
|
|
|
|
|
node.query("DROP TABLE movies_table")
|
|
|
|
table.delete()
|
|
|
|
|
|
|
|
|
2022-05-13 13:55:42 +00:00
|
|
|
@pytest.mark.parametrize("started_cluster", [False], indirect=["started_cluster"])
|
2022-01-14 17:58:56 +00:00
|
|
|
def test_incorrect_data_type_secure(started_cluster):
|
|
|
|
client = get_meili_secure_client(started_cluster)
|
|
|
|
table = client.index("new_table")
|
|
|
|
data = []
|
|
|
|
for i in range(0, 100):
|
2022-05-13 13:55:42 +00:00
|
|
|
data.append({"id": i, "data": hex(i * i), "aaaa": "Hello"})
|
|
|
|
|
|
|
|
push_data(client, table, data)
|
2022-01-14 17:58:56 +00:00
|
|
|
|
2022-05-13 13:55:42 +00:00
|
|
|
node = started_cluster.instances["meili"]
|
2023-02-20 13:29:04 +00:00
|
|
|
node.query("DROP TABLE IF EXISTS strange_meili_table")
|
2022-05-13 13:55:42 +00:00
|
|
|
node.query(
|
|
|
|
"CREATE TABLE strange_meili_table(id UInt64, data String, bbbb String) ENGINE = MeiliSearch('http://meili_secure:7700', 'new_table', 'password')"
|
|
|
|
)
|
2022-01-14 17:58:56 +00:00
|
|
|
|
2022-01-27 16:22:05 +00:00
|
|
|
error = node.query_and_get_error("SELECT bbbb FROM strange_meili_table")
|
2022-05-13 13:55:42 +00:00
|
|
|
assert "MEILISEARCH_MISSING_SOME_COLUMNS" in error
|
2022-01-14 17:58:56 +00:00
|
|
|
|
|
|
|
node.query("DROP TABLE strange_meili_table")
|
|
|
|
table.delete()
|
|
|
|
|
2022-05-13 13:55:42 +00:00
|
|
|
|
|
|
|
@pytest.mark.parametrize("started_cluster", [False], indirect=["started_cluster"])
|
2022-01-14 17:58:56 +00:00
|
|
|
def test_insert_secure(started_cluster):
|
|
|
|
client = get_meili_secure_client(started_cluster)
|
|
|
|
new_table = client.index("new_table")
|
|
|
|
big_table = client.index("big_table")
|
|
|
|
|
2022-05-13 13:55:42 +00:00
|
|
|
node = started_cluster.instances["meili"]
|
2023-02-20 13:29:04 +00:00
|
|
|
node.query("DROP TABLE IF EXISTS new_table")
|
2022-05-13 13:55:42 +00:00
|
|
|
node.query(
|
|
|
|
"CREATE TABLE new_table(id UInt64, data String) ENGINE = MeiliSearch('http://meili_secure:7700', 'new_table', 'password')"
|
|
|
|
)
|
|
|
|
|
|
|
|
node.query(
|
|
|
|
"INSERT INTO new_table (id, data) VALUES (1, '1') (2, '2') (3, '3') (4, '4') (5, '5') (6, '6') (7, '7')"
|
|
|
|
)
|
2023-02-20 13:29:04 +00:00
|
|
|
sleep(5)
|
2022-01-14 17:58:56 +00:00
|
|
|
assert len(new_table.get_documents()) == 7
|
|
|
|
|
2023-02-20 13:29:04 +00:00
|
|
|
node.query("DROP TABLE IF EXISTS big_table")
|
2022-05-13 13:55:42 +00:00
|
|
|
node.query(
|
|
|
|
"CREATE TABLE big_table(id UInt64, data String) ENGINE = MeiliSearch('http://meili_secure:7700', 'big_table', 'password')"
|
|
|
|
)
|
2022-01-14 17:58:56 +00:00
|
|
|
|
|
|
|
values = ""
|
|
|
|
for i in range(1, 40001):
|
2022-05-13 13:55:42 +00:00
|
|
|
values += "(" + str(i) + ", " + "'" + str(i) + "'" + ") "
|
|
|
|
|
2022-01-14 17:58:56 +00:00
|
|
|
node.query("INSERT INTO big_table (id, data) VALUES " + values)
|
|
|
|
sleep(5)
|
2022-05-13 13:55:42 +00:00
|
|
|
ans = big_table.update_sortable_attributes(["id"])
|
|
|
|
client.wait_for_task(ans["uid"])
|
|
|
|
docs = big_table.get_documents({"limit": 40010})
|
2022-01-14 17:58:56 +00:00
|
|
|
assert len(docs) == 40000
|
|
|
|
|
|
|
|
node.query("DROP TABLE new_table")
|
|
|
|
node.query("DROP TABLE big_table")
|
|
|
|
new_table.delete()
|
|
|
|
big_table.delete()
|
|
|
|
|
2022-05-13 13:55:42 +00:00
|
|
|
|
|
|
|
@pytest.mark.parametrize("started_cluster", [False], indirect=["started_cluster"])
|
2022-01-14 17:58:56 +00:00
|
|
|
def test_security_levels(started_cluster):
|
|
|
|
client = get_meili_secure_client(started_cluster)
|
2022-05-12 13:51:00 +00:00
|
|
|
new_table = client.index("new_table")
|
2022-05-13 13:55:42 +00:00
|
|
|
search_key = client.get_keys()["results"][0]["key"]
|
|
|
|
admin_key = client.get_keys()["results"][1]["key"]
|
|
|
|
|
2022-01-14 17:58:56 +00:00
|
|
|
values = ""
|
|
|
|
for i in range(1, 101):
|
2022-05-13 13:55:42 +00:00
|
|
|
values += "(" + str(i) + ", " + "'" + str(i) + "'" + ") "
|
2022-01-14 17:58:56 +00:00
|
|
|
|
2022-05-13 13:55:42 +00:00
|
|
|
node = started_cluster.instances["meili"]
|
2023-02-20 13:29:04 +00:00
|
|
|
node.query("DROP TABLE IF EXISTS read_table")
|
2022-05-13 13:55:42 +00:00
|
|
|
node.query(
|
|
|
|
f"CREATE TABLE read_table(id UInt64, data String) ENGINE = MeiliSearch('http://meili_secure:7700', 'new_table', '{search_key}')"
|
|
|
|
)
|
2023-02-20 13:29:04 +00:00
|
|
|
node.query("DROP TABLE IF EXISTS write_table")
|
2022-05-13 13:55:42 +00:00
|
|
|
node.query(
|
|
|
|
f"CREATE TABLE write_table(id UInt64, data String) ENGINE = MeiliSearch('http://meili_secure:7700', 'new_table', '{admin_key}')"
|
|
|
|
)
|
2022-01-14 17:58:56 +00:00
|
|
|
|
2022-05-13 13:55:42 +00:00
|
|
|
error = node.query_and_get_error(
|
|
|
|
"INSERT INTO read_table (id, data) VALUES " + values
|
|
|
|
)
|
|
|
|
assert "MEILISEARCH_EXCEPTION" in error
|
2022-01-14 17:58:56 +00:00
|
|
|
|
|
|
|
node.query("INSERT INTO write_table (id, data) VALUES " + values)
|
2023-02-20 13:29:04 +00:00
|
|
|
sleep(5)
|
2022-05-13 13:55:42 +00:00
|
|
|
assert len(new_table.get_documents({"limit": 40010})) == 100
|
|
|
|
|
|
|
|
ans1 = (
|
|
|
|
"["
|
|
|
|
+ ", ".join(
|
|
|
|
node.query(
|
|
|
|
'SELECT * FROM read_table where meiliMatch(\'"q"=""\') \
|
|
|
|
format JSONEachRow settings output_format_json_quote_64bit_integers=0'
|
|
|
|
).split("\n")[:-1]
|
|
|
|
)
|
|
|
|
+ "]"
|
|
|
|
)
|
|
|
|
ans2 = (
|
|
|
|
"["
|
|
|
|
+ ", ".join(
|
|
|
|
node.query(
|
|
|
|
"SELECT * FROM write_table \
|
|
|
|
format JSONEachRow settings output_format_json_quote_64bit_integers=0"
|
|
|
|
).split("\n")[:-1]
|
|
|
|
)
|
|
|
|
+ "]"
|
|
|
|
)
|
2022-01-14 17:58:56 +00:00
|
|
|
|
|
|
|
assert ans1 == ans2
|
|
|
|
|
|
|
|
docs = json.loads(ans1)
|
|
|
|
assert len(docs) == 100
|
|
|
|
|
|
|
|
node.query("DROP TABLE read_table")
|
|
|
|
node.query("DROP TABLE write_table")
|
|
|
|
client.index("new_table").delete()
|
|
|
|
|
2022-01-27 16:22:05 +00:00
|
|
|
|
2022-05-13 13:55:42 +00:00
|
|
|
@pytest.mark.parametrize("started_cluster", [False], indirect=["started_cluster"])
|
2022-01-27 16:22:05 +00:00
|
|
|
def test_types(started_cluster):
|
|
|
|
client = get_meili_client(started_cluster)
|
|
|
|
table = client.index("types_table")
|
|
|
|
|
|
|
|
data = {
|
2022-05-13 13:55:42 +00:00
|
|
|
"id": 1,
|
|
|
|
"UInt8_test": 128,
|
|
|
|
"UInt16_test": 32768,
|
|
|
|
"UInt32_test": 2147483648,
|
|
|
|
"UInt64_test": 9223372036854775808,
|
|
|
|
"Int8_test": -128,
|
|
|
|
"Int16_test": -32768,
|
|
|
|
"Int32_test": -2147483648,
|
|
|
|
"Int64_test": -9223372036854775808,
|
|
|
|
"String_test": "abacaba",
|
|
|
|
"Float32_test": 42.42,
|
|
|
|
"Float64_test": 42.42,
|
|
|
|
"Array_test": [["aba", "caba"], ["2d", "array"]],
|
|
|
|
"Null_test1": "value",
|
|
|
|
"Null_test2": NULL,
|
|
|
|
"Bool_test1": True,
|
|
|
|
"Bool_test2": False,
|
|
|
|
"Json_test": {"a": 1, "b": {"in_json": "qwerty"}},
|
|
|
|
}
|
2022-01-27 16:22:05 +00:00
|
|
|
|
|
|
|
push_data(client, table, data)
|
|
|
|
|
2022-05-13 13:55:42 +00:00
|
|
|
node = started_cluster.instances["meili"]
|
2023-02-20 13:29:04 +00:00
|
|
|
node.query("DROP TABLE IF EXISTS types_table")
|
2022-05-13 13:55:42 +00:00
|
|
|
node.query(
|
|
|
|
"CREATE TABLE types_table(\
|
2022-01-27 16:22:05 +00:00
|
|
|
id UInt64,\
|
|
|
|
UInt8_test UInt8,\
|
|
|
|
UInt16_test UInt16,\
|
|
|
|
UInt32_test UInt32,\
|
|
|
|
UInt64_test UInt64,\
|
|
|
|
Int8_test Int8,\
|
|
|
|
Int16_test Int16,\
|
|
|
|
Int32_test Int32,\
|
|
|
|
Int64_test Int64,\
|
|
|
|
String_test String,\
|
|
|
|
Float32_test Float32,\
|
|
|
|
Float64_test Float64,\
|
|
|
|
Array_test Array(Array(String)),\
|
|
|
|
Null_test1 Nullable(String),\
|
|
|
|
Null_test2 Nullable(String),\
|
|
|
|
Bool_test1 Boolean,\
|
|
|
|
Bool_test2 Boolean,\
|
|
|
|
Json_test String\
|
2022-05-13 13:55:42 +00:00
|
|
|
) ENGINE = MeiliSearch('http://meili1:7700', 'types_table', '')"
|
|
|
|
)
|
|
|
|
|
|
|
|
assert node.query("SELECT id FROM types_table") == "1\n"
|
|
|
|
assert node.query("SELECT UInt8_test FROM types_table") == "128\n"
|
|
|
|
assert node.query("SELECT UInt16_test FROM types_table") == "32768\n"
|
|
|
|
assert node.query("SELECT UInt32_test FROM types_table") == "2147483648\n"
|
|
|
|
assert node.query("SELECT UInt64_test FROM types_table") == "9223372036854775808\n"
|
|
|
|
assert node.query("SELECT Int8_test FROM types_table") == "-128\n"
|
|
|
|
assert node.query("SELECT Int16_test FROM types_table") == "-32768\n"
|
|
|
|
assert node.query("SELECT Int32_test FROM types_table") == "-2147483648\n"
|
|
|
|
assert node.query("SELECT Int64_test FROM types_table") == "-9223372036854775808\n"
|
|
|
|
assert node.query("SELECT String_test FROM types_table") == "abacaba\n"
|
|
|
|
assert node.query("SELECT Float32_test FROM types_table") == "42.42\n"
|
|
|
|
assert node.query("SELECT Float32_test FROM types_table") == "42.42\n"
|
|
|
|
assert (
|
|
|
|
node.query("SELECT Array_test FROM types_table")
|
|
|
|
== "[['aba','caba'],['2d','array']]\n"
|
|
|
|
)
|
|
|
|
assert node.query("SELECT Null_test1 FROM types_table") == "value\n"
|
|
|
|
assert node.query("SELECT Null_test2 FROM types_table") == "NULL\n"
|
|
|
|
assert node.query("SELECT Bool_test1 FROM types_table") == "true\n"
|
|
|
|
assert node.query("SELECT Bool_test2 FROM types_table") == "false\n"
|
|
|
|
assert (
|
|
|
|
node.query("SELECT Json_test FROM types_table")
|
|
|
|
== '{"a":1,"b":{"in_json":"qwerty"}}\n'
|
|
|
|
)
|
|
|
|
|
2022-01-27 16:22:05 +00:00
|
|
|
node.query("DROP TABLE types_table")
|
2022-05-13 13:55:42 +00:00
|
|
|
table.delete()
|
2022-01-27 16:22:05 +00:00
|
|
|
|
2022-05-13 13:55:42 +00:00
|
|
|
|
|
|
|
@pytest.mark.parametrize("started_cluster", [False], indirect=["started_cluster"])
|
2022-02-26 18:58:37 +00:00
|
|
|
def test_named_collection(started_cluster):
|
|
|
|
client = get_meili_client(started_cluster)
|
|
|
|
table = client.index("new_table")
|
|
|
|
data = []
|
|
|
|
for i in range(0, 100):
|
2022-05-13 13:55:42 +00:00
|
|
|
data.append({"id": i, "data": hex(i * i)})
|
2022-02-26 18:58:37 +00:00
|
|
|
|
|
|
|
push_data(client, table, data)
|
|
|
|
|
2022-05-13 13:55:42 +00:00
|
|
|
node = started_cluster.instances["meili"]
|
2023-02-20 13:29:04 +00:00
|
|
|
node.query("DROP TABLE IF EXISTS simple_meili_table")
|
2022-02-26 18:58:37 +00:00
|
|
|
node.query(
|
2022-05-13 13:55:42 +00:00
|
|
|
"CREATE TABLE simple_meili_table(id UInt64, data String) ENGINE = MeiliSearch( named_collection_for_meili )"
|
|
|
|
)
|
|
|
|
|
|
|
|
assert node.query("SELECT COUNT() FROM simple_meili_table") == "100\n"
|
|
|
|
assert (
|
|
|
|
node.query("SELECT sum(id) FROM simple_meili_table")
|
|
|
|
== str(sum(range(0, 100))) + "\n"
|
|
|
|
)
|
|
|
|
|
|
|
|
assert (
|
|
|
|
node.query("SELECT data FROM simple_meili_table WHERE id = 42")
|
|
|
|
== hex(42 * 42) + "\n"
|
|
|
|
)
|
2022-02-26 18:58:37 +00:00
|
|
|
node.query("DROP TABLE simple_meili_table")
|
2022-05-13 13:55:42 +00:00
|
|
|
table.delete()
|
2022-02-26 18:58:37 +00:00
|
|
|
|
|
|
|
|
2022-05-13 13:55:42 +00:00
|
|
|
@pytest.mark.parametrize("started_cluster", [False], indirect=["started_cluster"])
|
2022-02-26 18:58:37 +00:00
|
|
|
def test_named_collection_secure(started_cluster):
|
2022-03-27 20:00:28 +00:00
|
|
|
client_secure = get_meili_secure_client(started_cluster)
|
|
|
|
client_free = get_meili_client(started_cluster)
|
|
|
|
table_secure = client_secure.index("new_table")
|
|
|
|
table_free = client_free.index("new_table")
|
2022-05-13 13:55:42 +00:00
|
|
|
|
2022-02-26 18:58:37 +00:00
|
|
|
data = []
|
|
|
|
for i in range(0, 100):
|
2022-05-13 13:55:42 +00:00
|
|
|
data.append({"id": i, "data": hex(i * i)})
|
2022-02-26 18:58:37 +00:00
|
|
|
|
2022-03-27 20:00:28 +00:00
|
|
|
push_data(client_secure, table_secure, data)
|
|
|
|
push_data(client_free, table_free, data)
|
2022-02-26 18:58:37 +00:00
|
|
|
|
2022-05-13 13:55:42 +00:00
|
|
|
node = started_cluster.instances["meili"]
|
2023-02-20 13:29:04 +00:00
|
|
|
node.query("DROP TABLE IF EXISTS simple_meili_table")
|
2022-02-26 18:58:37 +00:00
|
|
|
node.query(
|
2022-05-13 13:55:42 +00:00
|
|
|
"CREATE TABLE simple_meili_table(id UInt64, data String) ENGINE = MeiliSearch( named_collection_for_meili_secure )"
|
|
|
|
)
|
2022-03-27 20:00:28 +00:00
|
|
|
|
2023-02-20 13:29:04 +00:00
|
|
|
node.query("DROP TABLE IF EXISTS wrong_meili_table")
|
2022-03-27 20:00:28 +00:00
|
|
|
node.query(
|
2022-05-13 13:55:42 +00:00
|
|
|
"CREATE TABLE wrong_meili_table(id UInt64, data String) ENGINE = MeiliSearch( named_collection_for_meili_secure_no_password )"
|
|
|
|
)
|
2022-02-26 18:58:37 +00:00
|
|
|
|
2023-02-20 13:29:04 +00:00
|
|
|
node.query("DROP TABLE IF EXISTS combine_meili_table")
|
2022-02-26 18:58:37 +00:00
|
|
|
node.query(
|
2022-12-21 23:27:22 +00:00
|
|
|
'CREATE TABLE combine_meili_table(id UInt64, data String) ENGINE = MeiliSearch( named_collection_for_meili_secure_no_password, key="password" )'
|
2022-05-13 13:55:42 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
assert node.query("SELECT COUNT() FROM simple_meili_table") == "100\n"
|
|
|
|
assert (
|
|
|
|
node.query("SELECT sum(id) FROM simple_meili_table")
|
|
|
|
== str(sum(range(0, 100))) + "\n"
|
|
|
|
)
|
|
|
|
assert (
|
|
|
|
node.query("SELECT data FROM simple_meili_table WHERE id = 42")
|
|
|
|
== hex(42 * 42) + "\n"
|
|
|
|
)
|
|
|
|
|
|
|
|
assert node.query("SELECT COUNT() FROM combine_meili_table") == "100\n"
|
|
|
|
assert (
|
|
|
|
node.query("SELECT sum(id) FROM combine_meili_table")
|
|
|
|
== str(sum(range(0, 100))) + "\n"
|
|
|
|
)
|
|
|
|
assert (
|
|
|
|
node.query("SELECT data FROM combine_meili_table WHERE id = 42")
|
|
|
|
== hex(42 * 42) + "\n"
|
|
|
|
)
|
2022-03-27 20:00:28 +00:00
|
|
|
|
2022-02-26 18:58:37 +00:00
|
|
|
error = node.query_and_get_error("SELECT COUNT() FROM wrong_meili_table")
|
2022-05-13 13:55:42 +00:00
|
|
|
assert "MEILISEARCH_EXCEPTION" in error
|
2022-01-27 16:22:05 +00:00
|
|
|
|
2022-02-26 18:58:37 +00:00
|
|
|
error = node.query_and_get_error("SELECT sum(id) FROM wrong_meili_table")
|
2022-05-13 13:55:42 +00:00
|
|
|
assert "MEILISEARCH_EXCEPTION" in error
|
2022-01-27 16:22:05 +00:00
|
|
|
|
2022-02-26 18:58:37 +00:00
|
|
|
error = node.query_and_get_error("SELECT data FROM wrong_meili_table WHERE id = 42")
|
2022-05-13 13:55:42 +00:00
|
|
|
assert "MEILISEARCH_EXCEPTION" in error
|
2022-01-27 16:22:05 +00:00
|
|
|
|
2022-02-26 18:58:37 +00:00
|
|
|
node.query("DROP TABLE simple_meili_table")
|
|
|
|
node.query("DROP TABLE wrong_meili_table")
|
2022-03-27 20:00:28 +00:00
|
|
|
node.query("DROP TABLE combine_meili_table")
|
|
|
|
table_secure.delete()
|
|
|
|
table_free.delete()
|
|
|
|
|
2022-02-28 19:43:43 +00:00
|
|
|
|
2022-05-13 13:55:42 +00:00
|
|
|
@pytest.mark.parametrize("started_cluster", [False], indirect=["started_cluster"])
|
2022-02-28 19:43:43 +00:00
|
|
|
def test_table_function(started_cluster):
|
|
|
|
client = get_meili_client(started_cluster)
|
|
|
|
table = client.index("new_table")
|
|
|
|
data = []
|
|
|
|
for i in range(0, 100):
|
2022-05-13 13:55:42 +00:00
|
|
|
data.append({"id": i, "data": hex(i * i)})
|
2022-02-28 19:43:43 +00:00
|
|
|
|
|
|
|
push_data(client, table, data)
|
|
|
|
|
2022-05-13 13:55:42 +00:00
|
|
|
node = started_cluster.instances["meili"]
|
|
|
|
|
|
|
|
assert (
|
|
|
|
node.query(
|
2022-08-28 00:08:51 +00:00
|
|
|
"SELECT COUNT() FROM meilisearch('http://meili1:7700', 'new_table', '')"
|
2022-05-13 13:55:42 +00:00
|
|
|
)
|
|
|
|
== "100\n"
|
|
|
|
)
|
|
|
|
assert (
|
|
|
|
node.query(
|
2022-08-28 00:08:51 +00:00
|
|
|
"SELECT sum(id) FROM meilisearch('http://meili1:7700', 'new_table', '')"
|
2022-05-13 13:55:42 +00:00
|
|
|
)
|
|
|
|
== str(sum(range(0, 100))) + "\n"
|
|
|
|
)
|
|
|
|
assert (
|
|
|
|
node.query(
|
2022-08-28 00:08:51 +00:00
|
|
|
"SELECT data FROM meilisearch('http://meili1:7700', 'new_table', '') WHERE id = 42"
|
2022-05-13 13:55:42 +00:00
|
|
|
)
|
|
|
|
== hex(42 * 42) + "\n"
|
|
|
|
)
|
2022-02-28 19:43:43 +00:00
|
|
|
|
|
|
|
table.delete()
|
|
|
|
|
|
|
|
|
2022-05-13 13:55:42 +00:00
|
|
|
@pytest.mark.parametrize("started_cluster", [False], indirect=["started_cluster"])
|
2022-02-28 19:43:43 +00:00
|
|
|
def test_table_function_secure(started_cluster):
|
|
|
|
client = get_meili_secure_client(started_cluster)
|
|
|
|
table = client.index("new_table")
|
|
|
|
data = []
|
|
|
|
for i in range(0, 100):
|
2022-05-13 13:55:42 +00:00
|
|
|
data.append({"id": i, "data": hex(i * i)})
|
2022-02-28 19:43:43 +00:00
|
|
|
|
|
|
|
push_data(client, table, data)
|
|
|
|
|
2022-05-13 13:55:42 +00:00
|
|
|
node = started_cluster.instances["meili"]
|
|
|
|
|
|
|
|
assert (
|
|
|
|
node.query(
|
2022-08-28 00:08:51 +00:00
|
|
|
"SELECT COUNT() FROM meilisearch('http://meili_secure:7700', 'new_table', 'password')"
|
2022-05-13 13:55:42 +00:00
|
|
|
)
|
|
|
|
== "100\n"
|
|
|
|
)
|
|
|
|
assert (
|
|
|
|
node.query(
|
2022-08-28 00:08:51 +00:00
|
|
|
"SELECT sum(id) FROM meilisearch('http://meili_secure:7700', 'new_table', 'password')"
|
2022-05-13 13:55:42 +00:00
|
|
|
)
|
|
|
|
== str(sum(range(0, 100))) + "\n"
|
|
|
|
)
|
|
|
|
assert (
|
|
|
|
node.query(
|
2022-08-28 00:08:51 +00:00
|
|
|
"SELECT data FROM meilisearch('http://meili_secure:7700', 'new_table', 'password') WHERE id = 42"
|
2022-05-13 13:55:42 +00:00
|
|
|
)
|
|
|
|
== hex(42 * 42) + "\n"
|
|
|
|
)
|
|
|
|
|
|
|
|
error = node.query_and_get_error(
|
2022-08-28 00:08:51 +00:00
|
|
|
"SELECT COUNT() FROM meilisearch('http://meili_secure:7700', 'new_table', 'wrong_password')"
|
2022-05-13 13:55:42 +00:00
|
|
|
)
|
|
|
|
assert "MEILISEARCH_EXCEPTION" in error
|
|
|
|
|
|
|
|
error = node.query_and_get_error(
|
2022-08-28 00:08:51 +00:00
|
|
|
"SELECT sum(id) FROM meilisearch('http://meili_secure:7700', 'new_table', 'wrong_password')"
|
2022-05-13 13:55:42 +00:00
|
|
|
)
|
|
|
|
assert "MEILISEARCH_EXCEPTION" in error
|
|
|
|
|
|
|
|
error = node.query_and_get_error(
|
2022-08-28 00:08:51 +00:00
|
|
|
"SELECT data FROM meilisearch('http://meili_secure:7700', 'new_table', 'wrong_password') WHERE id = 42"
|
2022-05-13 13:55:42 +00:00
|
|
|
)
|
|
|
|
assert "MEILISEARCH_EXCEPTION" in error
|
2022-02-28 19:43:43 +00:00
|
|
|
|
|
|
|
table.delete()
|
|
|
|
|
2022-05-13 13:55:42 +00:00
|
|
|
|
|
|
|
@pytest.mark.parametrize("started_cluster", [False], indirect=["started_cluster"])
|
2022-02-28 19:43:43 +00:00
|
|
|
def test_types_in_table_function(started_cluster):
|
|
|
|
client = get_meili_client(started_cluster)
|
|
|
|
table = client.index("types_table")
|
|
|
|
|
|
|
|
data = {
|
2022-05-13 13:55:42 +00:00
|
|
|
"id": 1,
|
|
|
|
"UInt8_test": 128,
|
|
|
|
"UInt16_test": 32768,
|
|
|
|
"UInt32_test": 2147483648,
|
|
|
|
"Int8_test": -128,
|
|
|
|
"Int16_test": -32768,
|
|
|
|
"Int32_test": -2147483648,
|
|
|
|
"Int64_test": -9223372036854775808,
|
|
|
|
"String_test": "abacaba",
|
|
|
|
"Float32_test": 42.42,
|
|
|
|
"Float64_test": 42.42,
|
|
|
|
"Array_test": [["aba", "caba"], ["2d", "array"]],
|
|
|
|
"Null_test1": "value",
|
|
|
|
"Null_test2": NULL,
|
|
|
|
"Bool_test1": True,
|
|
|
|
"Bool_test2": False,
|
|
|
|
"Json_test": {"a": 1, "b": {"in_json": "qwerty"}},
|
|
|
|
}
|
2022-02-28 19:43:43 +00:00
|
|
|
|
|
|
|
push_data(client, table, data)
|
|
|
|
|
2022-05-13 13:55:42 +00:00
|
|
|
node = started_cluster.instances["meili"]
|
|
|
|
|
|
|
|
assert (
|
|
|
|
node.query(
|
2022-08-28 00:08:51 +00:00
|
|
|
"SELECT id FROM meilisearch('http://meili1:7700', 'types_table', '')"
|
2022-05-13 13:55:42 +00:00
|
|
|
)
|
|
|
|
== "1\n"
|
|
|
|
)
|
|
|
|
assert (
|
|
|
|
node.query(
|
2022-08-28 00:08:51 +00:00
|
|
|
"SELECT UInt8_test FROM meilisearch('http://meili1:7700', 'types_table', '')"
|
2022-05-13 13:55:42 +00:00
|
|
|
)
|
|
|
|
== "128\n"
|
|
|
|
)
|
|
|
|
assert (
|
|
|
|
node.query(
|
2022-08-28 00:08:51 +00:00
|
|
|
"SELECT UInt16_test FROM meilisearch('http://meili1:7700', 'types_table', '')"
|
2022-05-13 13:55:42 +00:00
|
|
|
)
|
|
|
|
== "32768\n"
|
|
|
|
)
|
|
|
|
assert (
|
|
|
|
node.query(
|
2022-08-28 00:08:51 +00:00
|
|
|
"SELECT UInt32_test FROM meilisearch('http://meili1:7700', 'types_table', '')"
|
2022-05-13 13:55:42 +00:00
|
|
|
)
|
|
|
|
== "2147483648\n"
|
|
|
|
)
|
|
|
|
assert (
|
|
|
|
node.query(
|
2022-08-28 00:08:51 +00:00
|
|
|
"SELECT Int8_test FROM meilisearch('http://meili1:7700', 'types_table', '')"
|
2022-05-13 13:55:42 +00:00
|
|
|
)
|
|
|
|
== "-128\n"
|
|
|
|
)
|
|
|
|
assert (
|
|
|
|
node.query(
|
2022-08-28 00:08:51 +00:00
|
|
|
"SELECT Int16_test FROM meilisearch('http://meili1:7700', 'types_table', '')"
|
2022-05-13 13:55:42 +00:00
|
|
|
)
|
|
|
|
== "-32768\n"
|
|
|
|
)
|
|
|
|
assert (
|
|
|
|
node.query(
|
2022-08-28 00:08:51 +00:00
|
|
|
"SELECT Int32_test FROM meilisearch('http://meili1:7700', 'types_table', '')"
|
2022-05-13 13:55:42 +00:00
|
|
|
)
|
|
|
|
== "-2147483648\n"
|
|
|
|
)
|
|
|
|
assert (
|
|
|
|
node.query(
|
2022-08-28 00:08:51 +00:00
|
|
|
"SELECT Int64_test FROM meilisearch('http://meili1:7700', 'types_table', '')"
|
2022-05-13 13:55:42 +00:00
|
|
|
)
|
|
|
|
== "-9223372036854775808\n"
|
|
|
|
)
|
|
|
|
assert (
|
|
|
|
node.query(
|
2022-08-28 00:08:51 +00:00
|
|
|
"SELECT String_test FROM meilisearch('http://meili1:7700', 'types_table', '')"
|
2022-05-13 13:55:42 +00:00
|
|
|
)
|
|
|
|
== "abacaba\n"
|
|
|
|
)
|
|
|
|
assert (
|
|
|
|
node.query(
|
2022-08-28 00:08:51 +00:00
|
|
|
"SELECT Float32_test FROM meilisearch('http://meili1:7700', 'types_table', '')"
|
2022-05-13 13:55:42 +00:00
|
|
|
)
|
|
|
|
== "42.42\n"
|
|
|
|
)
|
|
|
|
assert (
|
|
|
|
node.query(
|
2022-08-28 00:08:51 +00:00
|
|
|
"SELECT Float32_test FROM meilisearch('http://meili1:7700', 'types_table', '')"
|
2022-05-13 13:55:42 +00:00
|
|
|
)
|
|
|
|
== "42.42\n"
|
|
|
|
)
|
|
|
|
assert (
|
|
|
|
node.query(
|
2022-08-28 00:08:51 +00:00
|
|
|
"SELECT Array_test FROM meilisearch('http://meili1:7700', 'types_table', '')"
|
2022-05-13 13:55:42 +00:00
|
|
|
)
|
|
|
|
== "[['aba','caba'],['2d','array']]\n"
|
|
|
|
)
|
|
|
|
assert (
|
|
|
|
node.query(
|
2022-08-28 00:08:51 +00:00
|
|
|
"SELECT Null_test1 FROM meilisearch('http://meili1:7700', 'types_table', '')"
|
2022-05-13 13:55:42 +00:00
|
|
|
)
|
|
|
|
== "value\n"
|
|
|
|
)
|
|
|
|
assert (
|
|
|
|
node.query(
|
2022-08-28 00:08:51 +00:00
|
|
|
"SELECT Null_test2 FROM meilisearch('http://meili1:7700', 'types_table', '')"
|
2022-05-13 13:55:42 +00:00
|
|
|
)
|
|
|
|
== "NULL\n"
|
|
|
|
)
|
|
|
|
assert (
|
|
|
|
node.query(
|
2022-08-28 00:08:51 +00:00
|
|
|
"SELECT Bool_test1 FROM meilisearch('http://meili1:7700', 'types_table', '')"
|
2022-05-13 13:55:42 +00:00
|
|
|
)
|
|
|
|
== "1\n"
|
|
|
|
)
|
|
|
|
assert (
|
|
|
|
node.query(
|
2022-08-28 00:08:51 +00:00
|
|
|
"SELECT Bool_test2 FROM meilisearch('http://meili1:7700', 'types_table', '')"
|
2022-05-13 13:55:42 +00:00
|
|
|
)
|
|
|
|
== "0\n"
|
|
|
|
)
|
|
|
|
assert (
|
|
|
|
node.query(
|
2022-08-28 00:08:51 +00:00
|
|
|
"SELECT Json_test FROM meilisearch('http://meili1:7700', 'types_table', '')"
|
2022-05-13 13:55:42 +00:00
|
|
|
)
|
|
|
|
== '{"a":1,"b":{"in_json":"qwerty"}}\n'
|
|
|
|
)
|
|
|
|
|
|
|
|
table.delete()
|