|
| 1 | +#include <ydb/core/base/table_vector_index.h> |
1 | 2 | #include <ydb/core/kqp/ut/common/kqp_ut_common.h>
|
2 | 3 | #include <ydb/core/tx/datashard/change_exchange.h>
|
3 | 4 | #include <ydb/core/tx/schemeshard/ut_helpers/helpers.h>
|
|
8 | 9 | using namespace NKikimr;
|
9 | 10 | using namespace NSchemeShard;
|
10 | 11 | using namespace NSchemeShardUT_Private;
|
| 12 | +using namespace NKikimr::NTableIndex::NTableVectorKmeansTreeIndex; |
11 | 13 |
|
12 | 14 | void SetEnableMoveIndex(TTestActorRuntime &runtime, TTestEnv&, ui64 schemeShard, bool value) {
|
13 | 15 | auto request = MakeHolder<NConsole::TEvConsole::TEvConfigNotificationRequest>();
|
@@ -1020,6 +1022,51 @@ Y_UNIT_TEST_SUITE(TSchemeShardMoveTest) {
|
1020 | 1022 | NLs::IndexesCount(2)});
|
1021 | 1023 | }
|
1022 | 1024 |
|
| 1025 | + Y_UNIT_TEST(ReplaceVectorIndex) { |
| 1026 | + TTestBasicRuntime runtime; |
| 1027 | + TTestEnv env(runtime); |
| 1028 | + ui64 txId = 100; |
| 1029 | + |
| 1030 | + TestCreateTable(runtime, ++txId, "/MyRoot", R"( |
| 1031 | + Name: "Table" |
| 1032 | + Columns { Name: "key" Type: "Uint32" } |
| 1033 | + Columns { Name: "embedding" Type: "String" } |
| 1034 | + Columns { Name: "prefix" Type: "Uint32" } |
| 1035 | + Columns { Name: "value" Type: "String" } |
| 1036 | + KeyColumnNames: ["key"] |
| 1037 | + )"); |
| 1038 | + env.TestWaitNotification(runtime, txId); |
| 1039 | + |
| 1040 | + TestBuildVectorIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/Table", "index1", {"embedding"}); |
| 1041 | + env.TestWaitNotification(runtime, txId); |
| 1042 | + |
| 1043 | + TestBuildVectorIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/Table", "index2", {"prefix", "embedding"}); |
| 1044 | + env.TestWaitNotification(runtime, txId); |
| 1045 | + |
| 1046 | + TestDescribeResult(DescribePath(runtime, "/MyRoot/Table"), {NLs::PathExist, NLs::PathVersionEqual(9), NLs::IndexesCount(2)}); |
| 1047 | + |
| 1048 | + TestMoveIndex(runtime, ++txId, "/MyRoot/Table", "index2", "index1", true); |
| 1049 | + env.TestWaitNotification(runtime, txId); |
| 1050 | + |
| 1051 | + TestDescribeResult(DescribePath(runtime, "/MyRoot/Table/index2"), {NLs::PathNotExist}); |
| 1052 | + TestDescribeResult(DescribePath(runtime, "/MyRoot/Table"), {NLs::PathExist, NLs::IndexesCount(1)}); |
| 1053 | + TestDescribeResult(DescribePrivatePath(runtime, "/MyRoot/Table/index1/indexImplPrefixTable"), |
| 1054 | + { NLs::PathExist, NLs::CheckColumns(PrefixTable, {"prefix", IdColumn}, {}, {"prefix", IdColumn}, true) }); |
| 1055 | + |
| 1056 | + // Replace again - it previously crashed here when Dec/IncAliveChildren were incorrect |
| 1057 | + |
| 1058 | + TestBuildVectorIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/Table", "index2", {"embedding"}); |
| 1059 | + env.TestWaitNotification(runtime, txId); |
| 1060 | + |
| 1061 | + TestMoveIndex(runtime, ++txId, "/MyRoot/Table", "index2", "index1", true); |
| 1062 | + env.TestWaitNotification(runtime, txId); |
| 1063 | + |
| 1064 | + TestDescribeResult(DescribePath(runtime, "/MyRoot/Table/index2"), {NLs::PathNotExist}); |
| 1065 | + TestDescribeResult(DescribePath(runtime, "/MyRoot/Table"), {NLs::PathExist, NLs::IndexesCount(1)}); |
| 1066 | + TestDescribeResult(DescribePrivatePath(runtime, "/MyRoot/Table/index1/indexImplPrefixTable"), {NLs::PathNotExist}); |
| 1067 | + } |
| 1068 | + |
| 1069 | + |
1023 | 1070 | Y_UNIT_TEST(AsyncIndexWithSyncInFly) {
|
1024 | 1071 | TTestBasicRuntime runtime;
|
1025 | 1072 | TTestEnv env(runtime);
|
|
0 commit comments