Skip to content

Commit

Permalink
Add basic test on actual Elasticsearch foreign server
Browse files Browse the repository at this point in the history
  • Loading branch information
gruuya committed Dec 16, 2021
1 parent 46d3a95 commit 4a1cdc2
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 7 deletions.
2 changes: 1 addition & 1 deletion engine/src/Multicorn
Submodule Multicorn updated 1 files
+14 −0 src/python.c
44 changes: 40 additions & 4 deletions test/splitgraph/commands/test_mounting.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
from datetime import datetime as dt
from test.splitgraph.conftest import _mount_mongo, _mount_mysql, _mount_postgres
from test.splitgraph.conftest import (
_mount_mongo,
_mount_mysql,
_mount_postgres,
_mount_elasticsearch,
)

import pytest
from splitgraph.core.repository import Repository
Expand All @@ -11,6 +16,7 @@
PG_MNT = Repository.from_schema("test/pg_mount")
MG_MNT = Repository.from_schema("test_mg_mount")
MYSQL_MNT = Repository.from_schema("test/mysql_mount")
ES_MNT = Repository.from_schema("test/es_mount")


@pytest.mark.mounting
Expand Down Expand Up @@ -43,7 +49,7 @@ def test_mount_mysql(local_engine_empty):
# Mount MySQL with a set schema instead of letting the FDW detect it
_mount_mysql(MYSQL_MNT)
result = get_engine().run_sql(
"""SELECT mushroom_id, name, discovery, friendly, binary_data, varbinary_data
"""SELECT mushroom_id, name, discovery, friendly, binary_data, varbinary_data
FROM "test/mysql_mount".mushrooms"""
)
assert len(result) == 2
Expand All @@ -54,6 +60,36 @@ def test_mount_mysql(local_engine_empty):
MYSQL_MNT.delete()


@pytest.mark.mounting
def test_mount_elasticsearch(local_engine_empty):
try:
# Mount Elasticsearch with a set schema instead of letting the FDW detect it
_mount_elasticsearch(ES_MNT)
result = get_engine().run_sql(
"""SELECT account_number, balance, firstname, lastname, age, gender,
address, employer, email, city, state
FROM "test/es_mount".account"""
)
assert len(result) == 1000

# Assert random record matches
assert result[28] == (
140,
26696,
"Cotton",
"Christensen",
32,
"M",
"878 Schermerhorn Street",
"Prowaste",
"cottonchristensen@prowaste.com",
"Mayfair,",
"LA",
)
finally:
ES_MNT.delete()


@pytest.mark.mounting
def test_mount_introspection_preview(local_engine_empty):
handler = PostgreSQLDataSource(
Expand Down Expand Up @@ -140,8 +176,8 @@ def test_cross_joins(local_engine_empty):
"""SELECT "test/pg_mount".fruits.fruit_id,
test_mg_mount.stuff.name,
"test/pg_mount".fruits.name as spirit_fruit
FROM "test/pg_mount".fruits
JOIN test_mg_mount.stuff
FROM "test/pg_mount".fruits
JOIN test_mg_mount.stuff
ON "test/pg_mount".fruits.fruit_id = test_mg_mount.stuff.duration"""
)
== [(2, "James", "orange")]
Expand Down
4 changes: 2 additions & 2 deletions test/splitgraph/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ def _mount_elasticsearch(repository):
},
"schema": {
"account_number": "integer",
"balance": "integer",
"balance": "double precision",
"firstname": "character varying (20)",
"lastname": "character varying (20)",
"age": "integer",
"age": "smallint",
"gender": "character varying (1)",
"address": "text",
"employer": "character varying (10)",
Expand Down

0 comments on commit 4a1cdc2

Please sign in to comment.