aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordcherednik <dcherednik@ydb.tech>2023-07-21 11:54:24 +0300
committerdcherednik <dcherednik@ydb.tech>2023-07-21 11:54:24 +0300
commit4e61cae929165ef52b951130a966f2c9ba5319bd (patch)
treea2316e76bfe273617df2e122e943b8202f22932b
parent3b23aaacfaa9814c88de0113c7732cddaf99a448 (diff)
downloadydb-4e61cae929165ef52b951130a966f2c9ba5319bd.tar.gz
Move kqp related tests to ydb.
-rw-r--r--ydb/tests/CMakeLists.txt1
-rw-r--r--ydb/tests/functional/CMakeLists.txt9
-rw-r--r--ydb/tests/functional/kqp/CMakeLists.txt10
-rw-r--r--ydb/tests/functional/kqp/kqp_indexes/CMakeLists.darwin-x86_64.txt66
-rw-r--r--ydb/tests/functional/kqp/kqp_indexes/CMakeLists.linux-aarch64.txt69
-rw-r--r--ydb/tests/functional/kqp/kqp_indexes/CMakeLists.linux-x86_64.txt71
-rw-r--r--ydb/tests/functional/kqp/kqp_indexes/CMakeLists.txt17
-rw-r--r--ydb/tests/functional/kqp/kqp_indexes/CMakeLists.windows-x86_64.txt59
-rw-r--r--ydb/tests/functional/kqp/kqp_indexes/main.cpp149
-rw-r--r--ydb/tests/functional/kqp/kqp_indexes/ya.make23
-rw-r--r--ydb/tests/functional/kqp/kqp_query_session/CMakeLists.darwin-x86_64.txt74
-rw-r--r--ydb/tests/functional/kqp/kqp_query_session/CMakeLists.linux-aarch64.txt77
-rw-r--r--ydb/tests/functional/kqp/kqp_query_session/CMakeLists.linux-x86_64.txt79
-rw-r--r--ydb/tests/functional/kqp/kqp_query_session/CMakeLists.txt17
-rw-r--r--ydb/tests/functional/kqp/kqp_query_session/CMakeLists.windows-x86_64.txt67
-rw-r--r--ydb/tests/functional/kqp/kqp_query_session/main.cpp121
-rw-r--r--ydb/tests/functional/kqp/kqp_query_session/ya.make28
-rw-r--r--ydb/tests/functional/kqp/ya.make4
-rw-r--r--ydb/tests/functional/ya.make1
19 files changed, 942 insertions, 0 deletions
diff --git a/ydb/tests/CMakeLists.txt b/ydb/tests/CMakeLists.txt
index ba1c90c695..01bef33295 100644
--- a/ydb/tests/CMakeLists.txt
+++ b/ydb/tests/CMakeLists.txt
@@ -6,4 +6,5 @@
# original buildsystem will not be accepted.
+add_subdirectory(functional)
add_subdirectory(tools)
diff --git a/ydb/tests/functional/CMakeLists.txt b/ydb/tests/functional/CMakeLists.txt
new file mode 100644
index 0000000000..d4d91abdcd
--- /dev/null
+++ b/ydb/tests/functional/CMakeLists.txt
@@ -0,0 +1,9 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+add_subdirectory(kqp)
diff --git a/ydb/tests/functional/kqp/CMakeLists.txt b/ydb/tests/functional/kqp/CMakeLists.txt
new file mode 100644
index 0000000000..fadd85119e
--- /dev/null
+++ b/ydb/tests/functional/kqp/CMakeLists.txt
@@ -0,0 +1,10 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+add_subdirectory(kqp_indexes)
+add_subdirectory(kqp_query_session)
diff --git a/ydb/tests/functional/kqp/kqp_indexes/CMakeLists.darwin-x86_64.txt b/ydb/tests/functional/kqp/kqp_indexes/CMakeLists.darwin-x86_64.txt
new file mode 100644
index 0000000000..b4f7a85bd0
--- /dev/null
+++ b/ydb/tests/functional/kqp/kqp_indexes/CMakeLists.darwin-x86_64.txt
@@ -0,0 +1,66 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_executable(ydb-tests-functional-kqp-kqp_indexes)
+target_link_libraries(ydb-tests-functional-kqp-kqp_indexes PUBLIC
+ contrib-libs-cxxsupp
+ yutil
+ library-cpp-cpuid_check
+ cpp-testing-unittest_main
+ cpp-threading-local_executor
+ cpp-client-ydb_table
+ cpp-client-draft
+)
+target_link_options(ydb-tests-functional-kqp-kqp_indexes PRIVATE
+ -Wl,-platform_version,macos,11.0,11.0
+ -fPIC
+ -fPIC
+ -framework
+ CoreFoundation
+)
+target_sources(ydb-tests-functional-kqp-kqp_indexes PRIVATE
+ ${CMAKE_SOURCE_DIR}/ydb/tests/functional/kqp/kqp_indexes/main.cpp
+)
+set_property(
+ TARGET
+ ydb-tests-functional-kqp-kqp_indexes
+ PROPERTY
+ SPLIT_FACTOR
+ 1
+)
+add_yunittest(
+ NAME
+ ydb-tests-functional-kqp-kqp_indexes
+ TEST_TARGET
+ ydb-tests-functional-kqp-kqp_indexes
+ TEST_ARG
+ --print-before-suite
+ --print-before-test
+ --fork-tests
+ --print-times
+ --show-fails
+)
+set_yunittest_property(
+ TEST
+ ydb-tests-functional-kqp-kqp_indexes
+ PROPERTY
+ LABELS
+ MEDIUM
+)
+set_yunittest_property(
+ TEST
+ ydb-tests-functional-kqp-kqp_indexes
+ PROPERTY
+ PROCESSORS
+ 1
+)
+target_allocator(ydb-tests-functional-kqp-kqp_indexes
+ system_allocator
+)
+vcs_info(ydb-tests-functional-kqp-kqp_indexes)
diff --git a/ydb/tests/functional/kqp/kqp_indexes/CMakeLists.linux-aarch64.txt b/ydb/tests/functional/kqp/kqp_indexes/CMakeLists.linux-aarch64.txt
new file mode 100644
index 0000000000..a2c60cd580
--- /dev/null
+++ b/ydb/tests/functional/kqp/kqp_indexes/CMakeLists.linux-aarch64.txt
@@ -0,0 +1,69 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_executable(ydb-tests-functional-kqp-kqp_indexes)
+target_link_libraries(ydb-tests-functional-kqp-kqp_indexes PUBLIC
+ contrib-libs-linux-headers
+ contrib-libs-cxxsupp
+ yutil
+ cpp-testing-unittest_main
+ cpp-threading-local_executor
+ cpp-client-ydb_table
+ cpp-client-draft
+)
+target_link_options(ydb-tests-functional-kqp-kqp_indexes PRIVATE
+ -ldl
+ -lrt
+ -Wl,--no-as-needed
+ -fPIC
+ -fPIC
+ -lpthread
+ -lrt
+ -ldl
+)
+target_sources(ydb-tests-functional-kqp-kqp_indexes PRIVATE
+ ${CMAKE_SOURCE_DIR}/ydb/tests/functional/kqp/kqp_indexes/main.cpp
+)
+set_property(
+ TARGET
+ ydb-tests-functional-kqp-kqp_indexes
+ PROPERTY
+ SPLIT_FACTOR
+ 1
+)
+add_yunittest(
+ NAME
+ ydb-tests-functional-kqp-kqp_indexes
+ TEST_TARGET
+ ydb-tests-functional-kqp-kqp_indexes
+ TEST_ARG
+ --print-before-suite
+ --print-before-test
+ --fork-tests
+ --print-times
+ --show-fails
+)
+set_yunittest_property(
+ TEST
+ ydb-tests-functional-kqp-kqp_indexes
+ PROPERTY
+ LABELS
+ MEDIUM
+)
+set_yunittest_property(
+ TEST
+ ydb-tests-functional-kqp-kqp_indexes
+ PROPERTY
+ PROCESSORS
+ 1
+)
+target_allocator(ydb-tests-functional-kqp-kqp_indexes
+ cpp-malloc-jemalloc
+)
+vcs_info(ydb-tests-functional-kqp-kqp_indexes)
diff --git a/ydb/tests/functional/kqp/kqp_indexes/CMakeLists.linux-x86_64.txt b/ydb/tests/functional/kqp/kqp_indexes/CMakeLists.linux-x86_64.txt
new file mode 100644
index 0000000000..73d7bc8954
--- /dev/null
+++ b/ydb/tests/functional/kqp/kqp_indexes/CMakeLists.linux-x86_64.txt
@@ -0,0 +1,71 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_executable(ydb-tests-functional-kqp-kqp_indexes)
+target_link_libraries(ydb-tests-functional-kqp-kqp_indexes PUBLIC
+ contrib-libs-linux-headers
+ contrib-libs-cxxsupp
+ yutil
+ library-cpp-cpuid_check
+ cpp-testing-unittest_main
+ cpp-threading-local_executor
+ cpp-client-ydb_table
+ cpp-client-draft
+)
+target_link_options(ydb-tests-functional-kqp-kqp_indexes PRIVATE
+ -ldl
+ -lrt
+ -Wl,--no-as-needed
+ -fPIC
+ -fPIC
+ -lpthread
+ -lrt
+ -ldl
+)
+target_sources(ydb-tests-functional-kqp-kqp_indexes PRIVATE
+ ${CMAKE_SOURCE_DIR}/ydb/tests/functional/kqp/kqp_indexes/main.cpp
+)
+set_property(
+ TARGET
+ ydb-tests-functional-kqp-kqp_indexes
+ PROPERTY
+ SPLIT_FACTOR
+ 1
+)
+add_yunittest(
+ NAME
+ ydb-tests-functional-kqp-kqp_indexes
+ TEST_TARGET
+ ydb-tests-functional-kqp-kqp_indexes
+ TEST_ARG
+ --print-before-suite
+ --print-before-test
+ --fork-tests
+ --print-times
+ --show-fails
+)
+set_yunittest_property(
+ TEST
+ ydb-tests-functional-kqp-kqp_indexes
+ PROPERTY
+ LABELS
+ MEDIUM
+)
+set_yunittest_property(
+ TEST
+ ydb-tests-functional-kqp-kqp_indexes
+ PROPERTY
+ PROCESSORS
+ 1
+)
+target_allocator(ydb-tests-functional-kqp-kqp_indexes
+ cpp-malloc-tcmalloc
+ libs-tcmalloc-no_percpu_cache
+)
+vcs_info(ydb-tests-functional-kqp-kqp_indexes)
diff --git a/ydb/tests/functional/kqp/kqp_indexes/CMakeLists.txt b/ydb/tests/functional/kqp/kqp_indexes/CMakeLists.txt
new file mode 100644
index 0000000000..f8b31df0c1
--- /dev/null
+++ b/ydb/tests/functional/kqp/kqp_indexes/CMakeLists.txt
@@ -0,0 +1,17 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" AND NOT HAVE_CUDA)
+ include(CMakeLists.linux-aarch64.txt)
+elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
+ include(CMakeLists.darwin-x86_64.txt)
+elseif (WIN32 AND CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64" AND NOT HAVE_CUDA)
+ include(CMakeLists.windows-x86_64.txt)
+elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND NOT HAVE_CUDA)
+ include(CMakeLists.linux-x86_64.txt)
+endif()
diff --git a/ydb/tests/functional/kqp/kqp_indexes/CMakeLists.windows-x86_64.txt b/ydb/tests/functional/kqp/kqp_indexes/CMakeLists.windows-x86_64.txt
new file mode 100644
index 0000000000..143c4402ab
--- /dev/null
+++ b/ydb/tests/functional/kqp/kqp_indexes/CMakeLists.windows-x86_64.txt
@@ -0,0 +1,59 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_executable(ydb-tests-functional-kqp-kqp_indexes)
+target_link_libraries(ydb-tests-functional-kqp-kqp_indexes PUBLIC
+ contrib-libs-cxxsupp
+ yutil
+ library-cpp-cpuid_check
+ cpp-testing-unittest_main
+ cpp-threading-local_executor
+ cpp-client-ydb_table
+ cpp-client-draft
+)
+target_sources(ydb-tests-functional-kqp-kqp_indexes PRIVATE
+ ${CMAKE_SOURCE_DIR}/ydb/tests/functional/kqp/kqp_indexes/main.cpp
+)
+set_property(
+ TARGET
+ ydb-tests-functional-kqp-kqp_indexes
+ PROPERTY
+ SPLIT_FACTOR
+ 1
+)
+add_yunittest(
+ NAME
+ ydb-tests-functional-kqp-kqp_indexes
+ TEST_TARGET
+ ydb-tests-functional-kqp-kqp_indexes
+ TEST_ARG
+ --print-before-suite
+ --print-before-test
+ --fork-tests
+ --print-times
+ --show-fails
+)
+set_yunittest_property(
+ TEST
+ ydb-tests-functional-kqp-kqp_indexes
+ PROPERTY
+ LABELS
+ MEDIUM
+)
+set_yunittest_property(
+ TEST
+ ydb-tests-functional-kqp-kqp_indexes
+ PROPERTY
+ PROCESSORS
+ 1
+)
+target_allocator(ydb-tests-functional-kqp-kqp_indexes
+ system_allocator
+)
+vcs_info(ydb-tests-functional-kqp-kqp_indexes)
diff --git a/ydb/tests/functional/kqp/kqp_indexes/main.cpp b/ydb/tests/functional/kqp/kqp_indexes/main.cpp
new file mode 100644
index 0000000000..0a8e0e4cb1
--- /dev/null
+++ b/ydb/tests/functional/kqp/kqp_indexes/main.cpp
@@ -0,0 +1,149 @@
+#include <util/system/env.h>
+#include <library/cpp/testing/unittest/registar.h>
+
+#include <ydb/public/sdk/cpp/client/ydb_driver/driver.h>
+#include <ydb/public/sdk/cpp/client/ydb_table/table.h>
+#include <ydb/public/sdk/cpp/client/draft/ydb_scripting.h>
+
+#include <library/cpp/threading/local_executor/local_executor.h>
+
+using namespace NYdb;
+using namespace NYdb::NTable;
+
+Y_UNIT_TEST_SUITE(ConsistentIndexRead)
+{
+ Y_UNIT_TEST(InteractiveTx)
+ {
+ TString connectionString = GetEnv("YDB_ENDPOINT") + "/?database=" + GetEnv("YDB_DATABASE");
+ auto config = TDriverConfig(connectionString);
+ auto driver = TDriver(config);
+ auto tableClient = TTableClient(driver);
+ auto session = tableClient.GetSession().GetValueSync().GetSession();
+
+ auto res = session.ExecuteSchemeQuery(R"(
+ CREATE TABLE `/local/SecondaryKeys` (
+ Key Int32,
+ Fk Int32,
+ Value String,
+ PRIMARY KEY (Key),
+ INDEX Index GLOBAL ON (Fk)
+ );
+ )").GetValueSync();
+ UNIT_ASSERT_C(res.IsSuccess(), res.GetIssues().ToString());
+
+ static const TString deleteRow(R"(
+ DELETE FROM `/local/SecondaryKeys` ON (Key) VALUES (2)
+ )");
+
+ static const TString addRow(R"(
+ REPLACE INTO `/local/SecondaryKeys` (Key, Fk, Value) VALUES
+ (2, 2, "PPP")
+ )");
+
+ static const TString selectRow(R"(
+ SELECT * FROM `/local/SecondaryKeys` VIEW Index WHERE Fk = 2;
+ )");
+
+ {
+ auto result = session.ExecuteDataQuery(
+ addRow,
+ TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx())
+ .ExtractValueSync();
+ UNIT_ASSERT_C(result.IsSuccess(), result.GetIssues().ToString());
+ }
+
+ Sleep(TDuration::Seconds(10));
+
+ NPar::LocalExecutor().RunAdditionalThreads(12);
+ NPar::LocalExecutor().ExecRange([=, &tableClient](int id) mutable {
+ NYdb::NTable::TExecDataQuerySettings execSettings;
+ execSettings.KeepInQueryCache(true);
+
+ size_t i = 5000;
+ while (--i) {
+ auto sessionResult = tableClient.GetSession().GetValueSync();
+ if (!sessionResult.IsSuccess()) {
+ Cerr << sessionResult.GetStatus() << " " << sessionResult.GetIssues().ToString() << Endl;
+ continue;
+ }
+ auto s = sessionResult.GetSession();
+ switch (id % 3) {
+ case 0: {
+ auto result = s.ExecuteDataQuery(
+ deleteRow,
+ TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx(),
+ execSettings)
+ .ExtractValueSync();
+ UNIT_ASSERT_C(result.IsSuccess() || result.GetStatus() == EStatus::ABORTED, result.GetIssues().ToString());
+ break;
+ }
+ case 1: {
+ auto result = s.ExecuteDataQuery(
+ addRow,
+ TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx(),
+ execSettings)
+ .ExtractValueSync();
+ UNIT_ASSERT_C(result.IsSuccess() || result.GetStatus() == EStatus::ABORTED, result.GetIssues().ToString());
+ break;
+ }
+ case 2: {
+ auto result = s.ExecuteDataQuery(
+ selectRow,
+ TTxControl::BeginTx(TTxSettings::SerializableRW()),
+ execSettings)
+ .ExtractValueSync();
+
+ // We expect read is always success
+ UNIT_ASSERT_C(result.IsSuccess(), result.GetIssues().ToString());
+
+ if (result.IsSuccess()) {
+ auto tx = result.GetTransaction();
+ auto commitResult = tx->Commit().ExtractValueSync();
+ UNIT_ASSERT_C(commitResult.IsSuccess() || commitResult.GetStatus() == EStatus::ABORTED, commitResult.GetIssues().ToString());
+ }
+ break;
+ }
+ }
+ }
+ }, 0, 12, NPar::TLocalExecutor::WAIT_COMPLETE | NPar::TLocalExecutor::MED_PRIORITY);
+ }
+}
+
+Y_UNIT_TEST_SUITE(KqpExtTest)
+{
+ Y_UNIT_TEST(SecondaryIndexSelectUsingScripting) {
+ TString connectionString = GetEnv("YDB_ENDPOINT") + "/?database=" + GetEnv("YDB_DATABASE");
+ auto config = TDriverConfig(connectionString);
+ auto driver = TDriver(config);
+ NYdb::NScripting::TScriptingClient client(driver);
+ {
+ const TString createTableSql(R"(
+ --!syntax_v1
+ CREATE TABLE `/local/SharedHouseholds` (
+ guest_huid Uint64, guest_id Uint64, owner_huid Uint64, owner_id Uint64, household_id String,
+ PRIMARY KEY (guest_huid, owner_huid, household_id),
+ INDEX shared_households_owner_huid GLOBAL SYNC ON (`owner_huid`)
+ );)");
+ auto result = client.ExecuteYqlScript(createTableSql).GetValueSync();
+ UNIT_ASSERT_C(result.IsSuccess(), result.GetIssues().ToString());
+ }
+
+ {
+ const TString query(R"(
+ --!syntax_v1
+ SELECT
+ guest_id
+ FROM
+ SharedHouseholds VIEW shared_households_owner_huid
+ WHERE
+ owner_huid == 1 AND
+ household_id == "1";
+ )");
+
+ auto result = client.ExecuteYqlScript(query).GetValueSync();
+
+ UNIT_ASSERT_C(result.GetIssues().Empty(), result.GetIssues().ToString());
+ UNIT_ASSERT(result.IsSuccess());
+ }
+ }
+}
diff --git a/ydb/tests/functional/kqp/kqp_indexes/ya.make b/ydb/tests/functional/kqp/kqp_indexes/ya.make
new file mode 100644
index 0000000000..f99aa67490
--- /dev/null
+++ b/ydb/tests/functional/kqp/kqp_indexes/ya.make
@@ -0,0 +1,23 @@
+UNITTEST()
+
+ENV(YDB_USE_IN_MEMORY_PDISKS=true)
+
+ENV(YDB_ERASURE=block_4-2)
+
+PEERDIR(
+ library/cpp/threading/local_executor
+ ydb/public/sdk/cpp/client/ydb_table
+ ydb/public/sdk/cpp/client/draft
+)
+
+SRCS(
+ main.cpp
+)
+
+INCLUDE(${ARCADIA_ROOT}/ydb/public/tools/ydb_recipe/recipe.inc)
+
+SIZE(MEDIUM)
+
+REQUIREMENTS(ram:16)
+
+END()
diff --git a/ydb/tests/functional/kqp/kqp_query_session/CMakeLists.darwin-x86_64.txt b/ydb/tests/functional/kqp/kqp_query_session/CMakeLists.darwin-x86_64.txt
new file mode 100644
index 0000000000..92fb4da3a1
--- /dev/null
+++ b/ydb/tests/functional/kqp/kqp_query_session/CMakeLists.darwin-x86_64.txt
@@ -0,0 +1,74 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_executable(ydb-tests-functional-kqp-kqp_query_session)
+target_link_libraries(ydb-tests-functional-kqp-kqp_query_session PUBLIC
+ contrib-libs-cxxsupp
+ yutil
+ library-cpp-cpuid_check
+ cpp-testing-unittest_main
+ cpp-threading-local_executor
+ cpp-client-ydb_discovery
+ cpp-client-draft
+ services-ydb-ut_helpers
+)
+target_link_options(ydb-tests-functional-kqp-kqp_query_session PRIVATE
+ -Wl,-platform_version,macos,11.0,11.0
+ -fPIC
+ -fPIC
+ -framework
+ CoreFoundation
+)
+target_sources(ydb-tests-functional-kqp-kqp_query_session PRIVATE
+ ${CMAKE_SOURCE_DIR}/ydb/tests/functional/kqp/kqp_query_session/main.cpp
+)
+set_property(
+ TARGET
+ ydb-tests-functional-kqp-kqp_query_session
+ PROPERTY
+ SPLIT_FACTOR
+ 1
+)
+add_yunittest(
+ NAME
+ ydb-tests-functional-kqp-kqp_query_session
+ TEST_TARGET
+ ydb-tests-functional-kqp-kqp_query_session
+ TEST_ARG
+ --print-before-suite
+ --print-before-test
+ --fork-tests
+ --print-times
+ --show-fails
+)
+set_yunittest_property(
+ TEST
+ ydb-tests-functional-kqp-kqp_query_session
+ PROPERTY
+ LABELS
+ MEDIUM
+)
+set_yunittest_property(
+ TEST
+ ydb-tests-functional-kqp-kqp_query_session
+ PROPERTY
+ PROCESSORS
+ 1
+)
+set_yunittest_property(
+ TEST
+ ydb-tests-functional-kqp-kqp_query_session
+ PROPERTY
+ TIMEOUT
+ 60
+)
+target_allocator(ydb-tests-functional-kqp-kqp_query_session
+ system_allocator
+)
+vcs_info(ydb-tests-functional-kqp-kqp_query_session)
diff --git a/ydb/tests/functional/kqp/kqp_query_session/CMakeLists.linux-aarch64.txt b/ydb/tests/functional/kqp/kqp_query_session/CMakeLists.linux-aarch64.txt
new file mode 100644
index 0000000000..3ec96d8104
--- /dev/null
+++ b/ydb/tests/functional/kqp/kqp_query_session/CMakeLists.linux-aarch64.txt
@@ -0,0 +1,77 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_executable(ydb-tests-functional-kqp-kqp_query_session)
+target_link_libraries(ydb-tests-functional-kqp-kqp_query_session PUBLIC
+ contrib-libs-linux-headers
+ contrib-libs-cxxsupp
+ yutil
+ cpp-testing-unittest_main
+ cpp-threading-local_executor
+ cpp-client-ydb_discovery
+ cpp-client-draft
+ services-ydb-ut_helpers
+)
+target_link_options(ydb-tests-functional-kqp-kqp_query_session PRIVATE
+ -ldl
+ -lrt
+ -Wl,--no-as-needed
+ -fPIC
+ -fPIC
+ -lpthread
+ -lrt
+ -ldl
+)
+target_sources(ydb-tests-functional-kqp-kqp_query_session PRIVATE
+ ${CMAKE_SOURCE_DIR}/ydb/tests/functional/kqp/kqp_query_session/main.cpp
+)
+set_property(
+ TARGET
+ ydb-tests-functional-kqp-kqp_query_session
+ PROPERTY
+ SPLIT_FACTOR
+ 1
+)
+add_yunittest(
+ NAME
+ ydb-tests-functional-kqp-kqp_query_session
+ TEST_TARGET
+ ydb-tests-functional-kqp-kqp_query_session
+ TEST_ARG
+ --print-before-suite
+ --print-before-test
+ --fork-tests
+ --print-times
+ --show-fails
+)
+set_yunittest_property(
+ TEST
+ ydb-tests-functional-kqp-kqp_query_session
+ PROPERTY
+ LABELS
+ MEDIUM
+)
+set_yunittest_property(
+ TEST
+ ydb-tests-functional-kqp-kqp_query_session
+ PROPERTY
+ PROCESSORS
+ 1
+)
+set_yunittest_property(
+ TEST
+ ydb-tests-functional-kqp-kqp_query_session
+ PROPERTY
+ TIMEOUT
+ 60
+)
+target_allocator(ydb-tests-functional-kqp-kqp_query_session
+ cpp-malloc-jemalloc
+)
+vcs_info(ydb-tests-functional-kqp-kqp_query_session)
diff --git a/ydb/tests/functional/kqp/kqp_query_session/CMakeLists.linux-x86_64.txt b/ydb/tests/functional/kqp/kqp_query_session/CMakeLists.linux-x86_64.txt
new file mode 100644
index 0000000000..850bb90816
--- /dev/null
+++ b/ydb/tests/functional/kqp/kqp_query_session/CMakeLists.linux-x86_64.txt
@@ -0,0 +1,79 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_executable(ydb-tests-functional-kqp-kqp_query_session)
+target_link_libraries(ydb-tests-functional-kqp-kqp_query_session PUBLIC
+ contrib-libs-linux-headers
+ contrib-libs-cxxsupp
+ yutil
+ library-cpp-cpuid_check
+ cpp-testing-unittest_main
+ cpp-threading-local_executor
+ cpp-client-ydb_discovery
+ cpp-client-draft
+ services-ydb-ut_helpers
+)
+target_link_options(ydb-tests-functional-kqp-kqp_query_session PRIVATE
+ -ldl
+ -lrt
+ -Wl,--no-as-needed
+ -fPIC
+ -fPIC
+ -lpthread
+ -lrt
+ -ldl
+)
+target_sources(ydb-tests-functional-kqp-kqp_query_session PRIVATE
+ ${CMAKE_SOURCE_DIR}/ydb/tests/functional/kqp/kqp_query_session/main.cpp
+)
+set_property(
+ TARGET
+ ydb-tests-functional-kqp-kqp_query_session
+ PROPERTY
+ SPLIT_FACTOR
+ 1
+)
+add_yunittest(
+ NAME
+ ydb-tests-functional-kqp-kqp_query_session
+ TEST_TARGET
+ ydb-tests-functional-kqp-kqp_query_session
+ TEST_ARG
+ --print-before-suite
+ --print-before-test
+ --fork-tests
+ --print-times
+ --show-fails
+)
+set_yunittest_property(
+ TEST
+ ydb-tests-functional-kqp-kqp_query_session
+ PROPERTY
+ LABELS
+ MEDIUM
+)
+set_yunittest_property(
+ TEST
+ ydb-tests-functional-kqp-kqp_query_session
+ PROPERTY
+ PROCESSORS
+ 1
+)
+set_yunittest_property(
+ TEST
+ ydb-tests-functional-kqp-kqp_query_session
+ PROPERTY
+ TIMEOUT
+ 60
+)
+target_allocator(ydb-tests-functional-kqp-kqp_query_session
+ cpp-malloc-tcmalloc
+ libs-tcmalloc-no_percpu_cache
+)
+vcs_info(ydb-tests-functional-kqp-kqp_query_session)
diff --git a/ydb/tests/functional/kqp/kqp_query_session/CMakeLists.txt b/ydb/tests/functional/kqp/kqp_query_session/CMakeLists.txt
new file mode 100644
index 0000000000..f8b31df0c1
--- /dev/null
+++ b/ydb/tests/functional/kqp/kqp_query_session/CMakeLists.txt
@@ -0,0 +1,17 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" AND NOT HAVE_CUDA)
+ include(CMakeLists.linux-aarch64.txt)
+elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
+ include(CMakeLists.darwin-x86_64.txt)
+elseif (WIN32 AND CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64" AND NOT HAVE_CUDA)
+ include(CMakeLists.windows-x86_64.txt)
+elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND NOT HAVE_CUDA)
+ include(CMakeLists.linux-x86_64.txt)
+endif()
diff --git a/ydb/tests/functional/kqp/kqp_query_session/CMakeLists.windows-x86_64.txt b/ydb/tests/functional/kqp/kqp_query_session/CMakeLists.windows-x86_64.txt
new file mode 100644
index 0000000000..10e8236f14
--- /dev/null
+++ b/ydb/tests/functional/kqp/kqp_query_session/CMakeLists.windows-x86_64.txt
@@ -0,0 +1,67 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_executable(ydb-tests-functional-kqp-kqp_query_session)
+target_link_libraries(ydb-tests-functional-kqp-kqp_query_session PUBLIC
+ contrib-libs-cxxsupp
+ yutil
+ library-cpp-cpuid_check
+ cpp-testing-unittest_main
+ cpp-threading-local_executor
+ cpp-client-ydb_discovery
+ cpp-client-draft
+ services-ydb-ut_helpers
+)
+target_sources(ydb-tests-functional-kqp-kqp_query_session PRIVATE
+ ${CMAKE_SOURCE_DIR}/ydb/tests/functional/kqp/kqp_query_session/main.cpp
+)
+set_property(
+ TARGET
+ ydb-tests-functional-kqp-kqp_query_session
+ PROPERTY
+ SPLIT_FACTOR
+ 1
+)
+add_yunittest(
+ NAME
+ ydb-tests-functional-kqp-kqp_query_session
+ TEST_TARGET
+ ydb-tests-functional-kqp-kqp_query_session
+ TEST_ARG
+ --print-before-suite
+ --print-before-test
+ --fork-tests
+ --print-times
+ --show-fails
+)
+set_yunittest_property(
+ TEST
+ ydb-tests-functional-kqp-kqp_query_session
+ PROPERTY
+ LABELS
+ MEDIUM
+)
+set_yunittest_property(
+ TEST
+ ydb-tests-functional-kqp-kqp_query_session
+ PROPERTY
+ PROCESSORS
+ 1
+)
+set_yunittest_property(
+ TEST
+ ydb-tests-functional-kqp-kqp_query_session
+ PROPERTY
+ TIMEOUT
+ 60
+)
+target_allocator(ydb-tests-functional-kqp-kqp_query_session
+ system_allocator
+)
+vcs_info(ydb-tests-functional-kqp-kqp_query_session)
diff --git a/ydb/tests/functional/kqp/kqp_query_session/main.cpp b/ydb/tests/functional/kqp/kqp_query_session/main.cpp
new file mode 100644
index 0000000000..9ed753bbd7
--- /dev/null
+++ b/ydb/tests/functional/kqp/kqp_query_session/main.cpp
@@ -0,0 +1,121 @@
+#include <util/system/env.h>
+#include <library/cpp/testing/unittest/registar.h>
+
+#include <ydb/services/ydb/ut_helpers/ut_helpers_query.h>
+#include <ydb/public/sdk/cpp/client/ydb_driver/driver.h>
+#include <ydb/public/sdk/cpp/client/ydb_discovery/discovery.h>
+#include <ydb/public/sdk/cpp/client/draft/ydb_scripting.h>
+
+#include <library/cpp/threading/local_executor/local_executor.h>
+#include <library/cpp/grpc/client/grpc_common.h>
+
+#include <ydb/public/api/grpc/ydb_query_v1.grpc.pb.h>
+
+#include <stdio.h>
+
+#include <thread>
+
+using namespace NYdb;
+using namespace NTestHelpers;
+using namespace NYdb::NDiscovery;
+
+static TString CreateHostWithPort(const TEndpointInfo& info) {
+ return info.Address + ":" + ToString(info.Port);
+}
+
+static TString Exec(const TString& cmd) {
+ std::array<char, 256> buffer;
+ TString result;
+ std::unique_ptr<FILE, decltype(&pclose)> pipe(popen(cmd.data(), "r"), pclose);
+ if (!pipe) {
+ throw std::runtime_error("Unable to create pipe with process: " + cmd);
+ }
+ while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) {
+ result += buffer.data();
+ }
+ return result;
+}
+
+Y_UNIT_TEST_SUITE(KqpQuerySession)
+{
+ Y_UNIT_TEST(NoLocalAttach)
+ {
+ if (Exec("uname -s") != "Linux\n") {
+ Cerr << "This test works on linux only" << Endl;
+ return;
+ }
+
+ UNIT_ASSERT_C(Exec("whoami") != "root\n", "Do not run this test as root user. "
+ "This test will kill processes");
+
+ using namespace NGrpc;
+
+ TString connectionString = GetEnv("YDB_ENDPOINT") + "/?database=" + GetEnv("YDB_DATABASE");
+ auto config = TDriverConfig(connectionString);
+ auto driver = TDriver(config);
+
+ auto hs = [](const TEndpointInfo& info) {
+ return info.Port; //Actualy uniq for test
+ };
+
+ auto eq = [](const TEndpointInfo& l, const TEndpointInfo& r) {
+ return l.Address == r.Address && l.Port == r.Port;
+ };
+
+ std::unordered_map<TEndpointInfo, ui64, decltype(hs), decltype(eq)> endpoints;
+ {
+ auto client = TDiscoveryClient(driver);
+ auto res = client.ListEndpoints().GetValueSync();
+ UNIT_ASSERT_C(res.IsSuccess(), res.GetIssues().ToString());
+ for (const auto& x : res.GetEndpointsInfo()) {
+ auto cmd = Sprintf("ps axu | grep grpc-port=%d | grep -v \"grep\" | awk {'print $2'}", x.Port);
+ endpoints[x] = std::stoull(Exec(cmd).data());
+ }
+ }
+
+ UNIT_ASSERT_C(endpoints.size() > 2, "We must run at least 3 unique node to perform this test");
+
+ auto host1 = endpoints.begin();
+ auto host2 = ++endpoints.begin();
+
+ auto sessionId = CreateQuerySession(TGRpcClientConfig(CreateHostWithPort(host1->first)));
+
+ bool allDoneOk = true;
+
+ NGrpc::TGRpcClientLow clientLow;
+
+ auto readyToKill = NThreading::NewPromise<NGrpc::IStreamRequestCtrl::TPtr>();
+ auto doCheckAttach = [&] {
+ auto p = CheckAttach(clientLow, TGRpcClientConfig(CreateHostWithPort(host2->first)), sessionId, Ydb::StatusIds::SUCCESS, allDoneOk);
+ readyToKill.SetValue(p);
+ };
+
+ std::thread checkAttachThread(doCheckAttach);
+
+ auto processor = readyToKill.GetFuture().GetValueSync();
+
+ // Stop node which proxyed session stream
+ Exec(Sprintf("kill -19 %lu", host2->second));
+
+ // Give some time for interconnect to decide node is dead
+ Sleep(TDuration::Seconds(30));
+
+ // Resume node
+ Exec(Sprintf("kill -18 %lu", host2->second));
+
+ {
+ // Try to attach to same session - extect session was destroyed
+ // Using host where session actor worked
+ CheckAttach(TGRpcClientConfig(CreateHostWithPort(host1->first)), sessionId, Ydb::StatusIds::BAD_SESSION, allDoneOk);
+ // Using kqp proxy
+ CheckAttach(TGRpcClientConfig(CreateHostWithPort(host2->first)), sessionId, Ydb::StatusIds::BAD_SESSION, allDoneOk);
+ }
+
+ // Right now we requered to cancel stream from client side
+ processor->Cancel();
+
+ checkAttachThread.join();
+
+ UNIT_ASSERT(allDoneOk);
+ }
+}
diff --git a/ydb/tests/functional/kqp/kqp_query_session/ya.make b/ydb/tests/functional/kqp/kqp_query_session/ya.make
new file mode 100644
index 0000000000..b10ea5f1b2
--- /dev/null
+++ b/ydb/tests/functional/kqp/kqp_query_session/ya.make
@@ -0,0 +1,28 @@
+UNITTEST()
+
+ENV(YDB_USE_IN_MEMORY_PDISKS=true)
+
+ENV(YDB_ERASURE=block_4-2)
+
+ENV(USE_YDB_TRUNK_RECIPE_TOOLS=true)
+
+TIMEOUT(60)
+
+PEERDIR(
+ library/cpp/threading/local_executor
+ ydb/public/sdk/cpp/client/ydb_discovery
+ ydb/public/sdk/cpp/client/draft
+ ydb/services/ydb/ut_helpers
+)
+
+SRCS(
+ main.cpp
+)
+
+INCLUDE(${ARCADIA_ROOT}/ydb/public/tools/ydb_recipe/recipe.inc)
+
+SIZE(MEDIUM)
+
+REQUIREMENTS(ram:16)
+
+END()
diff --git a/ydb/tests/functional/kqp/ya.make b/ydb/tests/functional/kqp/ya.make
new file mode 100644
index 0000000000..a3d1a951e6
--- /dev/null
+++ b/ydb/tests/functional/kqp/ya.make
@@ -0,0 +1,4 @@
+RECURSE(
+ kqp_indexes
+ kqp_query_session
+)
diff --git a/ydb/tests/functional/ya.make b/ydb/tests/functional/ya.make
index 3d13664a7a..851335c7f4 100644
--- a/ydb/tests/functional/ya.make
+++ b/ydb/tests/functional/ya.make
@@ -9,6 +9,7 @@ RECURSE(
dynumber
encryption
hive
+ kqp
large_serializable
limits
open_source