@@ -4368,11 +4368,10 @@ public void testStoreIngestionRecordTransformerError(AAConfig aaConfig) throws E
4368
4368
4369
4369
@ DataProvider
4370
4370
public static Object [][] testAssembledValueSizeProvider () {
4371
- Set <Integer > schemaIdSet = new HashSet <>();
4372
- for (AvroProtocolDefinition avroProtocolDefinition : AvroProtocolDefinition .values ()) {
4373
- avroProtocolDefinition .currentProtocolVersion .ifPresent (schemaIdSet ::add );
4374
- }
4375
- return DataProviderUtils .allPermutationGenerator (AAConfig .values (), schemaIdSet .toArray ());
4371
+ Object [] testSchemaIds =
4372
+ { VeniceWriter .VENICE_DEFAULT_VALUE_SCHEMA_ID , AvroProtocolDefinition .CHUNK .getCurrentProtocolVersion (),
4373
+ AvroProtocolDefinition .CHUNKED_VALUE_MANIFEST .getCurrentProtocolVersion () };
4374
+ return DataProviderUtils .allPermutationGenerator (AAConfig .values (), testSchemaIds , DataProviderUtils .BOOLEAN );
4376
4375
}
4377
4376
4378
4377
/**
@@ -4383,7 +4382,7 @@ public static Object[][] testAssembledValueSizeProvider() {
4383
4382
* @throws Exception
4384
4383
*/
4385
4384
@ Test (dataProvider = "testAssembledValueSizeProvider" )
4386
- public void testAssembledValueSizeSensor (AAConfig aaConfig , int testSchemaId ) throws Exception {
4385
+ public void testAssembledValueSizeSensor (AAConfig aaConfig , int testSchemaId , boolean hasRmd ) throws Exception {
4387
4386
int numChunks = 10 ;
4388
4387
long expectedRecordSize = (long ) numChunks * ChunkingTestUtils .CHUNK_LENGTH ;
4389
4388
PubSubTopicPartition tp = new PubSubTopicPartitionImpl (pubSubTopic , PARTITION_FOO );
@@ -4395,8 +4394,6 @@ public void testAssembledValueSizeSensor(AAConfig aaConfig, int testSchemaId) th
4395
4394
ChunkingTestUtils .createChunkValueManifestRecord (putKeyFoo , messages .get (0 ), numChunks , tp );
4396
4395
messages .add (manifestMessage );
4397
4396
4398
- // The only expected real-life case should be when schemaId values are chunk=-10 and manifest=-20
4399
- boolean useRealSchemaId = testSchemaId == AvroProtocolDefinition .CHUNKED_VALUE_MANIFEST .getCurrentProtocolVersion ();
4400
4397
runTest (Collections .singleton (PARTITION_FOO ), () -> {
4401
4398
TestUtils .waitForNonDeterministicAssertion (
4402
4399
5 ,
@@ -4406,8 +4403,9 @@ public void testAssembledValueSizeSensor(AAConfig aaConfig, int testSchemaId) th
4406
4403
for (PubSubMessage <KafkaKey , KafkaMessageEnvelope , Long > message : messages ) {
4407
4404
try {
4408
4405
Put put = (Put ) message .getValue ().getPayloadUnion ();
4409
- if (!useRealSchemaId ) {
4410
- put .schemaId = testSchemaId ;
4406
+ if (put .schemaId == AvroProtocolDefinition .CHUNKED_VALUE_MANIFEST .getCurrentProtocolVersion ()) {
4407
+ put .schemaId = testSchemaId ; // set manifest schemaId to testSchemaId to see if metrics are still recorded
4408
+ put .replicationMetadataPayload = (hasRmd ) ? ByteBuffer .allocate (10 ) : VeniceWriter .EMPTY_BYTE_BUFFER ;
4411
4409
}
4412
4410
LeaderProducedRecordContext leaderProducedRecordContext = mock (LeaderProducedRecordContext .class );
4413
4411
when (leaderProducedRecordContext .getMessageType ()).thenReturn (MessageType .PUT );
@@ -4426,13 +4424,25 @@ public void testAssembledValueSizeSensor(AAConfig aaConfig, int testSchemaId) th
4426
4424
}
4427
4425
}
4428
4426
4429
- // Verify that the size of the assembled record was recorded in the metrics only if schemaId=-20
4427
+ // Verify that the assembled record metrics are only recorded if schemaId=-20 which indicates a manifest
4430
4428
HostLevelIngestionStats hostLevelIngestionStats = storeIngestionTaskUnderTest .hostLevelIngestionStats ;
4431
- if (useRealSchemaId ) {
4432
- verify (hostLevelIngestionStats , timeout (1000 )).recordAssembledValueSize (eq (expectedRecordSize ), anyLong ());
4433
- verify (hostLevelIngestionStats , timeout (1000 ).times (1 )).recordAssembledValueSize (anyLong (), anyLong ());
4429
+ if (testSchemaId == AvroProtocolDefinition .CHUNKED_VALUE_MANIFEST .getCurrentProtocolVersion ()) {
4430
+ if (hasRmd ) { // should have metrics for rmd but not value size
4431
+ verify (hostLevelIngestionStats , timeout (1000 )).recordAssembledRmdSize (eq (expectedRecordSize ), anyLong ());
4432
+ verify (hostLevelIngestionStats , timeout (1000 ).times (1 )).recordAssembledRmdSize (anyLong (), anyLong ());
4433
+ verify (hostLevelIngestionStats , times (0 )).recordAssembledValueSize (anyLong (), anyLong ());
4434
+ verify (hostLevelIngestionStats , times (0 )).recordAssembledRecordSizeRatio (anyDouble (), anyLong ());
4435
+ } else { // should have metrics for value but not rmd size
4436
+ verify (hostLevelIngestionStats , timeout (1000 )).recordAssembledValueSize (eq (expectedRecordSize ), anyLong ());
4437
+ verify (hostLevelIngestionStats , timeout (1000 ).times (1 )).recordAssembledValueSize (anyLong (), anyLong ());
4438
+ verify (hostLevelIngestionStats , timeout (1000 ).times (1 ))
4439
+ .recordAssembledRecordSizeRatio (anyDouble (), anyLong ());
4440
+ verify (hostLevelIngestionStats , times (0 )).recordAssembledRmdSize (anyLong (), anyLong ());
4441
+ }
4434
4442
} else {
4435
4443
verify (hostLevelIngestionStats , times (0 )).recordAssembledValueSize (anyLong (), anyLong ());
4444
+ verify (hostLevelIngestionStats , times (0 )).recordAssembledRmdSize (anyLong (), anyLong ());
4445
+ verify (hostLevelIngestionStats , times (0 )).recordAssembledRecordSizeRatio (anyDouble (), anyLong ());
4436
4446
}
4437
4447
}, aaConfig );
4438
4448
}
0 commit comments