-
Notifications
You must be signed in to change notification settings - Fork 606
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integration tests for YDB external datasource (over YQ) (#3899)
- Loading branch information
1 parent
d675d50
commit 632a236
Showing
17 changed files
with
301 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import logging | ||
import pytest | ||
|
||
import ydb.public.api.protos.draft.fq_pb2 as fq | ||
import ydb.public.api.protos.ydb_value_pb2 as ydb | ||
from ydb.tests.tools.fq_runner.kikimr_utils import yq_v2 | ||
|
||
from ydb.tests.tools.fq_runner.fq_client import FederatedQueryClient | ||
from utils.settings import Settings | ||
|
||
|
||
class TestYdb: | ||
@yq_v2 | ||
@pytest.mark.parametrize("fq_client", [{"folder_id": "my_folder"}], indirect=True) | ||
def test_simple(self, fq_client: FederatedQueryClient, settings: Settings): | ||
table_name = 'simple_table' | ||
conn_name = f'conn_{table_name}' | ||
query_name = f'query_{table_name}' | ||
|
||
fq_client.create_ydb_connection( | ||
name=conn_name, | ||
database_id=settings.ydb.dbname, | ||
) | ||
|
||
sql = fR''' | ||
SELECT * | ||
FROM {conn_name}.{table_name}; | ||
''' | ||
|
||
query_id = fq_client.create_query(query_name, sql, type=fq.QueryContent.QueryType.ANALYTICS).result.query_id | ||
fq_client.wait_query_status(query_id, fq.QueryMeta.COMPLETED) | ||
|
||
data = fq_client.get_result_data(query_id) | ||
result_set = data.result.result_set | ||
logging.debug(str(result_set)) | ||
assert len(result_set.columns) == 1 | ||
assert result_set.columns[0].name == "number" | ||
assert result_set.columns[0].type == ydb.Type( | ||
optional_type=ydb.OptionalType(item=ydb.Type(type_id=ydb.Type.INT32)) | ||
) | ||
assert len(result_set.rows) == 3 | ||
assert result_set.rows[0].items[0].int32_value == 1 | ||
assert result_set.rows[1].items[0].int32_value == 2 | ||
assert result_set.rows[2].items[0].int32_value == 3 |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
|
||
set -ex | ||
|
||
/ydb -p ${PROFILE} yql -s ' | ||
CREATE TABLE simple_table (number Int32, PRIMARY KEY (number)); | ||
COMMIT; | ||
INSERT INTO simple_table (number) VALUES | ||
(1), | ||
(2), | ||
(3); | ||
COMMIT; | ||
CREATE TABLE join_table (id Int32, data STRING, PRIMARY KEY (id)); | ||
COMMIT; | ||
INSERT INTO join_table (id, data) VALUES | ||
(1, "ydb10"), | ||
(2, "ydb20"), | ||
(3, "ydb30"); | ||
COMMIT; | ||
' | ||
|
||
retVal=$? | ||
if [ $retVal -ne 0 ]; then | ||
echo $retVal | ||
exit $retVal | ||
fi | ||
|
||
echo $(date +"%T.%6N") "SUCCESS" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
set -ex | ||
|
||
export PROFILE=tests-ydb-client-$(LC_ALL=C tr -dc A-Za-z0-9 </dev/urandom | head -c 8) | ||
|
||
# Wait until server is up | ||
timeout 30s bash -c 'until /ydb --endpoint grpc://tests-fq-generic-ydb:2136 --database /local scheme ls; do sleep 3; done' | ||
|
||
# Run initialization scripts | ||
/ydb config profile create ${PROFILE} --endpoint grpc://tests-fq-generic-ydb:2136 --database /local | ||
/bin/bash ./01_basic.sh |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.