@@ -58,6 +58,71 @@ Y_UNIT_TEST_SUITE(DstCreator) {
5858 UNIT_ASSERT_VALUES_EQUAL (replCfg.GetConsistency (), NKikimrSchemeOp::TTableReplicationConfig::CONSISTENCY_WEAK);
5959 }
6060
61+ void WithSyncIndex (const TString& replicatedPath) {
62+ TEnv env;
63+ env.GetRuntime ().SetLogPriority (NKikimrServices::REPLICATION_CONTROLLER, NLog::PRI_TRACE);
64+
65+ const auto tableDesc = TTestTableDescription{
66+ .Name = " Table" ,
67+ .KeyColumns = {" key" },
68+ .Columns = {
69+ {.Name = " key" , .Type = " Uint32" },
70+ {.Name = " value" , .Type = " Uint32" },
71+ },
72+ .ReplicationConfig = Nothing (),
73+ };
74+
75+ const TString indexName = " index_by_value" ;
76+
77+ env.CreateTableWithIndex (" /Root" , *MakeTableDescription (tableDesc),
78+ indexName, TVector<TString>{" value" }, NKikimrSchemeOp::EIndexTypeGlobal,
79+ TVector<TString>{}, TDuration::Seconds (5000 ));
80+ env.GetRuntime ().Register (CreateDstCreator (
81+ env.GetSender (), env.GetSchemeshardId (" /Root/Table" ), env.GetYdbProxy (), env.GetPathId (" /Root" ),
82+ 1 /* rid */ , 1 /* tid */ , TReplication::ETargetKind::Table, " /Root/Table" , replicatedPath
83+ ));
84+
85+ auto ev = env.GetRuntime ().GrabEdgeEvent <TEvPrivate::TEvCreateDstResult>(env.GetSender ());
86+ UNIT_ASSERT_VALUES_EQUAL (ev->Get ()->Status , NKikimrScheme::StatusSuccess);
87+
88+ {
89+ auto desc = env.GetDescription (replicatedPath);
90+ const auto & replicatedDesc = desc.GetPathDescription ().GetTable ();
91+
92+ UNIT_ASSERT_VALUES_EQUAL (replicatedDesc.KeyColumnNamesSize (), tableDesc.KeyColumns .size ());
93+ for (ui32 i = 0 ; i < replicatedDesc.KeyColumnNamesSize (); ++i) {
94+ UNIT_ASSERT_VALUES_EQUAL (replicatedDesc.GetKeyColumnNames (i), tableDesc.KeyColumns [i]);
95+ }
96+
97+ UNIT_ASSERT_VALUES_EQUAL (replicatedDesc.ColumnsSize (), tableDesc.Columns .size ());
98+ for (ui32 i = 0 ; i < replicatedDesc.ColumnsSize (); ++i) {
99+ auto pred = [name = replicatedDesc.GetColumns (i).GetName ()](const auto & column) {
100+ return name == column.Name ;
101+ };
102+
103+ UNIT_ASSERT (FindIfPtr (tableDesc.Columns , pred));
104+ }
105+
106+ const auto & replCfg = replicatedDesc.GetReplicationConfig ();
107+ UNIT_ASSERT_VALUES_EQUAL (replCfg.GetMode (), NKikimrSchemeOp::TTableReplicationConfig::REPLICATION_MODE_READ_ONLY);
108+ UNIT_ASSERT_VALUES_EQUAL (replCfg.GetConsistency (), NKikimrSchemeOp::TTableReplicationConfig::CONSISTENCY_WEAK);
109+ }
110+
111+ {
112+ auto desc = env.GetDescription (replicatedPath + " /" + indexName);
113+ UNIT_ASSERT_VALUES_EQUAL (desc.GetPathDescription ().GetTableIndex ().GetName (), indexName);
114+ UNIT_ASSERT_VALUES_EQUAL (desc.GetPathDescription ().GetTableIndex ().GetType (), NKikimrSchemeOp::EIndexType::EIndexTypeGlobal);
115+ }
116+
117+ {
118+ auto desc = env.GetDescription (replicatedPath + " /" + indexName + " /indexImplTable" );
119+ Cerr << desc.DebugString () << Endl;
120+ const auto & indexTableDesc = desc.GetPathDescription ().GetTable ();
121+ UNIT_ASSERT_VALUES_EQUAL (indexTableDesc.KeyColumnNamesSize (), 2 );
122+ }
123+ }
124+
125+
61126 Y_UNIT_TEST (Basic) {
62127 Basic (" /Root/Replicated" );
63128 }
@@ -66,6 +131,15 @@ Y_UNIT_TEST_SUITE(DstCreator) {
66131 Basic (" /Root/Dir/Replicated" );
67132 }
68133
134+ Y_UNIT_TEST (WithSyncIndex) {
135+ WithSyncIndex (" /Root/Replicated" );
136+ }
137+
138+ Y_UNIT_TEST (WithSyncIndexWithIntermediateDir) {
139+ WithSyncIndex (" /Root/Dir/Replicated" );
140+ }
141+
142+
69143 Y_UNIT_TEST (SameOwner) {
70144 TEnv env;
71145 env.GetRuntime ().SetLogPriority (NKikimrServices::REPLICATION_CONTROLLER, NLog::PRI_TRACE);
0 commit comments