diff options
author | vvvv <vvvv@yandex-team.ru> | 2022-02-21 20:19:03 +0300 |
---|---|---|
committer | vvvv <vvvv@yandex-team.ru> | 2022-02-21 20:19:03 +0300 |
commit | 3dd4a9038a29ff0dfa07a658d65a199367ad48b0 (patch) | |
tree | f67f50382ab4ac45b2d831ec4ed9c6c2ff2ebebe | |
parent | ba303e94a7c1791a2ad4360013f0502dfc2f35ef (diff) | |
download | ydb-3dd4a9038a29ff0dfa07a658d65a199367ad48b0.tar.gz |
YQL-13710 multithreaded test
ref:f15045945e687c3d8e95568a5e69b768438921a8
-rw-r--r-- | ydb/library/yql/parser/pg_query_wrapper/ut/wrapper_ut.cpp | 67 | ||||
-rw-r--r-- | ydb/library/yql/parser/pg_query_wrapper/ut/ya.make | 3 |
2 files changed, 70 insertions, 0 deletions
diff --git a/ydb/library/yql/parser/pg_query_wrapper/ut/wrapper_ut.cpp b/ydb/library/yql/parser/pg_query_wrapper/ut/wrapper_ut.cpp index cafd5bf0c7..2acd2d8e12 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/ut/wrapper_ut.cpp +++ b/ydb/library/yql/parser/pg_query_wrapper/ut/wrapper_ut.cpp @@ -1,6 +1,7 @@ #include <ydb/library/yql/parser/pg_query_wrapper/wrapper.h> #include <util/stream/str.h> +#include <util/system/thread.h> #include <library/cpp/testing/unittest/registar.h> using namespace NYql; @@ -44,3 +45,69 @@ Y_UNIT_TEST_SUITE(TWrapperTests) { UNIT_ASSERT_VALUES_EQUAL(events.Issue->Position.Column, 3); } } + +const ui32 threadsCount = 10; + +Y_UNIT_TEST_SUITE(TMTWrapperTests) { + Y_UNIT_TEST(TestOk) { + TVector<THolder<TThread>> threads; + for (ui32 i = 0; i < threadsCount; ++i) { + threads.emplace_back(MakeHolder<TThread>([]() { + ui32 iters = 10000; +#if defined(_san_enabled_) + iters /= 100; +#endif + for (ui32 i = 0; i < iters; ++i) { + TEvents events; + PGParse(TString("SELECT 1"), events); + Y_ENSURE(events.Result); + Y_ENSURE(!events.Issue); + const auto expected = "({RAWSTMT :stmt {SELECT :distinctClause <> :intoClause <> :targetList " + "({RESTARGET :name <> :indirection <> :val {A_CONST :val 1 :location 7} :location 7}) :fromClause <> " + ":whereClause <> :groupClause <> :havingClause <> :windowClause <> :valuesLists <> :sortClause <> " + ":limitOffset <> :limitCount <> :limitOption 0 :lockingClause <> :withClause <> :op 0 :all false :larg <> " + ":rarg <>} :stmt_location 0 :stmt_len 0})"; + Y_ENSURE(*events.Result == expected); + } + })); + } + + for (ui32 i = 0; i < threadsCount; ++i) { + threads[i]->Start(); + } + + for (ui32 i = 0; i < threadsCount; ++i) { + threads[i]->Join(); + } + } + + Y_UNIT_TEST(TestFail) { + TVector<THolder<TThread>> threads; + for (ui32 i = 0; i < threadsCount; ++i) { + threads.emplace_back(MakeHolder<TThread>([]() { + ui32 iters = 10000; +#if defined(_san_enabled_) + iters /= 100; +#endif + for (ui32 i = 0; i < iters; ++i) { + TEvents events; + PGParse(TString(" \n SELECT1"), events); + Y_ENSURE(!events.Result); + Y_ENSURE(events.Issue); + auto msg = events.Issue->Message; + Y_ENSURE(msg == "syntax error at or near \"SELECT1\""); + Y_ENSURE(events.Issue->Position.Row == 2); + Y_ENSURE(events.Issue->Position.Column == 3); + } + })); + } + + for (ui32 i = 0; i < threadsCount; ++i) { + threads[i]->Start(); + } + + for (ui32 i = 0; i < threadsCount; ++i) { + threads[i]->Join(); + } + } +} diff --git a/ydb/library/yql/parser/pg_query_wrapper/ut/ya.make b/ydb/library/yql/parser/pg_query_wrapper/ut/ya.make index 18f7a8de0a..0108453258 100644 --- a/ydb/library/yql/parser/pg_query_wrapper/ut/ya.make +++ b/ydb/library/yql/parser/pg_query_wrapper/ut/ya.make @@ -2,6 +2,9 @@ UNITTEST_FOR(ydb/library/yql/parser/pg_query_wrapper) OWNER(g:yql) +TIMEOUT(600) +SIZE(MEDIUM) + SRCS( wrapper_ut.cpp ) |