@@ -1000,6 +1000,11 @@ Y_UNIT_TEST_SUITE(KafkaProtocol) {
1000
1000
TString topicName = " /Root/topic-0-test" ;
1001
1001
TString shortTopicName = " topic-0-test" ;
1002
1002
TString notExistsTopicName = " /Root/not-exists" ;
1003
+
1004
+ TString tableName = " /Root/table-0-test" ;
1005
+ TString feedName = " feed" ;
1006
+ TString feedPath = tableName + " /" + feedName;
1007
+
1003
1008
ui64 minActivePartitions = 10 ;
1004
1009
1005
1010
TString key = " record-key" ;
@@ -1207,6 +1212,60 @@ Y_UNIT_TEST_SUITE(KafkaProtocol) {
1207
1212
}
1208
1213
}
1209
1214
1215
+ {
1216
+ NYdb::NTable::TTableClient tableClient (*testServer.Driver );
1217
+ tableClient.RetryOperationSync ([&](TSession session)
1218
+ {
1219
+ NYdb::NTable::TTableBuilder builder;
1220
+ builder.AddNonNullableColumn (" key" , NYdb::EPrimitiveType::Int64).SetPrimaryKeyColumn (" key" );
1221
+ builder.AddNonNullableColumn (" value" , NYdb::EPrimitiveType::Int64);
1222
+
1223
+ auto createResult = session.CreateTable (tableName, builder.Build ()).ExtractValueSync ();
1224
+ UNIT_ASSERT_VALUES_EQUAL (createResult.IsTransportError (), false );
1225
+ Cerr << createResult.GetIssues ().ToString () << " \n " ;
1226
+ UNIT_ASSERT_VALUES_EQUAL (createResult.GetStatus (), EStatus::SUCCESS);
1227
+
1228
+ auto alterResult = session.AlterTable (tableName, NYdb::NTable::TAlterTableSettings ()
1229
+ .AppendAddChangefeeds (NYdb::NTable::TChangefeedDescription (feedName,
1230
+ NYdb::NTable::EChangefeedMode::Updates,
1231
+ NYdb::NTable::EChangefeedFormat::Json))
1232
+ ).ExtractValueSync ();
1233
+ Cerr << alterResult.GetIssues ().ToString () << " \n " ;
1234
+ UNIT_ASSERT_VALUES_EQUAL (alterResult.IsTransportError (), false );
1235
+ UNIT_ASSERT_VALUES_EQUAL (alterResult.GetStatus (), EStatus::SUCCESS);
1236
+ return alterResult;
1237
+ }
1238
+ );
1239
+
1240
+ TValueBuilder rows;
1241
+ rows.BeginList ();
1242
+ rows.AddListItem ()
1243
+ .BeginStruct ()
1244
+ .AddMember (" key" ).Int64 (1 )
1245
+ .AddMember (" value" ).Int64 (2 )
1246
+ .EndStruct ();
1247
+ rows.EndList ();
1248
+
1249
+ auto upsertResult = tableClient.BulkUpsert (tableName, rows.Build ()).GetValueSync ();
1250
+ UNIT_ASSERT_EQUAL (upsertResult.GetStatus (), EStatus::SUCCESS);
1251
+ }
1252
+
1253
+ {
1254
+ // Check CDC
1255
+ std::vector<std::pair<TString, std::vector<i32 >>> topics {{feedPath, {0 }}};
1256
+ auto msg = client.Fetch (topics);
1257
+ UNIT_ASSERT_VALUES_EQUAL (msg->Responses .size (), 1 );
1258
+ UNIT_ASSERT_VALUES_EQUAL (msg->Responses [0 ].Partitions .size (), 1 );
1259
+ UNIT_ASSERT_VALUES_EQUAL (msg->Responses [0 ].Partitions [0 ].ErrorCode , static_cast <TKafkaInt16>(EKafkaErrors::NONE_ERROR));
1260
+ UNIT_ASSERT_VALUES_EQUAL (msg->Responses [0 ].Partitions [0 ].Records .has_value (), true );
1261
+ UNIT_ASSERT_VALUES_EQUAL (msg->Responses [0 ].Partitions [0 ].Records ->Records .size (), 1 );
1262
+ auto record = msg->Responses [0 ].Partitions [0 ].Records ->Records [0 ];
1263
+
1264
+ auto data = record.Value .value ();
1265
+ auto dataStr = TString (data.data (), data.size ());
1266
+ UNIT_ASSERT_VALUES_EQUAL (dataStr, " {\" update\" :{\" value\" :2},\" key\" :[1]}" );
1267
+ }
1268
+
1210
1269
} // Y_UNIT_TEST(FetchScenario)
1211
1270
1212
1271
Y_UNIT_TEST (BalanceScenario) {
@@ -2300,4 +2359,53 @@ Y_UNIT_TEST_SUITE(KafkaProtocol) {
2300
2359
2301
2360
Sleep (TDuration::Seconds (1 ));
2302
2361
}
2362
+
2363
+ Y_UNIT_TEST (LoginWithApiKeyWithoutAt) {
2364
+ TInsecureTestServer testServer;
2365
+
2366
+ TString topicName = " /Root/topic-0-test" ;
2367
+
2368
+ NYdb::NTopic::TTopicClient pqClient (*testServer.Driver );
2369
+ {
2370
+ auto result =
2371
+ pqClient
2372
+ .CreateTopic (topicName,
2373
+ NYdb::NTopic::TCreateTopicSettings ()
2374
+ .PartitioningSettings (10 , 100 )
2375
+ .BeginAddConsumer (" consumer-0" ).EndAddConsumer ())
2376
+ .ExtractValueSync ();
2377
+ UNIT_ASSERT_VALUES_EQUAL (result.IsTransportError (), false );
2378
+ UNIT_ASSERT_VALUES_EQUAL (result.GetStatus (), EStatus::SUCCESS);
2379
+ }
2380
+
2381
+ auto settings = NTopic::TReadSessionSettings ()
2382
+ .AppendTopics (NTopic::TTopicReadSettings (topicName))
2383
+ .ConsumerName (" consumer-0" );
2384
+ auto topicReader = pqClient.CreateReadSession (settings);
2385
+
2386
+ TTestClient client (testServer.Port );
2387
+
2388
+ {
2389
+ auto msg = client.ApiVersions ();
2390
+
2391
+ UNIT_ASSERT_VALUES_EQUAL (msg->ErrorCode , static_cast <TKafkaInt16>(EKafkaErrors::NONE_ERROR));
2392
+ UNIT_ASSERT_VALUES_EQUAL (msg->ApiKeys .size (), 18u );
2393
+ }
2394
+
2395
+ {
2396
+ auto msg = client.SaslHandshake ();
2397
+
2398
+ UNIT_ASSERT_VALUES_EQUAL (msg->ErrorCode , static_cast <TKafkaInt16>(EKafkaErrors::NONE_ERROR));
2399
+ UNIT_ASSERT_VALUES_EQUAL (msg->Mechanisms .size (), 1u );
2400
+ UNIT_ASSERT_VALUES_EQUAL (*msg->Mechanisms [0 ], " PLAIN" );
2401
+ }
2402
+
2403
+ {
2404
+ auto msg = client.SaslAuthenticate (" /Root" , " ApiKey-value-valid" );
2405
+ Cerr << msg->ErrorMessage << " \n " ;
2406
+ UNIT_ASSERT_VALUES_EQUAL (msg->ErrorCode , static_cast <TKafkaInt16>(EKafkaErrors::NONE_ERROR));
2407
+ }
2408
+
2409
+ Sleep (TDuration::Seconds (1 ));
2410
+ }
2303
2411
} // Y_UNIT_TEST_SUITE(KafkaProtocol)
0 commit comments