aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorqrort <qrort@yandex-team.com>2023-03-16 12:16:32 +0300
committerqrort <qrort@yandex-team.com>2023-03-16 12:16:32 +0300
commitc0a27a5678596a0eb1a60ecf3fc4135531675bf7 (patch)
treeec8bb196ef436a221016280ee4a807f7d8dc9b6e
parent08655020c8e2770e2462b48a54106ef30564ea69 (diff)
downloadydb-c0a27a5678596a0eb1a60ecf3fc4135531675bf7.tar.gz
rename files for pytest auto-discovery, set canondata roots, tweak imports, update README
-rw-r--r--ydb/tests/functional/README.md17
-rwxr-xr-xydb/tests/functional/blobstorage/test_pdisk_format_info.py (renamed from ydb/tests/functional/blobstorage/pdisk_format_info.py)0
-rw-r--r--ydb/tests/functional/blobstorage/test_replication.py (renamed from ydb/tests/functional/blobstorage/replication.py)0
-rw-r--r--ydb/tests/functional/blobstorage/test_self_heal.py (renamed from ydb/tests/functional/blobstorage/self_heal.py)0
-rw-r--r--ydb/tests/functional/blobstorage/test_tablet_channel_migration.py (renamed from ydb/tests/functional/blobstorage/tablet_channel_migration.py)0
-rw-r--r--ydb/tests/functional/blobstorage/ya.make8
-rw-r--r--ydb/tests/functional/hive/test_create_tablets.py (renamed from ydb/tests/functional/hive/create_tablets.py)0
-rw-r--r--ydb/tests/functional/hive/ya.make2
-rw-r--r--ydb/tests/functional/scheme_tests/tablet_scheme_tests.py2
-rw-r--r--ydb/tests/functional/scheme_tests/ya.make2
-rw-r--r--ydb/tests/functional/serverless/test_serverless.py (renamed from ydb/tests/functional/serverless/test.py)0
-rw-r--r--ydb/tests/functional/serverless/ya.make2
-rw-r--r--ydb/tests/functional/suite_tests/test_base.py2
-rw-r--r--ydb/tests/functional/suite_tests/ya.make1
-rw-r--r--ydb/tests/library/sqs/tables.py2
-rw-r--r--ydb/tests/library/sqs/test_base.py2
-rw-r--r--ydb/tests/library/sqs/ya.make2
-rw-r--r--ydb/tests/oss/canonical/conftest.py13
-rw-r--r--ydb/tests/oss/prepare/generate_test_context.py6
-rwxr-xr-xydb/tests/oss/prepare/prepare.sh4
20 files changed, 37 insertions, 28 deletions
diff --git a/ydb/tests/functional/README.md b/ydb/tests/functional/README.md
index e2ad851d346..a46021eb824 100644
--- a/ydb/tests/functional/README.md
+++ b/ydb/tests/functional/README.md
@@ -2,9 +2,16 @@
YDB function tests can be run via pytest. To launch them, complete the following steps:
+0. Note that to run those tests, you will need Python version 3.10+ and Pytest version 7+.
1. Build YDB. You can use [this guide](https://github.com/ydb-platform/ydb/blob/main/BUILD.md).
2. Install `grpc-tools` package. You can use [this guide](https://grpc.io/docs/languages/python/quickstart).
-3. Initialize the following enviroment variables:
+3. Install some more packages:
+ ```
+ pip install PyHamcrest
+ pip install tornado
+ pip install xmltodict
+ ```
+4. Initialize the following enviroment variables:
- `source_root` should match the root of YDB GitHub repo. If you did not change any of the commands from YDB
build guide, then you should export the variable via
```
@@ -15,15 +22,11 @@ YDB function tests can be run via pytest. To launch them, complete the following
```
export build_root=~/ydbwork/build
```
- - `test_target` should match the suite from functional tests, which you wish to run. For example, you can export this variable via
- ```
- export test_target=ydb_cli
- ```
-4. Launch the script, which prepares the environment for YDB tests:
+5. Launch the script, which prepares the environment for YDB tests:
```
source ${source_root}/ydb/tests/oss/prepare/prepare.sh
```
-5. The script will put you inside directory with test sources, and you can run them:
+6. The script will put you inside directory with test sources, and you can run them:
```
pytest -s
```
diff --git a/ydb/tests/functional/blobstorage/pdisk_format_info.py b/ydb/tests/functional/blobstorage/test_pdisk_format_info.py
index 6f6ee7ed27a..6f6ee7ed27a 100755
--- a/ydb/tests/functional/blobstorage/pdisk_format_info.py
+++ b/ydb/tests/functional/blobstorage/test_pdisk_format_info.py
diff --git a/ydb/tests/functional/blobstorage/replication.py b/ydb/tests/functional/blobstorage/test_replication.py
index cdf6df6f3f5..cdf6df6f3f5 100644
--- a/ydb/tests/functional/blobstorage/replication.py
+++ b/ydb/tests/functional/blobstorage/test_replication.py
diff --git a/ydb/tests/functional/blobstorage/self_heal.py b/ydb/tests/functional/blobstorage/test_self_heal.py
index e18b22bae17..e18b22bae17 100644
--- a/ydb/tests/functional/blobstorage/self_heal.py
+++ b/ydb/tests/functional/blobstorage/test_self_heal.py
diff --git a/ydb/tests/functional/blobstorage/tablet_channel_migration.py b/ydb/tests/functional/blobstorage/test_tablet_channel_migration.py
index 2223404de2f..2223404de2f 100644
--- a/ydb/tests/functional/blobstorage/tablet_channel_migration.py
+++ b/ydb/tests/functional/blobstorage/test_tablet_channel_migration.py
diff --git a/ydb/tests/functional/blobstorage/ya.make b/ydb/tests/functional/blobstorage/ya.make
index 9dfebe22c99..7d240d08017 100644
--- a/ydb/tests/functional/blobstorage/ya.make
+++ b/ydb/tests/functional/blobstorage/ya.make
@@ -2,10 +2,10 @@ PY3TEST()
ENV(YDB_DRIVER_BINARY="ydb/apps/ydbd/ydbd")
TEST_SRCS(
- pdisk_format_info.py
- replication.py
- self_heal.py
- tablet_channel_migration.py
+ test_pdisk_format_info.py
+ test_replication.py
+ test_self_heal.py
+ test_tablet_channel_migration.py
)
IF (SANITIZER_TYPE)
diff --git a/ydb/tests/functional/hive/create_tablets.py b/ydb/tests/functional/hive/test_create_tablets.py
index 57db28ffa0c..57db28ffa0c 100644
--- a/ydb/tests/functional/hive/create_tablets.py
+++ b/ydb/tests/functional/hive/test_create_tablets.py
diff --git a/ydb/tests/functional/hive/ya.make b/ydb/tests/functional/hive/ya.make
index dde32bff182..e2751fc7029 100644
--- a/ydb/tests/functional/hive/ya.make
+++ b/ydb/tests/functional/hive/ya.make
@@ -1,8 +1,8 @@
PY3TEST()
ENV(YDB_DRIVER_BINARY="ydb/apps/ydbd/ydbd")
TEST_SRCS(
- create_tablets.py
hive_matchers.py
+ test_create_tablets.py
test_kill_tablets.py
test_drain.py
)
diff --git a/ydb/tests/functional/scheme_tests/tablet_scheme_tests.py b/ydb/tests/functional/scheme_tests/tablet_scheme_tests.py
index a057a6c5d83..045a1bf0bab 100644
--- a/ydb/tests/functional/scheme_tests/tablet_scheme_tests.py
+++ b/ydb/tests/functional/scheme_tests/tablet_scheme_tests.py
@@ -10,6 +10,7 @@ from ydb.tests.library.common.local_db_scheme import get_scheme
from ydb.tests.library.common.types import TabletTypes
from ydb.tests.library.harness.kikimr_cluster import kikimr_cluster_factory
from ydb.tests.library.kv.helpers import create_tablets_and_wait_for_start
+from ydb.tests.oss.canonical import set_canondata_root
def write_canonical_file(tablet, content):
@@ -55,6 +56,7 @@ class TestTabletSchemes(object):
cls.shard_index = itertools.count(start=1)
cls.to_prepare = (
TabletTypes.PERSQUEUE, TabletTypes.KEYVALUEFLAT, TabletTypes.FLAT_DATASHARD, TabletTypes.KESUS)
+ set_canondata_root('ydb/tests/functional/scheme_tests/canondata')
def prepare_tablet(self, tablet_type):
if tablet_type in self.to_prepare:
diff --git a/ydb/tests/functional/scheme_tests/ya.make b/ydb/tests/functional/scheme_tests/ya.make
index 6d89eed3504..dfa1b5b75be 100644
--- a/ydb/tests/functional/scheme_tests/ya.make
+++ b/ydb/tests/functional/scheme_tests/ya.make
@@ -17,7 +17,7 @@ DATA(
PEERDIR(
ydb/tests/library
+ ydb/tests/oss/canonical
)
END()
-
diff --git a/ydb/tests/functional/serverless/test.py b/ydb/tests/functional/serverless/test_serverless.py
index fefe1a2d77c..fefe1a2d77c 100644
--- a/ydb/tests/functional/serverless/test.py
+++ b/ydb/tests/functional/serverless/test_serverless.py
diff --git a/ydb/tests/functional/serverless/ya.make b/ydb/tests/functional/serverless/ya.make
index 7902668e950..d81b0bb8f41 100644
--- a/ydb/tests/functional/serverless/ya.make
+++ b/ydb/tests/functional/serverless/ya.make
@@ -2,7 +2,7 @@ PY3TEST()
TEST_SRCS(
conftest.py
- test.py
+ test_serverless.py
)
FORK_TEST_FILES()
diff --git a/ydb/tests/functional/suite_tests/test_base.py b/ydb/tests/functional/suite_tests/test_base.py
index 738ae502709..9a6b180cb31 100644
--- a/ydb/tests/functional/suite_tests/test_base.py
+++ b/ydb/tests/functional/suite_tests/test_base.py
@@ -18,6 +18,7 @@ import ydb.tests.library.common.yatest_common as yatest_common
from ydb.tests.library.harness.kikimr_cluster import kikimr_cluster_factory
from ydb.tests.library.harness.kikimr_config import KikimrConfigGenerator
from ydb.tests.oss.ydb_sdk_import import ydb
+from ydb.tests.oss.canonical import set_canondata_root
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
@@ -260,6 +261,7 @@ class BaseSuiteRunner(object):
cls.query_id = itertools.count(start=1)
cls.files = {}
cls.plan = False
+ set_canondata_root('ydb/tests/functional/suite_tests/canondata')
@classmethod
def teardown_class(cls):
diff --git a/ydb/tests/functional/suite_tests/ya.make b/ydb/tests/functional/suite_tests/ya.make
index c6ad71be643..4aaf44cfcdf 100644
--- a/ydb/tests/functional/suite_tests/ya.make
+++ b/ydb/tests/functional/suite_tests/ya.make
@@ -23,6 +23,7 @@ IF (NOT SANITIZER_TYPE AND NOT WITH_VALGRIND)
PEERDIR(
ydb/tests/library
+ ydb/tests/oss/canonical
ydb/tests/oss/ydb_sdk_import
)
diff --git a/ydb/tests/library/sqs/tables.py b/ydb/tests/library/sqs/tables.py
index 2f7eef4961b..4c17299c755 100644
--- a/ydb/tests/library/sqs/tables.py
+++ b/ydb/tests/library/sqs/tables.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-import ydb
+from ydb.tests.oss.ydb_sdk_import import ydb
from enum import Enum
diff --git a/ydb/tests/library/sqs/test_base.py b/ydb/tests/library/sqs/test_base.py
index 138ca4608aa..b390fb43cc7 100644
--- a/ydb/tests/library/sqs/test_base.py
+++ b/ydb/tests/library/sqs/test_base.py
@@ -20,7 +20,7 @@ from ydb.tests.library.sqs.tables import create_all_tables as create_all_sqs_tab
from ydb.tests.library.sqs.requests_client import SqsHttpApi
from ydb.tests.library.sqs.matchers import ReadResponseMatcher
-import ydb
+from ydb.tests.oss.ydb_sdk_import import ydb
from concurrent import futures
diff --git a/ydb/tests/library/sqs/ya.make b/ydb/tests/library/sqs/ya.make
index 8fead202b56..4dcae89751d 100644
--- a/ydb/tests/library/sqs/ya.make
+++ b/ydb/tests/library/sqs/ya.make
@@ -15,7 +15,7 @@ IF (NOT PYTHON3)
ENDIF()
PEERDIR(
- ydb/public/sdk/python
+ ydb/tests/oss/ydb_sdk_import
contrib/python/xmltodict
)
diff --git a/ydb/tests/oss/canonical/conftest.py b/ydb/tests/oss/canonical/conftest.py
index 8d1626c29a0..478b461f2cb 100644
--- a/ydb/tests/oss/canonical/conftest.py
+++ b/ydb/tests/oss/canonical/conftest.py
@@ -5,9 +5,10 @@ from ydb.tests.oss.canonical import canons_meta, is_oss
@pytest.fixture(scope='function', autouse=is_oss)
def set_canondata_directory(request):
test_info = request.node._nodeid.split('::')
- test_filename = test_info[0].split('/')[-1][:-3]
- test_classname = test_info[1]
- test_name = test_info[2]
- for c in ['[', ']', '/']:
- test_name = test_name.replace(c, '_')
- canons_meta.directory = '.'.join([test_filename, test_classname, test_name])
+ if len(test_info) > 2:
+ test_filename = test_info[0].split('/')[-1][:-3]
+ test_classname = test_info[1]
+ test_name = test_info[2]
+ for c in ['[', ']', '/']:
+ test_name = test_name.replace(c, '_')
+ canons_meta.directory = '.'.join([test_filename, test_classname, test_name])
diff --git a/ydb/tests/oss/prepare/generate_test_context.py b/ydb/tests/oss/prepare/generate_test_context.py
index 7d23d53a9f6..43c4158fc36 100644
--- a/ydb/tests/oss/prepare/generate_test_context.py
+++ b/ydb/tests/oss/prepare/generate_test_context.py
@@ -6,7 +6,7 @@ test_context = {
'runtime': {
'build_root': '',
'output_path': '',
- 'project_path': 'ydb/tests/functional/ydb_cli',
+ 'project_path': 'ydb/tests/functional',
'source_root': '',
'work_path': ''
}
@@ -20,12 +20,12 @@ if __name__ == '__main__':
test_context['runtime']['build_root'] = args.build_root
test_context['runtime']['output_path'] = os.path.join(
args.source_root,
- 'ydb/tests/functional/ydb_cli/test-results/py3test/testing_out_stuff'
+ 'ydb/tests/functional/test-results/py3test/testing_out_stuff'
)
test_context['runtime']['source_root'] = args.source_root
test_context['runtime']['work_path'] = os.path.join(
args.source_root,
- 'ydb/tests/functional/ydb_cli/test-results/py3test'
+ 'ydb/tests/functional/test-results/py3test'
)
strdata = json.dumps(test_context, indent=4)
with open("test.context", "w") as outfile:
diff --git a/ydb/tests/oss/prepare/prepare.sh b/ydb/tests/oss/prepare/prepare.sh
index 82bdc35d7cd..519e291e758 100755
--- a/ydb/tests/oss/prepare/prepare.sh
+++ b/ydb/tests/oss/prepare/prepare.sh
@@ -2,7 +2,7 @@
python ${source_root}/ydb/tests/oss/prepare/compile_protos.py --source-root ${source_root}
-cd ${source_root}/ydb/tests/functional/${test_target}
+cd ${source_root}/ydb/tests/functional
mkdir test-results
mkdir test-results/py3test
mkdir test-results/py3test/testing_out_stuff
@@ -15,5 +15,5 @@ export PYTHONPATH=${source_root}:${source_root}/library/python/testing/yatest_co
export YDB_DRIVER_BINARY="ydb/apps/ydbd/ydbd"
export PYTEST_PLUGINS=ya,conftests,canonical
-export YA_TEST_CONTEXT_FILE=${source_root}/ydb/tests/functional/${test_target}/test-results/test.context
+export YA_TEST_CONTEXT_FILE=${source_root}/ydb/tests/functional/test-results/test.context
export YDB_OPENSOURCE=yes