From 04faa0924ee144d484d5eda1deedf53d9ed19e7b Mon Sep 17 00:00:00 2001 From: st-shchetinin Date: Fri, 19 Jul 2024 20:17:20 +0300 Subject: [PATCH 01/36] divided the tests into groups --- CMakeLists.txt | 3 +- README.md | 14 + tests/integration/CMakeLists.txt | 1 + .../basic_example_it/CMakeLists.txt | 12 + .../basic_example_it/basic_example.cpp | 612 ++++++++++++++++++ .../basic_example_it/basic_example.h | 13 + .../basic_example_it/basic_example_data.cpp | 205 ++++++ tests/integration/basic_example_it/main.cpp | 50 ++ tests/{ => ut}/CMakeLists.txt | 0 tests/{ => ut}/client/CMakeLists.txt | 16 +- tests/{ => ut}/client/coordination_ut.cpp | 0 .../{ => ut}/client/discovery_mutator_ut.cpp | 0 tests/{ => ut}/client/driver_ut.cpp | 0 tests/{ => ut}/client/endpoints_ut.cpp | 0 .../oauth2_token_exchange/CMakeLists.txt | 2 +- .../oauth2_token_exchange/credentials_ut.cpp | 0 .../jwt_token_source_ut.cpp | 0 tests/{ => ut}/client/params_ut.cpp | 0 tests/{ => ut}/client/result_ut.cpp | 0 tests/{ => ut}/client/value_ut.cpp | 0 .../ydb_scripting_response_headers_ut.cpp | 0 tests/{ => ut}/json_value/CMakeLists.txt | 2 +- .../{ => ut}/json_value/ydb_json_value_ut.cpp | 0 tests/{ => ut}/library/CMakeLists.txt | 0 tests/{ => ut}/library/cache/CMakeLists.txt | 0 tests/{ => ut}/library/cache/cache_ut.cpp | 0 .../case_insensitive_string/CMakeLists.txt | 0 .../case_insensitive_string_ut.cpp | 0 .../{ => ut}/library/cgiparam/CMakeLists.txt | 2 +- tests/{ => ut}/library/cgiparam/ut.cpp | 0 tests/{ => ut}/library/charset/CMakeLists.txt | 0 .../{ => ut}/library/charset/ci_string_ut.cpp | 0 .../{ => ut}/library/charset/codepage_ut.cpp | 0 tests/{ => ut}/library/charset/iconv_ut.cpp | 0 .../{ => ut}/library/charset/recyr_int_ut.cpp | 0 tests/{ => ut}/library/charset/wide_ut.cpp | 0 .../library/containers/CMakeLists.txt | 0 .../containers/disjoint_interval_tree_ut.cpp | 0 .../containers/intrusive_rb_tree_ut.cpp | 0 .../library/containers/paged_vector_ut.cpp | 0 .../library/containers/stack_vector_ut.cpp | 0 .../{ => ut}/library/coroutine/CMakeLists.txt | 0 .../library/coroutine/engine/CMakeLists.txt | 0 .../library/coroutine/engine/coroutine_ut.cpp | 0 .../coroutine/engine/stack/CMakeLists.txt | 0 .../engine/stack/stack_allocator_ut.cpp | 0 .../engine/stack/stack_guards_ut.cpp | 0 .../coroutine/engine/stack/stack_pool_ut.cpp | 0 .../coroutine/engine/stack/stack_ut.cpp | 0 .../coroutine/engine/stack/stack_utils_ut.cpp | 0 .../library/dbg_output/CMakeLists.txt | 0 .../library/dbg_output/dbg_output_ut.cpp | 0 tests/{ => ut}/library/diff/CMakeLists.txt | 2 +- tests/{ => ut}/library/diff/ut.cpp | 0 tests/{ => ut}/library/digest/CMakeLists.txt | 0 .../library/digest/lower_case/CMakeLists.txt | 0 .../library/digest/lower_case/hash_ops_ut.cpp | 0 .../library/digest/lower_case/lchash_ut.cpp | 0 .../library/digest/md5/CMakeLists.txt | 0 .../library/digest/md5/md5_medium_ut.cpp | 0 tests/{ => ut}/library/digest/md5/md5_ut.cpp | 0 .../library/digest/murmur/CMakeLists.txt | 2 +- tests/{ => ut}/library/digest/murmur/ut.cpp | 0 tests/{ => ut}/library/json/CMakeLists.txt | 0 .../library/json/json_prettifier_ut.cpp | 0 .../library/json/json_reader_fast_ut.cpp | 0 .../{ => ut}/library/json/json_reader_ut.cpp | 0 .../library/json/json_saveload_ut.cpp | 0 .../{ => ut}/library/json/json_writer_ut.cpp | 0 .../library/json/writer/CMakeLists.txt | 0 .../{ => ut}/library/json/writer/json_ut.cpp | 0 .../library/json/writer/json_value_ut.cpp | 0 .../library/operation_id/CMakeLists.txt | 2 +- .../library/operation_id/operation_id_ut.cpp | 0 tests/{ => ut}/library/testing/CMakeLists.txt | 0 .../library/testing/common/CMakeLists.txt | 0 .../library/testing/common/env_ut.cpp | 2 +- .../library/testing/common/network_ut.cpp | 0 .../library/testing/common/scope_ut.cpp | 0 .../testing/gmock_in_unittest/CMakeLists.txt | 0 .../testing/gmock_in_unittest/example_ut.cpp | 0 .../library/testing/gtest/CMakeLists.txt | 0 .../{ => ut}/library/testing/gtest/README.md | 0 .../library/testing/gtest/golden/data.txt | 0 .../library/testing/gtest/matchers_ut.cpp | 0 tests/{ => ut}/library/testing/gtest/ut.cpp | 0 .../testing/gtest_extensions/CMakeLists.txt | 0 .../testing/gtest_extensions/README.md | 0 .../gtest_extensions/gtest_extensions_ut.cpp | 0 .../testing/gtest_extensions/probe_ut.cpp | 0 .../library/testing/unittest/CMakeLists.txt | 2 +- .../library/testing/unittest/main.cpp | 0 .../testing/unittest/test_port_manager.cpp | 0 tests/{ => ut}/library/yql/CMakeLists.txt | 4 +- tests/{ => ut}/library/yql/utf8_ut.cpp | 0 tests/{ => ut}/library/yql/yql_decimal_ut.cpp | 0 tests/{ => ut}/library/yql/yql_issue_ut.cpp | 0 .../{ => ut}/library/yql/yql_wide_int_ut.cpp | 0 tests/{ => ut}/util/CMakeLists.txt | 0 tests/{ => ut}/util/charset/CMakeLists.txt | 0 .../util/charset/data/invalid_UTF8.bin | Bin tests/{ => ut}/util/charset/data/test1.txt | 0 tests/{ => ut}/util/charset/utf8_ut.cpp | 0 tests/{ => ut}/util/charset/wide_ut.cpp | 0 tests/{ => ut}/util/digest/CMakeLists.txt | 0 tests/{ => ut}/util/digest/city_ut.cpp | 0 tests/{ => ut}/util/digest/fnv_ut.cpp | 0 tests/{ => ut}/util/digest/multi_ut.cpp | 0 tests/{ => ut}/util/digest/murmur_ut.cpp | 0 tests/{ => ut}/util/digest/sequence_ut.cpp | 0 tests/{ => ut}/util/folder/CMakeLists.txt | 0 tests/{ => ut}/util/folder/dirut_ut.cpp | 0 tests/{ => ut}/util/folder/filelist_ut.cpp | 0 tests/{ => ut}/util/folder/fts_ut.cpp | 0 tests/{ => ut}/util/folder/iterator_ut.cpp | 0 tests/{ => ut}/util/folder/path_ut.cpp | 0 tests/{ => ut}/util/folder/pathsplit_ut.cpp | 6 +- tests/{ => ut}/util/network/CMakeLists.txt | 0 tests/{ => ut}/util/network/address_ut.cpp | 0 tests/{ => ut}/util/network/endpoint_ut.cpp | 0 tests/{ => ut}/util/network/iovec_ut.cpp | 0 tests/{ => ut}/util/network/ip_ut.cpp | 0 tests/{ => ut}/util/network/poller_ut.cpp | 0 tests/{ => ut}/util/network/sock_ut.cpp | 0 tests/{ => ut}/util/network/socket_ut.cpp | 0 125 files changed, 930 insertions(+), 22 deletions(-) create mode 100644 tests/integration/CMakeLists.txt create mode 100644 tests/integration/basic_example_it/CMakeLists.txt create mode 100644 tests/integration/basic_example_it/basic_example.cpp create mode 100644 tests/integration/basic_example_it/basic_example.h create mode 100644 tests/integration/basic_example_it/basic_example_data.cpp create mode 100644 tests/integration/basic_example_it/main.cpp rename tests/{ => ut}/CMakeLists.txt (100%) rename tests/{ => ut}/client/CMakeLists.txt (77%) rename tests/{ => ut}/client/coordination_ut.cpp (100%) rename tests/{ => ut}/client/discovery_mutator_ut.cpp (100%) rename tests/{ => ut}/client/driver_ut.cpp (100%) rename tests/{ => ut}/client/endpoints_ut.cpp (100%) rename tests/{ => ut}/client/oauth2_token_exchange/CMakeLists.txt (83%) rename tests/{ => ut}/client/oauth2_token_exchange/credentials_ut.cpp (100%) rename tests/{ => ut}/client/oauth2_token_exchange/jwt_token_source_ut.cpp (100%) rename tests/{ => ut}/client/params_ut.cpp (100%) rename tests/{ => ut}/client/result_ut.cpp (100%) rename tests/{ => ut}/client/value_ut.cpp (100%) rename tests/{ => ut}/client/ydb_scripting_response_headers_ut.cpp (100%) rename tests/{ => ut}/json_value/CMakeLists.txt (85%) rename tests/{ => ut}/json_value/ydb_json_value_ut.cpp (100%) rename tests/{ => ut}/library/CMakeLists.txt (100%) rename tests/{ => ut}/library/cache/CMakeLists.txt (100%) rename tests/{ => ut}/library/cache/cache_ut.cpp (100%) rename tests/{ => ut}/library/case_insensitive_string/CMakeLists.txt (100%) rename tests/{ => ut}/library/case_insensitive_string/case_insensitive_string_ut.cpp (100%) rename tests/{ => ut}/library/cgiparam/CMakeLists.txt (70%) rename tests/{ => ut}/library/cgiparam/ut.cpp (100%) rename tests/{ => ut}/library/charset/CMakeLists.txt (100%) rename tests/{ => ut}/library/charset/ci_string_ut.cpp (100%) rename tests/{ => ut}/library/charset/codepage_ut.cpp (100%) rename tests/{ => ut}/library/charset/iconv_ut.cpp (100%) rename tests/{ => ut}/library/charset/recyr_int_ut.cpp (100%) rename tests/{ => ut}/library/charset/wide_ut.cpp (100%) rename tests/{ => ut}/library/containers/CMakeLists.txt (100%) rename tests/{ => ut}/library/containers/disjoint_interval_tree_ut.cpp (100%) rename tests/{ => ut}/library/containers/intrusive_rb_tree_ut.cpp (100%) rename tests/{ => ut}/library/containers/paged_vector_ut.cpp (100%) rename tests/{ => ut}/library/containers/stack_vector_ut.cpp (100%) rename tests/{ => ut}/library/coroutine/CMakeLists.txt (100%) rename tests/{ => ut}/library/coroutine/engine/CMakeLists.txt (100%) rename tests/{ => ut}/library/coroutine/engine/coroutine_ut.cpp (100%) rename tests/{ => ut}/library/coroutine/engine/stack/CMakeLists.txt (100%) rename tests/{ => ut}/library/coroutine/engine/stack/stack_allocator_ut.cpp (100%) rename tests/{ => ut}/library/coroutine/engine/stack/stack_guards_ut.cpp (100%) rename tests/{ => ut}/library/coroutine/engine/stack/stack_pool_ut.cpp (100%) rename tests/{ => ut}/library/coroutine/engine/stack/stack_ut.cpp (100%) rename tests/{ => ut}/library/coroutine/engine/stack/stack_utils_ut.cpp (100%) rename tests/{ => ut}/library/dbg_output/CMakeLists.txt (100%) rename tests/{ => ut}/library/dbg_output/dbg_output_ut.cpp (100%) rename tests/{ => ut}/library/diff/CMakeLists.txt (81%) rename tests/{ => ut}/library/diff/ut.cpp (100%) rename tests/{ => ut}/library/digest/CMakeLists.txt (100%) rename tests/{ => ut}/library/digest/lower_case/CMakeLists.txt (100%) rename tests/{ => ut}/library/digest/lower_case/hash_ops_ut.cpp (100%) rename tests/{ => ut}/library/digest/lower_case/lchash_ut.cpp (100%) rename tests/{ => ut}/library/digest/md5/CMakeLists.txt (100%) rename tests/{ => ut}/library/digest/md5/md5_medium_ut.cpp (100%) rename tests/{ => ut}/library/digest/md5/md5_ut.cpp (100%) rename tests/{ => ut}/library/digest/murmur/CMakeLists.txt (78%) rename tests/{ => ut}/library/digest/murmur/ut.cpp (100%) rename tests/{ => ut}/library/json/CMakeLists.txt (100%) rename tests/{ => ut}/library/json/json_prettifier_ut.cpp (100%) rename tests/{ => ut}/library/json/json_reader_fast_ut.cpp (100%) rename tests/{ => ut}/library/json/json_reader_ut.cpp (100%) rename tests/{ => ut}/library/json/json_saveload_ut.cpp (100%) rename tests/{ => ut}/library/json/json_writer_ut.cpp (100%) rename tests/{ => ut}/library/json/writer/CMakeLists.txt (100%) rename tests/{ => ut}/library/json/writer/json_ut.cpp (100%) rename tests/{ => ut}/library/json/writer/json_value_ut.cpp (100%) rename tests/{ => ut}/library/operation_id/CMakeLists.txt (79%) rename tests/{ => ut}/library/operation_id/operation_id_ut.cpp (100%) rename tests/{ => ut}/library/testing/CMakeLists.txt (100%) rename tests/{ => ut}/library/testing/common/CMakeLists.txt (100%) rename tests/{ => ut}/library/testing/common/env_ut.cpp (98%) rename tests/{ => ut}/library/testing/common/network_ut.cpp (100%) rename tests/{ => ut}/library/testing/common/scope_ut.cpp (100%) rename tests/{ => ut}/library/testing/gmock_in_unittest/CMakeLists.txt (100%) rename tests/{ => ut}/library/testing/gmock_in_unittest/example_ut.cpp (100%) rename tests/{ => ut}/library/testing/gtest/CMakeLists.txt (100%) rename tests/{ => ut}/library/testing/gtest/README.md (100%) rename tests/{ => ut}/library/testing/gtest/golden/data.txt (100%) rename tests/{ => ut}/library/testing/gtest/matchers_ut.cpp (100%) rename tests/{ => ut}/library/testing/gtest/ut.cpp (100%) rename tests/{ => ut}/library/testing/gtest_extensions/CMakeLists.txt (100%) rename tests/{ => ut}/library/testing/gtest_extensions/README.md (100%) rename tests/{ => ut}/library/testing/gtest_extensions/gtest_extensions_ut.cpp (100%) rename tests/{ => ut}/library/testing/gtest_extensions/probe_ut.cpp (100%) rename tests/{ => ut}/library/testing/unittest/CMakeLists.txt (80%) rename tests/{ => ut}/library/testing/unittest/main.cpp (100%) rename tests/{ => ut}/library/testing/unittest/test_port_manager.cpp (100%) rename tests/{ => ut}/library/yql/CMakeLists.txt (88%) rename tests/{ => ut}/library/yql/utf8_ut.cpp (100%) rename tests/{ => ut}/library/yql/yql_decimal_ut.cpp (100%) rename tests/{ => ut}/library/yql/yql_issue_ut.cpp (100%) rename tests/{ => ut}/library/yql/yql_wide_int_ut.cpp (100%) rename tests/{ => ut}/util/CMakeLists.txt (100%) rename tests/{ => ut}/util/charset/CMakeLists.txt (100%) rename tests/{ => ut}/util/charset/data/invalid_UTF8.bin (100%) rename tests/{ => ut}/util/charset/data/test1.txt (100%) rename tests/{ => ut}/util/charset/utf8_ut.cpp (100%) rename tests/{ => ut}/util/charset/wide_ut.cpp (100%) rename tests/{ => ut}/util/digest/CMakeLists.txt (100%) rename tests/{ => ut}/util/digest/city_ut.cpp (100%) rename tests/{ => ut}/util/digest/fnv_ut.cpp (100%) rename tests/{ => ut}/util/digest/multi_ut.cpp (100%) rename tests/{ => ut}/util/digest/murmur_ut.cpp (100%) rename tests/{ => ut}/util/digest/sequence_ut.cpp (100%) rename tests/{ => ut}/util/folder/CMakeLists.txt (100%) rename tests/{ => ut}/util/folder/dirut_ut.cpp (100%) rename tests/{ => ut}/util/folder/filelist_ut.cpp (100%) rename tests/{ => ut}/util/folder/fts_ut.cpp (100%) rename tests/{ => ut}/util/folder/iterator_ut.cpp (100%) rename tests/{ => ut}/util/folder/path_ut.cpp (100%) rename tests/{ => ut}/util/folder/pathsplit_ut.cpp (98%) rename tests/{ => ut}/util/network/CMakeLists.txt (100%) rename tests/{ => ut}/util/network/address_ut.cpp (100%) rename tests/{ => ut}/util/network/endpoint_ut.cpp (100%) rename tests/{ => ut}/util/network/iovec_ut.cpp (100%) rename tests/{ => ut}/util/network/ip_ut.cpp (100%) rename tests/{ => ut}/util/network/poller_ut.cpp (100%) rename tests/{ => ut}/util/network/sock_ut.cpp (100%) rename tests/{ => ut}/util/network/socket_ut.cpp (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index e77c6294227..ec337718d0e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,7 +47,8 @@ endif() if (YDB_SDK_TESTS) enable_testing() - add_subdirectory(tests) + add_subdirectory(tests/ut) + add_subdirectory(tests/integration) endif() if (YDB_SDK_INSTALL) diff --git a/README.md b/README.md index c7d5c734dd0..538de61c015 100644 --- a/README.md +++ b/README.md @@ -122,6 +122,20 @@ cmake --build --preset release Specify a level of parallelism by passing the `-j` option into the command below (e.g. `-j$(nproc)`) +Running all tests: + ```bash ctest -j$(nproc) --preset release ``` + +Running unit tests only: + +```bash +ctest -j$(nproc) --preset release -R .*_ut +``` + +Running integration tests only: + +```bash +ctest -j$(nproc) --preset release -R .*_it +``` \ No newline at end of file diff --git a/tests/integration/CMakeLists.txt b/tests/integration/CMakeLists.txt new file mode 100644 index 00000000000..4f45b490bef --- /dev/null +++ b/tests/integration/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(basic_example_it) \ No newline at end of file diff --git a/tests/integration/basic_example_it/CMakeLists.txt b/tests/integration/basic_example_it/CMakeLists.txt new file mode 100644 index 00000000000..4f1d39530c4 --- /dev/null +++ b/tests/integration/basic_example_it/CMakeLists.txt @@ -0,0 +1,12 @@ +add_ydb_test(NAME basic-example_it + SOURCES + main.cpp + basic_example_data.cpp + basic_example.cpp + basic_example.h + LINK_LIBRARIES + yutil + library-getopt + YDB-CPP-SDK::Table + GTest::gtest_main +) \ No newline at end of file diff --git a/tests/integration/basic_example_it/basic_example.cpp b/tests/integration/basic_example_it/basic_example.cpp new file mode 100644 index 00000000000..e5bf7644d4b --- /dev/null +++ b/tests/integration/basic_example_it/basic_example.cpp @@ -0,0 +1,612 @@ +#include "basic_example.h" + +#include + +#include + +using namespace NYdb; +using namespace NYdb::NTable; + +class TYdbErrorException : public yexception { +public: + TYdbErrorException(const TStatus& status) + : Status(status) {} + + TStatus Status; +}; + +static void ThrowOnError(const TStatus& status) { + if (!status.IsSuccess()) { + throw TYdbErrorException(status) << status; + } +} + +static void PrintStatus(const TStatus& status) { + std::cerr << "Status: " << ToString(status.GetStatus()) << std::endl; + status.GetIssues().PrintTo(std::cerr); +} + +static std::string JoinPath(const std::string& basePath, const std::string& path) { + if (basePath.empty()) { + return path; + } + + TPathSplitUnix prefixPathSplit(basePath); + prefixPathSplit.AppendComponent(path); + + return prefixPathSplit.Reconstruct(); +} + +/////////////////////////////////////////////////////////////////////////////// + +//! Creates sample tables with CrateTable API. +static void CreateTables(TTableClient client, const std::string& path) { + ThrowOnError(client.RetryOperationSync([path](TSession session) { + auto seriesDesc = TTableBuilder() + .AddNullableColumn("series_id", EPrimitiveType::Uint64) + .AddNullableColumn("title", EPrimitiveType::Utf8) + .AddNullableColumn("series_info", EPrimitiveType::Utf8) + .AddNullableColumn("release_date", EPrimitiveType::Uint64) + .SetPrimaryKeyColumn("series_id") + .Build(); + + return session.CreateTable(JoinPath(path, "series"), std::move(seriesDesc)).GetValueSync(); + })); + + ThrowOnError(client.RetryOperationSync([path](TSession session) { + auto seasonsDesc = TTableBuilder() + .AddNullableColumn("series_id", EPrimitiveType::Uint64) + .AddNullableColumn("season_id", EPrimitiveType::Uint64) + .AddNullableColumn("title", EPrimitiveType::Utf8) + .AddNullableColumn("first_aired", EPrimitiveType::Uint64) + .AddNullableColumn("last_aired", EPrimitiveType::Uint64) + .SetPrimaryKeyColumns({"series_id", "season_id"}) + .Build(); + + return session.CreateTable(JoinPath(path, "seasons"), std::move(seasonsDesc)).GetValueSync(); + })); + + ThrowOnError(client.RetryOperationSync([path](TSession session) { + auto episodesDesc = TTableBuilder() + .AddNullableColumn("series_id", EPrimitiveType::Uint64) + .AddNullableColumn("season_id", EPrimitiveType::Uint64) + .AddNullableColumn("episode_id", EPrimitiveType::Uint64) + .AddNullableColumn("title", EPrimitiveType::Utf8) + .AddNullableColumn("air_date", EPrimitiveType::Uint64) + .SetPrimaryKeyColumns({"series_id", "season_id", "episode_id"}) + .Build(); + + return session.CreateTable(JoinPath(path, "episodes"), + std::move(episodesDesc)).GetValueSync(); + })); +} + +//! Describe existing table. +static std::string DescribeTable(TTableClient client, const std::string& path, const std::string& name) { + std::optional desc; + std::string result; + ThrowOnError(client.RetryOperationSync([path, name, &desc](TSession session) { + auto result = session.DescribeTable(JoinPath(path, name)).GetValueSync(); + + if (result.IsSuccess()) { + desc = result.GetTableDescription(); + } + + return result; + })); + + result += std::format("> Describe table: {}", name); + for (auto& column : desc->GetColumns()) { + result += std::format("Column, name: {}, type: {}", column.Name, FormatType(column.Type)); + } + return result; +} + +/////////////////////////////////////////////////////////////////////////////// + +//! Fills sample tables with data in single parameterized data query. +static TStatus FillTableDataTransaction(TSession session, const std::string& path) { + auto query = std::format(R"( + PRAGMA TablePathPrefix("{}"); + + DECLARE $seriesData AS List>; + + DECLARE $seasonsData AS List>; + + DECLARE $episodesData AS List>; + + REPLACE INTO series + SELECT + series_id, + title, + series_info, + CAST(release_date AS Uint16) AS release_date + FROM AS_TABLE($seriesData); + + REPLACE INTO seasons + SELECT + series_id, + season_id, + title, + CAST(first_aired AS Uint16) AS first_aired, + CAST(last_aired AS Uint16) AS last_aired + FROM AS_TABLE($seasonsData); + + REPLACE INTO episodes + SELECT + series_id, + season_id, + episode_id, + title, + CAST(air_date AS Uint16) AS air_date + FROM AS_TABLE($episodesData); + )", path); + + auto params = GetTablesDataParams(); + + return session.ExecuteDataQuery( + query, + TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx(), + params).GetValueSync(); +} + +//! Shows basic usage of YDB data queries and transactions. +static TStatus SelectSimpleTransaction(TSession session, const std::string& path, + std::optional& resultSet) +{ + auto query = std::format(R"( + PRAGMA TablePathPrefix("{}"); + + SELECT series_id, title, CAST(CAST(release_date AS Date) AS String) AS release_date + FROM series + WHERE series_id = 1; + )", path); + + auto txControl = + // Begin new transaction with SerializableRW mode + TTxControl::BeginTx(TTxSettings::SerializableRW()) + // Commit transaction at the end of the query + .CommitTx(); + + // Executes data query with specified transaction control settings. + auto result = session.ExecuteDataQuery(query, txControl).GetValueSync(); + + if (result.IsSuccess()) { + // Index of result set corresponds to its order in YQL query + resultSet = result.GetResultSet(0); + } + + return result; +} + +//! Shows basic usage of mutating operations. +static TStatus UpsertSimpleTransaction(TSession session, const std::string& path) { + auto query = std::format(R"( + --!syntax_v1 + PRAGMA TablePathPrefix("{}"); + + UPSERT INTO episodes (series_id, season_id, episode_id, title) VALUES + (2, 6, 1, "TBD"); + )", path); + + return session.ExecuteDataQuery(query, + TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx()).GetValueSync(); +} + +//! Shows usage of parameters in data queries. +static TStatus SelectWithParamsTransaction(TSession session, const std::string& path, + ui64 seriesId, ui64 seasonId, std::optional& resultSet) +{ + auto query = std::format(R"( + --!syntax_v1 + PRAGMA TablePathPrefix("{}"); + + DECLARE $seriesId AS Uint64; + DECLARE $seasonId AS Uint64; + + SELECT sa.title AS season_title, sr.title AS series_title + FROM seasons AS sa + INNER JOIN series AS sr + ON sa.series_id = sr.series_id + WHERE sa.series_id = $seriesId AND sa.season_id = $seasonId; + )", path); + + // Type of parameter values should be exactly the same as in DECLARE statements. + auto params = session.GetParamsBuilder() + .AddParam("$seriesId") + .Uint64(seriesId) + .Build() + .AddParam("$seasonId") + .Uint64(seasonId) + .Build() + .Build(); + + auto result = session.ExecuteDataQuery( + query, + TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx(), + params).GetValueSync(); + + if (result.IsSuccess()) { + resultSet = result.GetResultSet(0); + } + + return result; +} + +//! Shows usage of prepared queries. +static TStatus PreparedSelectTransaction(TSession session, const std::string& path, + ui64 seriesId, ui64 seasonId, ui64 episodeId, std::optional& resultSet) +{ + // Once prepared, query data is stored in the session and identified by QueryId. + // Local query cache is used to keep track of queries, prepared in current session. + auto query = std::format(R"( + --!syntax_v1 + PRAGMA TablePathPrefix("{}"); + + DECLARE $seriesId AS Uint64; + DECLARE $seasonId AS Uint64; + DECLARE $episodeId AS Uint64; + + SELECT * + FROM episodes + WHERE series_id = $seriesId AND season_id = $seasonId AND episode_id = $episodeId; + )", path); + + // Prepare query or get result from query cache + auto prepareResult = session.PrepareDataQuery(query).GetValueSync(); + if (!prepareResult.IsSuccess()) { + return prepareResult; + } + + if (!prepareResult.IsQueryFromCache()) { + std::cerr << "+Finished preparing query: PreparedSelectTransaction" << std::endl; + } + + auto dataQuery = prepareResult.GetQuery(); + + auto params = dataQuery.GetParamsBuilder() + .AddParam("$seriesId") + .Uint64(seriesId) + .Build() + .AddParam("$seasonId") + .Uint64(seasonId) + .Build() + .AddParam("$episodeId") + .Uint64(episodeId) + .Build() + .Build(); + + auto result = dataQuery.Execute(TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx(), + params).GetValueSync(); + + if (result.IsSuccess()) { + resultSet = result.GetResultSet(0); + } + + return result; +} + +//! Shows usage of transactions consisting of multiple data queries with client logic between them. +static TStatus MultiStepTransaction(TSession session, const std::string& path, ui64 seriesId, ui64 seasonId, + std::optional& resultSet) +{ + auto query1 = std::format(R"( + --!syntax_v1 + PRAGMA TablePathPrefix("{}"); + + DECLARE $seriesId AS Uint64; + DECLARE $seasonId AS Uint64; + + SELECT first_aired AS from_date FROM seasons + WHERE series_id = $seriesId AND season_id = $seasonId; + )", path); + + auto params1 = session.GetParamsBuilder() + .AddParam("$seriesId") + .Uint64(seriesId) + .Build() + .AddParam("$seasonId") + .Uint64(seasonId) + .Build() + .Build(); + + // Execute first query to get the required values to the client. + // Transaction control settings don't set CommitTx flag to keep transaction active + // after query execution. + auto result = session.ExecuteDataQuery( + query1, + TTxControl::BeginTx(TTxSettings::SerializableRW()), + params1).GetValueSync(); + + if (!result.IsSuccess()) { + return result; + } + + // Get active transaction id + auto tx = result.GetTransaction(); + + TResultSetParser parser(result.GetResultSet(0)); + parser.TryNextRow(); + auto date = parser.ColumnParser("from_date").GetOptionalUint64(); + + // Perform some client logic on returned values + auto userFunc = [] (const TInstant fromDate) { + return fromDate + TDuration::Days(15); + }; + + TInstant fromDate = TInstant::Days(*date); + TInstant toDate = userFunc(fromDate); + + // Construct next query based on the results of client logic + auto query2 = std::format(R"( + --!syntax_v1 + PRAGMA TablePathPrefix("{}"); + + DECLARE $seriesId AS Uint64; + DECLARE $fromDate AS Uint64; + DECLARE $toDate AS Uint64; + + SELECT season_id, episode_id, title, air_date FROM episodes + WHERE series_id = $seriesId AND air_date >= $fromDate AND air_date <= $toDate; + )", path); + + auto params2 = session.GetParamsBuilder() + .AddParam("$seriesId") + .Uint64(seriesId) + .Build() + .AddParam("$fromDate") + .Uint64(fromDate.Days()) + .Build() + .AddParam("$toDate") + .Uint64(toDate.Days()) + .Build() + .Build(); + + // Execute second query. + // Transaction control settings continues active transaction (tx) and + // commits it at the end of second query execution. + result = session.ExecuteDataQuery( + query2, + TTxControl::Tx(*tx).CommitTx(), + params2).GetValueSync(); + + if (result.IsSuccess()) { + resultSet = result.GetResultSet(0); + } + + return result; +} + +// Show usage of explicit Begin/Commit transaction control calls. +// In most cases it's better to use transaction control settings in ExecuteDataQuery calls instead +// to avoid additional hops to YDB cluster and allow more efficient execution of queries. +static TStatus ExplicitTclTransaction(TSession session, const std::string& path, const TInstant& airDate) { + auto beginResult = session.BeginTransaction(TTxSettings::SerializableRW()).GetValueSync(); + if (!beginResult.IsSuccess()) { + return beginResult; + } + + // Get newly created transaction id + auto tx = beginResult.GetTransaction(); + + auto query = std::format(R"( + --!syntax_v1 + PRAGMA TablePathPrefix("{}"); + + DECLARE $airDate AS Date; + + UPDATE episodes SET air_date = CAST($airDate AS Uint16) WHERE title = "TBD"; + )", path); + + auto params = session.GetParamsBuilder() + .AddParam("$airDate") + .Date(airDate) + .Build() + .Build(); + + // Execute data query. + // Transaction control settings continues active transaction (tx) + auto updateResult = session.ExecuteDataQuery(query, + TTxControl::Tx(tx), + params).GetValueSync(); + + if (!updateResult.IsSuccess()) { + return updateResult; + } + + // Commit active transaction (tx) + return tx.Commit().GetValueSync(); +} + +/////////////////////////////////////////////////////////////////////////////// + +void SelectSimple(TTableClient client, const std::string& path) { + std::optional resultSet; + ThrowOnError(client.RetryOperationSync([path, &resultSet](TSession session) { + return SelectSimpleTransaction(session, path, resultSet); + })); + + TResultSetParser parser(*resultSet); + if (parser.TryNextRow()) { + std::cout << "> SelectSimple:" << std::endl << "Series" + << ", Id: " << ToString(parser.ColumnParser("series_id").GetOptionalUint64()) + << ", Title: " << ToString(parser.ColumnParser("title").GetOptionalUtf8()) + << ", Release date: " << ToString(parser.ColumnParser("release_date").GetOptionalString()) + << std::endl; + } +} + +void UpsertSimple(TTableClient client, const std::string& path) { + ThrowOnError(client.RetryOperationSync([path](TSession session) { + return UpsertSimpleTransaction(session, path); + })); +} + +void SelectWithParams(TTableClient client, const std::string& path) { + std::optional resultSet; + ThrowOnError(client.RetryOperationSync([path, &resultSet](TSession session) { + return SelectWithParamsTransaction(session, path, 2, 3, resultSet); + })); + + TResultSetParser parser(*resultSet); + if (parser.TryNextRow()) { + std::cout << "> SelectWithParams:" << std::endl << "Season" + << ", Title: " << ToString(parser.ColumnParser("season_title").GetOptionalUtf8()) + << ", Series title: " << ToString(parser.ColumnParser("series_title").GetOptionalUtf8()) + << std::endl; + } +} + +void PreparedSelect(TTableClient client, const std::string& path, ui32 seriesId, ui32 seasonId, ui32 episodeId) { + std::optional resultSet; + ThrowOnError(client.RetryOperationSync([path, seriesId, seasonId, episodeId, &resultSet](TSession session) { + return PreparedSelectTransaction(session, path, seriesId, seasonId, episodeId, resultSet); + })); + + TResultSetParser parser(*resultSet); + if (parser.TryNextRow()) { + auto airDate = TInstant::Days(*parser.ColumnParser("air_date").GetOptionalUint64()); + + std::cout << "> PreparedSelect:" << std::endl << "Episode " << ToString(parser.ColumnParser("episode_id").GetOptionalUint64()) + << ", Title: " << ToString(parser.ColumnParser("title").GetOptionalUtf8()) + << ", Air date: " << airDate.FormatLocalTime("%a %b %d, %Y") + << std::endl; + } +} + +void MultiStep(TTableClient client, const std::string& path) { + std::optional resultSet; + ThrowOnError(client.RetryOperationSync([path, &resultSet](TSession session) { + return MultiStepTransaction(session, path, 2, 5, resultSet); + })); + + TResultSetParser parser(*resultSet); + std::cout << "> MultiStep:" << std::endl; + while (parser.TryNextRow()) { + auto airDate = TInstant::Days(*parser.ColumnParser("air_date").GetOptionalUint64()); + + std::cout << "Episode " << ToString(parser.ColumnParser("episode_id").GetOptionalUint64()) + << ", Season: " << ToString(parser.ColumnParser("season_id").GetOptionalUint64()) + << ", Title: " << ToString(parser.ColumnParser("title").GetOptionalUtf8()) + << ", Air date: " << airDate.FormatLocalTime("%a %b %d, %Y") + << std::endl; + } +} + +void ExplicitTcl(TTableClient client, const std::string& path) { + ThrowOnError(client.RetryOperationSync([path](TSession session) { + return ExplicitTclTransaction(session, path, TInstant::Now()); + })); +} + +void ScanQuerySelect(TTableClient client, const std::string& path) { + auto query = std::format(R"( + --!syntax_v1 + PRAGMA TablePathPrefix("{}"); + + DECLARE $series AS List; + + SELECT series_id, season_id, title, CAST(CAST(first_aired AS Date) AS String) AS first_aired + FROM seasons + WHERE series_id IN $series + )", path); + + auto parameters = TParamsBuilder() + .AddParam("$series") + .BeginList() + .AddListItem().Uint64(1) + .AddListItem().Uint64(10) + .EndList().Build() + .Build(); + + // Executes scan query + auto result = client.StreamExecuteScanQuery(query, parameters).GetValueSync(); + + if (!result.IsSuccess()) { + std::cerr << "ScanQuery execution failure: " << result.GetIssues().ToString() << std::endl; + return; + } + + bool eos = false; + std::cout << "> ScanQuerySelect:" << std::endl; + while (!eos) { + auto streamPart = result.ReadNext().ExtractValueSync(); + + if (!streamPart.IsSuccess()) { + eos = true; + if (!streamPart.EOS()) { + std::cerr << "ScanQuery execution failure: " << streamPart.GetIssues().ToString() << std::endl; + } + continue; + } + + if (streamPart.HasResultSet()) { + auto rs = streamPart.ExtractResultSet(); + auto columns = rs.GetColumnsMeta(); + + TResultSetParser parser(rs); + while (parser.TryNextRow()) { + std::cout << "Season" + << ", SeriesId: " << ToString(parser.ColumnParser("series_id").GetOptionalUint64()) + << ", SeasonId: " << ToString(parser.ColumnParser("season_id").GetOptionalUint64()) + << ", Title: " << ToString(parser.ColumnParser("title").GetOptionalUtf8()) + << ", Air date: " << ToString(parser.ColumnParser("first_aired").GetOptionalString()) + << std::endl; + } + } + } +} + +/////////////////////////////////////////////////////////////////////////////// + +std::unique_ptr Run(const TDriver& driver, const std::string& path) { + TTableClient client(driver); + auto response = std::make_unique(); + try { + CreateTables(client, path); + + response->result += DescribeTable(client, path, "series"); + + ThrowOnError(client.RetryOperationSync([path](TSession session) { + return FillTableDataTransaction(session, path); + })); + + SelectSimple(client, path); + UpsertSimple(client, path); + + SelectWithParams(client, path); + + PreparedSelect(client, path, 2, 3, 7); + PreparedSelect(client, path, 2, 3, 8); + + MultiStep(client, path); + + ExplicitTcl(client, path); + + PreparedSelect(client, path, 2, 6, 1); + + ScanQuerySelect(client, path); + } + catch (const TYdbErrorException& e) { + response->success = false; + std::cerr << "Execution failed due to fatal error:" << std::endl; + PrintStatus(e.Status); + return response; + } + response->success = true; + return response; +} diff --git a/tests/integration/basic_example_it/basic_example.h b/tests/integration/basic_example_it/basic_example.h new file mode 100644 index 00000000000..d4f619e4c25 --- /dev/null +++ b/tests/integration/basic_example_it/basic_example.h @@ -0,0 +1,13 @@ +#pragma once + +#include +#include + +struct Response { + bool success; + std::string result; +}; + +NYdb::TParams GetTablesDataParams(); + +std::unique_ptr Run(const NYdb::TDriver& driver, const std::string& path); diff --git a/tests/integration/basic_example_it/basic_example_data.cpp b/tests/integration/basic_example_it/basic_example_data.cpp new file mode 100644 index 00000000000..e27bf1528c7 --- /dev/null +++ b/tests/integration/basic_example_it/basic_example_data.cpp @@ -0,0 +1,205 @@ +#include "basic_example.h" + +using namespace NYdb; +using namespace NYdb::NTable; + +struct TSeries { + ui64 SeriesId; + std::string Title; + TInstant ReleaseDate; + std::string SeriesInfo; + + TSeries(ui64 seriesId, const std::string& title, const TInstant& releaseDate, const std::string& seriesInfo) + : SeriesId(seriesId) + , Title(title) + , ReleaseDate(releaseDate) + , SeriesInfo(seriesInfo) {} +}; + +struct TSeason { + ui64 SeriesId; + ui64 SeasonId; + std::string Title; + TInstant FirstAired; + TInstant LastAired; + + TSeason(ui64 seriesId, ui64 seasonId, const std::string& title, const TInstant& firstAired, const TInstant& lastAired) + : SeriesId(seriesId) + , SeasonId(seasonId) + , Title(title) + , FirstAired(firstAired) + , LastAired(lastAired) {} +}; + +struct TEpisode { + ui64 SeriesId; + ui64 SeasonId; + ui64 EpisodeId; + std::string Title; + TInstant AirDate; + + TEpisode(ui64 seriesId, ui64 seasonId, ui64 episodeId, const std::string& title, const TInstant& airDate) + : SeriesId(seriesId) + , SeasonId(seasonId) + , EpisodeId(episodeId) + , Title(title) + , AirDate(airDate) {} +}; + +TParams GetTablesDataParams() { + std::vector seriesData = { + TSeries(1, "IT Crowd", TInstant::ParseIso8601("2006-02-03"), + "The IT Crowd is a British sitcom produced by Channel 4, written by Graham Linehan, produced by " + "Ash Atalla and starring Chris O'Dowd, Richard Ayoade, Katherine Parkinson, and Matt Berry."), + TSeries(2, "Silicon Valley", TInstant::ParseIso8601("2014-04-06"), + "Silicon Valley is an American comedy television series created by Mike Judge, John Altschuler and " + "Dave Krinsky. The series focuses on five young men who founded a startup company in Silicon Valley.") + }; + + std::vector seasonsData = { + TSeason(1, 1, "Season 1", TInstant::ParseIso8601("2006-02-03"), TInstant::ParseIso8601("2006-03-03")), + TSeason(1, 2, "Season 2", TInstant::ParseIso8601("2007-08-24"), TInstant::ParseIso8601("2007-09-28")), + TSeason(1, 3, "Season 3", TInstant::ParseIso8601("2008-11-21"), TInstant::ParseIso8601("2008-12-26")), + TSeason(1, 4, "Season 4", TInstant::ParseIso8601("2010-06-25"), TInstant::ParseIso8601("2010-07-30")), + TSeason(2, 1, "Season 1", TInstant::ParseIso8601("2014-04-06"), TInstant::ParseIso8601("2014-06-01")), + TSeason(2, 2, "Season 2", TInstant::ParseIso8601("2015-04-12"), TInstant::ParseIso8601("2015-06-14")), + TSeason(2, 3, "Season 3", TInstant::ParseIso8601("2016-04-24"), TInstant::ParseIso8601("2016-06-26")), + TSeason(2, 4, "Season 4", TInstant::ParseIso8601("2017-04-23"), TInstant::ParseIso8601("2017-06-25")), + TSeason(2, 5, "Season 5", TInstant::ParseIso8601("2018-03-25"), TInstant::ParseIso8601("2018-05-13")) + }; + + std::vector episodesData = { + TEpisode(1, 1, 1, "Yesterday's Jam", TInstant::ParseIso8601("2006-02-03")), + TEpisode(1, 1, 2, "Calamity Jen", TInstant::ParseIso8601("2006-02-03")), + TEpisode(1, 1, 3, "Fifty-Fifty", TInstant::ParseIso8601("2006-02-10")), + TEpisode(1, 1, 4, "The Red Door", TInstant::ParseIso8601("2006-02-17")), + TEpisode(1, 1, 5, "The Haunting of Bill Crouse", TInstant::ParseIso8601("2006-02-24")), + TEpisode(1, 1, 6, "Aunt Irma Visits", TInstant::ParseIso8601("2006-03-03")), + TEpisode(1, 2, 1, "The Work Outing", TInstant::ParseIso8601("2006-08-24")), + TEpisode(1, 2, 2, "Return of the Golden Child", TInstant::ParseIso8601("2007-08-31")), + TEpisode(1, 2, 3, "Moss and the German", TInstant::ParseIso8601("2007-09-07")), + TEpisode(1, 2, 4, "The Dinner Party", TInstant::ParseIso8601("2007-09-14")), + TEpisode(1, 2, 5, "Smoke and Mirrors", TInstant::ParseIso8601("2007-09-21")), + TEpisode(1, 2, 6, "Men Without Women", TInstant::ParseIso8601("2007-09-28")), + TEpisode(1, 3, 1, "From Hell", TInstant::ParseIso8601("2008-11-21")), + TEpisode(1, 3, 2, "Are We Not Men?", TInstant::ParseIso8601("2008-11-28")), + TEpisode(1, 3, 3, "Tramps Like Us", TInstant::ParseIso8601("2008-12-05")), + TEpisode(1, 3, 4, "The Speech", TInstant::ParseIso8601("2008-12-12")), + TEpisode(1, 3, 5, "Friendface", TInstant::ParseIso8601("2008-12-19")), + TEpisode(1, 3, 6, "Calendar Geeks", TInstant::ParseIso8601("2008-12-26")), + TEpisode(1, 4, 1, "Jen The Fredo", TInstant::ParseIso8601("2010-06-25")), + TEpisode(1, 4, 2, "The Final Countdown", TInstant::ParseIso8601("2010-07-02")), + TEpisode(1, 4, 3, "Something Happened", TInstant::ParseIso8601("2010-07-09")), + TEpisode(1, 4, 4, "Italian For Beginners", TInstant::ParseIso8601("2010-07-16")), + TEpisode(1, 4, 5, "Bad Boys", TInstant::ParseIso8601("2010-07-23")), + TEpisode(1, 4, 6, "Reynholm vs Reynholm", TInstant::ParseIso8601("2010-07-30")), + TEpisode(2, 1, 1, "Minimum Viable Product", TInstant::ParseIso8601("2014-04-06")), + TEpisode(2, 1, 2, "The Cap Table", TInstant::ParseIso8601("2014-04-13")), + TEpisode(2, 1, 3, "Articles of Incorporation", TInstant::ParseIso8601("2014-04-20")), + TEpisode(2, 1, 4, "Fiduciary Duties", TInstant::ParseIso8601("2014-04-27")), + TEpisode(2, 1, 5, "Signaling Risk", TInstant::ParseIso8601("2014-05-04")), + TEpisode(2, 1, 6, "Third Party Insourcing", TInstant::ParseIso8601("2014-05-11")), + TEpisode(2, 1, 7, "Proof of Concept", TInstant::ParseIso8601("2014-05-18")), + TEpisode(2, 1, 8, "Optimal Tip-to-Tip Efficiency", TInstant::ParseIso8601("2014-06-01")), + TEpisode(2, 2, 1, "Sand Hill Shuffle", TInstant::ParseIso8601("2015-04-12")), + TEpisode(2, 2, 2, "Runaway Devaluation", TInstant::ParseIso8601("2015-04-19")), + TEpisode(2, 2, 3, "Bad Money", TInstant::ParseIso8601("2015-04-26")), + TEpisode(2, 2, 4, "The Lady", TInstant::ParseIso8601("2015-05-03")), + TEpisode(2, 2, 5, "Server Space", TInstant::ParseIso8601("2015-05-10")), + TEpisode(2, 2, 6, "Homicide", TInstant::ParseIso8601("2015-05-17")), + TEpisode(2, 2, 7, "Adult Content", TInstant::ParseIso8601("2015-05-24")), + TEpisode(2, 2, 8, "White Hat/Black Hat", TInstant::ParseIso8601("2015-05-31")), + TEpisode(2, 2, 9, "Binding Arbitration", TInstant::ParseIso8601("2015-06-07")), + TEpisode(2, 2, 10, "Two Days of the Condor", TInstant::ParseIso8601("2015-06-14")), + TEpisode(2, 3, 1, "Founder Friendly", TInstant::ParseIso8601("2016-04-24")), + TEpisode(2, 3, 2, "Two in the Box", TInstant::ParseIso8601("2016-05-01")), + TEpisode(2, 3, 3, "Meinertzhagen's Haversack", TInstant::ParseIso8601("2016-05-08")), + TEpisode(2, 3, 4, "Maleant Data Systems Solutions", TInstant::ParseIso8601("2016-05-15")), + TEpisode(2, 3, 5, "The Empty Chair", TInstant::ParseIso8601("2016-05-22")), + TEpisode(2, 3, 6, "Bachmanity Insanity", TInstant::ParseIso8601("2016-05-29")), + TEpisode(2, 3, 7, "To Build a Better Beta", TInstant::ParseIso8601("2016-06-05")), + TEpisode(2, 3, 8, "Bachman's Earnings Over-Ride", TInstant::ParseIso8601("2016-06-12")), + TEpisode(2, 3, 9, "Daily Active Users", TInstant::ParseIso8601("2016-06-19")), + TEpisode(2, 3, 10, "The Uptick", TInstant::ParseIso8601("2016-06-26")), + TEpisode(2, 4, 1, "Success Failure", TInstant::ParseIso8601("2017-04-23")), + TEpisode(2, 4, 2, "Terms of Service", TInstant::ParseIso8601("2017-04-30")), + TEpisode(2, 4, 3, "Intellectual Property", TInstant::ParseIso8601("2017-05-07")), + TEpisode(2, 4, 4, "Teambuilding Exercise", TInstant::ParseIso8601("2017-05-14")), + TEpisode(2, 4, 5, "The Blood Boy", TInstant::ParseIso8601("2017-05-21")), + TEpisode(2, 4, 6, "Customer Service", TInstant::ParseIso8601("2017-05-28")), + TEpisode(2, 4, 7, "The Patent Troll", TInstant::ParseIso8601("2017-06-04")), + TEpisode(2, 4, 8, "The Keenan Vortex", TInstant::ParseIso8601("2017-06-11")), + TEpisode(2, 4, 9, "Hooli-Con", TInstant::ParseIso8601("2017-06-18")), + TEpisode(2, 4, 10, "Server Error", TInstant::ParseIso8601("2017-06-25")), + TEpisode(2, 5, 1, "Grow Fast or Die Slow", TInstant::ParseIso8601("2018-03-25")), + TEpisode(2, 5, 2, "Reorientation", TInstant::ParseIso8601("2018-04-01")), + TEpisode(2, 5, 3, "Chief Operating Officer", TInstant::ParseIso8601("2018-04-08")), + TEpisode(2, 5, 4, "Tech Evangelist", TInstant::ParseIso8601("2018-04-15")), + TEpisode(2, 5, 5, "Facial Recognition", TInstant::ParseIso8601("2018-04-22")), + TEpisode(2, 5, 6, "Artificial Emotional Intelligence", TInstant::ParseIso8601("2018-04-29")), + TEpisode(2, 5, 7, "Initial Coin Offering", TInstant::ParseIso8601("2018-05-06")), + TEpisode(2, 5, 8, "Fifty-One Percent", TInstant::ParseIso8601("2018-05-13")) + }; + + TParamsBuilder paramsBuilder; + + auto& seriesParam = paramsBuilder.AddParam("$seriesData"); + seriesParam.BeginList(); + for (auto& series : seriesData) { + seriesParam.AddListItem() + .BeginStruct() + .AddMember("series_id") + .Uint64(series.SeriesId) + .AddMember("title") + .Utf8(series.Title) + .AddMember("release_date") + .Date(series.ReleaseDate) + .AddMember("series_info") + .Utf8(series.SeriesInfo) + .EndStruct(); + } + seriesParam.EndList(); + seriesParam.Build(); + + auto& seasonsParam = paramsBuilder.AddParam("$seasonsData"); + seasonsParam.BeginList(); + for (auto& season : seasonsData) { + seasonsParam.AddListItem() + .BeginStruct() + .AddMember("series_id") + .Uint64(season.SeriesId) + .AddMember("season_id") + .Uint64(season.SeasonId) + .AddMember("title") + .Utf8(season.Title) + .AddMember("first_aired") + .Date(season.FirstAired) + .AddMember("last_aired") + .Date(season.LastAired) + .EndStruct(); + } + seasonsParam.EndList(); + seasonsParam.Build(); + + auto& episodesParam = paramsBuilder.AddParam("$episodesData"); + episodesParam.BeginList(); + for (auto& episode : episodesData) { + episodesParam.AddListItem() + .BeginStruct() + .AddMember("series_id") + .Uint64(episode.SeriesId) + .AddMember("season_id") + .Uint64(episode.SeasonId) + .AddMember("episode_id") + .Uint64(episode.EpisodeId) + .AddMember("title") + .Utf8(episode.Title) + .AddMember("air_date") + .Date(episode.AirDate) + .EndStruct(); + } + episodesParam.EndList(); + episodesParam.Build(); + + return paramsBuilder.Build(); +} diff --git a/tests/integration/basic_example_it/main.cpp b/tests/integration/basic_example_it/main.cpp new file mode 100644 index 00000000000..9786e75ec79 --- /dev/null +++ b/tests/integration/basic_example_it/main.cpp @@ -0,0 +1,50 @@ +#include "basic_example.h" + +#include + +#include + +#include +#include + +#include + +using namespace NLastGetopt; +using namespace NYdb; + +void StopHandler(int) { + exit(1); +} + +TEST(Integration, BasicExample) { + TOpts opts = TOpts::Default(); + + std::string endpoint = "localhost:2136"; + std::string database = "/Root/test"; + std::string path; + std::string certPath; + + if (path.empty()) { + path = database; + } + + auto driverConfig = TDriverConfig() + .SetEndpoint(endpoint) + .SetDatabase(database) + .SetAuthToken(std::getenv("YDB_TOKEN") ? std::getenv("YDB_TOKEN") : ""); + + if (!certPath.empty()) { + std::string cert = TFileInput(certPath).ReadAll(); + driverConfig.UseSecureConnection(cert); + } + + TDriver driver(driverConfig); + + if (auto response = ::Run(driver, path); !response->success) { + std::cerr << std::format("The driver could not be started (path = {})", path) << std::endl; + FAIL(); + driver.Stop(true); + } + + driver.Stop(true); +} diff --git a/tests/CMakeLists.txt b/tests/ut/CMakeLists.txt similarity index 100% rename from tests/CMakeLists.txt rename to tests/ut/CMakeLists.txt diff --git a/tests/client/CMakeLists.txt b/tests/ut/client/CMakeLists.txt similarity index 77% rename from tests/client/CMakeLists.txt rename to tests/ut/client/CMakeLists.txt index e5d6d4acfb2..d35d68352ec 100644 --- a/tests/client/CMakeLists.txt +++ b/tests/ut/client/CMakeLists.txt @@ -1,6 +1,6 @@ add_subdirectory(oauth2_token_exchange) -add_ydb_test(NAME client-ydb_coordination-ut +add_ydb_test(NAME client-ydb_coordination_ut SOURCES coordination_ut.cpp LINK_LIBRARIES @@ -10,7 +10,7 @@ add_ydb_test(NAME client-ydb_coordination-ut api-grpc ) -add_ydb_test(NAME client-extensions-discovery_mutator-ut +add_ydb_test(NAME client-extensions-discovery_mutator_ut SOURCES discovery_mutator_ut.cpp LINK_LIBRARIES @@ -20,7 +20,7 @@ add_ydb_test(NAME client-extensions-discovery_mutator-ut YDB-CPP-SDK::Table ) -add_ydb_test(NAME client-ydb_driver-ut +add_ydb_test(NAME client-ydb_driver_ut SOURCES driver_ut.cpp LINK_LIBRARIES @@ -30,7 +30,7 @@ add_ydb_test(NAME client-ydb_driver-ut YDB-CPP-SDK::Table ) -add_ydb_test(NAME client-impl-ydb_endpoints-ut +add_ydb_test(NAME client-impl-ydb_endpoints_ut INCLUDE_DIRS ${YDB_SDK_SOURCE_DIR}/src/client/impl/ydb_endpoints SOURCES @@ -41,7 +41,7 @@ add_ydb_test(NAME client-impl-ydb_endpoints-ut client-impl-ydb_endpoints ) -add_ydb_test(NAME client-ydb_params-ut +add_ydb_test(NAME client-ydb_params_ut SOURCES params_ut.cpp LINK_LIBRARIES @@ -51,7 +51,7 @@ add_ydb_test(NAME client-ydb_params-ut YDB-CPP-SDK::YsonValue ) -add_ydb_test(NAME client-ydb_result-ut +add_ydb_test(NAME client-ydb_result_ut SOURCES result_ut.cpp LINK_LIBRARIES @@ -61,7 +61,7 @@ add_ydb_test(NAME client-ydb_result-ut YDB-CPP-SDK::Params ) -add_ydb_test(NAME client-ydb_value-ut +add_ydb_test(NAME client-ydb_value_ut SOURCES value_ut.cpp LINK_LIBRARIES @@ -73,7 +73,7 @@ add_ydb_test(NAME client-ydb_value-ut YDB-CPP-SDK::Params ) -add_ydb_test(NAME client-draft-ut +add_ydb_test(NAME client-draft_ut SOURCES ydb_scripting_response_headers_ut.cpp LINK_LIBRARIES diff --git a/tests/client/coordination_ut.cpp b/tests/ut/client/coordination_ut.cpp similarity index 100% rename from tests/client/coordination_ut.cpp rename to tests/ut/client/coordination_ut.cpp diff --git a/tests/client/discovery_mutator_ut.cpp b/tests/ut/client/discovery_mutator_ut.cpp similarity index 100% rename from tests/client/discovery_mutator_ut.cpp rename to tests/ut/client/discovery_mutator_ut.cpp diff --git a/tests/client/driver_ut.cpp b/tests/ut/client/driver_ut.cpp similarity index 100% rename from tests/client/driver_ut.cpp rename to tests/ut/client/driver_ut.cpp diff --git a/tests/client/endpoints_ut.cpp b/tests/ut/client/endpoints_ut.cpp similarity index 100% rename from tests/client/endpoints_ut.cpp rename to tests/ut/client/endpoints_ut.cpp diff --git a/tests/client/oauth2_token_exchange/CMakeLists.txt b/tests/ut/client/oauth2_token_exchange/CMakeLists.txt similarity index 83% rename from tests/client/oauth2_token_exchange/CMakeLists.txt rename to tests/ut/client/oauth2_token_exchange/CMakeLists.txt index a377bf8c809..a56f8432b44 100644 --- a/tests/client/oauth2_token_exchange/CMakeLists.txt +++ b/tests/ut/client/oauth2_token_exchange/CMakeLists.txt @@ -1,4 +1,4 @@ -add_ydb_test(NAME client-oauth2-ut +add_ydb_test(NAME client-oauth2_ut SOURCES credentials_ut.cpp jwt_token_source_ut.cpp diff --git a/tests/client/oauth2_token_exchange/credentials_ut.cpp b/tests/ut/client/oauth2_token_exchange/credentials_ut.cpp similarity index 100% rename from tests/client/oauth2_token_exchange/credentials_ut.cpp rename to tests/ut/client/oauth2_token_exchange/credentials_ut.cpp diff --git a/tests/client/oauth2_token_exchange/jwt_token_source_ut.cpp b/tests/ut/client/oauth2_token_exchange/jwt_token_source_ut.cpp similarity index 100% rename from tests/client/oauth2_token_exchange/jwt_token_source_ut.cpp rename to tests/ut/client/oauth2_token_exchange/jwt_token_source_ut.cpp diff --git a/tests/client/params_ut.cpp b/tests/ut/client/params_ut.cpp similarity index 100% rename from tests/client/params_ut.cpp rename to tests/ut/client/params_ut.cpp diff --git a/tests/client/result_ut.cpp b/tests/ut/client/result_ut.cpp similarity index 100% rename from tests/client/result_ut.cpp rename to tests/ut/client/result_ut.cpp diff --git a/tests/client/value_ut.cpp b/tests/ut/client/value_ut.cpp similarity index 100% rename from tests/client/value_ut.cpp rename to tests/ut/client/value_ut.cpp diff --git a/tests/client/ydb_scripting_response_headers_ut.cpp b/tests/ut/client/ydb_scripting_response_headers_ut.cpp similarity index 100% rename from tests/client/ydb_scripting_response_headers_ut.cpp rename to tests/ut/client/ydb_scripting_response_headers_ut.cpp diff --git a/tests/json_value/CMakeLists.txt b/tests/ut/json_value/CMakeLists.txt similarity index 85% rename from tests/json_value/CMakeLists.txt rename to tests/ut/json_value/CMakeLists.txt index 25a4cc4e82b..c17170583bc 100644 --- a/tests/json_value/CMakeLists.txt +++ b/tests/ut/json_value/CMakeLists.txt @@ -1,4 +1,4 @@ -add_ydb_test(NAME json_value-ut +add_ydb_test(NAME json_value_ut SOURCES ydb_json_value_ut.cpp LINK_LIBRARIES diff --git a/tests/json_value/ydb_json_value_ut.cpp b/tests/ut/json_value/ydb_json_value_ut.cpp similarity index 100% rename from tests/json_value/ydb_json_value_ut.cpp rename to tests/ut/json_value/ydb_json_value_ut.cpp diff --git a/tests/library/CMakeLists.txt b/tests/ut/library/CMakeLists.txt similarity index 100% rename from tests/library/CMakeLists.txt rename to tests/ut/library/CMakeLists.txt diff --git a/tests/library/cache/CMakeLists.txt b/tests/ut/library/cache/CMakeLists.txt similarity index 100% rename from tests/library/cache/CMakeLists.txt rename to tests/ut/library/cache/CMakeLists.txt diff --git a/tests/library/cache/cache_ut.cpp b/tests/ut/library/cache/cache_ut.cpp similarity index 100% rename from tests/library/cache/cache_ut.cpp rename to tests/ut/library/cache/cache_ut.cpp diff --git a/tests/library/case_insensitive_string/CMakeLists.txt b/tests/ut/library/case_insensitive_string/CMakeLists.txt similarity index 100% rename from tests/library/case_insensitive_string/CMakeLists.txt rename to tests/ut/library/case_insensitive_string/CMakeLists.txt diff --git a/tests/library/case_insensitive_string/case_insensitive_string_ut.cpp b/tests/ut/library/case_insensitive_string/case_insensitive_string_ut.cpp similarity index 100% rename from tests/library/case_insensitive_string/case_insensitive_string_ut.cpp rename to tests/ut/library/case_insensitive_string/case_insensitive_string_ut.cpp diff --git a/tests/library/cgiparam/CMakeLists.txt b/tests/ut/library/cgiparam/CMakeLists.txt similarity index 70% rename from tests/library/cgiparam/CMakeLists.txt rename to tests/ut/library/cgiparam/CMakeLists.txt index 8092f166649..9e6cda66f90 100644 --- a/tests/library/cgiparam/CMakeLists.txt +++ b/tests/ut/library/cgiparam/CMakeLists.txt @@ -1,4 +1,4 @@ -add_ydb_test(NAME library-cgiparam-ut +add_ydb_test(NAME library-cgiparam_ut SOURCES ut.cpp LINK_LIBRARIES diff --git a/tests/library/cgiparam/ut.cpp b/tests/ut/library/cgiparam/ut.cpp similarity index 100% rename from tests/library/cgiparam/ut.cpp rename to tests/ut/library/cgiparam/ut.cpp diff --git a/tests/library/charset/CMakeLists.txt b/tests/ut/library/charset/CMakeLists.txt similarity index 100% rename from tests/library/charset/CMakeLists.txt rename to tests/ut/library/charset/CMakeLists.txt diff --git a/tests/library/charset/ci_string_ut.cpp b/tests/ut/library/charset/ci_string_ut.cpp similarity index 100% rename from tests/library/charset/ci_string_ut.cpp rename to tests/ut/library/charset/ci_string_ut.cpp diff --git a/tests/library/charset/codepage_ut.cpp b/tests/ut/library/charset/codepage_ut.cpp similarity index 100% rename from tests/library/charset/codepage_ut.cpp rename to tests/ut/library/charset/codepage_ut.cpp diff --git a/tests/library/charset/iconv_ut.cpp b/tests/ut/library/charset/iconv_ut.cpp similarity index 100% rename from tests/library/charset/iconv_ut.cpp rename to tests/ut/library/charset/iconv_ut.cpp diff --git a/tests/library/charset/recyr_int_ut.cpp b/tests/ut/library/charset/recyr_int_ut.cpp similarity index 100% rename from tests/library/charset/recyr_int_ut.cpp rename to tests/ut/library/charset/recyr_int_ut.cpp diff --git a/tests/library/charset/wide_ut.cpp b/tests/ut/library/charset/wide_ut.cpp similarity index 100% rename from tests/library/charset/wide_ut.cpp rename to tests/ut/library/charset/wide_ut.cpp diff --git a/tests/library/containers/CMakeLists.txt b/tests/ut/library/containers/CMakeLists.txt similarity index 100% rename from tests/library/containers/CMakeLists.txt rename to tests/ut/library/containers/CMakeLists.txt diff --git a/tests/library/containers/disjoint_interval_tree_ut.cpp b/tests/ut/library/containers/disjoint_interval_tree_ut.cpp similarity index 100% rename from tests/library/containers/disjoint_interval_tree_ut.cpp rename to tests/ut/library/containers/disjoint_interval_tree_ut.cpp diff --git a/tests/library/containers/intrusive_rb_tree_ut.cpp b/tests/ut/library/containers/intrusive_rb_tree_ut.cpp similarity index 100% rename from tests/library/containers/intrusive_rb_tree_ut.cpp rename to tests/ut/library/containers/intrusive_rb_tree_ut.cpp diff --git a/tests/library/containers/paged_vector_ut.cpp b/tests/ut/library/containers/paged_vector_ut.cpp similarity index 100% rename from tests/library/containers/paged_vector_ut.cpp rename to tests/ut/library/containers/paged_vector_ut.cpp diff --git a/tests/library/containers/stack_vector_ut.cpp b/tests/ut/library/containers/stack_vector_ut.cpp similarity index 100% rename from tests/library/containers/stack_vector_ut.cpp rename to tests/ut/library/containers/stack_vector_ut.cpp diff --git a/tests/library/coroutine/CMakeLists.txt b/tests/ut/library/coroutine/CMakeLists.txt similarity index 100% rename from tests/library/coroutine/CMakeLists.txt rename to tests/ut/library/coroutine/CMakeLists.txt diff --git a/tests/library/coroutine/engine/CMakeLists.txt b/tests/ut/library/coroutine/engine/CMakeLists.txt similarity index 100% rename from tests/library/coroutine/engine/CMakeLists.txt rename to tests/ut/library/coroutine/engine/CMakeLists.txt diff --git a/tests/library/coroutine/engine/coroutine_ut.cpp b/tests/ut/library/coroutine/engine/coroutine_ut.cpp similarity index 100% rename from tests/library/coroutine/engine/coroutine_ut.cpp rename to tests/ut/library/coroutine/engine/coroutine_ut.cpp diff --git a/tests/library/coroutine/engine/stack/CMakeLists.txt b/tests/ut/library/coroutine/engine/stack/CMakeLists.txt similarity index 100% rename from tests/library/coroutine/engine/stack/CMakeLists.txt rename to tests/ut/library/coroutine/engine/stack/CMakeLists.txt diff --git a/tests/library/coroutine/engine/stack/stack_allocator_ut.cpp b/tests/ut/library/coroutine/engine/stack/stack_allocator_ut.cpp similarity index 100% rename from tests/library/coroutine/engine/stack/stack_allocator_ut.cpp rename to tests/ut/library/coroutine/engine/stack/stack_allocator_ut.cpp diff --git a/tests/library/coroutine/engine/stack/stack_guards_ut.cpp b/tests/ut/library/coroutine/engine/stack/stack_guards_ut.cpp similarity index 100% rename from tests/library/coroutine/engine/stack/stack_guards_ut.cpp rename to tests/ut/library/coroutine/engine/stack/stack_guards_ut.cpp diff --git a/tests/library/coroutine/engine/stack/stack_pool_ut.cpp b/tests/ut/library/coroutine/engine/stack/stack_pool_ut.cpp similarity index 100% rename from tests/library/coroutine/engine/stack/stack_pool_ut.cpp rename to tests/ut/library/coroutine/engine/stack/stack_pool_ut.cpp diff --git a/tests/library/coroutine/engine/stack/stack_ut.cpp b/tests/ut/library/coroutine/engine/stack/stack_ut.cpp similarity index 100% rename from tests/library/coroutine/engine/stack/stack_ut.cpp rename to tests/ut/library/coroutine/engine/stack/stack_ut.cpp diff --git a/tests/library/coroutine/engine/stack/stack_utils_ut.cpp b/tests/ut/library/coroutine/engine/stack/stack_utils_ut.cpp similarity index 100% rename from tests/library/coroutine/engine/stack/stack_utils_ut.cpp rename to tests/ut/library/coroutine/engine/stack/stack_utils_ut.cpp diff --git a/tests/library/dbg_output/CMakeLists.txt b/tests/ut/library/dbg_output/CMakeLists.txt similarity index 100% rename from tests/library/dbg_output/CMakeLists.txt rename to tests/ut/library/dbg_output/CMakeLists.txt diff --git a/tests/library/dbg_output/dbg_output_ut.cpp b/tests/ut/library/dbg_output/dbg_output_ut.cpp similarity index 100% rename from tests/library/dbg_output/dbg_output_ut.cpp rename to tests/ut/library/dbg_output/dbg_output_ut.cpp diff --git a/tests/library/diff/CMakeLists.txt b/tests/ut/library/diff/CMakeLists.txt similarity index 81% rename from tests/library/diff/CMakeLists.txt rename to tests/ut/library/diff/CMakeLists.txt index 81aa105a91a..250bdadf6d3 100644 --- a/tests/library/diff/CMakeLists.txt +++ b/tests/ut/library/diff/CMakeLists.txt @@ -1,4 +1,4 @@ -add_ydb_test(NAME library-diff-ut +add_ydb_test(NAME library-diff_ut SOURCES ut.cpp INCLUDE_DIRS diff --git a/tests/library/diff/ut.cpp b/tests/ut/library/diff/ut.cpp similarity index 100% rename from tests/library/diff/ut.cpp rename to tests/ut/library/diff/ut.cpp diff --git a/tests/library/digest/CMakeLists.txt b/tests/ut/library/digest/CMakeLists.txt similarity index 100% rename from tests/library/digest/CMakeLists.txt rename to tests/ut/library/digest/CMakeLists.txt diff --git a/tests/library/digest/lower_case/CMakeLists.txt b/tests/ut/library/digest/lower_case/CMakeLists.txt similarity index 100% rename from tests/library/digest/lower_case/CMakeLists.txt rename to tests/ut/library/digest/lower_case/CMakeLists.txt diff --git a/tests/library/digest/lower_case/hash_ops_ut.cpp b/tests/ut/library/digest/lower_case/hash_ops_ut.cpp similarity index 100% rename from tests/library/digest/lower_case/hash_ops_ut.cpp rename to tests/ut/library/digest/lower_case/hash_ops_ut.cpp diff --git a/tests/library/digest/lower_case/lchash_ut.cpp b/tests/ut/library/digest/lower_case/lchash_ut.cpp similarity index 100% rename from tests/library/digest/lower_case/lchash_ut.cpp rename to tests/ut/library/digest/lower_case/lchash_ut.cpp diff --git a/tests/library/digest/md5/CMakeLists.txt b/tests/ut/library/digest/md5/CMakeLists.txt similarity index 100% rename from tests/library/digest/md5/CMakeLists.txt rename to tests/ut/library/digest/md5/CMakeLists.txt diff --git a/tests/library/digest/md5/md5_medium_ut.cpp b/tests/ut/library/digest/md5/md5_medium_ut.cpp similarity index 100% rename from tests/library/digest/md5/md5_medium_ut.cpp rename to tests/ut/library/digest/md5/md5_medium_ut.cpp diff --git a/tests/library/digest/md5/md5_ut.cpp b/tests/ut/library/digest/md5/md5_ut.cpp similarity index 100% rename from tests/library/digest/md5/md5_ut.cpp rename to tests/ut/library/digest/md5/md5_ut.cpp diff --git a/tests/library/digest/murmur/CMakeLists.txt b/tests/ut/library/digest/murmur/CMakeLists.txt similarity index 78% rename from tests/library/digest/murmur/CMakeLists.txt rename to tests/ut/library/digest/murmur/CMakeLists.txt index 43226ad4d12..1c7ad9cf64a 100644 --- a/tests/library/digest/murmur/CMakeLists.txt +++ b/tests/ut/library/digest/murmur/CMakeLists.txt @@ -1,4 +1,4 @@ -add_ydb_test(NAME library-digest-murmur-ut +add_ydb_test(NAME library-digest-murmur_ut SOURCES ut.cpp INCLUDE_DIRS diff --git a/tests/library/digest/murmur/ut.cpp b/tests/ut/library/digest/murmur/ut.cpp similarity index 100% rename from tests/library/digest/murmur/ut.cpp rename to tests/ut/library/digest/murmur/ut.cpp diff --git a/tests/library/json/CMakeLists.txt b/tests/ut/library/json/CMakeLists.txt similarity index 100% rename from tests/library/json/CMakeLists.txt rename to tests/ut/library/json/CMakeLists.txt diff --git a/tests/library/json/json_prettifier_ut.cpp b/tests/ut/library/json/json_prettifier_ut.cpp similarity index 100% rename from tests/library/json/json_prettifier_ut.cpp rename to tests/ut/library/json/json_prettifier_ut.cpp diff --git a/tests/library/json/json_reader_fast_ut.cpp b/tests/ut/library/json/json_reader_fast_ut.cpp similarity index 100% rename from tests/library/json/json_reader_fast_ut.cpp rename to tests/ut/library/json/json_reader_fast_ut.cpp diff --git a/tests/library/json/json_reader_ut.cpp b/tests/ut/library/json/json_reader_ut.cpp similarity index 100% rename from tests/library/json/json_reader_ut.cpp rename to tests/ut/library/json/json_reader_ut.cpp diff --git a/tests/library/json/json_saveload_ut.cpp b/tests/ut/library/json/json_saveload_ut.cpp similarity index 100% rename from tests/library/json/json_saveload_ut.cpp rename to tests/ut/library/json/json_saveload_ut.cpp diff --git a/tests/library/json/json_writer_ut.cpp b/tests/ut/library/json/json_writer_ut.cpp similarity index 100% rename from tests/library/json/json_writer_ut.cpp rename to tests/ut/library/json/json_writer_ut.cpp diff --git a/tests/library/json/writer/CMakeLists.txt b/tests/ut/library/json/writer/CMakeLists.txt similarity index 100% rename from tests/library/json/writer/CMakeLists.txt rename to tests/ut/library/json/writer/CMakeLists.txt diff --git a/tests/library/json/writer/json_ut.cpp b/tests/ut/library/json/writer/json_ut.cpp similarity index 100% rename from tests/library/json/writer/json_ut.cpp rename to tests/ut/library/json/writer/json_ut.cpp diff --git a/tests/library/json/writer/json_value_ut.cpp b/tests/ut/library/json/writer/json_value_ut.cpp similarity index 100% rename from tests/library/json/writer/json_value_ut.cpp rename to tests/ut/library/json/writer/json_value_ut.cpp diff --git a/tests/library/operation_id/CMakeLists.txt b/tests/ut/library/operation_id/CMakeLists.txt similarity index 79% rename from tests/library/operation_id/CMakeLists.txt rename to tests/ut/library/operation_id/CMakeLists.txt index aba6fe8c745..754781f46f9 100644 --- a/tests/library/operation_id/CMakeLists.txt +++ b/tests/ut/library/operation_id/CMakeLists.txt @@ -1,4 +1,4 @@ -add_ydb_test(NAME operation_id-ut +add_ydb_test(NAME operation_id_ut SOURCES operation_id_ut.cpp LINK_LIBRARIES diff --git a/tests/library/operation_id/operation_id_ut.cpp b/tests/ut/library/operation_id/operation_id_ut.cpp similarity index 100% rename from tests/library/operation_id/operation_id_ut.cpp rename to tests/ut/library/operation_id/operation_id_ut.cpp diff --git a/tests/library/testing/CMakeLists.txt b/tests/ut/library/testing/CMakeLists.txt similarity index 100% rename from tests/library/testing/CMakeLists.txt rename to tests/ut/library/testing/CMakeLists.txt diff --git a/tests/library/testing/common/CMakeLists.txt b/tests/ut/library/testing/common/CMakeLists.txt similarity index 100% rename from tests/library/testing/common/CMakeLists.txt rename to tests/ut/library/testing/common/CMakeLists.txt diff --git a/tests/library/testing/common/env_ut.cpp b/tests/ut/library/testing/common/env_ut.cpp similarity index 98% rename from tests/library/testing/common/env_ut.cpp rename to tests/ut/library/testing/common/env_ut.cpp index 7a643ac9a68..73bb61b6f0c 100644 --- a/tests/library/testing/common/env_ut.cpp +++ b/tests/ut/library/testing/common/env_ut.cpp @@ -41,7 +41,7 @@ TEST(Runtime, BuildRoot) { TEST(Runtime, BinaryPath) { NTesting::TScopedEnvironment contextGuard("YA_TEST_CONTEXT_FILE", ""); // remove context filename Singleton()->ReInitialize(); - EXPECT_TRUE(TFsPath(BinaryPath("tests/library/testing/common")).Exists()); + EXPECT_TRUE(TFsPath(BinaryPath("tests/ut/library/testing/common")).Exists()); } TEST(Runtime, GetArcadiaTestsData) { diff --git a/tests/library/testing/common/network_ut.cpp b/tests/ut/library/testing/common/network_ut.cpp similarity index 100% rename from tests/library/testing/common/network_ut.cpp rename to tests/ut/library/testing/common/network_ut.cpp diff --git a/tests/library/testing/common/scope_ut.cpp b/tests/ut/library/testing/common/scope_ut.cpp similarity index 100% rename from tests/library/testing/common/scope_ut.cpp rename to tests/ut/library/testing/common/scope_ut.cpp diff --git a/tests/library/testing/gmock_in_unittest/CMakeLists.txt b/tests/ut/library/testing/gmock_in_unittest/CMakeLists.txt similarity index 100% rename from tests/library/testing/gmock_in_unittest/CMakeLists.txt rename to tests/ut/library/testing/gmock_in_unittest/CMakeLists.txt diff --git a/tests/library/testing/gmock_in_unittest/example_ut.cpp b/tests/ut/library/testing/gmock_in_unittest/example_ut.cpp similarity index 100% rename from tests/library/testing/gmock_in_unittest/example_ut.cpp rename to tests/ut/library/testing/gmock_in_unittest/example_ut.cpp diff --git a/tests/library/testing/gtest/CMakeLists.txt b/tests/ut/library/testing/gtest/CMakeLists.txt similarity index 100% rename from tests/library/testing/gtest/CMakeLists.txt rename to tests/ut/library/testing/gtest/CMakeLists.txt diff --git a/tests/library/testing/gtest/README.md b/tests/ut/library/testing/gtest/README.md similarity index 100% rename from tests/library/testing/gtest/README.md rename to tests/ut/library/testing/gtest/README.md diff --git a/tests/library/testing/gtest/golden/data.txt b/tests/ut/library/testing/gtest/golden/data.txt similarity index 100% rename from tests/library/testing/gtest/golden/data.txt rename to tests/ut/library/testing/gtest/golden/data.txt diff --git a/tests/library/testing/gtest/matchers_ut.cpp b/tests/ut/library/testing/gtest/matchers_ut.cpp similarity index 100% rename from tests/library/testing/gtest/matchers_ut.cpp rename to tests/ut/library/testing/gtest/matchers_ut.cpp diff --git a/tests/library/testing/gtest/ut.cpp b/tests/ut/library/testing/gtest/ut.cpp similarity index 100% rename from tests/library/testing/gtest/ut.cpp rename to tests/ut/library/testing/gtest/ut.cpp diff --git a/tests/library/testing/gtest_extensions/CMakeLists.txt b/tests/ut/library/testing/gtest_extensions/CMakeLists.txt similarity index 100% rename from tests/library/testing/gtest_extensions/CMakeLists.txt rename to tests/ut/library/testing/gtest_extensions/CMakeLists.txt diff --git a/tests/library/testing/gtest_extensions/README.md b/tests/ut/library/testing/gtest_extensions/README.md similarity index 100% rename from tests/library/testing/gtest_extensions/README.md rename to tests/ut/library/testing/gtest_extensions/README.md diff --git a/tests/library/testing/gtest_extensions/gtest_extensions_ut.cpp b/tests/ut/library/testing/gtest_extensions/gtest_extensions_ut.cpp similarity index 100% rename from tests/library/testing/gtest_extensions/gtest_extensions_ut.cpp rename to tests/ut/library/testing/gtest_extensions/gtest_extensions_ut.cpp diff --git a/tests/library/testing/gtest_extensions/probe_ut.cpp b/tests/ut/library/testing/gtest_extensions/probe_ut.cpp similarity index 100% rename from tests/library/testing/gtest_extensions/probe_ut.cpp rename to tests/ut/library/testing/gtest_extensions/probe_ut.cpp diff --git a/tests/library/testing/unittest/CMakeLists.txt b/tests/ut/library/testing/unittest/CMakeLists.txt similarity index 80% rename from tests/library/testing/unittest/CMakeLists.txt rename to tests/ut/library/testing/unittest/CMakeLists.txt index 3075f16e0c3..892155bf760 100644 --- a/tests/library/testing/unittest/CMakeLists.txt +++ b/tests/ut/library/testing/unittest/CMakeLists.txt @@ -5,7 +5,7 @@ add_ydb_test(NAME cpp-testing-unittest_ut cpp-testing-unittest_main ) -add_ydb_test(NAME cpp-testing-unittest_fat +add_ydb_test(NAME cpp-testing-unittest_fat_ut SOURCES test_port_manager.cpp LINK_LIBRARIES diff --git a/tests/library/testing/unittest/main.cpp b/tests/ut/library/testing/unittest/main.cpp similarity index 100% rename from tests/library/testing/unittest/main.cpp rename to tests/ut/library/testing/unittest/main.cpp diff --git a/tests/library/testing/unittest/test_port_manager.cpp b/tests/ut/library/testing/unittest/test_port_manager.cpp similarity index 100% rename from tests/library/testing/unittest/test_port_manager.cpp rename to tests/ut/library/testing/unittest/test_port_manager.cpp diff --git a/tests/library/yql/CMakeLists.txt b/tests/ut/library/yql/CMakeLists.txt similarity index 88% rename from tests/library/yql/CMakeLists.txt rename to tests/ut/library/yql/CMakeLists.txt index 7ded65d3897..6a3c2804f01 100644 --- a/tests/library/yql/CMakeLists.txt +++ b/tests/ut/library/yql/CMakeLists.txt @@ -1,4 +1,4 @@ -add_ydb_test(NAME yql-utils-ut +add_ydb_test(NAME yql-utils_ut SOURCES utf8_ut.cpp LINK_LIBRARIES @@ -7,7 +7,7 @@ add_ydb_test(NAME yql-utils-ut yql-utils ) -add_ydb_test(NAME yql-public-issue-ut +add_ydb_test(NAME yql-public-issue_ut SOURCES yql_issue_ut.cpp LINK_LIBRARIES diff --git a/tests/library/yql/utf8_ut.cpp b/tests/ut/library/yql/utf8_ut.cpp similarity index 100% rename from tests/library/yql/utf8_ut.cpp rename to tests/ut/library/yql/utf8_ut.cpp diff --git a/tests/library/yql/yql_decimal_ut.cpp b/tests/ut/library/yql/yql_decimal_ut.cpp similarity index 100% rename from tests/library/yql/yql_decimal_ut.cpp rename to tests/ut/library/yql/yql_decimal_ut.cpp diff --git a/tests/library/yql/yql_issue_ut.cpp b/tests/ut/library/yql/yql_issue_ut.cpp similarity index 100% rename from tests/library/yql/yql_issue_ut.cpp rename to tests/ut/library/yql/yql_issue_ut.cpp diff --git a/tests/library/yql/yql_wide_int_ut.cpp b/tests/ut/library/yql/yql_wide_int_ut.cpp similarity index 100% rename from tests/library/yql/yql_wide_int_ut.cpp rename to tests/ut/library/yql/yql_wide_int_ut.cpp diff --git a/tests/util/CMakeLists.txt b/tests/ut/util/CMakeLists.txt similarity index 100% rename from tests/util/CMakeLists.txt rename to tests/ut/util/CMakeLists.txt diff --git a/tests/util/charset/CMakeLists.txt b/tests/ut/util/charset/CMakeLists.txt similarity index 100% rename from tests/util/charset/CMakeLists.txt rename to tests/ut/util/charset/CMakeLists.txt diff --git a/tests/util/charset/data/invalid_UTF8.bin b/tests/ut/util/charset/data/invalid_UTF8.bin similarity index 100% rename from tests/util/charset/data/invalid_UTF8.bin rename to tests/ut/util/charset/data/invalid_UTF8.bin diff --git a/tests/util/charset/data/test1.txt b/tests/ut/util/charset/data/test1.txt similarity index 100% rename from tests/util/charset/data/test1.txt rename to tests/ut/util/charset/data/test1.txt diff --git a/tests/util/charset/utf8_ut.cpp b/tests/ut/util/charset/utf8_ut.cpp similarity index 100% rename from tests/util/charset/utf8_ut.cpp rename to tests/ut/util/charset/utf8_ut.cpp diff --git a/tests/util/charset/wide_ut.cpp b/tests/ut/util/charset/wide_ut.cpp similarity index 100% rename from tests/util/charset/wide_ut.cpp rename to tests/ut/util/charset/wide_ut.cpp diff --git a/tests/util/digest/CMakeLists.txt b/tests/ut/util/digest/CMakeLists.txt similarity index 100% rename from tests/util/digest/CMakeLists.txt rename to tests/ut/util/digest/CMakeLists.txt diff --git a/tests/util/digest/city_ut.cpp b/tests/ut/util/digest/city_ut.cpp similarity index 100% rename from tests/util/digest/city_ut.cpp rename to tests/ut/util/digest/city_ut.cpp diff --git a/tests/util/digest/fnv_ut.cpp b/tests/ut/util/digest/fnv_ut.cpp similarity index 100% rename from tests/util/digest/fnv_ut.cpp rename to tests/ut/util/digest/fnv_ut.cpp diff --git a/tests/util/digest/multi_ut.cpp b/tests/ut/util/digest/multi_ut.cpp similarity index 100% rename from tests/util/digest/multi_ut.cpp rename to tests/ut/util/digest/multi_ut.cpp diff --git a/tests/util/digest/murmur_ut.cpp b/tests/ut/util/digest/murmur_ut.cpp similarity index 100% rename from tests/util/digest/murmur_ut.cpp rename to tests/ut/util/digest/murmur_ut.cpp diff --git a/tests/util/digest/sequence_ut.cpp b/tests/ut/util/digest/sequence_ut.cpp similarity index 100% rename from tests/util/digest/sequence_ut.cpp rename to tests/ut/util/digest/sequence_ut.cpp diff --git a/tests/util/folder/CMakeLists.txt b/tests/ut/util/folder/CMakeLists.txt similarity index 100% rename from tests/util/folder/CMakeLists.txt rename to tests/ut/util/folder/CMakeLists.txt diff --git a/tests/util/folder/dirut_ut.cpp b/tests/ut/util/folder/dirut_ut.cpp similarity index 100% rename from tests/util/folder/dirut_ut.cpp rename to tests/ut/util/folder/dirut_ut.cpp diff --git a/tests/util/folder/filelist_ut.cpp b/tests/ut/util/folder/filelist_ut.cpp similarity index 100% rename from tests/util/folder/filelist_ut.cpp rename to tests/ut/util/folder/filelist_ut.cpp diff --git a/tests/util/folder/fts_ut.cpp b/tests/ut/util/folder/fts_ut.cpp similarity index 100% rename from tests/util/folder/fts_ut.cpp rename to tests/ut/util/folder/fts_ut.cpp diff --git a/tests/util/folder/iterator_ut.cpp b/tests/ut/util/folder/iterator_ut.cpp similarity index 100% rename from tests/util/folder/iterator_ut.cpp rename to tests/ut/util/folder/iterator_ut.cpp diff --git a/tests/util/folder/path_ut.cpp b/tests/ut/util/folder/path_ut.cpp similarity index 100% rename from tests/util/folder/path_ut.cpp rename to tests/ut/util/folder/path_ut.cpp diff --git a/tests/util/folder/pathsplit_ut.cpp b/tests/ut/util/folder/pathsplit_ut.cpp similarity index 98% rename from tests/util/folder/pathsplit_ut.cpp rename to tests/ut/util/folder/pathsplit_ut.cpp index 3a7767ab18c..a58b7e4cd52 100644 --- a/tests/util/folder/pathsplit_ut.cpp +++ b/tests/ut/util/folder/pathsplit_ut.cpp @@ -20,7 +20,7 @@ #define PSUF(NAME) NAME #define PSUF_LOCAL(NAME) NAME##Local - #include + #include #undef PSUF #undef PSUF_LOCAL @@ -30,7 +30,7 @@ #undef _win_ #define REVERT_WIN #endif - #include + #include #ifdef REVERT_WIN #define _win_ #undef REVERT_WIN @@ -44,7 +44,7 @@ #define _win_ #define REVERT_WIN #endif - #include + #include #ifdef REVERT_WIN #undef _win_ #undef REVERT_WIN diff --git a/tests/util/network/CMakeLists.txt b/tests/ut/util/network/CMakeLists.txt similarity index 100% rename from tests/util/network/CMakeLists.txt rename to tests/ut/util/network/CMakeLists.txt diff --git a/tests/util/network/address_ut.cpp b/tests/ut/util/network/address_ut.cpp similarity index 100% rename from tests/util/network/address_ut.cpp rename to tests/ut/util/network/address_ut.cpp diff --git a/tests/util/network/endpoint_ut.cpp b/tests/ut/util/network/endpoint_ut.cpp similarity index 100% rename from tests/util/network/endpoint_ut.cpp rename to tests/ut/util/network/endpoint_ut.cpp diff --git a/tests/util/network/iovec_ut.cpp b/tests/ut/util/network/iovec_ut.cpp similarity index 100% rename from tests/util/network/iovec_ut.cpp rename to tests/ut/util/network/iovec_ut.cpp diff --git a/tests/util/network/ip_ut.cpp b/tests/ut/util/network/ip_ut.cpp similarity index 100% rename from tests/util/network/ip_ut.cpp rename to tests/ut/util/network/ip_ut.cpp diff --git a/tests/util/network/poller_ut.cpp b/tests/ut/util/network/poller_ut.cpp similarity index 100% rename from tests/util/network/poller_ut.cpp rename to tests/ut/util/network/poller_ut.cpp diff --git a/tests/util/network/sock_ut.cpp b/tests/ut/util/network/sock_ut.cpp similarity index 100% rename from tests/util/network/sock_ut.cpp rename to tests/ut/util/network/sock_ut.cpp diff --git a/tests/util/network/socket_ut.cpp b/tests/ut/util/network/socket_ut.cpp similarity index 100% rename from tests/util/network/socket_ut.cpp rename to tests/ut/util/network/socket_ut.cpp From e7c81f90d223844ee85d12988b926242f2b39b1f Mon Sep 17 00:00:00 2001 From: st-shchetinin Date: Fri, 19 Jul 2024 22:24:49 +0300 Subject: [PATCH 02/36] basic_example integration test --- tests/integration/CMakeLists.txt | 6 +- .../basic_example_it/basic_example.cpp | 98 ++++++++++--------- tests/integration/basic_example_it/main.cpp | 9 +- tests/integration/config_ydb.h | 9 ++ tests/integration/config_ydb.h.in | 9 ++ 5 files changed, 81 insertions(+), 50 deletions(-) create mode 100644 tests/integration/config_ydb.h create mode 100644 tests/integration/config_ydb.h.in diff --git a/tests/integration/CMakeLists.txt b/tests/integration/CMakeLists.txt index 4f45b490bef..ecd7c101329 100644 --- a/tests/integration/CMakeLists.txt +++ b/tests/integration/CMakeLists.txt @@ -1 +1,5 @@ -add_subdirectory(basic_example_it) \ No newline at end of file +set(ENDPOINT "localhost:2136") +set(DATABASE "/Root/test") +configure_file(config_ydb.h.in ${CMAKE_CURRENT_SOURCE_DIR}/config_ydb.h @ONLY) + +add_subdirectory(basic_example_it) diff --git a/tests/integration/basic_example_it/basic_example.cpp b/tests/integration/basic_example_it/basic_example.cpp index e5bf7644d4b..bc5438065d2 100644 --- a/tests/integration/basic_example_it/basic_example.cpp +++ b/tests/integration/basic_example_it/basic_example.cpp @@ -95,9 +95,9 @@ static std::string DescribeTable(TTableClient client, const std::string& path, c return result; })); - result += std::format("> Describe table: {}", name); + result += std::format("> Describe table: {}\n", name); for (auto& column : desc->GetColumns()) { - result += std::format("Column, name: {}, type: {}", column.Name, FormatType(column.Type)); + result += std::format("Column, name: {}, type: {}\n", column.Name, FormatType(column.Type)); } return result; } @@ -434,7 +434,7 @@ static TStatus ExplicitTclTransaction(TSession session, const std::string& path, /////////////////////////////////////////////////////////////////////////////// -void SelectSimple(TTableClient client, const std::string& path) { +std::string SelectSimple(TTableClient client, const std::string& path) { std::optional resultSet; ThrowOnError(client.RetryOperationSync([path, &resultSet](TSession session) { return SelectSimpleTransaction(session, path, resultSet); @@ -442,12 +442,12 @@ void SelectSimple(TTableClient client, const std::string& path) { TResultSetParser parser(*resultSet); if (parser.TryNextRow()) { - std::cout << "> SelectSimple:" << std::endl << "Series" - << ", Id: " << ToString(parser.ColumnParser("series_id").GetOptionalUint64()) - << ", Title: " << ToString(parser.ColumnParser("title").GetOptionalUtf8()) - << ", Release date: " << ToString(parser.ColumnParser("release_date").GetOptionalString()) - << std::endl; + return std::format("> SelectSimple:\nSeries, Id: {}, Title: {}, Release date: {}\n" + , ToString(parser.ColumnParser("series_id").GetOptionalUint64()) + , ToString(parser.ColumnParser("title").GetOptionalUtf8()) + , ToString(parser.ColumnParser("release_date").GetOptionalString())); } + return ""; } void UpsertSimple(TTableClient client, const std::string& path) { @@ -456,23 +456,25 @@ void UpsertSimple(TTableClient client, const std::string& path) { })); } -void SelectWithParams(TTableClient client, const std::string& path) { +std::string SelectWithParams(TTableClient client, const std::string& path) { std::optional resultSet; + std::string result; ThrowOnError(client.RetryOperationSync([path, &resultSet](TSession session) { return SelectWithParamsTransaction(session, path, 2, 3, resultSet); })); TResultSetParser parser(*resultSet); if (parser.TryNextRow()) { - std::cout << "> SelectWithParams:" << std::endl << "Season" - << ", Title: " << ToString(parser.ColumnParser("season_title").GetOptionalUtf8()) - << ", Series title: " << ToString(parser.ColumnParser("series_title").GetOptionalUtf8()) - << std::endl; + return std::format("> SelectWithParams:\nSeason, Title: {}, Series title: {}\n" + , ToString(parser.ColumnParser("season_title").GetOptionalUtf8()) + , ToString(parser.ColumnParser("series_title").GetOptionalUtf8())); } + return ""; } -void PreparedSelect(TTableClient client, const std::string& path, ui32 seriesId, ui32 seasonId, ui32 episodeId) { +std::string PreparedSelect(TTableClient client, const std::string& path, ui32 seriesId, ui32 seasonId, ui32 episodeId) { std::optional resultSet; + std::string result; ThrowOnError(client.RetryOperationSync([path, seriesId, seasonId, episodeId, &resultSet](TSession session) { return PreparedSelectTransaction(session, path, seriesId, seasonId, episodeId, resultSet); })); @@ -481,30 +483,32 @@ void PreparedSelect(TTableClient client, const std::string& path, ui32 seriesId, if (parser.TryNextRow()) { auto airDate = TInstant::Days(*parser.ColumnParser("air_date").GetOptionalUint64()); - std::cout << "> PreparedSelect:" << std::endl << "Episode " << ToString(parser.ColumnParser("episode_id").GetOptionalUint64()) - << ", Title: " << ToString(parser.ColumnParser("title").GetOptionalUtf8()) - << ", Air date: " << airDate.FormatLocalTime("%a %b %d, %Y") - << std::endl; + return std::format("> PreparedSelect:\nEpisode {}, Title: {}, Air date: {}\n" + , ToString(parser.ColumnParser("episode_id").GetOptionalUint64()) + , ToString(parser.ColumnParser("title").GetOptionalUtf8()) + , airDate.FormatLocalTime("%a %b %d, %Y")); } + return ""; } -void MultiStep(TTableClient client, const std::string& path) { +std::string MultiStep(TTableClient client, const std::string& path) { std::optional resultSet; + std::string result; ThrowOnError(client.RetryOperationSync([path, &resultSet](TSession session) { return MultiStepTransaction(session, path, 2, 5, resultSet); })); TResultSetParser parser(*resultSet); - std::cout << "> MultiStep:" << std::endl; + result = "> MultiStep:\n"; while (parser.TryNextRow()) { auto airDate = TInstant::Days(*parser.ColumnParser("air_date").GetOptionalUint64()); - - std::cout << "Episode " << ToString(parser.ColumnParser("episode_id").GetOptionalUint64()) - << ", Season: " << ToString(parser.ColumnParser("season_id").GetOptionalUint64()) - << ", Title: " << ToString(parser.ColumnParser("title").GetOptionalUtf8()) - << ", Air date: " << airDate.FormatLocalTime("%a %b %d, %Y") - << std::endl; + result += std::format("Episode {}, Season: {}, Title: {}, Air date: {}\n" + , ToString(parser.ColumnParser("episode_id").GetOptionalUint64()) + , ToString(parser.ColumnParser("season_id").GetOptionalUint64()) + , ToString(parser.ColumnParser("title").GetOptionalUtf8()) + , airDate.FormatLocalTime("%a %b %d, %Y")); } + return result; } void ExplicitTcl(TTableClient client, const std::string& path) { @@ -513,7 +517,8 @@ void ExplicitTcl(TTableClient client, const std::string& path) { })); } -void ScanQuerySelect(TTableClient client, const std::string& path) { +std::string ScanQuerySelect(TTableClient client, const std::string& path) { + std::string result; auto query = std::format(R"( --!syntax_v1 PRAGMA TablePathPrefix("{}"); @@ -534,17 +539,18 @@ void ScanQuerySelect(TTableClient client, const std::string& path) { .Build(); // Executes scan query - auto result = client.StreamExecuteScanQuery(query, parameters).GetValueSync(); + auto resultScanQuery = client.StreamExecuteScanQuery(query, parameters).GetValueSync(); - if (!result.IsSuccess()) { - std::cerr << "ScanQuery execution failure: " << result.GetIssues().ToString() << std::endl; - return; + if (!resultScanQuery.IsSuccess()) { + std::cerr << "ScanQuery execution failure: " << resultScanQuery.GetIssues().ToString() << std::endl; + return ""; } bool eos = false; - std::cout << "> ScanQuerySelect:" << std::endl; + result = "> ScanQuerySelect:\n"; + while (!eos) { - auto streamPart = result.ReadNext().ExtractValueSync(); + auto streamPart = resultScanQuery.ReadNext().ExtractValueSync(); if (!streamPart.IsSuccess()) { eos = true; @@ -560,15 +566,15 @@ void ScanQuerySelect(TTableClient client, const std::string& path) { TResultSetParser parser(rs); while (parser.TryNextRow()) { - std::cout << "Season" - << ", SeriesId: " << ToString(parser.ColumnParser("series_id").GetOptionalUint64()) - << ", SeasonId: " << ToString(parser.ColumnParser("season_id").GetOptionalUint64()) - << ", Title: " << ToString(parser.ColumnParser("title").GetOptionalUtf8()) - << ", Air date: " << ToString(parser.ColumnParser("first_aired").GetOptionalString()) - << std::endl; + result += std::format("Season, SeriesId: {}, SeasonId: {}, Title: {}, Air date: {}\n" + , ToString(parser.ColumnParser("series_id").GetOptionalUint64()) + , ToString(parser.ColumnParser("season_id").GetOptionalUint64()) + , ToString(parser.ColumnParser("title").GetOptionalUtf8()) + , ToString(parser.ColumnParser("first_aired").GetOptionalString())); } } } + return result; } /////////////////////////////////////////////////////////////////////////////// @@ -585,21 +591,21 @@ std::unique_ptr Run(const TDriver& driver, const std::string& path) { return FillTableDataTransaction(session, path); })); - SelectSimple(client, path); + response->result += SelectSimple(client, path); UpsertSimple(client, path); - SelectWithParams(client, path); + response->result += SelectWithParams(client, path); - PreparedSelect(client, path, 2, 3, 7); - PreparedSelect(client, path, 2, 3, 8); + response->result += PreparedSelect(client, path, 2, 3, 7); + response->result += PreparedSelect(client, path, 2, 3, 8); - MultiStep(client, path); + response->result += MultiStep(client, path); ExplicitTcl(client, path); - PreparedSelect(client, path, 2, 6, 1); + response->result += PreparedSelect(client, path, 2, 6, 1); - ScanQuerySelect(client, path); + response->result += ScanQuerySelect(client, path); } catch (const TYdbErrorException& e) { response->success = false; diff --git a/tests/integration/basic_example_it/main.cpp b/tests/integration/basic_example_it/main.cpp index 9786e75ec79..870ba19d3b6 100644 --- a/tests/integration/basic_example_it/main.cpp +++ b/tests/integration/basic_example_it/main.cpp @@ -1,4 +1,5 @@ #include "basic_example.h" +#include "../config_ydb.h" #include @@ -19,8 +20,6 @@ void StopHandler(int) { TEST(Integration, BasicExample) { TOpts opts = TOpts::Default(); - std::string endpoint = "localhost:2136"; - std::string database = "/Root/test"; std::string path; std::string certPath; @@ -39,12 +38,16 @@ TEST(Integration, BasicExample) { } TDriver driver(driverConfig); + std::unique_ptr response = ::Run(driver, path); - if (auto response = ::Run(driver, path); !response->success) { + if (!response->success) { std::cerr << std::format("The driver could not be started (path = {})", path) << std::endl; FAIL(); driver.Stop(true); } + std::string correct_output = "> Describe table: series\nColumn, name: series_id, type: Uint64?\nColumn, name: title, type: Utf8?\nColumn, name: series_info, type: Utf8?\nColumn, name: release_date, type: Uint64?\n> SelectSimple:\nSeries, Id: 1, Title: IT Crowd, Release date: 2006-02-03\n> SelectWithParams:\nSeason, Title: Season 3, Series title: Silicon Valley\n> PreparedSelect:\nEpisode 7, Title: To Build a Better Beta, Air date: Sun Jun 05, 2016\n> PreparedSelect:\nEpisode 8, Title: Bachman's Earnings Over-Ride, Air date: Sun Jun 12, 2016\n> MultiStep:\nEpisode 1, Season: 5, Title: Grow Fast or Die Slow, Air date: Sun Mar 25, 2018\nEpisode 2, Season: 5, Title: Reorientation, Air date: Sun Apr 01, 2018\nEpisode 3, Season: 5, Title: Chief Operating Officer, Air date: Sun Apr 08, 2018\n> PreparedSelect:\nEpisode 1, Title: TBD, Air date: Fri Jul 19, 2024\n> ScanQuerySelect:\nSeason, SeriesId: 1, SeasonId: 1, Title: Season 1, Air date: 2006-02-03\nSeason, SeriesId: 1, SeasonId: 2, Title: Season 2, Air date: 2007-08-24\nSeason, SeriesId: 1, SeasonId: 3, Title: Season 3, Air date: 2008-11-21\nSeason, SeriesId: 1, SeasonId: 4, Title: Season 4, Air date: 2010-06-25\n"; + ASSERT_EQ(response->result, correct_output); + driver.Stop(true); } diff --git a/tests/integration/config_ydb.h b/tests/integration/config_ydb.h new file mode 100644 index 00000000000..f3a95c462b4 --- /dev/null +++ b/tests/integration/config_ydb.h @@ -0,0 +1,9 @@ +#ifndef CONFIG_YDB_H_IN +#define CONFIG_YDB_H_IN + +#include + +const std::string endpoint = "localhost:2136"; +const std::string database = "/Root/test"; + +#endif // CONFIG_YDB_H_IN diff --git a/tests/integration/config_ydb.h.in b/tests/integration/config_ydb.h.in new file mode 100644 index 00000000000..728d379bd83 --- /dev/null +++ b/tests/integration/config_ydb.h.in @@ -0,0 +1,9 @@ +#ifndef CONFIG_YDB_H_IN +#define CONFIG_YDB_H_IN + +#include + +const std::string endpoint = "@ENDPOINT@"; +const std::string database = "@DATABASE@"; + +#endif // CONFIG_YDB_H_IN From bf8d49e5cd131ade3ca4551a7b7a32dffc90be6c Mon Sep 17 00:00:00 2001 From: st-shchetinin Date: Mon, 22 Jul 2024 14:02:37 +0300 Subject: [PATCH 03/36] fix test: now -> 0 --- tests/integration/basic_example_it/basic_example.cpp | 2 +- tests/integration/basic_example_it/main.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration/basic_example_it/basic_example.cpp b/tests/integration/basic_example_it/basic_example.cpp index bc5438065d2..53639531e8c 100644 --- a/tests/integration/basic_example_it/basic_example.cpp +++ b/tests/integration/basic_example_it/basic_example.cpp @@ -513,7 +513,7 @@ std::string MultiStep(TTableClient client, const std::string& path) { void ExplicitTcl(TTableClient client, const std::string& path) { ThrowOnError(client.RetryOperationSync([path](TSession session) { - return ExplicitTclTransaction(session, path, TInstant::Now()); + return ExplicitTclTransaction(session, path, TInstant()); })); } diff --git a/tests/integration/basic_example_it/main.cpp b/tests/integration/basic_example_it/main.cpp index 870ba19d3b6..478d32bc978 100644 --- a/tests/integration/basic_example_it/main.cpp +++ b/tests/integration/basic_example_it/main.cpp @@ -46,7 +46,7 @@ TEST(Integration, BasicExample) { driver.Stop(true); } - std::string correct_output = "> Describe table: series\nColumn, name: series_id, type: Uint64?\nColumn, name: title, type: Utf8?\nColumn, name: series_info, type: Utf8?\nColumn, name: release_date, type: Uint64?\n> SelectSimple:\nSeries, Id: 1, Title: IT Crowd, Release date: 2006-02-03\n> SelectWithParams:\nSeason, Title: Season 3, Series title: Silicon Valley\n> PreparedSelect:\nEpisode 7, Title: To Build a Better Beta, Air date: Sun Jun 05, 2016\n> PreparedSelect:\nEpisode 8, Title: Bachman's Earnings Over-Ride, Air date: Sun Jun 12, 2016\n> MultiStep:\nEpisode 1, Season: 5, Title: Grow Fast or Die Slow, Air date: Sun Mar 25, 2018\nEpisode 2, Season: 5, Title: Reorientation, Air date: Sun Apr 01, 2018\nEpisode 3, Season: 5, Title: Chief Operating Officer, Air date: Sun Apr 08, 2018\n> PreparedSelect:\nEpisode 1, Title: TBD, Air date: Fri Jul 19, 2024\n> ScanQuerySelect:\nSeason, SeriesId: 1, SeasonId: 1, Title: Season 1, Air date: 2006-02-03\nSeason, SeriesId: 1, SeasonId: 2, Title: Season 2, Air date: 2007-08-24\nSeason, SeriesId: 1, SeasonId: 3, Title: Season 3, Air date: 2008-11-21\nSeason, SeriesId: 1, SeasonId: 4, Title: Season 4, Air date: 2010-06-25\n"; + std::string correct_output = "> Describe table: series\nColumn, name: series_id, type: Uint64?\nColumn, name: title, type: Utf8?\nColumn, name: series_info, type: Utf8?\nColumn, name: release_date, type: Uint64?\n> SelectSimple:\nSeries, Id: 1, Title: IT Crowd, Release date: 2006-02-03\n> SelectWithParams:\nSeason, Title: Season 3, Series title: Silicon Valley\n> PreparedSelect:\nEpisode 7, Title: To Build a Better Beta, Air date: Sun Jun 05, 2016\n> PreparedSelect:\nEpisode 8, Title: Bachman's Earnings Over-Ride, Air date: Sun Jun 12, 2016\n> MultiStep:\nEpisode 1, Season: 5, Title: Grow Fast or Die Slow, Air date: Sun Mar 25, 2018\nEpisode 2, Season: 5, Title: Reorientation, Air date: Sun Apr 01, 2018\nEpisode 3, Season: 5, Title: Chief Operating Officer, Air date: Sun Apr 08, 2018\n> PreparedSelect:\nEpisode 1, Title: TBD, Air date: Thu Jan 01, 1970\n> ScanQuerySelect:\nSeason, SeriesId: 1, SeasonId: 1, Title: Season 1, Air date: 2006-02-03\nSeason, SeriesId: 1, SeasonId: 2, Title: Season 2, Air date: 2007-08-24\nSeason, SeriesId: 1, SeasonId: 3, Title: Season 3, Air date: 2008-11-21\nSeason, SeriesId: 1, SeasonId: 4, Title: Season 4, Air date: 2010-06-25\n"; ASSERT_EQ(response->result, correct_output); driver.Stop(true); From 8cf44ff23f66faad302155cb52f023587a31ac0a Mon Sep 17 00:00:00 2001 From: st-shchetinin Date: Mon, 22 Jul 2024 14:04:17 +0300 Subject: [PATCH 04/36] CMakePresets divided the tests --- CMakePresets.json | 32 ++++++++++++++++++++++++++++++++ README.md | 4 ++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/CMakePresets.json b/CMakePresets.json index c6a68e365a3..e0b82ed4ddd 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -60,6 +60,38 @@ "execution": { "timeout": 1200 } + }, + { + "name": "release-unit", + "configurePreset": "release", + "displayName": "Default Unit Release Tests", + "filter" : { + "include": { + "name": ".*_ut" + } + }, + "output": { + "outputOnFailure": true + }, + "execution": { + "timeout": 1200 + } + }, + { + "name": "release-integration", + "configurePreset": "release", + "displayName": "Default Integration Release Tests", + "output": { + "outputOnFailure": true + }, + "filter" : { + "include": { + "name": ".*_it" + } + }, + "execution": { + "timeout": 1200 + } } ] } diff --git a/README.md b/README.md index 538de61c015..1e3355def5d 100644 --- a/README.md +++ b/README.md @@ -131,11 +131,11 @@ ctest -j$(nproc) --preset release Running unit tests only: ```bash -ctest -j$(nproc) --preset release -R .*_ut +ctest -j$(nproc) --preset release-unit ``` Running integration tests only: ```bash -ctest -j$(nproc) --preset release -R .*_it +ctest -j$(nproc) --preset release-integration ``` \ No newline at end of file From bc648741da2971cc9d0e68c3ea5796caea7f8661 Mon Sep 17 00:00:00 2001 From: st-shchetinin Date: Tue, 23 Jul 2024 15:33:13 +0300 Subject: [PATCH 05/36] remove launch basic example --- .github/workflows/pr_check.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pr_check.yaml b/.github/workflows/pr_check.yaml index 973b2671fef..4c03ef946ae 100644 --- a/.github/workflows/pr_check.yaml +++ b/.github/workflows/pr_check.yaml @@ -61,11 +61,11 @@ jobs: shell: bash run: | ctest -j32 --preset release - - name: Launch basic example - shell: bash - run: | - cd ../build - examples/basic_example/basic_example -e localhost:2136 -d /local -p /local/basic - examples/bulk_upsert_simple/bulk_upsert_simple -e localhost:2136 -d /local -p /local/bulk - examples/pagination/pagination -e localhost:2136 -d /local -p /local/pagination - examples/ttl/ttl -e localhost:2136 -d /local -p /local/ttl + # - name: Launch basic example + # shell: bash + # run: | + # cd ../build + # examples/basic_example/basic_example -e localhost:2136 -d /local -p /local/basic + # examples/bulk_upsert_simple/bulk_upsert_simple -e localhost:2136 -d /local -p /local/bulk + # examples/pagination/pagination -e localhost:2136 -d /local -p /local/pagination + # examples/ttl/ttl -e localhost:2136 -d /local -p /local/ttl From 24565ee0199db2e2933d3a245dae8d21c6fb4ced Mon Sep 17 00:00:00 2001 From: st-shchetinin Date: Tue, 23 Jul 2024 16:05:43 +0300 Subject: [PATCH 06/36] return examples in pr_check.yaml --- .github/workflows/pr_check.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pr_check.yaml b/.github/workflows/pr_check.yaml index 4c03ef946ae..973b2671fef 100644 --- a/.github/workflows/pr_check.yaml +++ b/.github/workflows/pr_check.yaml @@ -61,11 +61,11 @@ jobs: shell: bash run: | ctest -j32 --preset release - # - name: Launch basic example - # shell: bash - # run: | - # cd ../build - # examples/basic_example/basic_example -e localhost:2136 -d /local -p /local/basic - # examples/bulk_upsert_simple/bulk_upsert_simple -e localhost:2136 -d /local -p /local/bulk - # examples/pagination/pagination -e localhost:2136 -d /local -p /local/pagination - # examples/ttl/ttl -e localhost:2136 -d /local -p /local/ttl + - name: Launch basic example + shell: bash + run: | + cd ../build + examples/basic_example/basic_example -e localhost:2136 -d /local -p /local/basic + examples/bulk_upsert_simple/bulk_upsert_simple -e localhost:2136 -d /local -p /local/bulk + examples/pagination/pagination -e localhost:2136 -d /local -p /local/pagination + examples/ttl/ttl -e localhost:2136 -d /local -p /local/ttl From a996b4841ddac6aea58107adeab66bff7741e3a5 Mon Sep 17 00:00:00 2001 From: st-shchetinin Date: Tue, 23 Jul 2024 17:35:54 +0300 Subject: [PATCH 07/36] changed database --- tests/integration/CMakeLists.txt | 2 +- tests/integration/config_ydb.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration/CMakeLists.txt b/tests/integration/CMakeLists.txt index ecd7c101329..cedfcc058a0 100644 --- a/tests/integration/CMakeLists.txt +++ b/tests/integration/CMakeLists.txt @@ -1,5 +1,5 @@ set(ENDPOINT "localhost:2136") -set(DATABASE "/Root/test") +set(DATABASE "/local/basic") configure_file(config_ydb.h.in ${CMAKE_CURRENT_SOURCE_DIR}/config_ydb.h @ONLY) add_subdirectory(basic_example_it) diff --git a/tests/integration/config_ydb.h b/tests/integration/config_ydb.h index f3a95c462b4..5f3433a9749 100644 --- a/tests/integration/config_ydb.h +++ b/tests/integration/config_ydb.h @@ -4,6 +4,6 @@ #include const std::string endpoint = "localhost:2136"; -const std::string database = "/Root/test"; +const std::string database = "/local/basic"; #endif // CONFIG_YDB_H_IN From f11127d45cc8af4ee64f9d83e4cb1b518e9f9f51 Mon Sep 17 00:00:00 2001 From: st-shchetinin Date: Tue, 23 Jul 2024 17:35:54 +0300 Subject: [PATCH 08/36] changed database --- tests/integration/CMakeLists.txt | 2 +- tests/integration/config_ydb.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration/CMakeLists.txt b/tests/integration/CMakeLists.txt index cedfcc058a0..3821aea81f1 100644 --- a/tests/integration/CMakeLists.txt +++ b/tests/integration/CMakeLists.txt @@ -1,5 +1,5 @@ set(ENDPOINT "localhost:2136") -set(DATABASE "/local/basic") +set(DATABASE "/local") configure_file(config_ydb.h.in ${CMAKE_CURRENT_SOURCE_DIR}/config_ydb.h @ONLY) add_subdirectory(basic_example_it) diff --git a/tests/integration/config_ydb.h b/tests/integration/config_ydb.h index 5f3433a9749..f447dca4c2c 100644 --- a/tests/integration/config_ydb.h +++ b/tests/integration/config_ydb.h @@ -4,6 +4,6 @@ #include const std::string endpoint = "localhost:2136"; -const std::string database = "/local/basic"; +const std::string database = "/local"; #endif // CONFIG_YDB_H_IN From cb1811958b01d0e611e143e1c3203b47c9d943f4 Mon Sep 17 00:00:00 2001 From: st-shchetinin Date: Tue, 23 Jul 2024 18:44:20 +0300 Subject: [PATCH 09/36] divided into different jobs --- .github/workflows/examples.yaml | 26 +++++++++++ .github/workflows/pr_check.yaml | 71 ---------------------------- .github/workflows/tests.yaml | 82 +++++++++++++++++++++++++++++++++ 3 files changed, 108 insertions(+), 71 deletions(-) create mode 100644 .github/workflows/examples.yaml delete mode 100644 .github/workflows/pr_check.yaml create mode 100644 .github/workflows/tests.yaml diff --git a/.github/workflows/examples.yaml b/.github/workflows/examples.yaml new file mode 100644 index 00000000000..39213790ac4 --- /dev/null +++ b/.github/workflows/examples.yaml @@ -0,0 +1,26 @@ +main: + name: Examples + runs-on: ubuntu-22.04 + services: + ydb: + image: ydbplatform/local-ydb:latest + ports: + - 2135:2135 + - 2136:2136 + - 8765:8765 + volumes: + - /tmp/ydb_certs:/ydb_certs + env: + YDB_LOCAL_SURVIVE_RESTART: true + YDB_USE_IN_MEMORY_PDISKS: true + YDB_TABLE_ENABLE_PREPARED_DDL: true + options: '-h localhost' + steps: + - name: Launch basic example + shell: bash + run: | + cd ../build + examples/basic_example/basic_example -e localhost:2136 -d /local -p /local/basic + examples/bulk_upsert_simple/bulk_upsert_simple -e localhost:2136 -d /local -p /local/bulk + examples/pagination/pagination -e localhost:2136 -d /local -p /local/pagination + examples/ttl/ttl -e localhost:2136 -d /local -p /local/ttl \ No newline at end of file diff --git a/.github/workflows/pr_check.yaml b/.github/workflows/pr_check.yaml deleted file mode 100644 index 973b2671fef..00000000000 --- a/.github/workflows/pr_check.yaml +++ /dev/null @@ -1,71 +0,0 @@ -name: PR-check - -on: - push: - branches: - - main - pull_request: - branches: - - main -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number }} - cancel-in-progress: true -jobs: - main: - name: PR check for YDB C++ SDK - runs-on: ubuntu-22.04 - services: - ydb: - image: ydbplatform/local-ydb:latest - ports: - - 2135:2135 - - 2136:2136 - - 8765:8765 - volumes: - - /tmp/ydb_certs:/ydb_certs - env: - YDB_LOCAL_SURVIVE_RESTART: true - YDB_USE_IN_MEMORY_PDISKS: true - YDB_TABLE_ENABLE_PREPARED_DDL: true - options: '-h localhost' - steps: - - name: Checkout PR - uses: actions/checkout@v3 - if: github.event.pull_request.head.sha != '' - with: - submodules: true - ref: ${{ github.event.pull_request.head.sha }} - - name: Checkout - uses: actions/checkout@v3 - if: github.event.pull_request.head.sha == '' - with: - submodules: true - - name: Install dependencies - uses: ./.github/actions/prepare_vm - - name: Prepare ccache timestamp - id: ccache_cache_timestamp - shell: cmake -P {0} - run: | - string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC) - message("::set-output name=timestamp::${current_date}") - - name: Restore cache files - uses: actions/cache/restore@v4 - with: - path: ~/.ccache - key: ubuntu-22.04-ccache-${{steps.ccache_cache_timestamp.outputs.timestamp}} - restore-keys: | - ubuntu-22.04-ccache- - - name: Build - uses: ./.github/actions/build - - name: Test - shell: bash - run: | - ctest -j32 --preset release - - name: Launch basic example - shell: bash - run: | - cd ../build - examples/basic_example/basic_example -e localhost:2136 -d /local -p /local/basic - examples/bulk_upsert_simple/bulk_upsert_simple -e localhost:2136 -d /local -p /local/bulk - examples/pagination/pagination -e localhost:2136 -d /local -p /local/pagination - examples/ttl/ttl -e localhost:2136 -d /local -p /local/ttl diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml new file mode 100644 index 00000000000..55417c1bb4e --- /dev/null +++ b/.github/workflows/tests.yaml @@ -0,0 +1,82 @@ +name: PR-check + +on: + push: + branches: + - main + pull_request: + branches: + - main +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} + cancel-in-progress: true +jobs: + unit: + concurrency: + group: unit-${{ github.ref }}-${{ matrix.os }}-${{ matrix.go-version }} + cancel-in-progress: true + strategy: + fail-fast: false + matrix: + os: [ubuntu, macOS] + env: + OS: ${{ matrix.os }}-latest + runs-on: ${{ matrix.os }}-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Run tests + run: ctest -j32 --preset release-unit + - name: Upload unit-tests coverage report to Codecov + uses: codecov/codecov-action@v4 + with: + file: ./unit.txt + flags: unit,${{ matrix.os }},go-${{ matrix.go-version }} + name: unit + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + + integration: + concurrency: + group: integration-${{ github.ref }}-${{ matrix.os }}-${{ matrix.go-version }}-${{ matrix.ydb-version }} + cancel-in-progress: true + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + ydb-version: [23.3, 24.1] + services: + ydb: + image: ydbplatform/local-ydb:${{ matrix.ydb-version }} + ports: + - 2135:2135 + - 2136:2136 + - 8765:8765 + volumes: + - /tmp/ydb_certs:/ydb_certs + env: + YDB_LOCAL_SURVIVE_RESTART: true + YDB_USE_IN_MEMORY_PDISKS: true + YDB_TABLE_ENABLE_PREPARED_DDL: true + options: '-h localhost' + env: + OS: ubuntu-latest + YDB_VERSION: ${{ matrix.ydb-version }} + YDB_CONNECTION_STRING: grpc://localhost:2136/local + YDB_CONNECTION_STRING_SECURE: grpcs://localhost:2135/local + YDB_SSL_ROOT_CERTIFICATES_FILE: /tmp/ydb_certs/ca.pem + YDB_SESSIONS_SHUTDOWN_URLS: http://localhost:8765/actors/kqp_proxy?force_shutdown=all + HIDE_APPLICATION_OUTPUT: 1 + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Run tests + run: ctest -j32 --preset release-integration + - name: Upload integration-tests coverage report to Codecov + uses: codecov/codecov-action@v4 + with: + file: ./integration.txt + flags: integration,${{ matrix.os }},go-${{ matrix.go-version }},ydb-${{ matrix.ydb-version }} + name: integration + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} From 27bd629ccd73e0bc9152d943a90c765d292d6149 Mon Sep 17 00:00:00 2001 From: st-shchetinin Date: Tue, 23 Jul 2024 18:55:49 +0300 Subject: [PATCH 10/36] fix tests.yaml --- .github/workflows/tests.yaml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 55417c1bb4e..a024276a365 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -23,6 +23,23 @@ jobs: OS: ${{ matrix.os }}-latest runs-on: ${{ matrix.os }}-latest steps: + - name: Install dependencies + uses: ./.github/actions/prepare_vm + - name: Prepare ccache timestamp + id: ccache_cache_timestamp + shell: cmake -P {0} + run: | + string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC) + message("::set-output name=timestamp::${current_date}") + - name: Restore cache files + uses: actions/cache/restore@v4 + with: + path: ~/.ccache + key: ubuntu-22.04-ccache-${{steps.ccache_cache_timestamp.outputs.timestamp}} + restore-keys: | + ubuntu-22.04-ccache- + - name: Build + uses: ./.github/actions/build - name: Checkout code uses: actions/checkout@v4 - name: Run tests @@ -68,6 +85,23 @@ jobs: YDB_SESSIONS_SHUTDOWN_URLS: http://localhost:8765/actors/kqp_proxy?force_shutdown=all HIDE_APPLICATION_OUTPUT: 1 steps: + - name: Install dependencies + uses: ./.github/actions/prepare_vm + - name: Prepare ccache timestamp + id: ccache_cache_timestamp + shell: cmake -P {0} + run: | + string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC) + message("::set-output name=timestamp::${current_date}") + - name: Restore cache files + uses: actions/cache/restore@v4 + with: + path: ~/.ccache + key: ubuntu-22.04-ccache-${{steps.ccache_cache_timestamp.outputs.timestamp}} + restore-keys: | + ubuntu-22.04-ccache- + - name: Build + uses: ./.github/actions/build - name: Checkout code uses: actions/checkout@v4 - name: Run tests From ddb26b3c5b2a62bd9dde0be33bbdb97fc1b22ff4 Mon Sep 17 00:00:00 2001 From: st-shchetinin Date: Tue, 23 Jul 2024 18:55:49 +0300 Subject: [PATCH 11/36] fix tests.yaml --- .github/workflows/tests.yaml | 48 +++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index a024276a365..af82c50c75f 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -23,6 +23,17 @@ jobs: OS: ${{ matrix.os }}-latest runs-on: ${{ matrix.os }}-latest steps: + - name: Checkout PR + uses: actions/checkout@v3 + if: github.event.pull_request.head.sha != '' + with: + submodules: true + ref: ${{ github.event.pull_request.head.sha }} + - name: Checkout + uses: actions/checkout@v3 + if: github.event.pull_request.head.sha == '' + with: + submodules: true - name: Install dependencies uses: ./.github/actions/prepare_vm - name: Prepare ccache timestamp @@ -40,18 +51,18 @@ jobs: ubuntu-22.04-ccache- - name: Build uses: ./.github/actions/build - - name: Checkout code - uses: actions/checkout@v4 - - name: Run tests - run: ctest -j32 --preset release-unit - - name: Upload unit-tests coverage report to Codecov - uses: codecov/codecov-action@v4 - with: - file: ./unit.txt - flags: unit,${{ matrix.os }},go-${{ matrix.go-version }} - name: unit - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + - name: Test + shell: bash + - name: Run tests + run: ctest -j32 --preset release-unit + - name: Upload unit-tests coverage report to Codecov + uses: codecov/codecov-action@v4 + with: + file: ./unit.txt + flags: unit,${{ matrix.os }},go-${{ matrix.go-version }} + name: unit + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} integration: concurrency: @@ -85,6 +96,17 @@ jobs: YDB_SESSIONS_SHUTDOWN_URLS: http://localhost:8765/actors/kqp_proxy?force_shutdown=all HIDE_APPLICATION_OUTPUT: 1 steps: + - name: Checkout PR + uses: actions/checkout@v3 + if: github.event.pull_request.head.sha != '' + with: + submodules: true + ref: ${{ github.event.pull_request.head.sha }} + - name: Checkout + uses: actions/checkout@v3 + if: github.event.pull_request.head.sha == '' + with: + submodules: true - name: Install dependencies uses: ./.github/actions/prepare_vm - name: Prepare ccache timestamp @@ -102,8 +124,6 @@ jobs: ubuntu-22.04-ccache- - name: Build uses: ./.github/actions/build - - name: Checkout code - uses: actions/checkout@v4 - name: Run tests run: ctest -j32 --preset release-integration - name: Upload integration-tests coverage report to Codecov From d625fb02da53bf832bc6f5da03d0fa87ea79047b Mon Sep 17 00:00:00 2001 From: st-shchetinin Date: Tue, 23 Jul 2024 19:25:33 +0300 Subject: [PATCH 12/36] fix tests --- .github/workflows/tests.yaml | 170 +++++++++++++++-------------------- 1 file changed, 74 insertions(+), 96 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index af82c50c75f..7bba6352e32 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -12,70 +12,62 @@ concurrency: cancel-in-progress: true jobs: unit: - concurrency: - group: unit-${{ github.ref }}-${{ matrix.os }}-${{ matrix.go-version }} - cancel-in-progress: true - strategy: - fail-fast: false - matrix: - os: [ubuntu, macOS] - env: - OS: ${{ matrix.os }}-latest - runs-on: ${{ matrix.os }}-latest + name: PR check for YDB C++ SDK + runs-on: ubuntu-22.04 + services: + ydb: + image: ydbplatform/local-ydb:latest + ports: + - 2135:2135 + - 2136:2136 + - 8765:8765 + volumes: + - /tmp/ydb_certs:/ydb_certs + env: + YDB_LOCAL_SURVIVE_RESTART: true + YDB_USE_IN_MEMORY_PDISKS: true + YDB_TABLE_ENABLE_PREPARED_DDL: true + options: '-h localhost' steps: - - name: Checkout PR + - name: Checkout PR uses: actions/checkout@v3 if: github.event.pull_request.head.sha != '' with: submodules: true ref: ${{ github.event.pull_request.head.sha }} - - name: Checkout - uses: actions/checkout@v3 - if: github.event.pull_request.head.sha == '' - with: - submodules: true - - name: Install dependencies - uses: ./.github/actions/prepare_vm - - name: Prepare ccache timestamp - id: ccache_cache_timestamp - shell: cmake -P {0} - run: | - string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC) - message("::set-output name=timestamp::${current_date}") - - name: Restore cache files - uses: actions/cache/restore@v4 - with: - path: ~/.ccache - key: ubuntu-22.04-ccache-${{steps.ccache_cache_timestamp.outputs.timestamp}} - restore-keys: | - ubuntu-22.04-ccache- - - name: Build - uses: ./.github/actions/build - - name: Test - shell: bash - - name: Run tests - run: ctest -j32 --preset release-unit - - name: Upload unit-tests coverage report to Codecov - uses: codecov/codecov-action@v4 - with: - file: ./unit.txt - flags: unit,${{ matrix.os }},go-${{ matrix.go-version }} - name: unit - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + - name: Checkout + uses: actions/checkout@v3 + if: github.event.pull_request.head.sha == '' + with: + submodules: true + - name: Install dependencies + uses: ./.github/actions/prepare_vm + - name: Prepare ccache timestamp + id: ccache_cache_timestamp + shell: cmake -P {0} + run: | + string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC) + message("::set-output name=timestamp::${current_date}") + - name: Restore cache files + uses: actions/cache/restore@v4 + with: + path: ~/.ccache + key: ubuntu-22.04-ccache-${{steps.ccache_cache_timestamp.outputs.timestamp}} + restore-keys: | + ubuntu-22.04-ccache- + - name: Build + uses: ./.github/actions/build + - name: Test + shell: bash + run: | + ctest -j32 --preset release-unit - integration: - concurrency: - group: integration-${{ github.ref }}-${{ matrix.os }}-${{ matrix.go-version }}-${{ matrix.ydb-version }} - cancel-in-progress: true - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - ydb-version: [23.3, 24.1] + integrtion: + name: PR check for YDB C++ SDK + runs-on: ubuntu-22.04 services: ydb: - image: ydbplatform/local-ydb:${{ matrix.ydb-version }} + image: ydbplatform/local-ydb:latest ports: - 2135:2135 - 2136:2136 @@ -87,50 +79,36 @@ jobs: YDB_USE_IN_MEMORY_PDISKS: true YDB_TABLE_ENABLE_PREPARED_DDL: true options: '-h localhost' - env: - OS: ubuntu-latest - YDB_VERSION: ${{ matrix.ydb-version }} - YDB_CONNECTION_STRING: grpc://localhost:2136/local - YDB_CONNECTION_STRING_SECURE: grpcs://localhost:2135/local - YDB_SSL_ROOT_CERTIFICATES_FILE: /tmp/ydb_certs/ca.pem - YDB_SESSIONS_SHUTDOWN_URLS: http://localhost:8765/actors/kqp_proxy?force_shutdown=all - HIDE_APPLICATION_OUTPUT: 1 steps: - - name: Checkout PR + - name: Checkout PR uses: actions/checkout@v3 if: github.event.pull_request.head.sha != '' with: submodules: true ref: ${{ github.event.pull_request.head.sha }} - - name: Checkout - uses: actions/checkout@v3 - if: github.event.pull_request.head.sha == '' - with: - submodules: true - - name: Install dependencies - uses: ./.github/actions/prepare_vm - - name: Prepare ccache timestamp - id: ccache_cache_timestamp - shell: cmake -P {0} - run: | - string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC) - message("::set-output name=timestamp::${current_date}") - - name: Restore cache files - uses: actions/cache/restore@v4 - with: - path: ~/.ccache - key: ubuntu-22.04-ccache-${{steps.ccache_cache_timestamp.outputs.timestamp}} - restore-keys: | - ubuntu-22.04-ccache- - - name: Build - uses: ./.github/actions/build - - name: Run tests - run: ctest -j32 --preset release-integration - - name: Upload integration-tests coverage report to Codecov - uses: codecov/codecov-action@v4 - with: - file: ./integration.txt - flags: integration,${{ matrix.os }},go-${{ matrix.go-version }},ydb-${{ matrix.ydb-version }} - name: integration - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + - name: Checkout + uses: actions/checkout@v3 + if: github.event.pull_request.head.sha == '' + with: + submodules: true + - name: Install dependencies + uses: ./.github/actions/prepare_vm + - name: Prepare ccache timestamp + id: ccache_cache_timestamp + shell: cmake -P {0} + run: | + string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC) + message("::set-output name=timestamp::${current_date}") + - name: Restore cache files + uses: actions/cache/restore@v4 + with: + path: ~/.ccache + key: ubuntu-22.04-ccache-${{steps.ccache_cache_timestamp.outputs.timestamp}} + restore-keys: | + ubuntu-22.04-ccache- + - name: Build + uses: ./.github/actions/build + - name: Test + shell: bash + run: | + ctest -j32 --preset release-integration From bb7b60490e067a2d87a80a47106009625d15126a Mon Sep 17 00:00:00 2001 From: st-shchetinin Date: Tue, 23 Jul 2024 19:41:18 +0300 Subject: [PATCH 13/36] groups in tests --- .github/workflows/tests.yaml | 38 ++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 7bba6352e32..9708f16f359 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -12,22 +12,16 @@ concurrency: cancel-in-progress: true jobs: unit: - name: PR check for YDB C++ SDK - runs-on: ubuntu-22.04 - services: - ydb: - image: ydbplatform/local-ydb:latest - ports: - - 2135:2135 - - 2136:2136 - - 8765:8765 - volumes: - - /tmp/ydb_certs:/ydb_certs - env: - YDB_LOCAL_SURVIVE_RESTART: true - YDB_USE_IN_MEMORY_PDISKS: true - YDB_TABLE_ENABLE_PREPARED_DDL: true - options: '-h localhost' + concurrency: + group: unit-${{ github.ref }}-${{ matrix.os }}-${{ matrix.go-version }} + cancel-in-progress: true + strategy: + fail-fast: false + matrix: + os: [ubuntu, macOS] + env: + OS: ${{ matrix.os }}-latest + runs-on: ${{ matrix.os }}-latest steps: - name: Checkout PR uses: actions/checkout@v3 @@ -63,11 +57,17 @@ jobs: ctest -j32 --preset release-unit integrtion: - name: PR check for YDB C++ SDK - runs-on: ubuntu-22.04 + concurrency: + group: integration-${{ github.ref }}-${{ matrix.os }}-${{ matrix.go-version }}-${{ matrix.ydb-version }} + cancel-in-progress: true + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + ydb-version: [23.3, 24.1] services: ydb: - image: ydbplatform/local-ydb:latest + image: ydbplatform/local-ydb:${{ matrix.ydb-version }} ports: - 2135:2135 - 2136:2136 From 53e37bd7eeac68bd6c0c37af3c59b8f8e3d85399 Mon Sep 17 00:00:00 2001 From: st-shchetinin Date: Tue, 23 Jul 2024 19:49:19 +0300 Subject: [PATCH 14/36] fix spaces in yaml --- .github/workflows/tests.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 9708f16f359..46dca6c29e7 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -13,14 +13,14 @@ concurrency: jobs: unit: concurrency: - group: unit-${{ github.ref }}-${{ matrix.os }}-${{ matrix.go-version }} - cancel-in-progress: true - strategy: - fail-fast: false - matrix: - os: [ubuntu, macOS] - env: - OS: ${{ matrix.os }}-latest + group: unit-${{ github.ref }}-${{ matrix.os }}-${{ matrix.go-version }} + cancel-in-progress: true + strategy: + fail-fast: false + matrix: + os: [ubuntu, macOS] + env: + OS: ${{ matrix.os }}-latest runs-on: ${{ matrix.os }}-latest steps: - name: Checkout PR From 02ecbf38b92a4f04d51447583c6f148a60fca3cb Mon Sep 17 00:00:00 2001 From: st-shchetinin Date: Tue, 23 Jul 2024 20:12:57 +0300 Subject: [PATCH 15/36] added examples & remoed macOS --- .github/workflows/examples.yaml | 13 ++++++++++++- .github/workflows/tests.yaml | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/examples.yaml b/.github/workflows/examples.yaml index 39213790ac4..f16ea8c7cb0 100644 --- a/.github/workflows/examples.yaml +++ b/.github/workflows/examples.yaml @@ -1,4 +1,15 @@ -main: +name: Examples + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + main: name: Examples runs-on: ubuntu-22.04 services: diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 46dca6c29e7..5f1f206b3bf 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -18,7 +18,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu, macOS] + os: [ubuntu] env: OS: ${{ matrix.os }}-latest runs-on: ${{ matrix.os }}-latest From 60258e08a95749a526ea2d1632fa91a3190a93e1 Mon Sep 17 00:00:00 2001 From: st-shchetinin Date: Tue, 23 Jul 2024 20:19:15 +0300 Subject: [PATCH 16/36] fix examples --- .github/workflows/examples.yaml | 34 ++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/.github/workflows/examples.yaml b/.github/workflows/examples.yaml index f16ea8c7cb0..081fd013cb4 100644 --- a/.github/workflows/examples.yaml +++ b/.github/workflows/examples.yaml @@ -12,9 +12,13 @@ jobs: main: name: Examples runs-on: ubuntu-22.04 + strategy: + fail-fast: false + matrix: + ydb-version: [23.3, 24.1] services: ydb: - image: ydbplatform/local-ydb:latest + image: ydbplatform/local-ydb:${{ matrix.ydb-version }} ports: - 2135:2135 - 2136:2136 @@ -27,6 +31,34 @@ jobs: YDB_TABLE_ENABLE_PREPARED_DDL: true options: '-h localhost' steps: + - name: Checkout PR + uses: actions/checkout@v3 + if: github.event.pull_request.head.sha != '' + with: + submodules: true + ref: ${{ github.event.pull_request.head.sha }} + - name: Checkout + uses: actions/checkout@v3 + if: github.event.pull_request.head.sha == '' + with: + submodules: true + - name: Install dependencies + uses: ./.github/actions/prepare_vm + - name: Prepare ccache timestamp + id: ccache_cache_timestamp + shell: cmake -P {0} + run: | + string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC) + message("::set-output name=timestamp::${current_date}") + - name: Restore cache files + uses: actions/cache/restore@v4 + with: + path: ~/.ccache + key: ubuntu-22.04-ccache-${{steps.ccache_cache_timestamp.outputs.timestamp}} + restore-keys: | + ubuntu-22.04-ccache- + - name: Build + uses: ./.github/actions/build - name: Launch basic example shell: bash run: | From 148cded58f0fbdea846f4e0b169b21eb0ead033e Mon Sep 17 00:00:00 2001 From: st-shchetinin Date: Tue, 23 Jul 2024 20:53:49 +0300 Subject: [PATCH 17/36] database & endpoint in env --- .github/workflows/tests.yaml | 3 +++ tests/integration/CMakeLists.txt | 4 ---- tests/integration/basic_example_it/main.cpp | 5 +++-- tests/integration/config_ydb.h | 9 --------- tests/integration/config_ydb.h.in | 9 --------- 5 files changed, 6 insertions(+), 24 deletions(-) delete mode 100644 tests/integration/config_ydb.h delete mode 100644 tests/integration/config_ydb.h.in diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 5f1f206b3bf..ed8f25ddb8f 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -61,6 +61,9 @@ jobs: group: integration-${{ github.ref }}-${{ matrix.os }}-${{ matrix.go-version }}-${{ matrix.ydb-version }} cancel-in-progress: true runs-on: ubuntu-latest + env: + ENDPOINT: "localhost:2136" + DATABASE: "/local" strategy: fail-fast: false matrix: diff --git a/tests/integration/CMakeLists.txt b/tests/integration/CMakeLists.txt index 3821aea81f1..a7a4e7c9715 100644 --- a/tests/integration/CMakeLists.txt +++ b/tests/integration/CMakeLists.txt @@ -1,5 +1 @@ -set(ENDPOINT "localhost:2136") -set(DATABASE "/local") -configure_file(config_ydb.h.in ${CMAKE_CURRENT_SOURCE_DIR}/config_ydb.h @ONLY) - add_subdirectory(basic_example_it) diff --git a/tests/integration/basic_example_it/main.cpp b/tests/integration/basic_example_it/main.cpp index 478d32bc978..651e59241fb 100644 --- a/tests/integration/basic_example_it/main.cpp +++ b/tests/integration/basic_example_it/main.cpp @@ -1,5 +1,4 @@ #include "basic_example.h" -#include "../config_ydb.h" #include @@ -19,7 +18,9 @@ void StopHandler(int) { TEST(Integration, BasicExample) { TOpts opts = TOpts::Default(); - + + std::string database = std::getenv( "DATABASE" ); + std::string endpoint = std::getenv( "ENDPOINT" );; std::string path; std::string certPath; diff --git a/tests/integration/config_ydb.h b/tests/integration/config_ydb.h deleted file mode 100644 index f447dca4c2c..00000000000 --- a/tests/integration/config_ydb.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef CONFIG_YDB_H_IN -#define CONFIG_YDB_H_IN - -#include - -const std::string endpoint = "localhost:2136"; -const std::string database = "/local"; - -#endif // CONFIG_YDB_H_IN diff --git a/tests/integration/config_ydb.h.in b/tests/integration/config_ydb.h.in deleted file mode 100644 index 728d379bd83..00000000000 --- a/tests/integration/config_ydb.h.in +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef CONFIG_YDB_H_IN -#define CONFIG_YDB_H_IN - -#include - -const std::string endpoint = "@ENDPOINT@"; -const std::string database = "@DATABASE@"; - -#endif // CONFIG_YDB_H_IN From 5916be7d23e488e4521f6e9c696a20586c79c4de Mon Sep 17 00:00:00 2001 From: st-shchetinin Date: Wed, 24 Jul 2024 14:19:42 +0300 Subject: [PATCH 18/36] added labels for tests & devided test groups by labels --- .github/workflows/tests.yaml | 3 --- CMakePresets.json | 8 ++++++-- cmake/testing.cmake | 4 +++- .../integration/basic_example_it/CMakeLists.txt | 2 ++ tests/ut/client/CMakeLists.txt | 16 ++++++++++++++++ .../client/oauth2_token_exchange/CMakeLists.txt | 2 ++ tests/ut/json_value/CMakeLists.txt | 2 ++ tests/ut/library/cache/CMakeLists.txt | 2 ++ .../case_insensitive_string/CMakeLists.txt | 2 ++ tests/ut/library/cgiparam/CMakeLists.txt | 2 ++ tests/ut/library/charset/CMakeLists.txt | 10 ++++++++++ tests/ut/library/containers/CMakeLists.txt | 8 ++++++++ tests/ut/library/coroutine/engine/CMakeLists.txt | 2 ++ .../coroutine/engine/stack/CMakeLists.txt | 10 ++++++++++ tests/ut/library/dbg_output/CMakeLists.txt | 2 ++ tests/ut/library/diff/CMakeLists.txt | 2 ++ .../ut/library/digest/lower_case/CMakeLists.txt | 4 ++++ tests/ut/library/digest/md5/CMakeLists.txt | 4 ++++ tests/ut/library/digest/murmur/CMakeLists.txt | 2 ++ tests/ut/library/json/CMakeLists.txt | 10 ++++++++++ tests/ut/library/json/writer/CMakeLists.txt | 4 ++++ tests/ut/library/operation_id/CMakeLists.txt | 2 ++ tests/ut/library/testing/common/CMakeLists.txt | 2 ++ .../testing/gmock_in_unittest/CMakeLists.txt | 2 ++ tests/ut/library/testing/gtest/CMakeLists.txt | 2 ++ .../testing/gtest_extensions/CMakeLists.txt | 2 ++ tests/ut/library/testing/unittest/CMakeLists.txt | 4 ++++ tests/ut/library/yql/CMakeLists.txt | 8 ++++++++ tests/ut/util/charset/CMakeLists.txt | 4 ++++ tests/ut/util/digest/CMakeLists.txt | 10 ++++++++++ tests/ut/util/folder/CMakeLists.txt | 12 ++++++++++++ tests/ut/util/network/CMakeLists.txt | 14 ++++++++++++++ 32 files changed, 157 insertions(+), 6 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index ed8f25ddb8f..5f1f206b3bf 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -61,9 +61,6 @@ jobs: group: integration-${{ github.ref }}-${{ matrix.os }}-${{ matrix.go-version }}-${{ matrix.ydb-version }} cancel-in-progress: true runs-on: ubuntu-latest - env: - ENDPOINT: "localhost:2136" - DATABASE: "/local" strategy: fail-fast: false matrix: diff --git a/CMakePresets.json b/CMakePresets.json index e0b82ed4ddd..21da4dadc6b 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -67,7 +67,7 @@ "displayName": "Default Unit Release Tests", "filter" : { "include": { - "name": ".*_ut" + "label": "unit" } }, "output": { @@ -86,11 +86,15 @@ }, "filter" : { "include": { - "name": ".*_it" + "label": "integration" } }, "execution": { "timeout": 1200 + }, + "environment": { + "ENDPOINT": "localhost:2136", + "DATABASE": "/local" } } ] diff --git a/cmake/testing.cmake b/cmake/testing.cmake index 3d1ac921d89..1e44e956963 100644 --- a/cmake/testing.cmake +++ b/cmake/testing.cmake @@ -60,7 +60,7 @@ endfunction() function(add_ydb_test) set(opts "") set(oneval_args NAME) - set(multival_args INCLUDE_DIRS SOURCES LINK_LIBRARIES) + set(multival_args INCLUDE_DIRS SOURCES LINK_LIBRARIES LABELS) cmake_parse_arguments(YDB_TEST "${opts}" "${oneval_args}" @@ -72,6 +72,7 @@ function(add_ydb_test) target_include_directories(${YDB_TEST_NAME} PRIVATE ${YDB_TEST_INCLUDE_DIRS}) target_link_libraries(${YDB_TEST_NAME} PRIVATE ${YDB_TEST_LINK_LIBRARIES}) target_sources(${YDB_TEST_NAME} PRIVATE ${YDB_TEST_SOURCES}) + #set_tests_properties(${YDB_TEST_NAME} PROPERTIES LABELS "${YDB_TEST_LABELS}") if (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64") target_link_libraries(${YDB_TEST_NAME} PRIVATE @@ -121,6 +122,7 @@ function(add_ydb_test) PROPERTY LABELS MEDIUM + ${YDB_TEST_LABELS} ) set_yunittest_property( diff --git a/tests/integration/basic_example_it/CMakeLists.txt b/tests/integration/basic_example_it/CMakeLists.txt index 4f1d39530c4..1fbd6b395d9 100644 --- a/tests/integration/basic_example_it/CMakeLists.txt +++ b/tests/integration/basic_example_it/CMakeLists.txt @@ -9,4 +9,6 @@ add_ydb_test(NAME basic-example_it library-getopt YDB-CPP-SDK::Table GTest::gtest_main + LABELS + integration ) \ No newline at end of file diff --git a/tests/ut/client/CMakeLists.txt b/tests/ut/client/CMakeLists.txt index d35d68352ec..c10b96db557 100644 --- a/tests/ut/client/CMakeLists.txt +++ b/tests/ut/client/CMakeLists.txt @@ -8,6 +8,8 @@ add_ydb_test(NAME client-ydb_coordination_ut cpp-testing-unittest_main YDB-CPP-SDK::Coordination api-grpc + LABELS + unit ) add_ydb_test(NAME client-extensions-discovery_mutator_ut @@ -18,6 +20,8 @@ add_ydb_test(NAME client-extensions-discovery_mutator_ut cpp-testing-unittest_main YDB-CPP-SDK::DiscoveryMutator YDB-CPP-SDK::Table + LABELS + unit ) add_ydb_test(NAME client-ydb_driver_ut @@ -28,6 +32,8 @@ add_ydb_test(NAME client-ydb_driver_ut cpp-testing-unittest_main YDB-CPP-SDK::Driver YDB-CPP-SDK::Table + LABELS + unit ) add_ydb_test(NAME client-impl-ydb_endpoints_ut @@ -39,6 +45,8 @@ add_ydb_test(NAME client-impl-ydb_endpoints_ut yutil cpp-testing-unittest_main client-impl-ydb_endpoints + LABELS + unit ) add_ydb_test(NAME client-ydb_params_ut @@ -49,6 +57,8 @@ add_ydb_test(NAME client-ydb_params_ut cpp-testing-unittest_main YDB-CPP-SDK::Params YDB-CPP-SDK::YsonValue + LABELS + unit ) add_ydb_test(NAME client-ydb_result_ut @@ -59,6 +69,8 @@ add_ydb_test(NAME client-ydb_result_ut cpp-testing-unittest_main YDB-CPP-SDK::Result YDB-CPP-SDK::Params + LABELS + unit ) add_ydb_test(NAME client-ydb_value_ut @@ -71,6 +83,8 @@ add_ydb_test(NAME client-ydb_value_ut YDB-CPP-SDK::JsonValue YDB-CPP-SDK::YsonValue YDB-CPP-SDK::Params + LABELS + unit ) add_ydb_test(NAME client-draft_ut @@ -80,4 +94,6 @@ add_ydb_test(NAME client-draft_ut yutil cpp-testing-unittest_main YDB-CPP-SDK::Draft + LABELS + unit ) diff --git a/tests/ut/client/oauth2_token_exchange/CMakeLists.txt b/tests/ut/client/oauth2_token_exchange/CMakeLists.txt index a56f8432b44..2e87fb69841 100644 --- a/tests/ut/client/oauth2_token_exchange/CMakeLists.txt +++ b/tests/ut/client/oauth2_token_exchange/CMakeLists.txt @@ -7,4 +7,6 @@ add_ydb_test(NAME client-oauth2_ut cpp-testing-unittest_main library-http-server client-ydb_types-credentials-oauth2 + LABELS + unit ) diff --git a/tests/ut/json_value/CMakeLists.txt b/tests/ut/json_value/CMakeLists.txt index c17170583bc..e5becfaae57 100644 --- a/tests/ut/json_value/CMakeLists.txt +++ b/tests/ut/json_value/CMakeLists.txt @@ -9,4 +9,6 @@ add_ydb_test(NAME json_value_ut cpp-testing-unittest YDB-CPP-SDK::Proto YDB-CPP-SDK::Params + LABELS + unit ) diff --git a/tests/ut/library/cache/CMakeLists.txt b/tests/ut/library/cache/CMakeLists.txt index be659e273dc..ff74a781be7 100644 --- a/tests/ut/library/cache/CMakeLists.txt +++ b/tests/ut/library/cache/CMakeLists.txt @@ -5,4 +5,6 @@ add_ydb_test(NAME cache-cache_ut yutil cpp-testing-unittest_main library-cache + LABELS + unit ) \ No newline at end of file diff --git a/tests/ut/library/case_insensitive_string/CMakeLists.txt b/tests/ut/library/case_insensitive_string/CMakeLists.txt index 85dd71d3cff..06280932a5c 100644 --- a/tests/ut/library/case_insensitive_string/CMakeLists.txt +++ b/tests/ut/library/case_insensitive_string/CMakeLists.txt @@ -6,4 +6,6 @@ add_ydb_test(NAME library-case_insensitive_string_ut LINK_LIBRARIES library-case_insensitive_string cpp-testing-unittest_main + LABELS + unit ) diff --git a/tests/ut/library/cgiparam/CMakeLists.txt b/tests/ut/library/cgiparam/CMakeLists.txt index 9e6cda66f90..dab54cba6b4 100644 --- a/tests/ut/library/cgiparam/CMakeLists.txt +++ b/tests/ut/library/cgiparam/CMakeLists.txt @@ -4,4 +4,6 @@ add_ydb_test(NAME library-cgiparam_ut LINK_LIBRARIES library-cgiparam cpp-testing-unittest_main + LABELS + unit ) diff --git a/tests/ut/library/charset/CMakeLists.txt b/tests/ut/library/charset/CMakeLists.txt index 437b4144b4b..ea7c0752686 100644 --- a/tests/ut/library/charset/CMakeLists.txt +++ b/tests/ut/library/charset/CMakeLists.txt @@ -6,6 +6,8 @@ add_ydb_test(NAME library-charset-ci_string_ut LINK_LIBRARIES library-charset-lite cpp-testing-unittest_main + LABELS + unit ) add_ydb_test(NAME library-charset-codepage_ut @@ -16,6 +18,8 @@ add_ydb_test(NAME library-charset-codepage_ut LINK_LIBRARIES library-charset cpp-testing-unittest_main + LABELS + unit ) add_ydb_test(NAME library-charset-iconv_ut @@ -26,6 +30,8 @@ add_ydb_test(NAME library-charset-iconv_ut LINK_LIBRARIES library-charset cpp-testing-unittest_main + LABELS + unit ) add_ydb_test(NAME library-charset-recyr_int_ut @@ -36,6 +42,8 @@ add_ydb_test(NAME library-charset-recyr_int_ut LINK_LIBRARIES library-charset cpp-testing-unittest_main + LABELS + unit ) add_ydb_test(NAME library-charset-wide_ut @@ -46,4 +54,6 @@ add_ydb_test(NAME library-charset-wide_ut LINK_LIBRARIES library-charset cpp-testing-unittest_main + LABELS + unit ) diff --git a/tests/ut/library/containers/CMakeLists.txt b/tests/ut/library/containers/CMakeLists.txt index 0c1dad4287c..4a072f88c8f 100644 --- a/tests/ut/library/containers/CMakeLists.txt +++ b/tests/ut/library/containers/CMakeLists.txt @@ -6,6 +6,8 @@ add_ydb_test(NAME library-containers-disjoint_interval_tree_ut LINK_LIBRARIES containers-disjoint_interval_tree cpp-testing-unittest_main + LABELS + unit ) add_ydb_test(NAME library-containers-intrusive_rb_tree_ut @@ -16,6 +18,8 @@ add_ydb_test(NAME library-containers-intrusive_rb_tree_ut LINK_LIBRARIES containers-intrusive_rb_tree cpp-testing-unittest_main + LABELS + unit ) add_ydb_test(NAME library-containers-paged_vector_ut @@ -26,6 +30,8 @@ add_ydb_test(NAME library-containers-paged_vector_ut LINK_LIBRARIES containers-paged_vector cpp-testing-unittest_main + LABELS + unit ) add_ydb_test(NAME library-containers-stack_vector_ut @@ -34,4 +40,6 @@ add_ydb_test(NAME library-containers-stack_vector_ut LINK_LIBRARIES containers-stack_vector cpp-testing-unittest_main + LABELS + unit ) diff --git a/tests/ut/library/coroutine/engine/CMakeLists.txt b/tests/ut/library/coroutine/engine/CMakeLists.txt index ce3281b6462..e8ec7822187 100644 --- a/tests/ut/library/coroutine/engine/CMakeLists.txt +++ b/tests/ut/library/coroutine/engine/CMakeLists.txt @@ -6,6 +6,8 @@ add_ydb_test(NAME library-coroutine-engine-coroutine_ut LINK_LIBRARIES library-coroutine-engine cpp-testing-unittest_main + LABELS + unit ) add_subdirectory(stack) diff --git a/tests/ut/library/coroutine/engine/stack/CMakeLists.txt b/tests/ut/library/coroutine/engine/stack/CMakeLists.txt index 93b7dbacd97..03ed5f9c409 100644 --- a/tests/ut/library/coroutine/engine/stack/CMakeLists.txt +++ b/tests/ut/library/coroutine/engine/stack/CMakeLists.txt @@ -6,6 +6,8 @@ add_ydb_test(NAME library-coroutine-engine-stack-stack_allocator_ut LINK_LIBRARIES library-coroutine-engine cpp-testing-gtest_main + LABELS + unit ) add_ydb_test(NAME library-coroutine-engine-stack-stack_guards_ut @@ -16,6 +18,8 @@ add_ydb_test(NAME library-coroutine-engine-stack-stack_guards_ut LINK_LIBRARIES library-coroutine-engine cpp-testing-gtest_main + LABELS + unit ) add_ydb_test(NAME library-coroutine-engine-stack-stack_pool_ut @@ -26,6 +30,8 @@ add_ydb_test(NAME library-coroutine-engine-stack-stack_pool_ut LINK_LIBRARIES library-coroutine-engine cpp-testing-gtest_main + LABELS + unit ) add_ydb_test(NAME library-coroutine-engine-stack-stack_ut @@ -36,6 +42,8 @@ add_ydb_test(NAME library-coroutine-engine-stack-stack_ut LINK_LIBRARIES library-coroutine-engine cpp-testing-gtest_main + LABELS + unit ) add_ydb_test(NAME library-coroutine-engine-stack-stack_utils_ut @@ -46,4 +54,6 @@ add_ydb_test(NAME library-coroutine-engine-stack-stack_utils_ut LINK_LIBRARIES library-coroutine-engine cpp-testing-gtest_main + LABELS + unit ) diff --git a/tests/ut/library/dbg_output/CMakeLists.txt b/tests/ut/library/dbg_output/CMakeLists.txt index 281a021e12b..ffdaf1d972f 100644 --- a/tests/ut/library/dbg_output/CMakeLists.txt +++ b/tests/ut/library/dbg_output/CMakeLists.txt @@ -8,4 +8,6 @@ add_ydb_test(NAME library-dbg_output-dbg_output_ut yutil library-dbg_output cpp-testing-unittest_main + LABELS + unit ) diff --git a/tests/ut/library/diff/CMakeLists.txt b/tests/ut/library/diff/CMakeLists.txt index 250bdadf6d3..82c1e415c8a 100644 --- a/tests/ut/library/diff/CMakeLists.txt +++ b/tests/ut/library/diff/CMakeLists.txt @@ -6,4 +6,6 @@ add_ydb_test(NAME library-diff_ut LINK_LIBRARIES library-diff cpp-testing-unittest_main + LABELS + unit ) diff --git a/tests/ut/library/digest/lower_case/CMakeLists.txt b/tests/ut/library/digest/lower_case/CMakeLists.txt index 537f45deba0..a7157c5373b 100644 --- a/tests/ut/library/digest/lower_case/CMakeLists.txt +++ b/tests/ut/library/digest/lower_case/CMakeLists.txt @@ -6,6 +6,8 @@ add_ydb_test(NAME library-digest-lower_case-hash_ops_ut LINK_LIBRARIES digest-lower_case cpp-testing-unittest_main + LABELS + unit ) add_ydb_test(NAME library-digest-lower_case-lchash_ut @@ -16,4 +18,6 @@ add_ydb_test(NAME library-digest-lower_case-lchash_ut LINK_LIBRARIES digest-lower_case cpp-testing-unittest_main + LABELS + unit ) diff --git a/tests/ut/library/digest/md5/CMakeLists.txt b/tests/ut/library/digest/md5/CMakeLists.txt index 57f0574b034..a1b10c30d1e 100644 --- a/tests/ut/library/digest/md5/CMakeLists.txt +++ b/tests/ut/library/digest/md5/CMakeLists.txt @@ -8,6 +8,8 @@ add_ydb_test(NAME library-digest-md5_medium_ut yutil digest-md5 cpp-testing-unittest_main + LABELS + unit ) add_ydb_test(NAME library-digest-md5_ut @@ -20,4 +22,6 @@ add_ydb_test(NAME library-digest-md5_ut yutil digest-md5 cpp-testing-unittest_main + LABELS + unit ) diff --git a/tests/ut/library/digest/murmur/CMakeLists.txt b/tests/ut/library/digest/murmur/CMakeLists.txt index 1c7ad9cf64a..30c6ea9bd65 100644 --- a/tests/ut/library/digest/murmur/CMakeLists.txt +++ b/tests/ut/library/digest/murmur/CMakeLists.txt @@ -6,4 +6,6 @@ add_ydb_test(NAME library-digest-murmur_ut LINK_LIBRARIES digest-murmur cpp-testing-unittest_main + LABELS + unit ) diff --git a/tests/ut/library/json/CMakeLists.txt b/tests/ut/library/json/CMakeLists.txt index 9f9a916d92e..134083b49c7 100644 --- a/tests/ut/library/json/CMakeLists.txt +++ b/tests/ut/library/json/CMakeLists.txt @@ -10,6 +10,8 @@ LINK_LIBRARIES yutil cpp-testing-unittest_main library-json +LABELS + unit ) add_ydb_test(NAME json-ut-json_reader_fast_ut @@ -25,6 +27,8 @@ LINK_LIBRARIES yutil cpp-testing-unittest_main library-json +LABELS + unit ) add_ydb_test(NAME json-ut-json_reader_ut @@ -39,6 +43,8 @@ LINK_LIBRARIES yutil cpp-testing-unittest_main library-json +LABELS + unit ) add_ydb_test(NAME json-ut-json_saveload_ut @@ -53,6 +59,8 @@ LINK_LIBRARIES yutil cpp-testing-unittest_main library-json +LABELS + unit ) add_ydb_test(NAME json-ut-json_writer_ut @@ -66,4 +74,6 @@ LINK_LIBRARIES yutil cpp-testing-unittest_main library-json +LABELS + unit ) diff --git a/tests/ut/library/json/writer/CMakeLists.txt b/tests/ut/library/json/writer/CMakeLists.txt index 24ee63e3899..511da59f136 100644 --- a/tests/ut/library/json/writer/CMakeLists.txt +++ b/tests/ut/library/json/writer/CMakeLists.txt @@ -10,6 +10,8 @@ LINK_LIBRARIES yutil library-json-writer cpp-testing-unittest_main +LABELS + unit ) add_ydb_test(NAME library-json-writer-json_value_ut @@ -23,4 +25,6 @@ LINK_LIBRARIES yutil library-json-writer cpp-testing-unittest_main +LABELS + unit ) diff --git a/tests/ut/library/operation_id/CMakeLists.txt b/tests/ut/library/operation_id/CMakeLists.txt index 754781f46f9..d034531ad88 100644 --- a/tests/ut/library/operation_id/CMakeLists.txt +++ b/tests/ut/library/operation_id/CMakeLists.txt @@ -6,4 +6,6 @@ add_ydb_test(NAME operation_id_ut cpp-testing-unittest_main library-operation_id cpp-testing-unittest + LABELS + unit ) diff --git a/tests/ut/library/testing/common/CMakeLists.txt b/tests/ut/library/testing/common/CMakeLists.txt index 20c847707b4..bb1b8803081 100644 --- a/tests/ut/library/testing/common/CMakeLists.txt +++ b/tests/ut/library/testing/common/CMakeLists.txt @@ -5,4 +5,6 @@ add_ydb_test(NAME cpp-testing-common_ut scope_ut.cpp LINK_LIBRARIES cpp-testing-gtest_main + LABELS + unit ) diff --git a/tests/ut/library/testing/gmock_in_unittest/CMakeLists.txt b/tests/ut/library/testing/gmock_in_unittest/CMakeLists.txt index e2918194e99..0c86f1ffc09 100644 --- a/tests/ut/library/testing/gmock_in_unittest/CMakeLists.txt +++ b/tests/ut/library/testing/gmock_in_unittest/CMakeLists.txt @@ -4,4 +4,6 @@ add_ydb_test(NAME cpp-testing-gmock_in_unittest_ut LINK_LIBRARIES cpp-testing-gmock_in_unittest cpp-testing-unittest_main + LABELS + unit ) diff --git a/tests/ut/library/testing/gtest/CMakeLists.txt b/tests/ut/library/testing/gtest/CMakeLists.txt index 746cddfdad6..e6b1fd3fe36 100644 --- a/tests/ut/library/testing/gtest/CMakeLists.txt +++ b/tests/ut/library/testing/gtest/CMakeLists.txt @@ -4,4 +4,6 @@ add_ydb_test(NAME cpp-testing-gtest_ut ut.cpp LINK_LIBRARIES cpp-testing-gtest_main + LABELS + unit ) diff --git a/tests/ut/library/testing/gtest_extensions/CMakeLists.txt b/tests/ut/library/testing/gtest_extensions/CMakeLists.txt index 94f82c25906..9c477ee568a 100644 --- a/tests/ut/library/testing/gtest_extensions/CMakeLists.txt +++ b/tests/ut/library/testing/gtest_extensions/CMakeLists.txt @@ -4,4 +4,6 @@ add_ydb_test(NAME cpp-testing-gtest_extensions_ut probe_ut.cpp LINK_LIBRARIES cpp-testing-gtest_main + LABELS + unit ) diff --git a/tests/ut/library/testing/unittest/CMakeLists.txt b/tests/ut/library/testing/unittest/CMakeLists.txt index 892155bf760..c4e5e252acc 100644 --- a/tests/ut/library/testing/unittest/CMakeLists.txt +++ b/tests/ut/library/testing/unittest/CMakeLists.txt @@ -3,6 +3,8 @@ add_ydb_test(NAME cpp-testing-unittest_ut main.cpp LINK_LIBRARIES cpp-testing-unittest_main + LABELS + unit ) add_ydb_test(NAME cpp-testing-unittest_fat_ut @@ -10,4 +12,6 @@ add_ydb_test(NAME cpp-testing-unittest_fat_ut test_port_manager.cpp LINK_LIBRARIES cpp-testing-unittest_main + LABELS + unit ) diff --git a/tests/ut/library/yql/CMakeLists.txt b/tests/ut/library/yql/CMakeLists.txt index 6a3c2804f01..a124b7c860e 100644 --- a/tests/ut/library/yql/CMakeLists.txt +++ b/tests/ut/library/yql/CMakeLists.txt @@ -5,6 +5,8 @@ add_ydb_test(NAME yql-utils_ut yutil cpp-testing-unittest_main yql-utils + LABELS + unit ) add_ydb_test(NAME yql-public-issue_ut @@ -15,6 +17,8 @@ add_ydb_test(NAME yql-public-issue_ut cpp-testing-unittest_main yql-public-issue unicode_normalization + LABELS + unit ) add_ydb_test(NAME yql-public-decimal_ut @@ -24,6 +28,8 @@ add_ydb_test(NAME yql-public-decimal_ut yutil cpp-testing-unittest_main yql-public-decimal + LABELS + unit ) add_ydb_test(NAME yql-public-wide_int_ut @@ -33,4 +39,6 @@ add_ydb_test(NAME yql-public-wide_int_ut yutil cpp-testing-unittest_main yql-public-decimal + LABELS + unit ) diff --git a/tests/ut/util/charset/CMakeLists.txt b/tests/ut/util/charset/CMakeLists.txt index 75d6027ea2e..1696fa35867 100644 --- a/tests/ut/util/charset/CMakeLists.txt +++ b/tests/ut/util/charset/CMakeLists.txt @@ -6,6 +6,8 @@ add_ydb_test(NAME util-charset-utf8_ut LINK_LIBRARIES util-charset cpp-testing-unittest_main + LABELS + unit ) add_ydb_test(NAME util-charset-wide_ut @@ -16,4 +18,6 @@ add_ydb_test(NAME util-charset-wide_ut LINK_LIBRARIES util-charset cpp-testing-unittest_main + LABELS + unit ) diff --git a/tests/ut/util/digest/CMakeLists.txt b/tests/ut/util/digest/CMakeLists.txt index 8101b1c26ef..b0e51b54d81 100644 --- a/tests/ut/util/digest/CMakeLists.txt +++ b/tests/ut/util/digest/CMakeLists.txt @@ -6,6 +6,8 @@ add_ydb_test(NAME util-digest-city_ut LINK_LIBRARIES yutil cpp-testing-unittest_main + LABELS + unit ) add_ydb_test(NAME util-digest-fnv_ut @@ -16,6 +18,8 @@ add_ydb_test(NAME util-digest-fnv_ut LINK_LIBRARIES yutil cpp-testing-unittest_main + LABELS + unit ) add_ydb_test(NAME util-digest-multi_ut @@ -24,6 +28,8 @@ add_ydb_test(NAME util-digest-multi_ut LINK_LIBRARIES yutil cpp-testing-unittest_main + LABELS + unit ) add_ydb_test(NAME util-digest-murmur_ut @@ -34,6 +40,8 @@ add_ydb_test(NAME util-digest-murmur_ut LINK_LIBRARIES yutil cpp-testing-unittest_main + LABELS + unit ) add_ydb_test(NAME util-digest-sequence_ut @@ -42,4 +50,6 @@ add_ydb_test(NAME util-digest-sequence_ut LINK_LIBRARIES yutil cpp-testing-unittest_main + LABELS + unit ) diff --git a/tests/ut/util/folder/CMakeLists.txt b/tests/ut/util/folder/CMakeLists.txt index 16d7478dd33..85325841ac1 100644 --- a/tests/ut/util/folder/CMakeLists.txt +++ b/tests/ut/util/folder/CMakeLists.txt @@ -6,6 +6,8 @@ add_ydb_test(NAME util-folder-dirut_ut LINK_LIBRARIES yutil cpp-testing-unittest_main + LABELS + unit ) add_ydb_test(NAME util-folder-filelist_ut @@ -16,6 +18,8 @@ add_ydb_test(NAME util-folder-filelist_ut LINK_LIBRARIES yutil cpp-testing-unittest_main + LABELS + unit ) add_ydb_test(NAME util-folder-fts_ut @@ -27,6 +31,8 @@ add_ydb_test(NAME util-folder-fts_ut yutil cpp-testing-unittest_main threading-future + LABELS + unit ) add_ydb_test(NAME util-folder-iterator_ut @@ -37,6 +43,8 @@ add_ydb_test(NAME util-folder-iterator_ut LINK_LIBRARIES yutil cpp-testing-unittest_main + LABELS + unit ) add_ydb_test(NAME util-folder-path_ut @@ -47,6 +55,8 @@ add_ydb_test(NAME util-folder-path_ut LINK_LIBRARIES yutil cpp-testing-unittest_main + LABELS + unit ) add_ydb_test(NAME util-folder-pathsplit_ut @@ -57,4 +67,6 @@ add_ydb_test(NAME util-folder-pathsplit_ut LINK_LIBRARIES yutil cpp-testing-unittest_main + LABELS + unit ) diff --git a/tests/ut/util/network/CMakeLists.txt b/tests/ut/util/network/CMakeLists.txt index 8dd5dc6911d..9a04a114d89 100644 --- a/tests/ut/util/network/CMakeLists.txt +++ b/tests/ut/util/network/CMakeLists.txt @@ -6,6 +6,8 @@ add_ydb_test(NAME util-network-iovec_ut LINK_LIBRARIES yutil cpp-testing-gtest_main + LABELS + unit ) add_ydb_test(NAME util-network-socket_ut @@ -16,6 +18,8 @@ add_ydb_test(NAME util-network-socket_ut LINK_LIBRARIES yutil cpp-testing-unittest_main + LABELS + unit ) add_ydb_test(NAME util-network-address_ut @@ -26,6 +30,8 @@ add_ydb_test(NAME util-network-address_ut LINK_LIBRARIES yutil cpp-testing-unittest_main + LABELS + unit ) add_ydb_test(NAME util-network-endpoint_ut @@ -36,6 +42,8 @@ add_ydb_test(NAME util-network-endpoint_ut LINK_LIBRARIES yutil cpp-testing-unittest_main + LABELS + unit ) add_ydb_test(NAME util-network-ip_ut @@ -46,6 +54,8 @@ add_ydb_test(NAME util-network-ip_ut LINK_LIBRARIES yutil cpp-testing-unittest_main + LABELS + unit ) add_ydb_test(NAME util-network-poller_ut @@ -56,6 +66,8 @@ add_ydb_test(NAME util-network-poller_ut LINK_LIBRARIES yutil cpp-testing-unittest_main + LABELS + unit ) add_ydb_test(NAME util-network-sock_ut @@ -67,4 +79,6 @@ add_ydb_test(NAME util-network-sock_ut yutil threading-future cpp-testing-unittest_main + LABELS + unit ) From ea3bac8bf14b60b1e4a5718c058a1b2964ec5c6a Mon Sep 17 00:00:00 2001 From: st-shchetinin Date: Wed, 24 Jul 2024 17:14:38 +0300 Subject: [PATCH 19/36] added docker-compose.yaml from rust-sdk --- docker-compose.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 docker-compose.yaml diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 00000000000..54bc92c68e8 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,10 @@ +version: "3.0" +services: + ydb: + image: cr.yandex/yc/yandex-docker-local-ydb:latest + hostname: localhost # for good discovery + environment: + YDB_ANONYMOUS_CREDENTIALS: 1 + ports: + - "2135:2135" # port with tls + - "2136:2136" # port without tls \ No newline at end of file From 2608352a925136cfa8c464995b3340f199529bbe Mon Sep 17 00:00:00 2001 From: st-shchetinin Date: Wed, 24 Jul 2024 17:25:09 +0300 Subject: [PATCH 20/36] added env in tests release --- CMakePresets.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakePresets.json b/CMakePresets.json index 21da4dadc6b..8d043605008 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -59,6 +59,10 @@ }, "execution": { "timeout": 1200 + }, + "environment": { + "ENDPOINT": "localhost:2136", + "DATABASE": "/local" } }, { From 99dde83b6aeb5c61c2766b48513716741520504c Mon Sep 17 00:00:00 2001 From: st-shchetinin Date: Thu, 25 Jul 2024 17:17:21 +0300 Subject: [PATCH 21/36] added lib --- examples/basic_example/CMakeLists.txt | 1 + examples/basic_example/basic_example.cpp | 6 +++++- tests/integration/basic_example_it/basic_example.cpp | 12 +++++------- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/examples/basic_example/CMakeLists.txt b/examples/basic_example/CMakeLists.txt index 55e4af14175..d5ef66ffdbf 100644 --- a/examples/basic_example/CMakeLists.txt +++ b/examples/basic_example/CMakeLists.txt @@ -4,6 +4,7 @@ target_link_libraries(basic_example PUBLIC yutil library-getopt YDB-CPP-SDK::Table + public-lib-json_value ) target_sources(basic_example PRIVATE diff --git a/examples/basic_example/basic_example.cpp b/examples/basic_example/basic_example.cpp index bc51087b051..6fbdeb3d932 100644 --- a/examples/basic_example/basic_example.cpp +++ b/examples/basic_example/basic_example.cpp @@ -1,6 +1,7 @@ #include "basic_example.h" #include +#include #include @@ -441,7 +442,10 @@ void SelectSimple(TTableClient client, const std::string& path) { ThrowOnError(client.RetryOperationSync([path, &resultSet](TSession session) { return SelectSimpleTransaction(session, path, resultSet); })); - + + if (resultSet.has_value()) { + std::cout << FormatResultSetJson(resultSet.value(), EBinaryStringEncoding::Base64); + } TResultSetParser parser(*resultSet); if (parser.TryNextRow()) { std::cout << "> SelectSimple:" << std::endl << "Series" diff --git a/tests/integration/basic_example_it/basic_example.cpp b/tests/integration/basic_example_it/basic_example.cpp index 53639531e8c..af348b5a695 100644 --- a/tests/integration/basic_example_it/basic_example.cpp +++ b/tests/integration/basic_example_it/basic_example.cpp @@ -1,6 +1,7 @@ #include "basic_example.h" #include +#include #include @@ -82,7 +83,7 @@ static void CreateTables(TTableClient client, const std::string& path) { } //! Describe existing table. -static std::string DescribeTable(TTableClient client, const std::string& path, const std::string& name) { +static void DescribeTable(TTableClient client, const std::string& path, const std::string& name) { std::optional desc; std::string result; ThrowOnError(client.RetryOperationSync([path, name, &desc](TSession session) { @@ -91,15 +92,13 @@ static std::string DescribeTable(TTableClient client, const std::string& path, c if (result.IsSuccess()) { desc = result.GetTableDescription(); } - return result; })); - result += std::format("> Describe table: {}\n", name); + std::cout << std::format("> Describe table: {}\n", name); for (auto& column : desc->GetColumns()) { - result += std::format("Column, name: {}, type: {}\n", column.Name, FormatType(column.Type)); + std::cout << std::format("Column, name: {}, type: {}\n", column.Name, FormatType(column.Type)); } - return result; } /////////////////////////////////////////////////////////////////////////////// @@ -439,7 +438,6 @@ std::string SelectSimple(TTableClient client, const std::string& path) { ThrowOnError(client.RetryOperationSync([path, &resultSet](TSession session) { return SelectSimpleTransaction(session, path, resultSet); })); - TResultSetParser parser(*resultSet); if (parser.TryNextRow()) { return std::format("> SelectSimple:\nSeries, Id: {}, Title: {}, Release date: {}\n" @@ -585,7 +583,7 @@ std::unique_ptr Run(const TDriver& driver, const std::string& path) { try { CreateTables(client, path); - response->result += DescribeTable(client, path, "series"); + DescribeTable(client, path, "series"); ThrowOnError(client.RetryOperationSync([path](TSession session) { return FillTableDataTransaction(session, path); From c09ba031045a81ee27777454cdcbfb19740494e4 Mon Sep 17 00:00:00 2001 From: st-shchetinin Date: Thu, 25 Jul 2024 20:27:23 +0300 Subject: [PATCH 22/36] json for SelectSimple --- .../basic_example_it/CMakeLists.txt | 1 + .../basic_example_it/basic_example.cpp | 27 +++++++++---------- .../basic_example_it/basic_example.h | 7 +---- tests/integration/basic_example_it/main.cpp | 7 +---- 4 files changed, 16 insertions(+), 26 deletions(-) diff --git a/tests/integration/basic_example_it/CMakeLists.txt b/tests/integration/basic_example_it/CMakeLists.txt index 1fbd6b395d9..5b1dbb5051f 100644 --- a/tests/integration/basic_example_it/CMakeLists.txt +++ b/tests/integration/basic_example_it/CMakeLists.txt @@ -9,6 +9,7 @@ add_ydb_test(NAME basic-example_it library-getopt YDB-CPP-SDK::Table GTest::gtest_main + public-lib-json_value LABELS integration ) \ No newline at end of file diff --git a/tests/integration/basic_example_it/basic_example.cpp b/tests/integration/basic_example_it/basic_example.cpp index af348b5a695..748c648696f 100644 --- a/tests/integration/basic_example_it/basic_example.cpp +++ b/tests/integration/basic_example_it/basic_example.cpp @@ -440,10 +440,11 @@ std::string SelectSimple(TTableClient client, const std::string& path) { })); TResultSetParser parser(*resultSet); if (parser.TryNextRow()) { - return std::format("> SelectSimple:\nSeries, Id: {}, Title: {}, Release date: {}\n" + std::cout << std::format("> SelectSimple:\nSeries, Id: {}, Title: {}, Release date: {}\n" , ToString(parser.ColumnParser("series_id").GetOptionalUint64()) , ToString(parser.ColumnParser("title").GetOptionalUtf8()) , ToString(parser.ColumnParser("release_date").GetOptionalString())); + return FormatResultSetJson(resultSet.value(), EBinaryStringEncoding::Unicode); } return ""; } @@ -577,9 +578,8 @@ std::string ScanQuerySelect(TTableClient client, const std::string& path) { /////////////////////////////////////////////////////////////////////////////// -std::unique_ptr Run(const TDriver& driver, const std::string& path) { +bool Run(const TDriver& driver, const std::string& path) { TTableClient client(driver); - auto response = std::make_unique(); try { CreateTables(client, path); @@ -589,28 +589,27 @@ std::unique_ptr Run(const TDriver& driver, const std::string& path) { return FillTableDataTransaction(session, path); })); - response->result += SelectSimple(client, path); + std::string expectedResultSelectSimple = "{\"series_id\":1,\"title\":\"IT Crowd\",\"release_date\":\"2006-02-03\"}"; + std::string resultSelectSimple = SelectSimple(client, path); UpsertSimple(client, path); - response->result += SelectWithParams(client, path); + SelectWithParams(client, path); - response->result += PreparedSelect(client, path, 2, 3, 7); - response->result += PreparedSelect(client, path, 2, 3, 8); + PreparedSelect(client, path, 2, 3, 7); + PreparedSelect(client, path, 2, 3, 8); - response->result += MultiStep(client, path); + MultiStep(client, path); ExplicitTcl(client, path); - response->result += PreparedSelect(client, path, 2, 6, 1); + PreparedSelect(client, path, 2, 6, 1); - response->result += ScanQuerySelect(client, path); + ScanQuerySelect(client, path); } catch (const TYdbErrorException& e) { - response->success = false; std::cerr << "Execution failed due to fatal error:" << std::endl; PrintStatus(e.Status); - return response; + return false; } - response->success = true; - return response; + return true; } diff --git a/tests/integration/basic_example_it/basic_example.h b/tests/integration/basic_example_it/basic_example.h index d4f619e4c25..99e0804f4bb 100644 --- a/tests/integration/basic_example_it/basic_example.h +++ b/tests/integration/basic_example_it/basic_example.h @@ -3,11 +3,6 @@ #include #include -struct Response { - bool success; - std::string result; -}; - NYdb::TParams GetTablesDataParams(); -std::unique_ptr Run(const NYdb::TDriver& driver, const std::string& path); +bool Run(const NYdb::TDriver& driver, const std::string& path); diff --git a/tests/integration/basic_example_it/main.cpp b/tests/integration/basic_example_it/main.cpp index 651e59241fb..2d63541694d 100644 --- a/tests/integration/basic_example_it/main.cpp +++ b/tests/integration/basic_example_it/main.cpp @@ -39,16 +39,11 @@ TEST(Integration, BasicExample) { } TDriver driver(driverConfig); - std::unique_ptr response = ::Run(driver, path); - if (!response->success) { - std::cerr << std::format("The driver could not be started (path = {})", path) << std::endl; + if (!::Run(driver, path)) { FAIL(); driver.Stop(true); } - std::string correct_output = "> Describe table: series\nColumn, name: series_id, type: Uint64?\nColumn, name: title, type: Utf8?\nColumn, name: series_info, type: Utf8?\nColumn, name: release_date, type: Uint64?\n> SelectSimple:\nSeries, Id: 1, Title: IT Crowd, Release date: 2006-02-03\n> SelectWithParams:\nSeason, Title: Season 3, Series title: Silicon Valley\n> PreparedSelect:\nEpisode 7, Title: To Build a Better Beta, Air date: Sun Jun 05, 2016\n> PreparedSelect:\nEpisode 8, Title: Bachman's Earnings Over-Ride, Air date: Sun Jun 12, 2016\n> MultiStep:\nEpisode 1, Season: 5, Title: Grow Fast or Die Slow, Air date: Sun Mar 25, 2018\nEpisode 2, Season: 5, Title: Reorientation, Air date: Sun Apr 01, 2018\nEpisode 3, Season: 5, Title: Chief Operating Officer, Air date: Sun Apr 08, 2018\n> PreparedSelect:\nEpisode 1, Title: TBD, Air date: Thu Jan 01, 1970\n> ScanQuerySelect:\nSeason, SeriesId: 1, SeasonId: 1, Title: Season 1, Air date: 2006-02-03\nSeason, SeriesId: 1, SeasonId: 2, Title: Season 2, Air date: 2007-08-24\nSeason, SeriesId: 1, SeasonId: 3, Title: Season 3, Air date: 2008-11-21\nSeason, SeriesId: 1, SeasonId: 4, Title: Season 4, Air date: 2010-06-25\n"; - ASSERT_EQ(response->result, correct_output); - driver.Stop(true); } From f648733fcd5ca44817a0a8e21be7cd2f2ca8c93b Mon Sep 17 00:00:00 2001 From: st-shchetinin Date: Fri, 26 Jul 2024 13:20:41 +0300 Subject: [PATCH 23/36] comparing json in a test --- examples/basic_example/basic_example.cpp | 9 +- .../basic_example_it/basic_example.cpp | 90 +++++-------------- .../basic_example_it/basic_example.h | 31 ++++++- tests/integration/basic_example_it/main.cpp | 62 +++++++++++-- 4 files changed, 110 insertions(+), 82 deletions(-) diff --git a/examples/basic_example/basic_example.cpp b/examples/basic_example/basic_example.cpp index 6fbdeb3d932..ae292f57783 100644 --- a/examples/basic_example/basic_example.cpp +++ b/examples/basic_example/basic_example.cpp @@ -442,10 +442,7 @@ void SelectSimple(TTableClient client, const std::string& path) { ThrowOnError(client.RetryOperationSync([path, &resultSet](TSession session) { return SelectSimpleTransaction(session, path, resultSet); })); - - if (resultSet.has_value()) { - std::cout << FormatResultSetJson(resultSet.value(), EBinaryStringEncoding::Base64); - } + TResultSetParser parser(*resultSet); if (parser.TryNextRow()) { std::cout << "> SelectSimple:" << std::endl << "Series" @@ -482,7 +479,7 @@ void PreparedSelect(TTableClient client, const std::string& path, uint32_t serie ThrowOnError(client.RetryOperationSync([path, seriesId, seasonId, episodeId, &resultSet](TSession session) { return PreparedSelectTransaction(session, path, seriesId, seasonId, episodeId, resultSet); })); - + TResultSetParser parser(*resultSet); if (parser.TryNextRow()) { auto airDate = TInstant::Days(*parser.ColumnParser("air_date").GetOptionalUint64()); @@ -501,6 +498,7 @@ void MultiStep(TTableClient client, const std::string& path) { })); TResultSetParser parser(*resultSet); + std::cout << "> MultiStep:" << std::endl; while (parser.TryNextRow()) { auto airDate = TInstant::Days(*parser.ColumnParser("air_date").GetOptionalUint64()); @@ -563,7 +561,6 @@ void ScanQuerySelect(TTableClient client, const std::string& path) { if (streamPart.HasResultSet()) { auto rs = streamPart.ExtractResultSet(); auto columns = rs.GetColumnsMeta(); - TResultSetParser parser(rs); while (parser.TryNextRow()) { std::cout << "Season" diff --git a/tests/integration/basic_example_it/basic_example.cpp b/tests/integration/basic_example_it/basic_example.cpp index 748c648696f..73e2ce083c7 100644 --- a/tests/integration/basic_example_it/basic_example.cpp +++ b/tests/integration/basic_example_it/basic_example.cpp @@ -8,21 +8,13 @@ using namespace NYdb; using namespace NYdb::NTable; -class TYdbErrorException : public yexception { -public: - TYdbErrorException(const TStatus& status) - : Status(status) {} - - TStatus Status; -}; - -static void ThrowOnError(const TStatus& status) { +void ThrowOnError(const TStatus& status) { if (!status.IsSuccess()) { throw TYdbErrorException(status) << status; } } -static void PrintStatus(const TStatus& status) { +void PrintStatus(const TStatus& status) { std::cerr << "Status: " << ToString(status.GetStatus()) << std::endl; status.GetIssues().PrintTo(std::cerr); } @@ -41,7 +33,7 @@ static std::string JoinPath(const std::string& basePath, const std::string& path /////////////////////////////////////////////////////////////////////////////// //! Creates sample tables with CrateTable API. -static void CreateTables(TTableClient client, const std::string& path) { +void CreateTables(TTableClient client, const std::string& path) { ThrowOnError(client.RetryOperationSync([path](TSession session) { auto seriesDesc = TTableBuilder() .AddNullableColumn("series_id", EPrimitiveType::Uint64) @@ -83,7 +75,7 @@ static void CreateTables(TTableClient client, const std::string& path) { } //! Describe existing table. -static void DescribeTable(TTableClient client, const std::string& path, const std::string& name) { +void DescribeTable(TTableClient client, const std::string& path, const std::string& name) { std::optional desc; std::string result; ThrowOnError(client.RetryOperationSync([path, name, &desc](TSession session) { @@ -104,7 +96,7 @@ static void DescribeTable(TTableClient client, const std::string& path, const st /////////////////////////////////////////////////////////////////////////////// //! Fills sample tables with data in single parameterized data query. -static TStatus FillTableDataTransaction(TSession session, const std::string& path) { +TStatus FillTableDataTransaction(TSession session, const std::string& path) { auto query = std::format(R"( PRAGMA TablePathPrefix("{}"); @@ -443,10 +435,9 @@ std::string SelectSimple(TTableClient client, const std::string& path) { std::cout << std::format("> SelectSimple:\nSeries, Id: {}, Title: {}, Release date: {}\n" , ToString(parser.ColumnParser("series_id").GetOptionalUint64()) , ToString(parser.ColumnParser("title").GetOptionalUtf8()) - , ToString(parser.ColumnParser("release_date").GetOptionalString())); - return FormatResultSetJson(resultSet.value(), EBinaryStringEncoding::Unicode); + , ToString(parser.ColumnParser("release_date").GetOptionalString())); } - return ""; + return FormatResultSetJson(resultSet.value(), EBinaryStringEncoding::Unicode); } void UpsertSimple(TTableClient client, const std::string& path) { @@ -464,16 +455,15 @@ std::string SelectWithParams(TTableClient client, const std::string& path) { TResultSetParser parser(*resultSet); if (parser.TryNextRow()) { - return std::format("> SelectWithParams:\nSeason, Title: {}, Series title: {}\n" + std::cout << std::format("> SelectWithParams:\nSeason, Title: {}, Series title: {}\n" , ToString(parser.ColumnParser("season_title").GetOptionalUtf8()) - , ToString(parser.ColumnParser("series_title").GetOptionalUtf8())); + , ToString(parser.ColumnParser("series_title").GetOptionalUtf8())); } - return ""; + return FormatResultSetJson(resultSet.value(), EBinaryStringEncoding::Unicode); } std::string PreparedSelect(TTableClient client, const std::string& path, ui32 seriesId, ui32 seasonId, ui32 episodeId) { std::optional resultSet; - std::string result; ThrowOnError(client.RetryOperationSync([path, seriesId, seasonId, episodeId, &resultSet](TSession session) { return PreparedSelectTransaction(session, path, seriesId, seasonId, episodeId, resultSet); })); @@ -481,33 +471,31 @@ std::string PreparedSelect(TTableClient client, const std::string& path, ui32 se TResultSetParser parser(*resultSet); if (parser.TryNextRow()) { auto airDate = TInstant::Days(*parser.ColumnParser("air_date").GetOptionalUint64()); - - return std::format("> PreparedSelect:\nEpisode {}, Title: {}, Air date: {}\n" + std::cout << std::format("> PreparedSelect:\nEpisode {}, Title: {}, Air date: {}\n" , ToString(parser.ColumnParser("episode_id").GetOptionalUint64()) , ToString(parser.ColumnParser("title").GetOptionalUtf8()) - , airDate.FormatLocalTime("%a %b %d, %Y")); + , airDate.FormatLocalTime("%a %b %d, %Y")); } - return ""; + return FormatResultSetJson(resultSet.value(), EBinaryStringEncoding::Unicode); } std::string MultiStep(TTableClient client, const std::string& path) { std::optional resultSet; - std::string result; ThrowOnError(client.RetryOperationSync([path, &resultSet](TSession session) { return MultiStepTransaction(session, path, 2, 5, resultSet); })); TResultSetParser parser(*resultSet); - result = "> MultiStep:\n"; + std::cout << "> MultiStep:\n"; while (parser.TryNextRow()) { auto airDate = TInstant::Days(*parser.ColumnParser("air_date").GetOptionalUint64()); - result += std::format("Episode {}, Season: {}, Title: {}, Air date: {}\n" + std::cout << std::format("Episode {}, Season: {}, Title: {}, Air date: {}\n" , ToString(parser.ColumnParser("episode_id").GetOptionalUint64()) , ToString(parser.ColumnParser("season_id").GetOptionalUint64()) , ToString(parser.ColumnParser("title").GetOptionalUtf8()) , airDate.FormatLocalTime("%a %b %d, %Y")); } - return result; + return FormatResultSetJson(resultSet.value(), EBinaryStringEncoding::Unicode); } void ExplicitTcl(TTableClient client, const std::string& path) { @@ -517,7 +505,6 @@ void ExplicitTcl(TTableClient client, const std::string& path) { } std::string ScanQuerySelect(TTableClient client, const std::string& path) { - std::string result; auto query = std::format(R"( --!syntax_v1 PRAGMA TablePathPrefix("{}"); @@ -546,7 +533,7 @@ std::string ScanQuerySelect(TTableClient client, const std::string& path) { } bool eos = false; - result = "> ScanQuerySelect:\n"; + std::cout << "> ScanQuerySelect:\n"; while (!eos) { auto streamPart = resultScanQuery.ReadNext().ExtractValueSync(); @@ -565,51 +552,14 @@ std::string ScanQuerySelect(TTableClient client, const std::string& path) { TResultSetParser parser(rs); while (parser.TryNextRow()) { - result += std::format("Season, SeriesId: {}, SeasonId: {}, Title: {}, Air date: {}\n" + std::cout << std::format("Season, SeriesId: {}, SeasonId: {}, Title: {}, Air date: {}\n" , ToString(parser.ColumnParser("series_id").GetOptionalUint64()) , ToString(parser.ColumnParser("season_id").GetOptionalUint64()) , ToString(parser.ColumnParser("title").GetOptionalUtf8()) , ToString(parser.ColumnParser("first_aired").GetOptionalString())); } + return FormatResultSetJson(rs, EBinaryStringEncoding::Unicode); } } - return result; -} - -/////////////////////////////////////////////////////////////////////////////// - -bool Run(const TDriver& driver, const std::string& path) { - TTableClient client(driver); - try { - CreateTables(client, path); - - DescribeTable(client, path, "series"); - - ThrowOnError(client.RetryOperationSync([path](TSession session) { - return FillTableDataTransaction(session, path); - })); - - std::string expectedResultSelectSimple = "{\"series_id\":1,\"title\":\"IT Crowd\",\"release_date\":\"2006-02-03\"}"; - std::string resultSelectSimple = SelectSimple(client, path); - UpsertSimple(client, path); - - SelectWithParams(client, path); - - PreparedSelect(client, path, 2, 3, 7); - PreparedSelect(client, path, 2, 3, 8); - - MultiStep(client, path); - - ExplicitTcl(client, path); - - PreparedSelect(client, path, 2, 6, 1); - - ScanQuerySelect(client, path); - } - catch (const TYdbErrorException& e) { - std::cerr << "Execution failed due to fatal error:" << std::endl; - PrintStatus(e.Status); - return false; - } - return true; + return ""; } diff --git a/tests/integration/basic_example_it/basic_example.h b/tests/integration/basic_example_it/basic_example.h index 99e0804f4bb..89db14ada08 100644 --- a/tests/integration/basic_example_it/basic_example.h +++ b/tests/integration/basic_example_it/basic_example.h @@ -3,6 +3,35 @@ #include #include +#include + +using namespace NYdb; +using namespace NYdb::NTable; + +struct RunArgs { + TDriver driver; + std::string path; +}; +class TYdbErrorException : public yexception { +public: + TYdbErrorException(const TStatus& status) + : Status(status) {} + + TStatus Status; +}; + NYdb::TParams GetTablesDataParams(); -bool Run(const NYdb::TDriver& driver, const std::string& path); +void CreateTables(TTableClient client, const std::string& path); +void DescribeTable(TTableClient client, const std::string& path, const std::string& name); +void ThrowOnError(const TStatus& status); +void PrintStatus(const TStatus& status); +TStatus FillTableDataTransaction(TSession session, const std::string& path); +std::string SelectSimple(TTableClient client, const std::string& path); +void UpsertSimple(TTableClient client, const std::string& path); +std::string SelectWithParams(TTableClient client, const std::string& path); +std::string PreparedSelect(TTableClient client, const std::string& path, ui32 seriesId, ui32 seasonId, ui32 episodeId); +std::string MultiStep(TTableClient client, const std::string& path); +void ExplicitTcl(TTableClient client, const std::string& path); +std::string PreparedSelect(TTableClient client, const std::string& path, ui32 seriesId, ui32 seasonId, ui32 episodeId); +std::string ScanQuerySelect(TTableClient client, const std::string& path); diff --git a/tests/integration/basic_example_it/main.cpp b/tests/integration/basic_example_it/main.cpp index 2d63541694d..72aa9b2d886 100644 --- a/tests/integration/basic_example_it/main.cpp +++ b/tests/integration/basic_example_it/main.cpp @@ -10,17 +10,16 @@ #include using namespace NLastGetopt; -using namespace NYdb; void StopHandler(int) { exit(1); } -TEST(Integration, BasicExample) { +RunArgs getRunArgs() { TOpts opts = TOpts::Default(); std::string database = std::getenv( "DATABASE" ); - std::string endpoint = std::getenv( "ENDPOINT" );; + std::string endpoint = std::getenv( "ENDPOINT" ); std::string path; std::string certPath; @@ -39,10 +38,63 @@ TEST(Integration, BasicExample) { } TDriver driver(driverConfig); + return {driver, path}; +} - if (!::Run(driver, path)) { - FAIL(); + +TEST(Integration, BasicExample) { + + auto [driver, path] = getRunArgs(); + + TTableClient client(driver); + + try { + CreateTables(client, path); + + DescribeTable(client, path, "series"); + + ThrowOnError(client.RetryOperationSync([path](TSession session) { + return FillTableDataTransaction(session, path); + })); + + std::string expectedResultSelectSimple = "{\"series_id\":1,\"title\":\"IT Crowd\",\"release_date\":\"2006-02-03\"}\n"; + std::string resultSelectSimple = SelectSimple(client, path); + ASSERT_EQ(resultSelectSimple, expectedResultSelectSimple); + + UpsertSimple(client, path); + + + std::string expectedResultSelectWithParams = "{\"season_title\":\"Season 3\",\"series_title\":\"Silicon Valley\"}\n"; + std::string resultSelectWithParms = SelectWithParams(client, path); + ASSERT_EQ(resultSelectWithParms, expectedResultSelectWithParams); + + std::string expectedResultPreparedSelect1 = "{\"air_date\":16957,\"episode_id\":7,\"season_id\":3,\"series_id\":2,\"title\":\"To Build a Better Beta\"}\n"; + std::string resultPreparedSelect1 = PreparedSelect(client, path, 2, 3, 7); + ASSERT_EQ(resultPreparedSelect1, expectedResultPreparedSelect1); + + std::string expectedResultPreparedSelect2 = "{\"air_date\":16964,\"episode_id\":8,\"season_id\":3,\"series_id\":2,\"title\":\"Bachman's Earnings Over-Ride\"}\n"; + std::string resultPreparedSelect2 = PreparedSelect(client, path, 2, 3, 8); + ASSERT_EQ(resultPreparedSelect2, expectedResultPreparedSelect2); + + std::string expectedResultMultiStep = "{\"season_id\":5,\"episode_id\":1,\"title\":\"Grow Fast or Die Slow\",\"air_date\":17615}\n{\"season_id\":5,\"episode_id\":2,\"title\":\"Reorientation\",\"air_date\":17622}\n{\"season_id\":5,\"episode_id\":3,\"title\":\"Chief Operating Officer\",\"air_date\":17629}\n"; + std::string resultMultiStep = MultiStep(client, path); + ASSERT_EQ(resultMultiStep, expectedResultMultiStep); + + ExplicitTcl(client, path); + + std::string expectedResultPreparedSelect3 = "{\"air_date\":0,\"episode_id\":1,\"season_id\":6,\"series_id\":2,\"title\":\"TBD\"}\n"; + std::string resultPreparedSelect3 = PreparedSelect(client, path, 2, 6, 1); + ASSERT_EQ(resultPreparedSelect3, expectedResultPreparedSelect3); + + std::string expectedResultScanQuerySelect = "{\"series_id\":1,\"season_id\":1,\"title\":\"Season 1\",\"first_aired\":\"2006-02-03\"}\n{\"series_id\":1,\"season_id\":2,\"title\":\"Season 2\",\"first_aired\":\"2007-08-24\"}\n{\"series_id\":1,\"season_id\":3,\"title\":\"Season 3\",\"first_aired\":\"2008-11-21\"}\n{\"series_id\":1,\"season_id\":4,\"title\":\"Season 4\",\"first_aired\":\"2010-06-25\"}\n"; + std::string resultScanQuerySelect = ScanQuerySelect(client, path); + ASSERT_EQ(resultScanQuerySelect, expectedResultScanQuerySelect); + } + catch (const TYdbErrorException& e) { + std::cerr << "Execution failed due to fatal error:" << std::endl; + PrintStatus(e.Status); driver.Stop(true); + FAIL(); } driver.Stop(true); From 354ba249cd08c92f6a390eccd295ec07bd0cdcd3 Mon Sep 17 00:00:00 2001 From: st-shchetinin Date: Sat, 27 Jul 2024 21:50:07 +0300 Subject: [PATCH 24/36] fix after review --- .github/workflows/examples.yaml | 5 +- .github/workflows/tests.yaml | 16 ++-- CMakePresets.json | 4 +- cmake/testing.cmake | 1 - docker-compose.yaml | 10 --- examples/basic_example/CMakeLists.txt | 1 - examples/basic_example/basic_example.cpp | 7 +- .../basic_example_it/CMakeLists.txt | 3 +- .../basic_example_it/basic_example.cpp | 79 ++----------------- .../basic_example_it/basic_example.h | 6 +- tests/integration/basic_example_it/main.cpp | 40 ++-------- 11 files changed, 33 insertions(+), 139 deletions(-) delete mode 100644 docker-compose.yaml diff --git a/.github/workflows/examples.yaml b/.github/workflows/examples.yaml index 081fd013cb4..81db06f6b2d 100644 --- a/.github/workflows/examples.yaml +++ b/.github/workflows/examples.yaml @@ -15,7 +15,7 @@ jobs: strategy: fail-fast: false matrix: - ydb-version: [23.3, 24.1] + ydb-version: [23.3, 24.1, trunk] services: ydb: image: ydbplatform/local-ydb:${{ matrix.ydb-version }} @@ -66,4 +66,5 @@ jobs: examples/basic_example/basic_example -e localhost:2136 -d /local -p /local/basic examples/bulk_upsert_simple/bulk_upsert_simple -e localhost:2136 -d /local -p /local/bulk examples/pagination/pagination -e localhost:2136 -d /local -p /local/pagination - examples/ttl/ttl -e localhost:2136 -d /local -p /local/ttl \ No newline at end of file + examples/ttl/ttl -e localhost:2136 -d /local -p /local/ttl + \ No newline at end of file diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 5f1f206b3bf..1e252db694b 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -13,15 +13,13 @@ concurrency: jobs: unit: concurrency: - group: unit-${{ github.ref }}-${{ matrix.os }}-${{ matrix.go-version }} + group: unit-${{ github.ref }}-${{ matrix.os }} cancel-in-progress: true strategy: fail-fast: false - matrix: - os: [ubuntu] env: - OS: ${{ matrix.os }}-latest - runs-on: ${{ matrix.os }}-latest + OS: ubuntu-22.04 + runs-on: ubuntu-22.04 steps: - name: Checkout PR uses: actions/checkout@v3 @@ -56,15 +54,15 @@ jobs: run: | ctest -j32 --preset release-unit - integrtion: + integration: concurrency: - group: integration-${{ github.ref }}-${{ matrix.os }}-${{ matrix.go-version }}-${{ matrix.ydb-version }} + group: integration-${{ github.ref }}-${{ matrix.ydb-version }} cancel-in-progress: true - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 strategy: fail-fast: false matrix: - ydb-version: [23.3, 24.1] + ydb-version: [23.3, 24.1, trunk] services: ydb: image: ydbplatform/local-ydb:${{ matrix.ydb-version }} diff --git a/CMakePresets.json b/CMakePresets.json index 8d043605008..4ffafcb236a 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -97,8 +97,8 @@ "timeout": 1200 }, "environment": { - "ENDPOINT": "localhost:2136", - "DATABASE": "/local" + "YDB_ENDPOINT": "localhost:2136", + "YDB_DATABASE": "/local" } } ] diff --git a/cmake/testing.cmake b/cmake/testing.cmake index 1e44e956963..bed39d0bc63 100644 --- a/cmake/testing.cmake +++ b/cmake/testing.cmake @@ -72,7 +72,6 @@ function(add_ydb_test) target_include_directories(${YDB_TEST_NAME} PRIVATE ${YDB_TEST_INCLUDE_DIRS}) target_link_libraries(${YDB_TEST_NAME} PRIVATE ${YDB_TEST_LINK_LIBRARIES}) target_sources(${YDB_TEST_NAME} PRIVATE ${YDB_TEST_SOURCES}) - #set_tests_properties(${YDB_TEST_NAME} PROPERTIES LABELS "${YDB_TEST_LABELS}") if (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64") target_link_libraries(${YDB_TEST_NAME} PRIVATE diff --git a/docker-compose.yaml b/docker-compose.yaml deleted file mode 100644 index 54bc92c68e8..00000000000 --- a/docker-compose.yaml +++ /dev/null @@ -1,10 +0,0 @@ -version: "3.0" -services: - ydb: - image: cr.yandex/yc/yandex-docker-local-ydb:latest - hostname: localhost # for good discovery - environment: - YDB_ANONYMOUS_CREDENTIALS: 1 - ports: - - "2135:2135" # port with tls - - "2136:2136" # port without tls \ No newline at end of file diff --git a/examples/basic_example/CMakeLists.txt b/examples/basic_example/CMakeLists.txt index d5ef66ffdbf..55e4af14175 100644 --- a/examples/basic_example/CMakeLists.txt +++ b/examples/basic_example/CMakeLists.txt @@ -4,7 +4,6 @@ target_link_libraries(basic_example PUBLIC yutil library-getopt YDB-CPP-SDK::Table - public-lib-json_value ) target_sources(basic_example PRIVATE diff --git a/examples/basic_example/basic_example.cpp b/examples/basic_example/basic_example.cpp index ae292f57783..80b2cc13675 100644 --- a/examples/basic_example/basic_example.cpp +++ b/examples/basic_example/basic_example.cpp @@ -1,7 +1,6 @@ #include "basic_example.h" #include -#include #include @@ -479,7 +478,7 @@ void PreparedSelect(TTableClient client, const std::string& path, uint32_t serie ThrowOnError(client.RetryOperationSync([path, seriesId, seasonId, episodeId, &resultSet](TSession session) { return PreparedSelectTransaction(session, path, seriesId, seasonId, episodeId, resultSet); })); - + TResultSetParser parser(*resultSet); if (parser.TryNextRow()) { auto airDate = TInstant::Days(*parser.ColumnParser("air_date").GetOptionalUint64()); @@ -498,7 +497,6 @@ void MultiStep(TTableClient client, const std::string& path) { })); TResultSetParser parser(*resultSet); - std::cout << "> MultiStep:" << std::endl; while (parser.TryNextRow()) { auto airDate = TInstant::Days(*parser.ColumnParser("air_date").GetOptionalUint64()); @@ -561,6 +559,7 @@ void ScanQuerySelect(TTableClient client, const std::string& path) { if (streamPart.HasResultSet()) { auto rs = streamPart.ExtractResultSet(); auto columns = rs.GetColumnsMeta(); + TResultSetParser parser(rs); while (parser.TryNextRow()) { std::cout << "Season" @@ -611,4 +610,4 @@ bool Run(const TDriver& driver, const std::string& path) { } return true; -} +} \ No newline at end of file diff --git a/tests/integration/basic_example_it/CMakeLists.txt b/tests/integration/basic_example_it/CMakeLists.txt index 5b1dbb5051f..e225a21c8ee 100644 --- a/tests/integration/basic_example_it/CMakeLists.txt +++ b/tests/integration/basic_example_it/CMakeLists.txt @@ -6,10 +6,9 @@ add_ydb_test(NAME basic-example_it basic_example.h LINK_LIBRARIES yutil - library-getopt YDB-CPP-SDK::Table GTest::gtest_main public-lib-json_value LABELS integration -) \ No newline at end of file +) diff --git a/tests/integration/basic_example_it/basic_example.cpp b/tests/integration/basic_example_it/basic_example.cpp index 73e2ce083c7..61acd7337ce 100644 --- a/tests/integration/basic_example_it/basic_example.cpp +++ b/tests/integration/basic_example_it/basic_example.cpp @@ -1,7 +1,7 @@ #include "basic_example.h" #include -#include +#include #include @@ -14,11 +14,6 @@ void ThrowOnError(const TStatus& status) { } } -void PrintStatus(const TStatus& status) { - std::cerr << "Status: " << ToString(status.GetStatus()) << std::endl; - status.GetIssues().PrintTo(std::cerr); -} - static std::string JoinPath(const std::string& basePath, const std::string& path) { if (basePath.empty()) { return path; @@ -74,25 +69,6 @@ void CreateTables(TTableClient client, const std::string& path) { })); } -//! Describe existing table. -void DescribeTable(TTableClient client, const std::string& path, const std::string& name) { - std::optional desc; - std::string result; - ThrowOnError(client.RetryOperationSync([path, name, &desc](TSession session) { - auto result = session.DescribeTable(JoinPath(path, name)).GetValueSync(); - - if (result.IsSuccess()) { - desc = result.GetTableDescription(); - } - return result; - })); - - std::cout << std::format("> Describe table: {}\n", name); - for (auto& column : desc->GetColumns()) { - std::cout << std::format("Column, name: {}, type: {}\n", column.Name, FormatType(column.Type)); - } -} - /////////////////////////////////////////////////////////////////////////////// //! Fills sample tables with data in single parameterized data query. @@ -430,13 +406,6 @@ std::string SelectSimple(TTableClient client, const std::string& path) { ThrowOnError(client.RetryOperationSync([path, &resultSet](TSession session) { return SelectSimpleTransaction(session, path, resultSet); })); - TResultSetParser parser(*resultSet); - if (parser.TryNextRow()) { - std::cout << std::format("> SelectSimple:\nSeries, Id: {}, Title: {}, Release date: {}\n" - , ToString(parser.ColumnParser("series_id").GetOptionalUint64()) - , ToString(parser.ColumnParser("title").GetOptionalUtf8()) - , ToString(parser.ColumnParser("release_date").GetOptionalString())); - } return FormatResultSetJson(resultSet.value(), EBinaryStringEncoding::Unicode); } @@ -452,13 +421,6 @@ std::string SelectWithParams(TTableClient client, const std::string& path) { ThrowOnError(client.RetryOperationSync([path, &resultSet](TSession session) { return SelectWithParamsTransaction(session, path, 2, 3, resultSet); })); - - TResultSetParser parser(*resultSet); - if (parser.TryNextRow()) { - std::cout << std::format("> SelectWithParams:\nSeason, Title: {}, Series title: {}\n" - , ToString(parser.ColumnParser("season_title").GetOptionalUtf8()) - , ToString(parser.ColumnParser("series_title").GetOptionalUtf8())); - } return FormatResultSetJson(resultSet.value(), EBinaryStringEncoding::Unicode); } @@ -467,15 +429,6 @@ std::string PreparedSelect(TTableClient client, const std::string& path, ui32 se ThrowOnError(client.RetryOperationSync([path, seriesId, seasonId, episodeId, &resultSet](TSession session) { return PreparedSelectTransaction(session, path, seriesId, seasonId, episodeId, resultSet); })); - - TResultSetParser parser(*resultSet); - if (parser.TryNextRow()) { - auto airDate = TInstant::Days(*parser.ColumnParser("air_date").GetOptionalUint64()); - std::cout << std::format("> PreparedSelect:\nEpisode {}, Title: {}, Air date: {}\n" - , ToString(parser.ColumnParser("episode_id").GetOptionalUint64()) - , ToString(parser.ColumnParser("title").GetOptionalUtf8()) - , airDate.FormatLocalTime("%a %b %d, %Y")); - } return FormatResultSetJson(resultSet.value(), EBinaryStringEncoding::Unicode); } @@ -484,17 +437,6 @@ std::string MultiStep(TTableClient client, const std::string& path) { ThrowOnError(client.RetryOperationSync([path, &resultSet](TSession session) { return MultiStepTransaction(session, path, 2, 5, resultSet); })); - - TResultSetParser parser(*resultSet); - std::cout << "> MultiStep:\n"; - while (parser.TryNextRow()) { - auto airDate = TInstant::Days(*parser.ColumnParser("air_date").GetOptionalUint64()); - std::cout << std::format("Episode {}, Season: {}, Title: {}, Air date: {}\n" - , ToString(parser.ColumnParser("episode_id").GetOptionalUint64()) - , ToString(parser.ColumnParser("season_id").GetOptionalUint64()) - , ToString(parser.ColumnParser("title").GetOptionalUtf8()) - , airDate.FormatLocalTime("%a %b %d, %Y")); - } return FormatResultSetJson(resultSet.value(), EBinaryStringEncoding::Unicode); } @@ -504,7 +446,8 @@ void ExplicitTcl(TTableClient client, const std::string& path) { })); } -std::string ScanQuerySelect(TTableClient client, const std::string& path) { +std::vector ScanQuerySelect(TTableClient client, const std::string& path) { + std::vector result; auto query = std::format(R"( --!syntax_v1 PRAGMA TablePathPrefix("{}"); @@ -529,11 +472,10 @@ std::string ScanQuerySelect(TTableClient client, const std::string& path) { if (!resultScanQuery.IsSuccess()) { std::cerr << "ScanQuery execution failure: " << resultScanQuery.GetIssues().ToString() << std::endl; - return ""; + return {}; } bool eos = false; - std::cout << "> ScanQuerySelect:\n"; while (!eos) { auto streamPart = resultScanQuery.ReadNext().ExtractValueSync(); @@ -549,17 +491,8 @@ std::string ScanQuerySelect(TTableClient client, const std::string& path) { if (streamPart.HasResultSet()) { auto rs = streamPart.ExtractResultSet(); auto columns = rs.GetColumnsMeta(); - - TResultSetParser parser(rs); - while (parser.TryNextRow()) { - std::cout << std::format("Season, SeriesId: {}, SeasonId: {}, Title: {}, Air date: {}\n" - , ToString(parser.ColumnParser("series_id").GetOptionalUint64()) - , ToString(parser.ColumnParser("season_id").GetOptionalUint64()) - , ToString(parser.ColumnParser("title").GetOptionalUtf8()) - , ToString(parser.ColumnParser("first_aired").GetOptionalString())); - } - return FormatResultSetJson(rs, EBinaryStringEncoding::Unicode); + result.push_back(FormatResultSetJson(rs, EBinaryStringEncoding::Unicode)); } } - return ""; + return result; } diff --git a/tests/integration/basic_example_it/basic_example.h b/tests/integration/basic_example_it/basic_example.h index 89db14ada08..feb46b7b41c 100644 --- a/tests/integration/basic_example_it/basic_example.h +++ b/tests/integration/basic_example_it/basic_example.h @@ -5,6 +5,8 @@ #include +#include + using namespace NYdb; using namespace NYdb::NTable; @@ -23,9 +25,7 @@ class TYdbErrorException : public yexception { NYdb::TParams GetTablesDataParams(); void CreateTables(TTableClient client, const std::string& path); -void DescribeTable(TTableClient client, const std::string& path, const std::string& name); void ThrowOnError(const TStatus& status); -void PrintStatus(const TStatus& status); TStatus FillTableDataTransaction(TSession session, const std::string& path); std::string SelectSimple(TTableClient client, const std::string& path); void UpsertSimple(TTableClient client, const std::string& path); @@ -34,4 +34,4 @@ std::string PreparedSelect(TTableClient client, const std::string& path, ui32 se std::string MultiStep(TTableClient client, const std::string& path); void ExplicitTcl(TTableClient client, const std::string& path); std::string PreparedSelect(TTableClient client, const std::string& path, ui32 seriesId, ui32 seasonId, ui32 episodeId); -std::string ScanQuerySelect(TTableClient client, const std::string& path); +std::vector ScanQuerySelect(TTableClient client, const std::string& path); diff --git a/tests/integration/basic_example_it/main.cpp b/tests/integration/basic_example_it/main.cpp index 72aa9b2d886..a3ccfee7dab 100644 --- a/tests/integration/basic_example_it/main.cpp +++ b/tests/integration/basic_example_it/main.cpp @@ -1,58 +1,36 @@ #include "basic_example.h" -#include - #include +#include #include #include #include -using namespace NLastGetopt; - -void StopHandler(int) { - exit(1); -} - -RunArgs getRunArgs() { - TOpts opts = TOpts::Default(); +RunArgs GetRunArgs() { - std::string database = std::getenv( "DATABASE" ); - std::string endpoint = std::getenv( "ENDPOINT" ); - std::string path; - std::string certPath; - - if (path.empty()) { - path = database; - } + std::string database = std::getenv("YDB_DATABASE"); + std::string endpoint = std::getenv("YDB_ENDPOINT"); auto driverConfig = TDriverConfig() .SetEndpoint(endpoint) .SetDatabase(database) .SetAuthToken(std::getenv("YDB_TOKEN") ? std::getenv("YDB_TOKEN") : ""); - if (!certPath.empty()) { - std::string cert = TFileInput(certPath).ReadAll(); - driverConfig.UseSecureConnection(cert); - } - TDriver driver(driverConfig); - return {driver, path}; + return {driver, database}; } - TEST(Integration, BasicExample) { - auto [driver, path] = getRunArgs(); + auto [driver, path] = GetRunArgs(); TTableClient client(driver); try { CreateTables(client, path); - DescribeTable(client, path, "series"); - ThrowOnError(client.RetryOperationSync([path](TSession session) { return FillTableDataTransaction(session, path); })); @@ -62,7 +40,6 @@ TEST(Integration, BasicExample) { ASSERT_EQ(resultSelectSimple, expectedResultSelectSimple); UpsertSimple(client, path); - std::string expectedResultSelectWithParams = "{\"season_title\":\"Season 3\",\"series_title\":\"Silicon Valley\"}\n"; std::string resultSelectWithParms = SelectWithParams(client, path); @@ -86,13 +63,12 @@ TEST(Integration, BasicExample) { std::string resultPreparedSelect3 = PreparedSelect(client, path, 2, 6, 1); ASSERT_EQ(resultPreparedSelect3, expectedResultPreparedSelect3); - std::string expectedResultScanQuerySelect = "{\"series_id\":1,\"season_id\":1,\"title\":\"Season 1\",\"first_aired\":\"2006-02-03\"}\n{\"series_id\":1,\"season_id\":2,\"title\":\"Season 2\",\"first_aired\":\"2007-08-24\"}\n{\"series_id\":1,\"season_id\":3,\"title\":\"Season 3\",\"first_aired\":\"2008-11-21\"}\n{\"series_id\":1,\"season_id\":4,\"title\":\"Season 4\",\"first_aired\":\"2010-06-25\"}\n"; - std::string resultScanQuerySelect = ScanQuerySelect(client, path); + std::vector expectedResultScanQuerySelect = {"{\"series_id\":1,\"season_id\":1,\"title\":\"Season 1\",\"first_aired\":\"2006-02-03\"}\n{\"series_id\":1,\"season_id\":2,\"title\":\"Season 2\",\"first_aired\":\"2007-08-24\"}\n{\"series_id\":1,\"season_id\":3,\"title\":\"Season 3\",\"first_aired\":\"2008-11-21\"}\n{\"series_id\":1,\"season_id\":4,\"title\":\"Season 4\",\"first_aired\":\"2010-06-25\"}\n"}; + std::vector resultScanQuerySelect = ScanQuerySelect(client, path); ASSERT_EQ(resultScanQuerySelect, expectedResultScanQuerySelect); } catch (const TYdbErrorException& e) { std::cerr << "Execution failed due to fatal error:" << std::endl; - PrintStatus(e.Status); driver.Stop(true); FAIL(); } From f71353f3edd6147ed329634e2a14c56ed366504d Mon Sep 17 00:00:00 2001 From: st-shchetinin Date: Mon, 29 Jul 2024 10:05:20 +0300 Subject: [PATCH 25/36] pulling a vector into a string --- tests/integration/basic_example_it/main.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/integration/basic_example_it/main.cpp b/tests/integration/basic_example_it/main.cpp index a3ccfee7dab..b712c2773bb 100644 --- a/tests/integration/basic_example_it/main.cpp +++ b/tests/integration/basic_example_it/main.cpp @@ -5,6 +5,7 @@ #include #include +#include #include @@ -63,8 +64,9 @@ TEST(Integration, BasicExample) { std::string resultPreparedSelect3 = PreparedSelect(client, path, 2, 6, 1); ASSERT_EQ(resultPreparedSelect3, expectedResultPreparedSelect3); - std::vector expectedResultScanQuerySelect = {"{\"series_id\":1,\"season_id\":1,\"title\":\"Season 1\",\"first_aired\":\"2006-02-03\"}\n{\"series_id\":1,\"season_id\":2,\"title\":\"Season 2\",\"first_aired\":\"2007-08-24\"}\n{\"series_id\":1,\"season_id\":3,\"title\":\"Season 3\",\"first_aired\":\"2008-11-21\"}\n{\"series_id\":1,\"season_id\":4,\"title\":\"Season 4\",\"first_aired\":\"2010-06-25\"}\n"}; - std::vector resultScanQuerySelect = ScanQuerySelect(client, path); + std::string expectedResultScanQuerySelect = "{\"series_id\":1,\"season_id\":1,\"title\":\"Season 1\",\"first_aired\":\"2006-02-03\"}\n{\"series_id\":1,\"season_id\":2,\"title\":\"Season 2\",\"first_aired\":\"2007-08-24\"}\n{\"series_id\":1,\"season_id\":3,\"title\":\"Season 3\",\"first_aired\":\"2008-11-21\"}\n{\"series_id\":1,\"season_id\":4,\"title\":\"Season 4\",\"first_aired\":\"2010-06-25\"}\n"; + std::vector resultScanQuerySelectVector = ScanQuerySelect(client, path); + std::string resultScanQuerySelect = std::reduce(resultScanQuerySelectVector.begin(), resultScanQuerySelectVector.end(), std::string()); ASSERT_EQ(resultScanQuerySelect, expectedResultScanQuerySelect); } catch (const TYdbErrorException& e) { From 0b71705bb216b52734eab9bee1b984eb352449ba Mon Sep 17 00:00:00 2001 From: st-shchetinin Date: Mon, 29 Jul 2024 10:06:34 +0300 Subject: [PATCH 26/36] remove extra spaces --- .github/workflows/examples.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/examples.yaml b/.github/workflows/examples.yaml index 81db06f6b2d..db9fcc14f19 100644 --- a/.github/workflows/examples.yaml +++ b/.github/workflows/examples.yaml @@ -67,4 +67,3 @@ jobs: examples/bulk_upsert_simple/bulk_upsert_simple -e localhost:2136 -d /local -p /local/bulk examples/pagination/pagination -e localhost:2136 -d /local -p /local/pagination examples/ttl/ttl -e localhost:2136 -d /local -p /local/ttl - \ No newline at end of file From 99108f750fd379bb19be3994fd25f715576e9028 Mon Sep 17 00:00:00 2001 From: st-shchetinin Date: Mon, 29 Jul 2024 10:14:34 +0300 Subject: [PATCH 27/36] pathsplit -> std::filesystem::path & ui64 -> uint64_t --- examples/basic_example/basic_example.cpp | 2 -- .../integration/basic_example_it/basic_example.cpp | 14 +++++++------- tests/integration/basic_example_it/main.cpp | 2 +- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/examples/basic_example/basic_example.cpp b/examples/basic_example/basic_example.cpp index 80b2cc13675..7f549751e0a 100644 --- a/examples/basic_example/basic_example.cpp +++ b/examples/basic_example/basic_example.cpp @@ -2,8 +2,6 @@ #include -#include - #include #include diff --git a/tests/integration/basic_example_it/basic_example.cpp b/tests/integration/basic_example_it/basic_example.cpp index 61acd7337ce..a26c43953b7 100644 --- a/tests/integration/basic_example_it/basic_example.cpp +++ b/tests/integration/basic_example_it/basic_example.cpp @@ -1,8 +1,8 @@ #include "basic_example.h" -#include #include +#include #include using namespace NYdb; @@ -19,10 +19,10 @@ static std::string JoinPath(const std::string& basePath, const std::string& path return path; } - TPathSplitUnix prefixPathSplit(basePath); - prefixPathSplit.AppendComponent(path); + std::filesystem::path prefixPathSplit(basePath); + prefixPathSplit /= path; - return prefixPathSplit.Reconstruct(); + return prefixPathSplit; } /////////////////////////////////////////////////////////////////////////////// @@ -176,7 +176,7 @@ static TStatus UpsertSimpleTransaction(TSession session, const std::string& path //! Shows usage of parameters in data queries. static TStatus SelectWithParamsTransaction(TSession session, const std::string& path, - ui64 seriesId, ui64 seasonId, std::optional& resultSet) + uint64_t seriesId, uint64_t seasonId, std::optional& resultSet) { auto query = std::format(R"( --!syntax_v1 @@ -216,7 +216,7 @@ static TStatus SelectWithParamsTransaction(TSession session, const std::string& //! Shows usage of prepared queries. static TStatus PreparedSelectTransaction(TSession session, const std::string& path, - ui64 seriesId, ui64 seasonId, ui64 episodeId, std::optional& resultSet) + uint64_t seriesId, uint64_t seasonId, uint64_t episodeId, std::optional& resultSet) { // Once prepared, query data is stored in the session and identified by QueryId. // Local query cache is used to keep track of queries, prepared in current session. @@ -268,7 +268,7 @@ static TStatus PreparedSelectTransaction(TSession session, const std::string& pa } //! Shows usage of transactions consisting of multiple data queries with client logic between them. -static TStatus MultiStepTransaction(TSession session, const std::string& path, ui64 seriesId, ui64 seasonId, +static TStatus MultiStepTransaction(TSession session, const std::string& path, uint64_t seriesId, uint64_t seasonId, std::optional& resultSet) { auto query1 = std::format(R"( diff --git a/tests/integration/basic_example_it/main.cpp b/tests/integration/basic_example_it/main.cpp index b712c2773bb..e0fa5dc176e 100644 --- a/tests/integration/basic_example_it/main.cpp +++ b/tests/integration/basic_example_it/main.cpp @@ -66,7 +66,7 @@ TEST(Integration, BasicExample) { std::string expectedResultScanQuerySelect = "{\"series_id\":1,\"season_id\":1,\"title\":\"Season 1\",\"first_aired\":\"2006-02-03\"}\n{\"series_id\":1,\"season_id\":2,\"title\":\"Season 2\",\"first_aired\":\"2007-08-24\"}\n{\"series_id\":1,\"season_id\":3,\"title\":\"Season 3\",\"first_aired\":\"2008-11-21\"}\n{\"series_id\":1,\"season_id\":4,\"title\":\"Season 4\",\"first_aired\":\"2010-06-25\"}\n"; std::vector resultScanQuerySelectVector = ScanQuerySelect(client, path); - std::string resultScanQuerySelect = std::reduce(resultScanQuerySelectVector.begin(), resultScanQuerySelectVector.end(), std::string()); + std::string resultScanQuerySelect = std::reduce(resultScanQuerySelectVector.begin(), resultScanQuerySelectVector.end()); ASSERT_EQ(resultScanQuerySelect, expectedResultScanQuerySelect); } catch (const TYdbErrorException& e) { From 0056b4a39353a04bf1dd03f8d36864ba922e19de Mon Sep 17 00:00:00 2001 From: st-shchetinin Date: Mon, 29 Jul 2024 17:39:05 +0300 Subject: [PATCH 28/36] space --- examples/basic_example/basic_example.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/basic_example/basic_example.cpp b/examples/basic_example/basic_example.cpp index 7f549751e0a..e52092d8f8c 100644 --- a/examples/basic_example/basic_example.cpp +++ b/examples/basic_example/basic_example.cpp @@ -608,4 +608,4 @@ bool Run(const TDriver& driver, const std::string& path) { } return true; -} \ No newline at end of file +} From 66fa3215053d6fb9c82c0fda971b55b539915d13 Mon Sep 17 00:00:00 2001 From: st-shchetinin Date: Mon, 29 Jul 2024 17:39:11 +0300 Subject: [PATCH 29/36] order by --- .../basic_example_it/basic_example.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/integration/basic_example_it/basic_example.cpp b/tests/integration/basic_example_it/basic_example.cpp index a26c43953b7..c297987098c 100644 --- a/tests/integration/basic_example_it/basic_example.cpp +++ b/tests/integration/basic_example_it/basic_example.cpp @@ -140,7 +140,8 @@ static TStatus SelectSimpleTransaction(TSession session, const std::string& path SELECT series_id, title, CAST(CAST(release_date AS Date) AS String) AS release_date FROM series - WHERE series_id = 1; + WHERE series_id = 1 + ORDER BY series_id; )", path); auto txControl = @@ -189,7 +190,8 @@ static TStatus SelectWithParamsTransaction(TSession session, const std::string& FROM seasons AS sa INNER JOIN series AS sr ON sa.series_id = sr.series_id - WHERE sa.series_id = $seriesId AND sa.season_id = $seasonId; + WHERE sa.series_id = $seriesId AND sa.season_id = $seasonId + ORDER BY season_title, series_title; )", path); // Type of parameter values should be exactly the same as in DECLARE statements. @@ -230,7 +232,8 @@ static TStatus PreparedSelectTransaction(TSession session, const std::string& pa SELECT * FROM episodes - WHERE series_id = $seriesId AND season_id = $seasonId AND episode_id = $episodeId; + WHERE series_id = $seriesId AND season_id = $seasonId AND episode_id = $episodeId + ORDER BY season_id, episode_id; )", path); // Prepare query or get result from query cache @@ -279,7 +282,8 @@ static TStatus MultiStepTransaction(TSession session, const std::string& path, u DECLARE $seasonId AS Uint64; SELECT first_aired AS from_date FROM seasons - WHERE series_id = $seriesId AND season_id = $seasonId; + WHERE series_id = $seriesId AND season_id = $seasonId + ORDER BY from_date; )", path); auto params1 = session.GetParamsBuilder() @@ -328,7 +332,8 @@ static TStatus MultiStepTransaction(TSession session, const std::string& path, u DECLARE $toDate AS Uint64; SELECT season_id, episode_id, title, air_date FROM episodes - WHERE series_id = $seriesId AND air_date >= $fromDate AND air_date <= $toDate; + WHERE series_id = $seriesId AND air_date >= $fromDate AND air_date <= $toDate + ORDER BY season_id, episode_id; )", path); auto params2 = session.GetParamsBuilder() @@ -457,6 +462,7 @@ std::vector ScanQuerySelect(TTableClient client, const std::string& SELECT series_id, season_id, title, CAST(CAST(first_aired AS Date) AS String) AS first_aired FROM seasons WHERE series_id IN $series + ORDER BY season_id; )", path); auto parameters = TParamsBuilder() From 1547afc7eab7041d24e33715190f32d37a4a9cb0 Mon Sep 17 00:00:00 2001 From: st-shchetinin Date: Mon, 29 Jul 2024 17:42:10 +0300 Subject: [PATCH 30/36] ut -> unit --- CMakeLists.txt | 2 +- tests/{ut => unit}/CMakeLists.txt | 0 tests/{ut => unit}/client/CMakeLists.txt | 0 tests/{ut => unit}/client/coordination_ut.cpp | 0 tests/{ut => unit}/client/discovery_mutator_ut.cpp | 0 tests/{ut => unit}/client/driver_ut.cpp | 0 tests/{ut => unit}/client/endpoints_ut.cpp | 0 .../client/oauth2_token_exchange/CMakeLists.txt | 0 .../client/oauth2_token_exchange/credentials_ut.cpp | 0 .../oauth2_token_exchange/jwt_token_source_ut.cpp | 0 tests/{ut => unit}/client/params_ut.cpp | 0 tests/{ut => unit}/client/result_ut.cpp | 0 tests/{ut => unit}/client/value_ut.cpp | 0 .../client/ydb_scripting_response_headers_ut.cpp | 0 tests/{ut => unit}/json_value/CMakeLists.txt | 0 tests/{ut => unit}/json_value/ydb_json_value_ut.cpp | 0 tests/{ut => unit}/library/CMakeLists.txt | 0 tests/{ut => unit}/library/cache/CMakeLists.txt | 0 tests/{ut => unit}/library/cache/cache_ut.cpp | 0 .../library/case_insensitive_string/CMakeLists.txt | 0 .../case_insensitive_string_ut.cpp | 0 tests/{ut => unit}/library/cgiparam/CMakeLists.txt | 0 tests/{ut => unit}/library/cgiparam/ut.cpp | 0 tests/{ut => unit}/library/charset/CMakeLists.txt | 0 tests/{ut => unit}/library/charset/ci_string_ut.cpp | 0 tests/{ut => unit}/library/charset/codepage_ut.cpp | 0 tests/{ut => unit}/library/charset/iconv_ut.cpp | 0 tests/{ut => unit}/library/charset/recyr_int_ut.cpp | 0 tests/{ut => unit}/library/charset/wide_ut.cpp | 0 .../{ut => unit}/library/containers/CMakeLists.txt | 0 .../containers/disjoint_interval_tree_ut.cpp | 0 .../library/containers/intrusive_rb_tree_ut.cpp | 0 .../library/containers/paged_vector_ut.cpp | 0 .../library/containers/stack_vector_ut.cpp | 0 tests/{ut => unit}/library/coroutine/CMakeLists.txt | 0 .../library/coroutine/engine/CMakeLists.txt | 0 .../library/coroutine/engine/coroutine_ut.cpp | 0 .../library/coroutine/engine/stack/CMakeLists.txt | 0 .../coroutine/engine/stack/stack_allocator_ut.cpp | 0 .../coroutine/engine/stack/stack_guards_ut.cpp | 0 .../coroutine/engine/stack/stack_pool_ut.cpp | 0 .../library/coroutine/engine/stack/stack_ut.cpp | 0 .../coroutine/engine/stack/stack_utils_ut.cpp | 0 .../{ut => unit}/library/dbg_output/CMakeLists.txt | 0 .../library/dbg_output/dbg_output_ut.cpp | 0 tests/{ut => unit}/library/diff/CMakeLists.txt | 0 tests/{ut => unit}/library/diff/ut.cpp | 0 tests/{ut => unit}/library/digest/CMakeLists.txt | 0 .../library/digest/lower_case/CMakeLists.txt | 0 .../library/digest/lower_case/hash_ops_ut.cpp | 0 .../library/digest/lower_case/lchash_ut.cpp | 0 .../{ut => unit}/library/digest/md5/CMakeLists.txt | 0 .../library/digest/md5/md5_medium_ut.cpp | 0 tests/{ut => unit}/library/digest/md5/md5_ut.cpp | 0 .../library/digest/murmur/CMakeLists.txt | 0 tests/{ut => unit}/library/digest/murmur/ut.cpp | 0 tests/{ut => unit}/library/json/CMakeLists.txt | 0 .../library/json/json_prettifier_ut.cpp | 0 .../library/json/json_reader_fast_ut.cpp | 0 tests/{ut => unit}/library/json/json_reader_ut.cpp | 0 .../{ut => unit}/library/json/json_saveload_ut.cpp | 0 tests/{ut => unit}/library/json/json_writer_ut.cpp | 0 .../{ut => unit}/library/json/writer/CMakeLists.txt | 0 tests/{ut => unit}/library/json/writer/json_ut.cpp | 0 .../library/json/writer/json_value_ut.cpp | 0 .../library/operation_id/CMakeLists.txt | 0 .../library/operation_id/operation_id_ut.cpp | 0 tests/{ut => unit}/library/testing/CMakeLists.txt | 0 .../library/testing/common/CMakeLists.txt | 0 .../{ut => unit}/library/testing/common/env_ut.cpp | 0 .../library/testing/common/network_ut.cpp | 0 .../library/testing/common/scope_ut.cpp | 0 .../testing/gmock_in_unittest/CMakeLists.txt | 0 .../testing/gmock_in_unittest/example_ut.cpp | 0 .../library/testing/gtest/CMakeLists.txt | 0 tests/{ut => unit}/library/testing/gtest/README.md | 0 .../library/testing/gtest/golden/data.txt | 0 .../library/testing/gtest/matchers_ut.cpp | 0 tests/{ut => unit}/library/testing/gtest/ut.cpp | 0 .../library/testing/gtest_extensions/CMakeLists.txt | 0 .../library/testing/gtest_extensions/README.md | 0 .../gtest_extensions/gtest_extensions_ut.cpp | 0 .../library/testing/gtest_extensions/probe_ut.cpp | 0 .../library/testing/unittest/CMakeLists.txt | 0 .../{ut => unit}/library/testing/unittest/main.cpp | 0 .../library/testing/unittest/test_port_manager.cpp | 0 tests/{ut => unit}/library/yql/CMakeLists.txt | 0 tests/{ut => unit}/library/yql/utf8_ut.cpp | 0 tests/{ut => unit}/library/yql/yql_decimal_ut.cpp | 0 tests/{ut => unit}/library/yql/yql_issue_ut.cpp | 0 tests/{ut => unit}/library/yql/yql_wide_int_ut.cpp | 0 tests/{ut => unit}/util/CMakeLists.txt | 0 tests/{ut => unit}/util/charset/CMakeLists.txt | 0 .../{ut => unit}/util/charset/data/invalid_UTF8.bin | Bin tests/{ut => unit}/util/charset/data/test1.txt | 0 tests/{ut => unit}/util/charset/utf8_ut.cpp | 0 tests/{ut => unit}/util/charset/wide_ut.cpp | 0 tests/{ut => unit}/util/digest/CMakeLists.txt | 0 tests/{ut => unit}/util/digest/city_ut.cpp | 0 tests/{ut => unit}/util/digest/fnv_ut.cpp | 0 tests/{ut => unit}/util/digest/multi_ut.cpp | 0 tests/{ut => unit}/util/digest/murmur_ut.cpp | 0 tests/{ut => unit}/util/digest/sequence_ut.cpp | 0 tests/{ut => unit}/util/folder/CMakeLists.txt | 0 tests/{ut => unit}/util/folder/dirut_ut.cpp | 0 tests/{ut => unit}/util/folder/filelist_ut.cpp | 0 tests/{ut => unit}/util/folder/fts_ut.cpp | 0 tests/{ut => unit}/util/folder/iterator_ut.cpp | 0 tests/{ut => unit}/util/folder/path_ut.cpp | 0 tests/{ut => unit}/util/folder/pathsplit_ut.cpp | 6 +++--- tests/{ut => unit}/util/network/CMakeLists.txt | 0 tests/{ut => unit}/util/network/address_ut.cpp | 0 tests/{ut => unit}/util/network/endpoint_ut.cpp | 0 tests/{ut => unit}/util/network/iovec_ut.cpp | 0 tests/{ut => unit}/util/network/ip_ut.cpp | 0 tests/{ut => unit}/util/network/poller_ut.cpp | 0 tests/{ut => unit}/util/network/sock_ut.cpp | 0 tests/{ut => unit}/util/network/socket_ut.cpp | 0 118 files changed, 4 insertions(+), 4 deletions(-) rename tests/{ut => unit}/CMakeLists.txt (100%) rename tests/{ut => unit}/client/CMakeLists.txt (100%) rename tests/{ut => unit}/client/coordination_ut.cpp (100%) rename tests/{ut => unit}/client/discovery_mutator_ut.cpp (100%) rename tests/{ut => unit}/client/driver_ut.cpp (100%) rename tests/{ut => unit}/client/endpoints_ut.cpp (100%) rename tests/{ut => unit}/client/oauth2_token_exchange/CMakeLists.txt (100%) rename tests/{ut => unit}/client/oauth2_token_exchange/credentials_ut.cpp (100%) rename tests/{ut => unit}/client/oauth2_token_exchange/jwt_token_source_ut.cpp (100%) rename tests/{ut => unit}/client/params_ut.cpp (100%) rename tests/{ut => unit}/client/result_ut.cpp (100%) rename tests/{ut => unit}/client/value_ut.cpp (100%) rename tests/{ut => unit}/client/ydb_scripting_response_headers_ut.cpp (100%) rename tests/{ut => unit}/json_value/CMakeLists.txt (100%) rename tests/{ut => unit}/json_value/ydb_json_value_ut.cpp (100%) rename tests/{ut => unit}/library/CMakeLists.txt (100%) rename tests/{ut => unit}/library/cache/CMakeLists.txt (100%) rename tests/{ut => unit}/library/cache/cache_ut.cpp (100%) rename tests/{ut => unit}/library/case_insensitive_string/CMakeLists.txt (100%) rename tests/{ut => unit}/library/case_insensitive_string/case_insensitive_string_ut.cpp (100%) rename tests/{ut => unit}/library/cgiparam/CMakeLists.txt (100%) rename tests/{ut => unit}/library/cgiparam/ut.cpp (100%) rename tests/{ut => unit}/library/charset/CMakeLists.txt (100%) rename tests/{ut => unit}/library/charset/ci_string_ut.cpp (100%) rename tests/{ut => unit}/library/charset/codepage_ut.cpp (100%) rename tests/{ut => unit}/library/charset/iconv_ut.cpp (100%) rename tests/{ut => unit}/library/charset/recyr_int_ut.cpp (100%) rename tests/{ut => unit}/library/charset/wide_ut.cpp (100%) rename tests/{ut => unit}/library/containers/CMakeLists.txt (100%) rename tests/{ut => unit}/library/containers/disjoint_interval_tree_ut.cpp (100%) rename tests/{ut => unit}/library/containers/intrusive_rb_tree_ut.cpp (100%) rename tests/{ut => unit}/library/containers/paged_vector_ut.cpp (100%) rename tests/{ut => unit}/library/containers/stack_vector_ut.cpp (100%) rename tests/{ut => unit}/library/coroutine/CMakeLists.txt (100%) rename tests/{ut => unit}/library/coroutine/engine/CMakeLists.txt (100%) rename tests/{ut => unit}/library/coroutine/engine/coroutine_ut.cpp (100%) rename tests/{ut => unit}/library/coroutine/engine/stack/CMakeLists.txt (100%) rename tests/{ut => unit}/library/coroutine/engine/stack/stack_allocator_ut.cpp (100%) rename tests/{ut => unit}/library/coroutine/engine/stack/stack_guards_ut.cpp (100%) rename tests/{ut => unit}/library/coroutine/engine/stack/stack_pool_ut.cpp (100%) rename tests/{ut => unit}/library/coroutine/engine/stack/stack_ut.cpp (100%) rename tests/{ut => unit}/library/coroutine/engine/stack/stack_utils_ut.cpp (100%) rename tests/{ut => unit}/library/dbg_output/CMakeLists.txt (100%) rename tests/{ut => unit}/library/dbg_output/dbg_output_ut.cpp (100%) rename tests/{ut => unit}/library/diff/CMakeLists.txt (100%) rename tests/{ut => unit}/library/diff/ut.cpp (100%) rename tests/{ut => unit}/library/digest/CMakeLists.txt (100%) rename tests/{ut => unit}/library/digest/lower_case/CMakeLists.txt (100%) rename tests/{ut => unit}/library/digest/lower_case/hash_ops_ut.cpp (100%) rename tests/{ut => unit}/library/digest/lower_case/lchash_ut.cpp (100%) rename tests/{ut => unit}/library/digest/md5/CMakeLists.txt (100%) rename tests/{ut => unit}/library/digest/md5/md5_medium_ut.cpp (100%) rename tests/{ut => unit}/library/digest/md5/md5_ut.cpp (100%) rename tests/{ut => unit}/library/digest/murmur/CMakeLists.txt (100%) rename tests/{ut => unit}/library/digest/murmur/ut.cpp (100%) rename tests/{ut => unit}/library/json/CMakeLists.txt (100%) rename tests/{ut => unit}/library/json/json_prettifier_ut.cpp (100%) rename tests/{ut => unit}/library/json/json_reader_fast_ut.cpp (100%) rename tests/{ut => unit}/library/json/json_reader_ut.cpp (100%) rename tests/{ut => unit}/library/json/json_saveload_ut.cpp (100%) rename tests/{ut => unit}/library/json/json_writer_ut.cpp (100%) rename tests/{ut => unit}/library/json/writer/CMakeLists.txt (100%) rename tests/{ut => unit}/library/json/writer/json_ut.cpp (100%) rename tests/{ut => unit}/library/json/writer/json_value_ut.cpp (100%) rename tests/{ut => unit}/library/operation_id/CMakeLists.txt (100%) rename tests/{ut => unit}/library/operation_id/operation_id_ut.cpp (100%) rename tests/{ut => unit}/library/testing/CMakeLists.txt (100%) rename tests/{ut => unit}/library/testing/common/CMakeLists.txt (100%) rename tests/{ut => unit}/library/testing/common/env_ut.cpp (100%) rename tests/{ut => unit}/library/testing/common/network_ut.cpp (100%) rename tests/{ut => unit}/library/testing/common/scope_ut.cpp (100%) rename tests/{ut => unit}/library/testing/gmock_in_unittest/CMakeLists.txt (100%) rename tests/{ut => unit}/library/testing/gmock_in_unittest/example_ut.cpp (100%) rename tests/{ut => unit}/library/testing/gtest/CMakeLists.txt (100%) rename tests/{ut => unit}/library/testing/gtest/README.md (100%) rename tests/{ut => unit}/library/testing/gtest/golden/data.txt (100%) rename tests/{ut => unit}/library/testing/gtest/matchers_ut.cpp (100%) rename tests/{ut => unit}/library/testing/gtest/ut.cpp (100%) rename tests/{ut => unit}/library/testing/gtest_extensions/CMakeLists.txt (100%) rename tests/{ut => unit}/library/testing/gtest_extensions/README.md (100%) rename tests/{ut => unit}/library/testing/gtest_extensions/gtest_extensions_ut.cpp (100%) rename tests/{ut => unit}/library/testing/gtest_extensions/probe_ut.cpp (100%) rename tests/{ut => unit}/library/testing/unittest/CMakeLists.txt (100%) rename tests/{ut => unit}/library/testing/unittest/main.cpp (100%) rename tests/{ut => unit}/library/testing/unittest/test_port_manager.cpp (100%) rename tests/{ut => unit}/library/yql/CMakeLists.txt (100%) rename tests/{ut => unit}/library/yql/utf8_ut.cpp (100%) rename tests/{ut => unit}/library/yql/yql_decimal_ut.cpp (100%) rename tests/{ut => unit}/library/yql/yql_issue_ut.cpp (100%) rename tests/{ut => unit}/library/yql/yql_wide_int_ut.cpp (100%) rename tests/{ut => unit}/util/CMakeLists.txt (100%) rename tests/{ut => unit}/util/charset/CMakeLists.txt (100%) rename tests/{ut => unit}/util/charset/data/invalid_UTF8.bin (100%) rename tests/{ut => unit}/util/charset/data/test1.txt (100%) rename tests/{ut => unit}/util/charset/utf8_ut.cpp (100%) rename tests/{ut => unit}/util/charset/wide_ut.cpp (100%) rename tests/{ut => unit}/util/digest/CMakeLists.txt (100%) rename tests/{ut => unit}/util/digest/city_ut.cpp (100%) rename tests/{ut => unit}/util/digest/fnv_ut.cpp (100%) rename tests/{ut => unit}/util/digest/multi_ut.cpp (100%) rename tests/{ut => unit}/util/digest/murmur_ut.cpp (100%) rename tests/{ut => unit}/util/digest/sequence_ut.cpp (100%) rename tests/{ut => unit}/util/folder/CMakeLists.txt (100%) rename tests/{ut => unit}/util/folder/dirut_ut.cpp (100%) rename tests/{ut => unit}/util/folder/filelist_ut.cpp (100%) rename tests/{ut => unit}/util/folder/fts_ut.cpp (100%) rename tests/{ut => unit}/util/folder/iterator_ut.cpp (100%) rename tests/{ut => unit}/util/folder/path_ut.cpp (100%) rename tests/{ut => unit}/util/folder/pathsplit_ut.cpp (98%) rename tests/{ut => unit}/util/network/CMakeLists.txt (100%) rename tests/{ut => unit}/util/network/address_ut.cpp (100%) rename tests/{ut => unit}/util/network/endpoint_ut.cpp (100%) rename tests/{ut => unit}/util/network/iovec_ut.cpp (100%) rename tests/{ut => unit}/util/network/ip_ut.cpp (100%) rename tests/{ut => unit}/util/network/poller_ut.cpp (100%) rename tests/{ut => unit}/util/network/sock_ut.cpp (100%) rename tests/{ut => unit}/util/network/socket_ut.cpp (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index ec337718d0e..152a6866e5e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,7 +47,7 @@ endif() if (YDB_SDK_TESTS) enable_testing() - add_subdirectory(tests/ut) + add_subdirectory(tests/unit) add_subdirectory(tests/integration) endif() diff --git a/tests/ut/CMakeLists.txt b/tests/unit/CMakeLists.txt similarity index 100% rename from tests/ut/CMakeLists.txt rename to tests/unit/CMakeLists.txt diff --git a/tests/ut/client/CMakeLists.txt b/tests/unit/client/CMakeLists.txt similarity index 100% rename from tests/ut/client/CMakeLists.txt rename to tests/unit/client/CMakeLists.txt diff --git a/tests/ut/client/coordination_ut.cpp b/tests/unit/client/coordination_ut.cpp similarity index 100% rename from tests/ut/client/coordination_ut.cpp rename to tests/unit/client/coordination_ut.cpp diff --git a/tests/ut/client/discovery_mutator_ut.cpp b/tests/unit/client/discovery_mutator_ut.cpp similarity index 100% rename from tests/ut/client/discovery_mutator_ut.cpp rename to tests/unit/client/discovery_mutator_ut.cpp diff --git a/tests/ut/client/driver_ut.cpp b/tests/unit/client/driver_ut.cpp similarity index 100% rename from tests/ut/client/driver_ut.cpp rename to tests/unit/client/driver_ut.cpp diff --git a/tests/ut/client/endpoints_ut.cpp b/tests/unit/client/endpoints_ut.cpp similarity index 100% rename from tests/ut/client/endpoints_ut.cpp rename to tests/unit/client/endpoints_ut.cpp diff --git a/tests/ut/client/oauth2_token_exchange/CMakeLists.txt b/tests/unit/client/oauth2_token_exchange/CMakeLists.txt similarity index 100% rename from tests/ut/client/oauth2_token_exchange/CMakeLists.txt rename to tests/unit/client/oauth2_token_exchange/CMakeLists.txt diff --git a/tests/ut/client/oauth2_token_exchange/credentials_ut.cpp b/tests/unit/client/oauth2_token_exchange/credentials_ut.cpp similarity index 100% rename from tests/ut/client/oauth2_token_exchange/credentials_ut.cpp rename to tests/unit/client/oauth2_token_exchange/credentials_ut.cpp diff --git a/tests/ut/client/oauth2_token_exchange/jwt_token_source_ut.cpp b/tests/unit/client/oauth2_token_exchange/jwt_token_source_ut.cpp similarity index 100% rename from tests/ut/client/oauth2_token_exchange/jwt_token_source_ut.cpp rename to tests/unit/client/oauth2_token_exchange/jwt_token_source_ut.cpp diff --git a/tests/ut/client/params_ut.cpp b/tests/unit/client/params_ut.cpp similarity index 100% rename from tests/ut/client/params_ut.cpp rename to tests/unit/client/params_ut.cpp diff --git a/tests/ut/client/result_ut.cpp b/tests/unit/client/result_ut.cpp similarity index 100% rename from tests/ut/client/result_ut.cpp rename to tests/unit/client/result_ut.cpp diff --git a/tests/ut/client/value_ut.cpp b/tests/unit/client/value_ut.cpp similarity index 100% rename from tests/ut/client/value_ut.cpp rename to tests/unit/client/value_ut.cpp diff --git a/tests/ut/client/ydb_scripting_response_headers_ut.cpp b/tests/unit/client/ydb_scripting_response_headers_ut.cpp similarity index 100% rename from tests/ut/client/ydb_scripting_response_headers_ut.cpp rename to tests/unit/client/ydb_scripting_response_headers_ut.cpp diff --git a/tests/ut/json_value/CMakeLists.txt b/tests/unit/json_value/CMakeLists.txt similarity index 100% rename from tests/ut/json_value/CMakeLists.txt rename to tests/unit/json_value/CMakeLists.txt diff --git a/tests/ut/json_value/ydb_json_value_ut.cpp b/tests/unit/json_value/ydb_json_value_ut.cpp similarity index 100% rename from tests/ut/json_value/ydb_json_value_ut.cpp rename to tests/unit/json_value/ydb_json_value_ut.cpp diff --git a/tests/ut/library/CMakeLists.txt b/tests/unit/library/CMakeLists.txt similarity index 100% rename from tests/ut/library/CMakeLists.txt rename to tests/unit/library/CMakeLists.txt diff --git a/tests/ut/library/cache/CMakeLists.txt b/tests/unit/library/cache/CMakeLists.txt similarity index 100% rename from tests/ut/library/cache/CMakeLists.txt rename to tests/unit/library/cache/CMakeLists.txt diff --git a/tests/ut/library/cache/cache_ut.cpp b/tests/unit/library/cache/cache_ut.cpp similarity index 100% rename from tests/ut/library/cache/cache_ut.cpp rename to tests/unit/library/cache/cache_ut.cpp diff --git a/tests/ut/library/case_insensitive_string/CMakeLists.txt b/tests/unit/library/case_insensitive_string/CMakeLists.txt similarity index 100% rename from tests/ut/library/case_insensitive_string/CMakeLists.txt rename to tests/unit/library/case_insensitive_string/CMakeLists.txt diff --git a/tests/ut/library/case_insensitive_string/case_insensitive_string_ut.cpp b/tests/unit/library/case_insensitive_string/case_insensitive_string_ut.cpp similarity index 100% rename from tests/ut/library/case_insensitive_string/case_insensitive_string_ut.cpp rename to tests/unit/library/case_insensitive_string/case_insensitive_string_ut.cpp diff --git a/tests/ut/library/cgiparam/CMakeLists.txt b/tests/unit/library/cgiparam/CMakeLists.txt similarity index 100% rename from tests/ut/library/cgiparam/CMakeLists.txt rename to tests/unit/library/cgiparam/CMakeLists.txt diff --git a/tests/ut/library/cgiparam/ut.cpp b/tests/unit/library/cgiparam/ut.cpp similarity index 100% rename from tests/ut/library/cgiparam/ut.cpp rename to tests/unit/library/cgiparam/ut.cpp diff --git a/tests/ut/library/charset/CMakeLists.txt b/tests/unit/library/charset/CMakeLists.txt similarity index 100% rename from tests/ut/library/charset/CMakeLists.txt rename to tests/unit/library/charset/CMakeLists.txt diff --git a/tests/ut/library/charset/ci_string_ut.cpp b/tests/unit/library/charset/ci_string_ut.cpp similarity index 100% rename from tests/ut/library/charset/ci_string_ut.cpp rename to tests/unit/library/charset/ci_string_ut.cpp diff --git a/tests/ut/library/charset/codepage_ut.cpp b/tests/unit/library/charset/codepage_ut.cpp similarity index 100% rename from tests/ut/library/charset/codepage_ut.cpp rename to tests/unit/library/charset/codepage_ut.cpp diff --git a/tests/ut/library/charset/iconv_ut.cpp b/tests/unit/library/charset/iconv_ut.cpp similarity index 100% rename from tests/ut/library/charset/iconv_ut.cpp rename to tests/unit/library/charset/iconv_ut.cpp diff --git a/tests/ut/library/charset/recyr_int_ut.cpp b/tests/unit/library/charset/recyr_int_ut.cpp similarity index 100% rename from tests/ut/library/charset/recyr_int_ut.cpp rename to tests/unit/library/charset/recyr_int_ut.cpp diff --git a/tests/ut/library/charset/wide_ut.cpp b/tests/unit/library/charset/wide_ut.cpp similarity index 100% rename from tests/ut/library/charset/wide_ut.cpp rename to tests/unit/library/charset/wide_ut.cpp diff --git a/tests/ut/library/containers/CMakeLists.txt b/tests/unit/library/containers/CMakeLists.txt similarity index 100% rename from tests/ut/library/containers/CMakeLists.txt rename to tests/unit/library/containers/CMakeLists.txt diff --git a/tests/ut/library/containers/disjoint_interval_tree_ut.cpp b/tests/unit/library/containers/disjoint_interval_tree_ut.cpp similarity index 100% rename from tests/ut/library/containers/disjoint_interval_tree_ut.cpp rename to tests/unit/library/containers/disjoint_interval_tree_ut.cpp diff --git a/tests/ut/library/containers/intrusive_rb_tree_ut.cpp b/tests/unit/library/containers/intrusive_rb_tree_ut.cpp similarity index 100% rename from tests/ut/library/containers/intrusive_rb_tree_ut.cpp rename to tests/unit/library/containers/intrusive_rb_tree_ut.cpp diff --git a/tests/ut/library/containers/paged_vector_ut.cpp b/tests/unit/library/containers/paged_vector_ut.cpp similarity index 100% rename from tests/ut/library/containers/paged_vector_ut.cpp rename to tests/unit/library/containers/paged_vector_ut.cpp diff --git a/tests/ut/library/containers/stack_vector_ut.cpp b/tests/unit/library/containers/stack_vector_ut.cpp similarity index 100% rename from tests/ut/library/containers/stack_vector_ut.cpp rename to tests/unit/library/containers/stack_vector_ut.cpp diff --git a/tests/ut/library/coroutine/CMakeLists.txt b/tests/unit/library/coroutine/CMakeLists.txt similarity index 100% rename from tests/ut/library/coroutine/CMakeLists.txt rename to tests/unit/library/coroutine/CMakeLists.txt diff --git a/tests/ut/library/coroutine/engine/CMakeLists.txt b/tests/unit/library/coroutine/engine/CMakeLists.txt similarity index 100% rename from tests/ut/library/coroutine/engine/CMakeLists.txt rename to tests/unit/library/coroutine/engine/CMakeLists.txt diff --git a/tests/ut/library/coroutine/engine/coroutine_ut.cpp b/tests/unit/library/coroutine/engine/coroutine_ut.cpp similarity index 100% rename from tests/ut/library/coroutine/engine/coroutine_ut.cpp rename to tests/unit/library/coroutine/engine/coroutine_ut.cpp diff --git a/tests/ut/library/coroutine/engine/stack/CMakeLists.txt b/tests/unit/library/coroutine/engine/stack/CMakeLists.txt similarity index 100% rename from tests/ut/library/coroutine/engine/stack/CMakeLists.txt rename to tests/unit/library/coroutine/engine/stack/CMakeLists.txt diff --git a/tests/ut/library/coroutine/engine/stack/stack_allocator_ut.cpp b/tests/unit/library/coroutine/engine/stack/stack_allocator_ut.cpp similarity index 100% rename from tests/ut/library/coroutine/engine/stack/stack_allocator_ut.cpp rename to tests/unit/library/coroutine/engine/stack/stack_allocator_ut.cpp diff --git a/tests/ut/library/coroutine/engine/stack/stack_guards_ut.cpp b/tests/unit/library/coroutine/engine/stack/stack_guards_ut.cpp similarity index 100% rename from tests/ut/library/coroutine/engine/stack/stack_guards_ut.cpp rename to tests/unit/library/coroutine/engine/stack/stack_guards_ut.cpp diff --git a/tests/ut/library/coroutine/engine/stack/stack_pool_ut.cpp b/tests/unit/library/coroutine/engine/stack/stack_pool_ut.cpp similarity index 100% rename from tests/ut/library/coroutine/engine/stack/stack_pool_ut.cpp rename to tests/unit/library/coroutine/engine/stack/stack_pool_ut.cpp diff --git a/tests/ut/library/coroutine/engine/stack/stack_ut.cpp b/tests/unit/library/coroutine/engine/stack/stack_ut.cpp similarity index 100% rename from tests/ut/library/coroutine/engine/stack/stack_ut.cpp rename to tests/unit/library/coroutine/engine/stack/stack_ut.cpp diff --git a/tests/ut/library/coroutine/engine/stack/stack_utils_ut.cpp b/tests/unit/library/coroutine/engine/stack/stack_utils_ut.cpp similarity index 100% rename from tests/ut/library/coroutine/engine/stack/stack_utils_ut.cpp rename to tests/unit/library/coroutine/engine/stack/stack_utils_ut.cpp diff --git a/tests/ut/library/dbg_output/CMakeLists.txt b/tests/unit/library/dbg_output/CMakeLists.txt similarity index 100% rename from tests/ut/library/dbg_output/CMakeLists.txt rename to tests/unit/library/dbg_output/CMakeLists.txt diff --git a/tests/ut/library/dbg_output/dbg_output_ut.cpp b/tests/unit/library/dbg_output/dbg_output_ut.cpp similarity index 100% rename from tests/ut/library/dbg_output/dbg_output_ut.cpp rename to tests/unit/library/dbg_output/dbg_output_ut.cpp diff --git a/tests/ut/library/diff/CMakeLists.txt b/tests/unit/library/diff/CMakeLists.txt similarity index 100% rename from tests/ut/library/diff/CMakeLists.txt rename to tests/unit/library/diff/CMakeLists.txt diff --git a/tests/ut/library/diff/ut.cpp b/tests/unit/library/diff/ut.cpp similarity index 100% rename from tests/ut/library/diff/ut.cpp rename to tests/unit/library/diff/ut.cpp diff --git a/tests/ut/library/digest/CMakeLists.txt b/tests/unit/library/digest/CMakeLists.txt similarity index 100% rename from tests/ut/library/digest/CMakeLists.txt rename to tests/unit/library/digest/CMakeLists.txt diff --git a/tests/ut/library/digest/lower_case/CMakeLists.txt b/tests/unit/library/digest/lower_case/CMakeLists.txt similarity index 100% rename from tests/ut/library/digest/lower_case/CMakeLists.txt rename to tests/unit/library/digest/lower_case/CMakeLists.txt diff --git a/tests/ut/library/digest/lower_case/hash_ops_ut.cpp b/tests/unit/library/digest/lower_case/hash_ops_ut.cpp similarity index 100% rename from tests/ut/library/digest/lower_case/hash_ops_ut.cpp rename to tests/unit/library/digest/lower_case/hash_ops_ut.cpp diff --git a/tests/ut/library/digest/lower_case/lchash_ut.cpp b/tests/unit/library/digest/lower_case/lchash_ut.cpp similarity index 100% rename from tests/ut/library/digest/lower_case/lchash_ut.cpp rename to tests/unit/library/digest/lower_case/lchash_ut.cpp diff --git a/tests/ut/library/digest/md5/CMakeLists.txt b/tests/unit/library/digest/md5/CMakeLists.txt similarity index 100% rename from tests/ut/library/digest/md5/CMakeLists.txt rename to tests/unit/library/digest/md5/CMakeLists.txt diff --git a/tests/ut/library/digest/md5/md5_medium_ut.cpp b/tests/unit/library/digest/md5/md5_medium_ut.cpp similarity index 100% rename from tests/ut/library/digest/md5/md5_medium_ut.cpp rename to tests/unit/library/digest/md5/md5_medium_ut.cpp diff --git a/tests/ut/library/digest/md5/md5_ut.cpp b/tests/unit/library/digest/md5/md5_ut.cpp similarity index 100% rename from tests/ut/library/digest/md5/md5_ut.cpp rename to tests/unit/library/digest/md5/md5_ut.cpp diff --git a/tests/ut/library/digest/murmur/CMakeLists.txt b/tests/unit/library/digest/murmur/CMakeLists.txt similarity index 100% rename from tests/ut/library/digest/murmur/CMakeLists.txt rename to tests/unit/library/digest/murmur/CMakeLists.txt diff --git a/tests/ut/library/digest/murmur/ut.cpp b/tests/unit/library/digest/murmur/ut.cpp similarity index 100% rename from tests/ut/library/digest/murmur/ut.cpp rename to tests/unit/library/digest/murmur/ut.cpp diff --git a/tests/ut/library/json/CMakeLists.txt b/tests/unit/library/json/CMakeLists.txt similarity index 100% rename from tests/ut/library/json/CMakeLists.txt rename to tests/unit/library/json/CMakeLists.txt diff --git a/tests/ut/library/json/json_prettifier_ut.cpp b/tests/unit/library/json/json_prettifier_ut.cpp similarity index 100% rename from tests/ut/library/json/json_prettifier_ut.cpp rename to tests/unit/library/json/json_prettifier_ut.cpp diff --git a/tests/ut/library/json/json_reader_fast_ut.cpp b/tests/unit/library/json/json_reader_fast_ut.cpp similarity index 100% rename from tests/ut/library/json/json_reader_fast_ut.cpp rename to tests/unit/library/json/json_reader_fast_ut.cpp diff --git a/tests/ut/library/json/json_reader_ut.cpp b/tests/unit/library/json/json_reader_ut.cpp similarity index 100% rename from tests/ut/library/json/json_reader_ut.cpp rename to tests/unit/library/json/json_reader_ut.cpp diff --git a/tests/ut/library/json/json_saveload_ut.cpp b/tests/unit/library/json/json_saveload_ut.cpp similarity index 100% rename from tests/ut/library/json/json_saveload_ut.cpp rename to tests/unit/library/json/json_saveload_ut.cpp diff --git a/tests/ut/library/json/json_writer_ut.cpp b/tests/unit/library/json/json_writer_ut.cpp similarity index 100% rename from tests/ut/library/json/json_writer_ut.cpp rename to tests/unit/library/json/json_writer_ut.cpp diff --git a/tests/ut/library/json/writer/CMakeLists.txt b/tests/unit/library/json/writer/CMakeLists.txt similarity index 100% rename from tests/ut/library/json/writer/CMakeLists.txt rename to tests/unit/library/json/writer/CMakeLists.txt diff --git a/tests/ut/library/json/writer/json_ut.cpp b/tests/unit/library/json/writer/json_ut.cpp similarity index 100% rename from tests/ut/library/json/writer/json_ut.cpp rename to tests/unit/library/json/writer/json_ut.cpp diff --git a/tests/ut/library/json/writer/json_value_ut.cpp b/tests/unit/library/json/writer/json_value_ut.cpp similarity index 100% rename from tests/ut/library/json/writer/json_value_ut.cpp rename to tests/unit/library/json/writer/json_value_ut.cpp diff --git a/tests/ut/library/operation_id/CMakeLists.txt b/tests/unit/library/operation_id/CMakeLists.txt similarity index 100% rename from tests/ut/library/operation_id/CMakeLists.txt rename to tests/unit/library/operation_id/CMakeLists.txt diff --git a/tests/ut/library/operation_id/operation_id_ut.cpp b/tests/unit/library/operation_id/operation_id_ut.cpp similarity index 100% rename from tests/ut/library/operation_id/operation_id_ut.cpp rename to tests/unit/library/operation_id/operation_id_ut.cpp diff --git a/tests/ut/library/testing/CMakeLists.txt b/tests/unit/library/testing/CMakeLists.txt similarity index 100% rename from tests/ut/library/testing/CMakeLists.txt rename to tests/unit/library/testing/CMakeLists.txt diff --git a/tests/ut/library/testing/common/CMakeLists.txt b/tests/unit/library/testing/common/CMakeLists.txt similarity index 100% rename from tests/ut/library/testing/common/CMakeLists.txt rename to tests/unit/library/testing/common/CMakeLists.txt diff --git a/tests/ut/library/testing/common/env_ut.cpp b/tests/unit/library/testing/common/env_ut.cpp similarity index 100% rename from tests/ut/library/testing/common/env_ut.cpp rename to tests/unit/library/testing/common/env_ut.cpp diff --git a/tests/ut/library/testing/common/network_ut.cpp b/tests/unit/library/testing/common/network_ut.cpp similarity index 100% rename from tests/ut/library/testing/common/network_ut.cpp rename to tests/unit/library/testing/common/network_ut.cpp diff --git a/tests/ut/library/testing/common/scope_ut.cpp b/tests/unit/library/testing/common/scope_ut.cpp similarity index 100% rename from tests/ut/library/testing/common/scope_ut.cpp rename to tests/unit/library/testing/common/scope_ut.cpp diff --git a/tests/ut/library/testing/gmock_in_unittest/CMakeLists.txt b/tests/unit/library/testing/gmock_in_unittest/CMakeLists.txt similarity index 100% rename from tests/ut/library/testing/gmock_in_unittest/CMakeLists.txt rename to tests/unit/library/testing/gmock_in_unittest/CMakeLists.txt diff --git a/tests/ut/library/testing/gmock_in_unittest/example_ut.cpp b/tests/unit/library/testing/gmock_in_unittest/example_ut.cpp similarity index 100% rename from tests/ut/library/testing/gmock_in_unittest/example_ut.cpp rename to tests/unit/library/testing/gmock_in_unittest/example_ut.cpp diff --git a/tests/ut/library/testing/gtest/CMakeLists.txt b/tests/unit/library/testing/gtest/CMakeLists.txt similarity index 100% rename from tests/ut/library/testing/gtest/CMakeLists.txt rename to tests/unit/library/testing/gtest/CMakeLists.txt diff --git a/tests/ut/library/testing/gtest/README.md b/tests/unit/library/testing/gtest/README.md similarity index 100% rename from tests/ut/library/testing/gtest/README.md rename to tests/unit/library/testing/gtest/README.md diff --git a/tests/ut/library/testing/gtest/golden/data.txt b/tests/unit/library/testing/gtest/golden/data.txt similarity index 100% rename from tests/ut/library/testing/gtest/golden/data.txt rename to tests/unit/library/testing/gtest/golden/data.txt diff --git a/tests/ut/library/testing/gtest/matchers_ut.cpp b/tests/unit/library/testing/gtest/matchers_ut.cpp similarity index 100% rename from tests/ut/library/testing/gtest/matchers_ut.cpp rename to tests/unit/library/testing/gtest/matchers_ut.cpp diff --git a/tests/ut/library/testing/gtest/ut.cpp b/tests/unit/library/testing/gtest/ut.cpp similarity index 100% rename from tests/ut/library/testing/gtest/ut.cpp rename to tests/unit/library/testing/gtest/ut.cpp diff --git a/tests/ut/library/testing/gtest_extensions/CMakeLists.txt b/tests/unit/library/testing/gtest_extensions/CMakeLists.txt similarity index 100% rename from tests/ut/library/testing/gtest_extensions/CMakeLists.txt rename to tests/unit/library/testing/gtest_extensions/CMakeLists.txt diff --git a/tests/ut/library/testing/gtest_extensions/README.md b/tests/unit/library/testing/gtest_extensions/README.md similarity index 100% rename from tests/ut/library/testing/gtest_extensions/README.md rename to tests/unit/library/testing/gtest_extensions/README.md diff --git a/tests/ut/library/testing/gtest_extensions/gtest_extensions_ut.cpp b/tests/unit/library/testing/gtest_extensions/gtest_extensions_ut.cpp similarity index 100% rename from tests/ut/library/testing/gtest_extensions/gtest_extensions_ut.cpp rename to tests/unit/library/testing/gtest_extensions/gtest_extensions_ut.cpp diff --git a/tests/ut/library/testing/gtest_extensions/probe_ut.cpp b/tests/unit/library/testing/gtest_extensions/probe_ut.cpp similarity index 100% rename from tests/ut/library/testing/gtest_extensions/probe_ut.cpp rename to tests/unit/library/testing/gtest_extensions/probe_ut.cpp diff --git a/tests/ut/library/testing/unittest/CMakeLists.txt b/tests/unit/library/testing/unittest/CMakeLists.txt similarity index 100% rename from tests/ut/library/testing/unittest/CMakeLists.txt rename to tests/unit/library/testing/unittest/CMakeLists.txt diff --git a/tests/ut/library/testing/unittest/main.cpp b/tests/unit/library/testing/unittest/main.cpp similarity index 100% rename from tests/ut/library/testing/unittest/main.cpp rename to tests/unit/library/testing/unittest/main.cpp diff --git a/tests/ut/library/testing/unittest/test_port_manager.cpp b/tests/unit/library/testing/unittest/test_port_manager.cpp similarity index 100% rename from tests/ut/library/testing/unittest/test_port_manager.cpp rename to tests/unit/library/testing/unittest/test_port_manager.cpp diff --git a/tests/ut/library/yql/CMakeLists.txt b/tests/unit/library/yql/CMakeLists.txt similarity index 100% rename from tests/ut/library/yql/CMakeLists.txt rename to tests/unit/library/yql/CMakeLists.txt diff --git a/tests/ut/library/yql/utf8_ut.cpp b/tests/unit/library/yql/utf8_ut.cpp similarity index 100% rename from tests/ut/library/yql/utf8_ut.cpp rename to tests/unit/library/yql/utf8_ut.cpp diff --git a/tests/ut/library/yql/yql_decimal_ut.cpp b/tests/unit/library/yql/yql_decimal_ut.cpp similarity index 100% rename from tests/ut/library/yql/yql_decimal_ut.cpp rename to tests/unit/library/yql/yql_decimal_ut.cpp diff --git a/tests/ut/library/yql/yql_issue_ut.cpp b/tests/unit/library/yql/yql_issue_ut.cpp similarity index 100% rename from tests/ut/library/yql/yql_issue_ut.cpp rename to tests/unit/library/yql/yql_issue_ut.cpp diff --git a/tests/ut/library/yql/yql_wide_int_ut.cpp b/tests/unit/library/yql/yql_wide_int_ut.cpp similarity index 100% rename from tests/ut/library/yql/yql_wide_int_ut.cpp rename to tests/unit/library/yql/yql_wide_int_ut.cpp diff --git a/tests/ut/util/CMakeLists.txt b/tests/unit/util/CMakeLists.txt similarity index 100% rename from tests/ut/util/CMakeLists.txt rename to tests/unit/util/CMakeLists.txt diff --git a/tests/ut/util/charset/CMakeLists.txt b/tests/unit/util/charset/CMakeLists.txt similarity index 100% rename from tests/ut/util/charset/CMakeLists.txt rename to tests/unit/util/charset/CMakeLists.txt diff --git a/tests/ut/util/charset/data/invalid_UTF8.bin b/tests/unit/util/charset/data/invalid_UTF8.bin similarity index 100% rename from tests/ut/util/charset/data/invalid_UTF8.bin rename to tests/unit/util/charset/data/invalid_UTF8.bin diff --git a/tests/ut/util/charset/data/test1.txt b/tests/unit/util/charset/data/test1.txt similarity index 100% rename from tests/ut/util/charset/data/test1.txt rename to tests/unit/util/charset/data/test1.txt diff --git a/tests/ut/util/charset/utf8_ut.cpp b/tests/unit/util/charset/utf8_ut.cpp similarity index 100% rename from tests/ut/util/charset/utf8_ut.cpp rename to tests/unit/util/charset/utf8_ut.cpp diff --git a/tests/ut/util/charset/wide_ut.cpp b/tests/unit/util/charset/wide_ut.cpp similarity index 100% rename from tests/ut/util/charset/wide_ut.cpp rename to tests/unit/util/charset/wide_ut.cpp diff --git a/tests/ut/util/digest/CMakeLists.txt b/tests/unit/util/digest/CMakeLists.txt similarity index 100% rename from tests/ut/util/digest/CMakeLists.txt rename to tests/unit/util/digest/CMakeLists.txt diff --git a/tests/ut/util/digest/city_ut.cpp b/tests/unit/util/digest/city_ut.cpp similarity index 100% rename from tests/ut/util/digest/city_ut.cpp rename to tests/unit/util/digest/city_ut.cpp diff --git a/tests/ut/util/digest/fnv_ut.cpp b/tests/unit/util/digest/fnv_ut.cpp similarity index 100% rename from tests/ut/util/digest/fnv_ut.cpp rename to tests/unit/util/digest/fnv_ut.cpp diff --git a/tests/ut/util/digest/multi_ut.cpp b/tests/unit/util/digest/multi_ut.cpp similarity index 100% rename from tests/ut/util/digest/multi_ut.cpp rename to tests/unit/util/digest/multi_ut.cpp diff --git a/tests/ut/util/digest/murmur_ut.cpp b/tests/unit/util/digest/murmur_ut.cpp similarity index 100% rename from tests/ut/util/digest/murmur_ut.cpp rename to tests/unit/util/digest/murmur_ut.cpp diff --git a/tests/ut/util/digest/sequence_ut.cpp b/tests/unit/util/digest/sequence_ut.cpp similarity index 100% rename from tests/ut/util/digest/sequence_ut.cpp rename to tests/unit/util/digest/sequence_ut.cpp diff --git a/tests/ut/util/folder/CMakeLists.txt b/tests/unit/util/folder/CMakeLists.txt similarity index 100% rename from tests/ut/util/folder/CMakeLists.txt rename to tests/unit/util/folder/CMakeLists.txt diff --git a/tests/ut/util/folder/dirut_ut.cpp b/tests/unit/util/folder/dirut_ut.cpp similarity index 100% rename from tests/ut/util/folder/dirut_ut.cpp rename to tests/unit/util/folder/dirut_ut.cpp diff --git a/tests/ut/util/folder/filelist_ut.cpp b/tests/unit/util/folder/filelist_ut.cpp similarity index 100% rename from tests/ut/util/folder/filelist_ut.cpp rename to tests/unit/util/folder/filelist_ut.cpp diff --git a/tests/ut/util/folder/fts_ut.cpp b/tests/unit/util/folder/fts_ut.cpp similarity index 100% rename from tests/ut/util/folder/fts_ut.cpp rename to tests/unit/util/folder/fts_ut.cpp diff --git a/tests/ut/util/folder/iterator_ut.cpp b/tests/unit/util/folder/iterator_ut.cpp similarity index 100% rename from tests/ut/util/folder/iterator_ut.cpp rename to tests/unit/util/folder/iterator_ut.cpp diff --git a/tests/ut/util/folder/path_ut.cpp b/tests/unit/util/folder/path_ut.cpp similarity index 100% rename from tests/ut/util/folder/path_ut.cpp rename to tests/unit/util/folder/path_ut.cpp diff --git a/tests/ut/util/folder/pathsplit_ut.cpp b/tests/unit/util/folder/pathsplit_ut.cpp similarity index 98% rename from tests/ut/util/folder/pathsplit_ut.cpp rename to tests/unit/util/folder/pathsplit_ut.cpp index a58b7e4cd52..72840dfacff 100644 --- a/tests/ut/util/folder/pathsplit_ut.cpp +++ b/tests/unit/util/folder/pathsplit_ut.cpp @@ -20,7 +20,7 @@ #define PSUF(NAME) NAME #define PSUF_LOCAL(NAME) NAME##Local - #include + #include #undef PSUF #undef PSUF_LOCAL @@ -30,7 +30,7 @@ #undef _win_ #define REVERT_WIN #endif - #include + #include #ifdef REVERT_WIN #define _win_ #undef REVERT_WIN @@ -44,7 +44,7 @@ #define _win_ #define REVERT_WIN #endif - #include + #include #ifdef REVERT_WIN #undef _win_ #undef REVERT_WIN diff --git a/tests/ut/util/network/CMakeLists.txt b/tests/unit/util/network/CMakeLists.txt similarity index 100% rename from tests/ut/util/network/CMakeLists.txt rename to tests/unit/util/network/CMakeLists.txt diff --git a/tests/ut/util/network/address_ut.cpp b/tests/unit/util/network/address_ut.cpp similarity index 100% rename from tests/ut/util/network/address_ut.cpp rename to tests/unit/util/network/address_ut.cpp diff --git a/tests/ut/util/network/endpoint_ut.cpp b/tests/unit/util/network/endpoint_ut.cpp similarity index 100% rename from tests/ut/util/network/endpoint_ut.cpp rename to tests/unit/util/network/endpoint_ut.cpp diff --git a/tests/ut/util/network/iovec_ut.cpp b/tests/unit/util/network/iovec_ut.cpp similarity index 100% rename from tests/ut/util/network/iovec_ut.cpp rename to tests/unit/util/network/iovec_ut.cpp diff --git a/tests/ut/util/network/ip_ut.cpp b/tests/unit/util/network/ip_ut.cpp similarity index 100% rename from tests/ut/util/network/ip_ut.cpp rename to tests/unit/util/network/ip_ut.cpp diff --git a/tests/ut/util/network/poller_ut.cpp b/tests/unit/util/network/poller_ut.cpp similarity index 100% rename from tests/ut/util/network/poller_ut.cpp rename to tests/unit/util/network/poller_ut.cpp diff --git a/tests/ut/util/network/sock_ut.cpp b/tests/unit/util/network/sock_ut.cpp similarity index 100% rename from tests/ut/util/network/sock_ut.cpp rename to tests/unit/util/network/sock_ut.cpp diff --git a/tests/ut/util/network/socket_ut.cpp b/tests/unit/util/network/socket_ut.cpp similarity index 100% rename from tests/ut/util/network/socket_ut.cpp rename to tests/unit/util/network/socket_ut.cpp From 3108bec7064094c4125911cb08e4236181996bcd Mon Sep 17 00:00:00 2001 From: st-shchetinin Date: Mon, 29 Jul 2024 20:40:20 +0300 Subject: [PATCH 31/36] added retry --- .../basic_example_it/basic_example.cpp | 106 ++++++++++-------- tests/integration/basic_example_it/main.cpp | 3 +- 2 files changed, 58 insertions(+), 51 deletions(-) diff --git a/tests/integration/basic_example_it/basic_example.cpp b/tests/integration/basic_example_it/basic_example.cpp index c297987098c..9b2858a2aec 100644 --- a/tests/integration/basic_example_it/basic_example.cpp +++ b/tests/integration/basic_example_it/basic_example.cpp @@ -404,6 +404,56 @@ static TStatus ExplicitTclTransaction(TSession session, const std::string& path, return tx.Commit().GetValueSync(); } +static TStatus ScanQuerySelect(TTableClient client, const std::string& path, std::vector & vectorResultSet) { + std::vector result; + auto query = std::format(R"( + --!syntax_v1 + PRAGMA TablePathPrefix("{}"); + + DECLARE $series AS List; + + SELECT series_id, season_id, title, CAST(CAST(first_aired AS Date) AS String) AS first_aired + FROM seasons + WHERE series_id IN $series + ORDER BY season_id; + )", path); + + auto parameters = TParamsBuilder() + .AddParam("$series") + .BeginList() + .AddListItem().Uint64(1) + .AddListItem().Uint64(10) + .EndList().Build() + .Build(); + + // Executes scan query + auto resultScanQuery = client.StreamExecuteScanQuery(query, parameters).GetValueSync(); + + if (!resultScanQuery.IsSuccess()) { + return resultScanQuery; + } + + bool eos = false; + + while (!eos) { + auto streamPart = resultScanQuery.ReadNext().ExtractValueSync(); + + if (!streamPart.IsSuccess()) { + eos = true; + if (!streamPart.EOS()) { + std::cerr << "ScanQuery execution failure: " << streamPart.GetIssues().ToString() << std::endl; + } + continue; + } + + if (streamPart.HasResultSet()) { + auto rs = streamPart.ExtractResultSet(); + vectorResultSet.push_back(rs); + } + } + return resultScanQuery; +} + /////////////////////////////////////////////////////////////////////////////// std::string SelectSimple(TTableClient client, const std::string& path) { @@ -452,53 +502,11 @@ void ExplicitTcl(TTableClient client, const std::string& path) { } std::vector ScanQuerySelect(TTableClient client, const std::string& path) { - std::vector result; - auto query = std::format(R"( - --!syntax_v1 - PRAGMA TablePathPrefix("{}"); - - DECLARE $series AS List; - - SELECT series_id, season_id, title, CAST(CAST(first_aired AS Date) AS String) AS first_aired - FROM seasons - WHERE series_id IN $series - ORDER BY season_id; - )", path); - - auto parameters = TParamsBuilder() - .AddParam("$series") - .BeginList() - .AddListItem().Uint64(1) - .AddListItem().Uint64(10) - .EndList().Build() - .Build(); - - // Executes scan query - auto resultScanQuery = client.StreamExecuteScanQuery(query, parameters).GetValueSync(); - - if (!resultScanQuery.IsSuccess()) { - std::cerr << "ScanQuery execution failure: " << resultScanQuery.GetIssues().ToString() << std::endl; - return {}; - } - - bool eos = false; - - while (!eos) { - auto streamPart = resultScanQuery.ReadNext().ExtractValueSync(); - - if (!streamPart.IsSuccess()) { - eos = true; - if (!streamPart.EOS()) { - std::cerr << "ScanQuery execution failure: " << streamPart.GetIssues().ToString() << std::endl; - } - continue; - } - - if (streamPart.HasResultSet()) { - auto rs = streamPart.ExtractResultSet(); - auto columns = rs.GetColumnsMeta(); - result.push_back(FormatResultSetJson(rs, EBinaryStringEncoding::Unicode)); - } - } - return result; + std::vector vectorResultSet; + ThrowOnError(client.RetryOperationSync([path, &vectorResultSet](TTableClient& client) { + return ScanQuerySelect(client, path, vectorResultSet); + })); + std::vector resultJson(vectorResultSet.size()); + std::transform(vectorResultSet.begin(), vectorResultSet.end(), resultJson.begin(), [](TResultSet& x){return FormatResultSetJson(x, EBinaryStringEncoding::Unicode);}); + return resultJson; } diff --git a/tests/integration/basic_example_it/main.cpp b/tests/integration/basic_example_it/main.cpp index e0fa5dc176e..b68aa4e095d 100644 --- a/tests/integration/basic_example_it/main.cpp +++ b/tests/integration/basic_example_it/main.cpp @@ -70,9 +70,8 @@ TEST(Integration, BasicExample) { ASSERT_EQ(resultScanQuerySelect, expectedResultScanQuerySelect); } catch (const TYdbErrorException& e) { - std::cerr << "Execution failed due to fatal error:" << std::endl; driver.Stop(true); - FAIL(); + FAIL() << "Execution failed due to fatal error:\nStatus: " << ToString(e.Status.GetStatus()) << std::endl << e.Status.GetIssues().ToString(); } driver.Stop(true); From 98bc556b3e116c2716138354cc5a4dc7da45e5a6 Mon Sep 17 00:00:00 2001 From: st-shchetinin Date: Mon, 29 Jul 2024 20:59:59 +0300 Subject: [PATCH 32/36] fix after review --- .github/workflows/tests.yaml | 2 +- CMakePresets.json | 4 ++-- .../basic_example_it/basic_example.cpp | 20 ++++++++++++++----- .../basic_example_it/basic_example.h | 1 + tests/integration/basic_example_it/main.cpp | 15 -------------- 5 files changed, 19 insertions(+), 23 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 1e252db694b..fe40c3407eb 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -1,4 +1,4 @@ -name: PR-check +name: Tests on: push: diff --git a/CMakePresets.json b/CMakePresets.json index 4ffafcb236a..0a2b024500f 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -61,8 +61,8 @@ "timeout": 1200 }, "environment": { - "ENDPOINT": "localhost:2136", - "DATABASE": "/local" + "YDB_ENDPOINT": "localhost:2136", + "YDB_DATABASE": "/local" } }, { diff --git a/tests/integration/basic_example_it/basic_example.cpp b/tests/integration/basic_example_it/basic_example.cpp index 9b2858a2aec..8a1c58f9dfa 100644 --- a/tests/integration/basic_example_it/basic_example.cpp +++ b/tests/integration/basic_example_it/basic_example.cpp @@ -25,6 +25,20 @@ static std::string JoinPath(const std::string& basePath, const std::string& path return prefixPathSplit; } +RunArgs GetRunArgs() { + + std::string database = std::getenv("YDB_DATABASE"); + std::string endpoint = std::getenv("YDB_ENDPOINT"); + + auto driverConfig = TDriverConfig() + .SetEndpoint(endpoint) + .SetDatabase(database) + .SetAuthToken(std::getenv("YDB_TOKEN") ? std::getenv("YDB_TOKEN") : ""); + + TDriver driver(driverConfig); + return {driver, JoinPath(database, "basic")}; +} + /////////////////////////////////////////////////////////////////////////////// //! Creates sample tables with CrateTable API. @@ -242,10 +256,6 @@ static TStatus PreparedSelectTransaction(TSession session, const std::string& pa return prepareResult; } - if (!prepareResult.IsQueryFromCache()) { - std::cerr << "+Finished preparing query: PreparedSelectTransaction" << std::endl; - } - auto dataQuery = prepareResult.GetQuery(); auto params = dataQuery.GetParamsBuilder() @@ -441,7 +451,7 @@ static TStatus ScanQuerySelect(TTableClient client, const std::string& path, std if (!streamPart.IsSuccess()) { eos = true; if (!streamPart.EOS()) { - std::cerr << "ScanQuery execution failure: " << streamPart.GetIssues().ToString() << std::endl; + return resultScanQuery; } continue; } diff --git a/tests/integration/basic_example_it/basic_example.h b/tests/integration/basic_example_it/basic_example.h index feb46b7b41c..ec8a23992f2 100644 --- a/tests/integration/basic_example_it/basic_example.h +++ b/tests/integration/basic_example_it/basic_example.h @@ -26,6 +26,7 @@ NYdb::TParams GetTablesDataParams(); void CreateTables(TTableClient client, const std::string& path); void ThrowOnError(const TStatus& status); +RunArgs GetRunArgs(); TStatus FillTableDataTransaction(TSession session, const std::string& path); std::string SelectSimple(TTableClient client, const std::string& path); void UpsertSimple(TTableClient client, const std::string& path); diff --git a/tests/integration/basic_example_it/main.cpp b/tests/integration/basic_example_it/main.cpp index b68aa4e095d..ce8a5a23a21 100644 --- a/tests/integration/basic_example_it/main.cpp +++ b/tests/integration/basic_example_it/main.cpp @@ -1,6 +1,5 @@ #include "basic_example.h" -#include #include #include @@ -9,20 +8,6 @@ #include -RunArgs GetRunArgs() { - - std::string database = std::getenv("YDB_DATABASE"); - std::string endpoint = std::getenv("YDB_ENDPOINT"); - - auto driverConfig = TDriverConfig() - .SetEndpoint(endpoint) - .SetDatabase(database) - .SetAuthToken(std::getenv("YDB_TOKEN") ? std::getenv("YDB_TOKEN") : ""); - - TDriver driver(driverConfig); - return {driver, database}; -} - TEST(Integration, BasicExample) { auto [driver, path] = GetRunArgs(); From b8336dae306600a75ba1c9e676e9b3ad04c07186 Mon Sep 17 00:00:00 2001 From: st-shchetinin Date: Mon, 29 Jul 2024 21:04:01 +0300 Subject: [PATCH 33/36] fix env_ut --- tests/unit/library/testing/common/env_ut.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/library/testing/common/env_ut.cpp b/tests/unit/library/testing/common/env_ut.cpp index 73bb61b6f0c..e6d316aa48d 100644 --- a/tests/unit/library/testing/common/env_ut.cpp +++ b/tests/unit/library/testing/common/env_ut.cpp @@ -41,7 +41,7 @@ TEST(Runtime, BuildRoot) { TEST(Runtime, BinaryPath) { NTesting::TScopedEnvironment contextGuard("YA_TEST_CONTEXT_FILE", ""); // remove context filename Singleton()->ReInitialize(); - EXPECT_TRUE(TFsPath(BinaryPath("tests/ut/library/testing/common")).Exists()); + EXPECT_TRUE(TFsPath(BinaryPath("tests/unit/library/testing/common")).Exists()); } TEST(Runtime, GetArcadiaTestsData) { From 900d86acae43490be9235bbc8752fbc00160ae3c Mon Sep 17 00:00:00 2001 From: st-shchetinin Date: Tue, 30 Jul 2024 11:56:29 +0300 Subject: [PATCH 34/36] fix after review --- .github/workflows/examples.yaml | 3 +++ tests/integration/basic_example_it/basic_example.cpp | 6 +++--- tests/integration/basic_example_it/basic_example.h | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/examples.yaml b/.github/workflows/examples.yaml index db9fcc14f19..45cc713e713 100644 --- a/.github/workflows/examples.yaml +++ b/.github/workflows/examples.yaml @@ -11,6 +11,9 @@ on: jobs: main: name: Examples + concurrency: + group: examples-${{ github.ref }}-${{ matrix.ydb-version }} + cancel-in-progress: true runs-on: ubuntu-22.04 strategy: fail-fast: false diff --git a/tests/integration/basic_example_it/basic_example.cpp b/tests/integration/basic_example_it/basic_example.cpp index 8a1c58f9dfa..c0d8a0c3161 100644 --- a/tests/integration/basic_example_it/basic_example.cpp +++ b/tests/integration/basic_example_it/basic_example.cpp @@ -25,7 +25,7 @@ static std::string JoinPath(const std::string& basePath, const std::string& path return prefixPathSplit; } -RunArgs GetRunArgs() { +TRunArgs GetRunArgs() { std::string database = std::getenv("YDB_DATABASE"); std::string endpoint = std::getenv("YDB_ENDPOINT"); @@ -451,7 +451,7 @@ static TStatus ScanQuerySelect(TTableClient client, const std::string& path, std if (!streamPart.IsSuccess()) { eos = true; if (!streamPart.EOS()) { - return resultScanQuery; + return streamPart; } continue; } @@ -461,7 +461,7 @@ static TStatus ScanQuerySelect(TTableClient client, const std::string& path, std vectorResultSet.push_back(rs); } } - return resultScanQuery; + return TStatus(EStatus::SUCCESS, NYql::TIssues()); } /////////////////////////////////////////////////////////////////////////////// diff --git a/tests/integration/basic_example_it/basic_example.h b/tests/integration/basic_example_it/basic_example.h index ec8a23992f2..63d43d585f7 100644 --- a/tests/integration/basic_example_it/basic_example.h +++ b/tests/integration/basic_example_it/basic_example.h @@ -10,7 +10,7 @@ using namespace NYdb; using namespace NYdb::NTable; -struct RunArgs { +struct TRunArgs { TDriver driver; std::string path; }; @@ -26,7 +26,7 @@ NYdb::TParams GetTablesDataParams(); void CreateTables(TTableClient client, const std::string& path); void ThrowOnError(const TStatus& status); -RunArgs GetRunArgs(); +TRunArgs GetRunArgs(); TStatus FillTableDataTransaction(TSession session, const std::string& path); std::string SelectSimple(TTableClient client, const std::string& path); void UpsertSimple(TTableClient client, const std::string& path); From b225192d4c7cbf5f78b403e6d8d3faa8b1a663d2 Mon Sep 17 00:00:00 2001 From: st-shchetinin Date: Tue, 30 Jul 2024 18:24:12 +0300 Subject: [PATCH 35/36] fix after review --- .github/workflows/examples.yaml | 7 +++---- tests/integration/basic_example_it/basic_example.h | 2 -- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/examples.yaml b/.github/workflows/examples.yaml index 45cc713e713..93d457875b5 100644 --- a/.github/workflows/examples.yaml +++ b/.github/workflows/examples.yaml @@ -7,13 +7,12 @@ on: pull_request: branches: - main - +concurrency: + group: examples-${{ github.ref }}-${{ matrix.ydb-version }} + cancel-in-progress: true jobs: main: name: Examples - concurrency: - group: examples-${{ github.ref }}-${{ matrix.ydb-version }} - cancel-in-progress: true runs-on: ubuntu-22.04 strategy: fail-fast: false diff --git a/tests/integration/basic_example_it/basic_example.h b/tests/integration/basic_example_it/basic_example.h index 63d43d585f7..9328880d25c 100644 --- a/tests/integration/basic_example_it/basic_example.h +++ b/tests/integration/basic_example_it/basic_example.h @@ -3,8 +3,6 @@ #include #include -#include - #include using namespace NYdb; From fd6257328bf829960dfad0773386260b7399c2db Mon Sep 17 00:00:00 2001 From: st-shchetinin Date: Tue, 30 Jul 2024 18:27:02 +0300 Subject: [PATCH 36/36] fix examples --- .github/workflows/examples.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/examples.yaml b/.github/workflows/examples.yaml index 93d457875b5..def8ce1fa1b 100644 --- a/.github/workflows/examples.yaml +++ b/.github/workflows/examples.yaml @@ -8,7 +8,7 @@ on: branches: - main concurrency: - group: examples-${{ github.ref }}-${{ matrix.ydb-version }} + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} cancel-in-progress: true jobs: main: