@@ -71,6 +71,51 @@ Y_UNIT_TEST_SUITE(StreamCreator) {
7171 Y_UNIT_TEST (WithResolvedTimestamps) {
7272 Basic (TDuration::Seconds (10 ));
7373 }
74+
75+ void TopicAutoPartitioning (bool enabled) {
76+ TEnv env (TFeatureFlags ().SetEnableTopicAutopartitioningForCDC (true ));
77+ env.GetRuntime ().SetLogPriority (NKikimrServices::REPLICATION_CONTROLLER, NLog::PRI_TRACE);
78+
79+ env.CreateTable (" /Root" , *MakeTableDescription (TTestTableDescription{
80+ .Name = " Table" ,
81+ .KeyColumns = {" key" },
82+ .Columns = {
83+ {.Name = " key" , .Type = " Uint32" },
84+ {.Name = " value" , .Type = " Utf8" },
85+ },
86+ .ReplicationConfig = Nothing (),
87+ }));
88+
89+ env.GetRuntime ().Register (CreateStreamCreator (
90+ env.GetSender (), env.GetYdbProxy (), 1 /* rid */ , 1 /* tid */ ,
91+ std::make_shared<TTargetTable::TTableConfig>(" /Root/Table" , " /Root/Replica" ),
92+ " Stream" , " replicationConsumer" , TDuration::Hours (1 ), std::nullopt , enabled
93+ ));
94+ {
95+ auto ev = env.GetRuntime ().GrabEdgeEvent <TEvPrivate::TEvRequestCreateStream>(env.GetSender ());
96+ env.GetRuntime ().Send (ev->Sender , env.GetSender (), new TEvPrivate::TEvAllowCreateStream ());
97+ }
98+ {
99+ auto ev = env.GetRuntime ().GrabEdgeEvent <TEvPrivate::TEvCreateStreamResult>(env.GetSender ());
100+ UNIT_ASSERT (ev->Get ()->IsSuccess ());
101+ }
102+
103+ auto desc = env.GetDescription (" /Root/Table/Stream/streamImpl" );
104+
105+ const auto & pqconfig = desc.GetPathDescription ().GetPersQueueGroup ().GetPQTabletConfig ();
106+ const auto & strategy = pqconfig.GetPartitionStrategy ();
107+
108+ if (enabled) {
109+ UNIT_ASSERT_EQUAL (strategy.GetPartitionStrategyType (), NKikimrPQ::TPQTabletConfig::CAN_SPLIT);
110+ } else {
111+ UNIT_ASSERT_EQUAL (strategy.GetPartitionStrategyType (), NKikimrPQ::TPQTabletConfig::DISABLED);
112+ }
113+ }
114+
115+ Y_UNIT_TEST (TopicAutoPartitioning) {
116+ TopicAutoPartitioning (true );
117+ TopicAutoPartitioning (false );
118+ }
74119}
75120
76121}
0 commit comments