aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorqrort <qrort@yandex-team.com>2023-03-16 21:10:13 +0300
committerqrort <qrort@yandex-team.com>2023-03-16 21:10:13 +0300
commit750b348097bc9cfc09fdb15b3cc689656b8b2832 (patch)
treef623b7f0dd48f1977500726435aaab589abb6704
parenta15045c0d0c51e6b98fd8b2bea6585f6a9a9985d (diff)
downloadydb-750b348097bc9cfc09fdb15b3cc689656b8b2832.tar.gz
redirect stdin,stdout,stderr to files, update run script, collect test report
-rw-r--r--ydb/tests/functional/README.md13
-rw-r--r--ydb/tests/library/harness/daemon.py25
-rw-r--r--ydb/tests/oss/launch/__init__.py (renamed from ydb/tests/oss/prepare/__init__.py)0
-rw-r--r--ydb/tests/oss/launch/compile_protos.py (renamed from ydb/tests/oss/prepare/compile_protos.py)0
-rw-r--r--ydb/tests/oss/launch/generate_test_context.py (renamed from ydb/tests/oss/prepare/generate_test_context.py)7
-rw-r--r--ydb/tests/oss/launch/launch.py37
-rwxr-xr-xydb/tests/oss/launch/prepare.sh19
-rw-r--r--ydb/tests/oss/launch/ya.make (renamed from ydb/tests/oss/prepare/ya.make)1
-rwxr-xr-xydb/tests/oss/prepare/prepare.sh19
-rw-r--r--ydb/tests/oss/ya.make2
10 files changed, 86 insertions, 37 deletions
diff --git a/ydb/tests/functional/README.md b/ydb/tests/functional/README.md
index a46021eb82..bd9e5b9387 100644
--- a/ydb/tests/functional/README.md
+++ b/ydb/tests/functional/README.md
@@ -22,11 +22,16 @@ YDB function tests can be run via pytest. To launch them, complete the following
```
export build_root=~/ydbwork/build
```
-5. Launch the script, which prepares the environment for YDB tests:
+5. Launch the script, which prepares the environment:
```
- source ${source_root}/ydb/tests/oss/prepare/prepare.sh
+ source ${source_root}/ydb/tests/oss/launch/prepare.sh
```
-6. The script will put you inside directory with test sources, and you can run them:
+7. Launch tests:
```
- pytest -s
+ python ${source_root}/ydb/tests/oss/launch/launch.py --test-dir ${source_root}/ydb/tests/functional --xml-dir ${source_root}/ydb/tests/functional/test-results/xml
+ ```
+ Note that you can also run a specific suite via `--suite` argument.
+6. The script invoke the tests. After that, you can see test report:
+ ```
+ cat ${source_root}/ydb/tests/functional/test-results/xml/res.xml
```
diff --git a/ydb/tests/library/harness/daemon.py b/ydb/tests/library/harness/daemon.py
index 1bff987f71..e92333a053 100644
--- a/ydb/tests/library/harness/daemon.py
+++ b/ydb/tests/library/harness/daemon.py
@@ -10,6 +10,7 @@ from yatest.common import process
import six
from ydb.tests.library.common.wait_for import wait_for
+from ydb.tests.library.common import yatest_common
from . import param_constants
@@ -54,9 +55,17 @@ class SeveralDaemonErrors(RuntimeError):
class Daemon(object):
- def __init__(self, command, cwd, timeout, stdin_file=None, stdout_file=None,
- stderr_file=None, stderr_on_error_lines=0, core_pattern=None):
-
+ def __init__(
+ self,
+ command,
+ cwd,
+ timeout,
+ stdin_file=yatest_common.work_path('stdin'),
+ stdout_file=yatest_common.work_path('stdout'),
+ stderr_file=yatest_common.work_path('stderr'),
+ stderr_on_error_lines=0,
+ core_pattern=None
+ ):
self.__cwd = cwd
self.__timeout = timeout
self.__command = tuple(command)
@@ -65,13 +74,9 @@ class Daemon(object):
self.__killed = False
self.__core_pattern = core_pattern
self.logger = logger.getChild(self.__class__.__name__)
- self.__stdout_file = sys.stdout
- self.__stdin_file = sys.stdin
- self.__stderr_file = sys.stderr
- if stdout_file is not None:
- self.__stdout_file = open(stdout_file, mode='w+b')
- self.__stdin_file = open(stdin_file, mode='w+b')
- self.__stderr_file = open(stderr_file, mode='w+b')
+ self.__stdout_file = open(stdout_file, mode='w+b')
+ self.__stdin_file = open(stdin_file, mode='w+b')
+ self.__stderr_file = open(stderr_file, mode='w+b')
@property
def daemon(self):
diff --git a/ydb/tests/oss/prepare/__init__.py b/ydb/tests/oss/launch/__init__.py
index e69de29bb2..e69de29bb2 100644
--- a/ydb/tests/oss/prepare/__init__.py
+++ b/ydb/tests/oss/launch/__init__.py
diff --git a/ydb/tests/oss/prepare/compile_protos.py b/ydb/tests/oss/launch/compile_protos.py
index 2c21ad7613..2c21ad7613 100644
--- a/ydb/tests/oss/prepare/compile_protos.py
+++ b/ydb/tests/oss/launch/compile_protos.py
diff --git a/ydb/tests/oss/prepare/generate_test_context.py b/ydb/tests/oss/launch/generate_test_context.py
index 43c4158fc3..99ec618e4e 100644
--- a/ydb/tests/oss/prepare/generate_test_context.py
+++ b/ydb/tests/oss/launch/generate_test_context.py
@@ -8,14 +8,15 @@ test_context = {
'output_path': '',
'project_path': 'ydb/tests/functional',
'source_root': '',
- 'work_path': ''
+ 'work_path': 'ydb/tests/functional/test-results'
}
}
if __name__ == '__main__':
parser = ArgumentParser()
parser.add_argument('--build-root', required=True, help='YDB build directory')
- parser.add_argument('--source-root', type=str, required=True, help='YDB root directory')
+ parser.add_argument('--source-root', required=True, help='YDB root directory')
+ parser.add_argument('--out-dir', required=True, help='test.context file dir')
args = parser.parse_args()
test_context['runtime']['build_root'] = args.build_root
test_context['runtime']['output_path'] = os.path.join(
@@ -28,5 +29,5 @@ if __name__ == '__main__':
'ydb/tests/functional/test-results/py3test'
)
strdata = json.dumps(test_context, indent=4)
- with open("test.context", "w") as outfile:
+ with open(os.path.join(args.out_dir, "test.context"), "w") as outfile:
outfile.write(strdata)
diff --git a/ydb/tests/oss/launch/launch.py b/ydb/tests/oss/launch/launch.py
new file mode 100644
index 0000000000..c02e9b9cfa
--- /dev/null
+++ b/ydb/tests/oss/launch/launch.py
@@ -0,0 +1,37 @@
+from argparse import ArgumentParser
+import xml.dom.minidom
+import pytest
+import os
+
+
+disabled_suites = {
+ 'clickbench', 'dynumber', 'large_serializable', 'rename', 'serializable'
+}
+
+if __name__ == '__main__':
+ parser = ArgumentParser()
+ parser.add_argument('--test-dir', required=True, help='tests source dir')
+ parser.add_argument('--xml-dir', required=True, help='XML dir')
+ parser.add_argument('--suite', help='suite to run')
+ args = parser.parse_args()
+ xml_res_file = os.path.join(args.xml_dir, 'res.xml')
+ suites = []
+ if args.suite:
+ suites = [args.suite]
+ else:
+ suites = [name for name in os.listdir(args.test_dir) if os.path.isdir(os.path.join(args.test_dir, name))]
+ suites.sort()
+
+ for suite in suites:
+ if suite not in disabled_suites:
+ print('Running suite: ', suite)
+ xml_path = os.path.join(args.xml_dir, suite)
+ pytest_args = "-o junit_logging=log -o junit_log_passing_tests=False -v --junit-xml={} {}".format(
+ xml_path,
+ os.path.join(args.test_dir, suite)
+ )
+ pytest.main(pytest_args.split(' '))
+ dom = xml.dom.minidom.parse(xml_path)
+ pretty_xml = dom.toprettyxml()
+ with open(xml_res_file, 'a') as xml_res:
+ xml_res.write(pretty_xml)
diff --git a/ydb/tests/oss/launch/prepare.sh b/ydb/tests/oss/launch/prepare.sh
new file mode 100755
index 0000000000..33052d1fa8
--- /dev/null
+++ b/ydb/tests/oss/launch/prepare.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+python ${source_root}/ydb/tests/oss/launch/compile_protos.py --source-root ${source_root}
+
+testresults=${source_root}/ydb/tests/functional/test-results
+
+mkdir ${testresults}
+mkdir ${testresults}/xml
+mkdir ${testresults}/py3test
+mkdir ${testresults}/py3test/testing_out_stuff
+
+python ${source_root}/ydb/tests/oss/launch/generate_test_context.py --build-root ${build_root} --source-root ${source_root} --out-dir ${testresults}
+
+export PYTHONPATH=${source_root}:${source_root}/library/python/testing/yatest_common:${source_root}/library/python/testing:${source_root}/library/python/pytest/plugins:${source_root}/ydb/tests/oss/canonical
+
+export YDB_DRIVER_BINARY="ydb/apps/ydbd/ydbd"
+export PYTEST_PLUGINS=ya,conftests,canonical
+export YA_TEST_CONTEXT_FILE=${testresults}/test.context
+export YDB_OPENSOURCE=yes
diff --git a/ydb/tests/oss/prepare/ya.make b/ydb/tests/oss/launch/ya.make
index 615fa58abe..61ba373fb9 100644
--- a/ydb/tests/oss/prepare/ya.make
+++ b/ydb/tests/oss/launch/ya.make
@@ -4,6 +4,7 @@ PY_SRCS(
__init__.py
compile_protos.py
generate_test_context.py
+ launch.py
)
END()
diff --git a/ydb/tests/oss/prepare/prepare.sh b/ydb/tests/oss/prepare/prepare.sh
deleted file mode 100755
index 519e291e75..0000000000
--- a/ydb/tests/oss/prepare/prepare.sh
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/bin/bash
-
-python ${source_root}/ydb/tests/oss/prepare/compile_protos.py --source-root ${source_root}
-
-cd ${source_root}/ydb/tests/functional
-mkdir test-results
-mkdir test-results/py3test
-mkdir test-results/py3test/testing_out_stuff
-
-cd test-results
-python ${source_root}/ydb/tests/oss/prepare/generate_test_context.py --build-root ${build_root} --source-root ${source_root}
-cd ..
-
-export PYTHONPATH=${source_root}:${source_root}/library/python/testing/yatest_common:${source_root}/library/python/testing:${source_root}/library/python/pytest/plugins:${source_root}/ydb/tests/oss/canonical
-
-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-results/test.context
-export YDB_OPENSOURCE=yes
diff --git a/ydb/tests/oss/ya.make b/ydb/tests/oss/ya.make
index 76c3fb1d4f..f9bf3f8458 100644
--- a/ydb/tests/oss/ya.make
+++ b/ydb/tests/oss/ya.make
@@ -1,5 +1,5 @@
RECURSE(
canonical
- prepare
+ launch
ydb_sdk_import
)