@@ -1252,11 +1252,63 @@ TCheckFunc PartitionKeys(TVector<TString> lastShardKeys) {
1252
1252
const auto & pathDescr = record.GetPathDescription ();
1253
1253
UNIT_ASSERT_VALUES_EQUAL (lastShardKeys.size (), pathDescr.TablePartitionsSize ());
1254
1254
for (size_t i = 0 ; i < lastShardKeys.size (); ++i) {
1255
- UNIT_ASSERT_STRING_CONTAINS (pathDescr.GetTablePartitions (i).GetEndOfRangeKeyPrefix (), lastShardKeys[i]);
1255
+ const auto & partition = pathDescr.GetTablePartitions (i);
1256
+ UNIT_ASSERT_STRING_CONTAINS_C (
1257
+ partition.GetEndOfRangeKeyPrefix (), lastShardKeys[i],
1258
+ " partition index: " << i << ' \n '
1259
+ << " actual key prefix: " << partition.GetEndOfRangeKeyPrefix ().Quote () << ' \n '
1260
+ << " expected key prefix: " << lastShardKeys[i].Quote () << ' \n '
1261
+ );
1256
1262
}
1257
1263
};
1258
1264
}
1259
1265
1266
+ namespace {
1267
+
1268
+ // Serializes / deserializes a value of type T to a cell vector string representation.
1269
+ template <typename T>
1270
+ struct TSplitBoundarySerializer {
1271
+ static TString Serialize (T splitBoundary) {
1272
+ const auto cell = TCell::Make (splitBoundary);
1273
+ TSerializedCellVec cellVec (TArrayRef<const TCell>(&cell, 1 ));
1274
+ return cellVec.ReleaseBuffer ();
1275
+ }
1276
+
1277
+ static TVector<T> Deserialize (const TString& serializedCells) {
1278
+ TSerializedCellVec cells (serializedCells);
1279
+ TVector<T> values;
1280
+ for (const auto & cell : cells.GetCells ()) {
1281
+ if (cell.IsNull ()) {
1282
+ // the last cell
1283
+ break ;
1284
+ }
1285
+ values.emplace_back (cell.AsValue <T>());
1286
+ }
1287
+ return values;
1288
+ }
1289
+ };
1290
+
1291
+ }
1292
+
1293
+ template <typename T>
1294
+ TCheckFunc SplitBoundaries (TVector<T>&& expectedBoundaries) {
1295
+ return [expectedBoundaries = std::move (expectedBoundaries)] (const NKikimrScheme::TEvDescribeSchemeResult& record) {
1296
+ const auto & pathDescr = record.GetPathDescription ();
1297
+ UNIT_ASSERT_VALUES_EQUAL (pathDescr.TablePartitionsSize (), expectedBoundaries.size () + 1 );
1298
+ for (size_t i = 0 ; i < expectedBoundaries.size (); ++i) {
1299
+ const auto & partition = pathDescr.GetTablePartitions (i);
1300
+ const auto actualBoundary = TSplitBoundarySerializer<T>::Deserialize (partition.GetEndOfRangeKeyPrefix ()).at (0 );
1301
+ UNIT_ASSERT_VALUES_EQUAL_C (
1302
+ actualBoundary, expectedBoundaries[i],
1303
+ " partition index: " << i << ' \n '
1304
+ << " actual key prefix: " << partition.GetEndOfRangeKeyPrefix ().Quote () << ' \n '
1305
+ );
1306
+ }
1307
+ };
1308
+ }
1309
+
1310
+ template TCheckFunc SplitBoundaries<ui32>(TVector<ui32>&&);
1311
+
1260
1312
TCheckFunc ServerlessComputeResourcesMode (NKikimrSubDomains::EServerlessComputeResourcesMode serverlessComputeResourcesMode) {
1261
1313
return [=] (const NKikimrScheme::TEvDescribeSchemeResult& record) {
1262
1314
UNIT_ASSERT_C (IsGoodDomainStatus (record.GetStatus ()), " Unexpected status: " << record.GetStatus ());
0 commit comments