@@ -4368,11 +4368,10 @@ public void testStoreIngestionRecordTransformerError(AAConfig aaConfig) throws E
43684368
43694369 @ DataProvider
43704370 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 );
43764375 }
43774376
43784377 /**
@@ -4383,7 +4382,7 @@ public static Object[][] testAssembledValueSizeProvider() {
43834382 * @throws Exception
43844383 */
43854384 @ 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 {
43874386 int numChunks = 10 ;
43884387 long expectedRecordSize = (long ) numChunks * ChunkingTestUtils .CHUNK_LENGTH ;
43894388 PubSubTopicPartition tp = new PubSubTopicPartitionImpl (pubSubTopic , PARTITION_FOO );
@@ -4395,8 +4394,6 @@ public void testAssembledValueSizeSensor(AAConfig aaConfig, int testSchemaId) th
43954394 ChunkingTestUtils .createChunkValueManifestRecord (putKeyFoo , messages .get (0 ), numChunks , tp );
43964395 messages .add (manifestMessage );
43974396
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 ();
44004397 runTest (Collections .singleton (PARTITION_FOO ), () -> {
44014398 TestUtils .waitForNonDeterministicAssertion (
44024399 5 ,
@@ -4406,8 +4403,9 @@ public void testAssembledValueSizeSensor(AAConfig aaConfig, int testSchemaId) th
44064403 for (PubSubMessage <KafkaKey , KafkaMessageEnvelope , Long > message : messages ) {
44074404 try {
44084405 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 ;
44114409 }
44124410 LeaderProducedRecordContext leaderProducedRecordContext = mock (LeaderProducedRecordContext .class );
44134411 when (leaderProducedRecordContext .getMessageType ()).thenReturn (MessageType .PUT );
@@ -4426,13 +4424,25 @@ public void testAssembledValueSizeSensor(AAConfig aaConfig, int testSchemaId) th
44264424 }
44274425 }
44284426
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
44304428 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+ }
44344442 } else {
44354443 verify (hostLevelIngestionStats , times (0 )).recordAssembledValueSize (anyLong (), anyLong ());
4444+ verify (hostLevelIngestionStats , times (0 )).recordAssembledRmdSize (anyLong (), anyLong ());
4445+ verify (hostLevelIngestionStats , times (0 )).recordAssembledRecordSizeRatio (anyDouble (), anyLong ());
44364446 }
44374447 }, aaConfig );
44384448 }
0 commit comments