-
Notifications
You must be signed in to change notification settings - Fork 605
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0b30738
commit fd31a6a
Showing
3 changed files
with
88 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# -*- coding: utf-8 -*- | ||
from ydb.tests.library.harness.kikimr_runner import KiKiMR | ||
from ydb.tests.library.harness.kikimr_config import KikimrConfigGenerator | ||
from ydb.tests.library.common.types import Erasure | ||
|
||
import ydb | ||
|
||
|
||
class TestExample(object): | ||
""" | ||
Example for python test | ||
TODO: change description to yours | ||
""" | ||
@classmethod | ||
def setup_class(cls): | ||
# TODO: remove comment below | ||
# This cluster will be initialized before all tests in current suite and will be stopped after all tests | ||
# See KikimrConfigGenerator for full possibilities (feature flags, configs, erasure, etc.) | ||
cls.cluster = KiKiMR(KikimrConfigGenerator(erasure=Erasure.NONE)) | ||
cls.cluster.start() | ||
|
||
cls.endpoint = "%s:%s" % ( | ||
cls.cluster.nodes[1].host, cls.cluster.nodes[1].port | ||
) | ||
cls.driver = ydb.Driver( | ||
ydb.DriverConfig( | ||
database='/Root', | ||
endpoint=cls.endpoint | ||
) | ||
) | ||
cls.driver.wait() | ||
|
||
@classmethod | ||
def teardown_class(cls): | ||
cls.driver.stop() | ||
cls.cluster.stop() | ||
|
||
def test_example(self): # TODO: change test name to yours | ||
""" | ||
Test description | ||
TODO: change description to yours | ||
""" | ||
|
||
with ydb.QuerySessionPool(self.driver) as session_pool: | ||
table_name = "unique_table_name_for_test" | ||
value = 42 | ||
|
||
query = f""" | ||
CREATE TABLE `{table_name}` ( | ||
id Int64 NOT NULL, | ||
value Int64 NOT NULL, | ||
PRIMARY KEY (id) | ||
) """ | ||
session_pool.execute_with_retries(query) | ||
|
||
query = f"""UPSERT INTO `{table_name}` (id, value) VALUES (1, {value});""" | ||
session_pool.execute_with_retries(query) | ||
|
||
query = f"""SELECT id, value FROM `{table_name}` WHERE id = 1;""" | ||
result_sets = session_pool.execute_with_retries(query) | ||
|
||
assert result_sets[0].rows[0]["id"] == 1 | ||
assert result_sets[0].rows[0]["value"] == 42 | ||
|
||
def test_example2(self): # TODO: change test name to yours | ||
""" | ||
There can be more than 1 test in the suite | ||
""" | ||
pass |
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,18 @@ | ||
PY3TEST() | ||
ENV(YDB_DRIVER_BINARY="ydb/apps/ydbd/ydbd") | ||
|
||
TEST_SRCS( | ||
test_example.py # TODO: change file name to yours | ||
) | ||
|
||
SIZE(MEDIUM) | ||
|
||
DEPENDS( | ||
ydb/apps/ydbd | ||
) | ||
|
||
PEERDIR( | ||
ydb/tests/library | ||
) | ||
|
||
END() |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
RECURSE( | ||
example | ||
fq | ||
functional | ||
library | ||
|