Skip to content

Commit e2ab35f

Browse files
committed
Add a rename test for vector index
1 parent 54f2daa commit e2ab35f

File tree

4 files changed

+53
-6
lines changed

4 files changed

+53
-6
lines changed

ydb/core/tx/schemeshard/ut_helpers/helpers.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1924,11 +1924,11 @@ namespace NSchemeShardUT_Private {
19241924
}
19251925

19261926
void TestBuildVectorIndex(TTestActorRuntime& runtime, ui64 id, ui64 schemeShard, const TString &dbName,
1927-
const TString &src, const TString &name, TString column,
1927+
const TString &src, const TString &name, TVector<TString> columns,
19281928
Ydb::StatusIds::StatusCode expectedStatus)
19291929
{
19301930
TestBuildIndex(runtime, id, schemeShard, dbName, src, TBuildIndexConfig{
1931-
name, NKikimrSchemeOp::EIndexTypeGlobalVectorKmeansTree, {column}, {}
1931+
name, NKikimrSchemeOp::EIndexTypeGlobalVectorKmeansTree, columns, {}
19321932
}, expectedStatus);
19331933
}
19341934

ydb/core/tx/schemeshard/ut_helpers/helpers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ namespace NSchemeShardUT_Private {
411411
const TString &src, const TString& columnName, const Ydb::TypedValue& literal, Ydb::StatusIds::StatusCode expectedStatus);
412412
void TestBuildIndex(TTestActorRuntime& runtime, ui64 id, ui64 schemeShard, const TString &dbName, const TString &src, const TBuildIndexConfig &cfg, Ydb::StatusIds::StatusCode expectedStatus = Ydb::StatusIds::SUCCESS);
413413
void TestBuildIndex(TTestActorRuntime& runtime, ui64 id, ui64 schemeShard, const TString &dbName, const TString &src, const TString &name, TVector<TString> columns, Ydb::StatusIds::StatusCode expectedStatus = Ydb::StatusIds::SUCCESS);
414-
void TestBuildVectorIndex(TTestActorRuntime& runtime, ui64 id, ui64 schemeShard, const TString &dbName, const TString &src, const TString &name, TString column, Ydb::StatusIds::StatusCode expectedStatus = Ydb::StatusIds::SUCCESS);
414+
void TestBuildVectorIndex(TTestActorRuntime& runtime, ui64 id, ui64 schemeShard, const TString &dbName, const TString &src, const TString &name, TVector<TString> columns, Ydb::StatusIds::StatusCode expectedStatus = Ydb::StatusIds::SUCCESS);
415415
TEvIndexBuilder::TEvCancelRequest* CreateCancelBuildIndexRequest(const ui64 id, const TString& dbName, const ui64 buildIndexId);
416416
NKikimrIndexBuilder::TEvCancelResponse TestCancelBuildIndex(TTestActorRuntime& runtime, const ui64 id, const ui64 schemeShard, const TString &dbName, const ui64 buildIndexId, const TVector<Ydb::StatusIds::StatusCode>& expectedStatuses = {Ydb::StatusIds::SUCCESS});
417417
TEvIndexBuilder::TEvListRequest* ListBuildIndexRequest(const TString& dbName);

ydb/core/tx/schemeshard/ut_index_build/ut_vector_index_build.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ Y_UNIT_TEST_SUITE(VectorIndexBuildTest) {
9292
{NLs::PathExist, NLs::IndexesCount(0), NLs::PathVersionEqual(3)});
9393

9494
ui64 buildIndexTx = ++txId;
95-
TestBuildVectorIndex(runtime, buildIndexTx, tenantSchemeShard, "/MyRoot/ServerLessDB", "/MyRoot/ServerLessDB/Table", "index1", "embedding");
95+
TestBuildVectorIndex(runtime, buildIndexTx, tenantSchemeShard, "/MyRoot/ServerLessDB", "/MyRoot/ServerLessDB/Table", "index1", {"embedding"});
9696
env.TestWaitNotification(runtime, buildIndexTx, tenantSchemeShard);
9797

9898
auto buildIndexOperations = TestListBuildIndex(runtime, tenantSchemeShard, "/MyRoot/ServerLessDB");
@@ -160,7 +160,7 @@ Y_UNIT_TEST_SUITE(VectorIndexBuildTest) {
160160

161161
WriteVectorTableRows(runtime, tenantSchemeShard, ++txId, "/MyRoot/ServerLessDB/Table", 0, 0, 200, {1, 5, 3, 4});
162162

163-
TestBuildVectorIndex(runtime, ++txId, tenantSchemeShard, "/MyRoot/ServerLessDB", "/MyRoot/ServerLessDB/Table", "index2", "embedding");
163+
TestBuildVectorIndex(runtime, ++txId, tenantSchemeShard, "/MyRoot/ServerLessDB", "/MyRoot/ServerLessDB/Table", "index2", {"embedding"});
164164
env.TestWaitNotification(runtime, txId, tenantSchemeShard);
165165

166166
TestDescribeResult(DescribePath(runtime, tenantSchemeShard, "/MyRoot/ServerLessDB/Table"),
@@ -422,7 +422,7 @@ Y_UNIT_TEST_SUITE(VectorIndexBuildTest) {
422422

423423
// Initiate index build:
424424
ui64 buildIndexTx = ++txId;
425-
TestBuildVectorIndex(runtime, buildIndexTx, tenantSchemeShard, "/MyRoot/CommonDB", "/MyRoot/CommonDB/Table", "index1", "embedding");
425+
TestBuildVectorIndex(runtime, buildIndexTx, tenantSchemeShard, "/MyRoot/CommonDB", "/MyRoot/CommonDB/Table", "index1", {"embedding"});
426426
{
427427
auto buildIndexOperations = TestListBuildIndex(runtime, tenantSchemeShard, "/MyRoot/CommonDB");
428428
UNIT_ASSERT_VALUES_EQUAL(buildIndexOperations.EntriesSize(), 1);

ydb/core/tx/schemeshard/ut_move/ut_move.cpp

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include <ydb/core/base/table_vector_index.h>
12
#include <ydb/core/kqp/ut/common/kqp_ut_common.h>
23
#include <ydb/core/tx/datashard/change_exchange.h>
34
#include <ydb/core/tx/schemeshard/ut_helpers/helpers.h>
@@ -8,6 +9,7 @@
89
using namespace NKikimr;
910
using namespace NSchemeShard;
1011
using namespace NSchemeShardUT_Private;
12+
using namespace NKikimr::NTableIndex::NTableVectorKmeansTreeIndex;
1113

1214
void SetEnableMoveIndex(TTestActorRuntime &runtime, TTestEnv&, ui64 schemeShard, bool value) {
1315
auto request = MakeHolder<NConsole::TEvConsole::TEvConfigNotificationRequest>();
@@ -1020,6 +1022,51 @@ Y_UNIT_TEST_SUITE(TSchemeShardMoveTest) {
10201022
NLs::IndexesCount(2)});
10211023
}
10221024

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+
10231070
Y_UNIT_TEST(AsyncIndexWithSyncInFly) {
10241071
TTestBasicRuntime runtime;
10251072
TTestEnv env(runtime);

0 commit comments

Comments
 (0)