@@ -1134,6 +1134,7 @@ Y_UNIT_TEST_SUITE(TCdcStreamTests) {
1134
1134
TTestBasicRuntime runtime;
1135
1135
TTestEnv env (runtime, TTestEnvOptions ()
1136
1136
.EnableProtoSourceIdInfo (true )
1137
+ .EnableChangefeedInitialScan (true )
1137
1138
.EnablePqBilling (serverless));
1138
1139
ui64 txId = 100 ;
1139
1140
@@ -1202,25 +1203,44 @@ Y_UNIT_TEST_SUITE(TCdcStreamTests) {
1202
1203
NLs::PathExist,
1203
1204
NLs::ExtractTenantSchemeshard (&schemeShard)
1204
1205
});
1205
-
1206
1206
UNIT_ASSERT (schemeShard != 0 && schemeShard != TTestTxConfig::SchemeShard);
1207
1207
1208
1208
TestCreateTable (runtime, schemeShard, ++txId, dbName, R"(
1209
1209
Name: "Table"
1210
1210
Columns { Name: "key" Type: "Uint64" }
1211
- Columns { Name: "value" Type: "Uint64 " }
1211
+ Columns { Name: "value" Type: "Utf8 " }
1212
1212
KeyColumnNames: ["key"]
1213
1213
UniformPartitionsCount: 2
1214
1214
)" );
1215
1215
env.TestWaitNotification (runtime, txId, schemeShard);
1216
1216
1217
1217
runtime.SetLogPriority (NKikimrServices::PERSQUEUE, NLog::PRI_NOTICE);
1218
+ {
1219
+ // should write at least 16MiB to exceed the topics non-metered limit
1220
+ const TString value = TString (500_KB, ' x' );
1221
+ for (size_t i = 0 ; i < 100 ; ++i) {
1222
+ const unsigned key = 3000 + i;
1223
+ const TString writeQuery = Sprintf (R"(
1224
+ (
1225
+ (let key '( '('key (Uint64 '%u ) ) ) )
1226
+ (let row '( '('value (Utf8 '%s) ) ) )
1227
+ (return (AsList (UpdateRow '__user__%s key row) ))
1228
+ )
1229
+ )" , key, value.c_str (), " Table" );
1230
+ NKikimrMiniKQL::TResult result;
1231
+ TString err;
1232
+ NKikimrProto::EReplyStatus status = LocalMiniKQL (runtime, TTestTxConfig::FakeHiveTablets + 6 , writeQuery, result, err);
1233
+ UNIT_ASSERT_VALUES_EQUAL (err, " " );
1234
+ UNIT_ASSERT_VALUES_EQUAL (status, NKikimrProto::EReplyStatus::OK);
1235
+ }
1236
+ }
1237
+
1218
1238
TVector<TString> meteringRecords;
1219
1239
runtime.SetObserverFunc ([&meteringRecords](TAutoPtr<IEventHandle>& ev) {
1220
1240
if (ev->GetTypeRewrite () != NMetering::TEvMetering::EvWriteMeteringJson) {
1221
1241
return TTestActorRuntime::EEventAction::PROCESS;
1222
1242
}
1223
-
1243
+ Cerr << " GOT METERING RECORD: " << ev-> Get <NMetering::TEvMetering::TEvWriteMeteringJson>()-> MeteringJson << Endl;
1224
1244
meteringRecords.push_back (ev->Get <NMetering::TEvMetering::TEvWriteMeteringJson>()->MeteringJson );
1225
1245
return TTestActorRuntime::EEventAction::PROCESS;
1226
1246
});
@@ -1229,8 +1249,9 @@ Y_UNIT_TEST_SUITE(TCdcStreamTests) {
1229
1249
TableName: "Table"
1230
1250
StreamDescription {
1231
1251
Name: "Stream"
1232
- Mode: ECdcStreamModeKeysOnly
1252
+ Mode: ECdcStreamModeNewImage
1233
1253
Format: ECdcStreamFormatProto
1254
+ State: ECdcStreamStateScan
1234
1255
}
1235
1256
)" );
1236
1257
env.TestWaitNotification (runtime, txId, schemeShard);
@@ -1239,26 +1260,22 @@ Y_UNIT_TEST_SUITE(TCdcStreamTests) {
1239
1260
env.SimulateSleep (runtime, TDuration::Seconds (10 ));
1240
1261
}
1241
1262
1242
- for (const auto & rec : meteringRecords) {
1243
- Cerr << " GOT METERING: " << rec << " \n " ;
1244
- }
1245
-
1246
1263
UNIT_ASSERT_VALUES_EQUAL (meteringRecords.size (), (serverless ? 3 : 0 ));
1247
1264
1248
1265
if (!meteringRecords) {
1249
1266
return ;
1250
1267
}
1251
1268
1252
1269
NJson::TJsonValue json;
1253
- NJson::ReadJsonTree (meteringRecords[ 0 ] , &json, true );
1270
+ NJson::ReadJsonTree (meteringRecords. back () , &json, true );
1254
1271
auto & map = json.GetMap ();
1255
1272
UNIT_ASSERT (map.contains (" schema" ));
1256
1273
UNIT_ASSERT (map.contains (" resource_id" ));
1257
1274
UNIT_ASSERT (map.contains (" tags" ));
1258
1275
UNIT_ASSERT (map.find (" tags" )->second .GetMap ().contains (" ydb_size" ));
1259
1276
UNIT_ASSERT_VALUES_EQUAL (map.find (" schema" )->second .GetString (), " ydb.serverless.v1" );
1260
1277
UNIT_ASSERT_VALUES_EQUAL (map.find (" resource_id" )->second .GetString (), Sprintf (" %s/Table/Stream/streamImpl" , dbName.c_str ()));
1261
- UNIT_ASSERT_VALUES_EQUAL (map.find (" tags" )->second .GetMap ().find (" ydb_size" )->second .GetInteger (), 0 );
1278
+ UNIT_ASSERT_GT (map.find (" tags" )->second .GetMap ().find (" ydb_size" )->second .GetInteger (), 0 );
1262
1279
}
1263
1280
1264
1281
Y_UNIT_TEST (MeteringServerless) {
0 commit comments