suneet-s commented on a change in pull request #10929:
URL: https://github.com/apache/druid/pull/10929#discussion_r587807948
##########
File path:
extensions-core/avro-extensions/src/test/java/org/apache/druid/data/input/avro/SchemaRegistryBasedAvroBytesDecoderTest.java
##########
@@ -109,27 +112,50 @@ public void testParse() throws Exception
}
@Test(expected = ParseException.class)
- public void testParseCorrupted() throws Exception
+ public void testParseCorruptedNotEnoughBytesToEvenGetSchemaInfo()
{
// Given
-
Mockito.when(registry.getSchemaById(ArgumentMatchers.eq(1234))).thenReturn(new
AvroSchema(SomeAvroDatum.getClassSchema()));
+ ByteBuffer bb = ByteBuffer.allocate(2).put((byte) 0).put(1, (byte) 1);
+ bb.rewind();
+ // When
+ GenericRecord record = new
SchemaRegistryBasedAvroBytesDecoder(registry).parse(bb);
+ Assert.assertNull(record);
Review comment:
```suggestion
Assert.fail("ParseException should have been thrown");
```
##########
File path:
integration-tests/src/main/java/org/apache/druid/testing/DockerConfigProvider.java
##########
@@ -317,6 +317,17 @@ public String getHistoricalInternalHost()
return "druid-historical";
}
+ @Override
+ public String getSchemaRegistryHost()
+ {
+ return dockerIp + ":8085";
+ }
+
+ @Override
+ public String getSchemaRegistryInternalHost()
+ {
+ return "schema-registry:8085";
+ }
Review comment:
It would be good to add comments here pointing devs to the source of
these definitions. I believe it's
`integration-tests/docker/docker-compose.schema-registry.yml`
##########
File path:
extensions-core/avro-extensions/src/test/java/org/apache/druid/data/input/avro/SchemaRegistryBasedAvroBytesDecoderTest.java
##########
@@ -109,27 +112,50 @@ public void testParse() throws Exception
}
@Test(expected = ParseException.class)
- public void testParseCorrupted() throws Exception
+ public void testParseCorruptedNotEnoughBytesToEvenGetSchemaInfo()
{
// Given
-
Mockito.when(registry.getSchemaById(ArgumentMatchers.eq(1234))).thenReturn(new
AvroSchema(SomeAvroDatum.getClassSchema()));
+ ByteBuffer bb = ByteBuffer.allocate(2).put((byte) 0).put(1, (byte) 1);
+ bb.rewind();
+ // When
+ GenericRecord record = new
SchemaRegistryBasedAvroBytesDecoder(registry).parse(bb);
+ Assert.assertNull(record);
Review comment:
Or just delete this line? Similar comment in `testParseCorruptedPartial`
##########
File path:
integration-tests/src/main/java/org/apache/druid/testing/utils/AvroSchemaRegistryEventSerializer.java
##########
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.testing.utils;
+
+import com.fasterxml.jackson.annotation.JacksonInject;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.google.common.collect.ImmutableMap;
+import io.confluent.kafka.schemaregistry.client.CachedSchemaRegistryClient;
+import org.apache.avro.Schema;
+import org.apache.avro.generic.GenericDatumWriter;
+import org.apache.avro.io.BinaryEncoder;
+import org.apache.avro.io.DatumWriter;
+import org.apache.avro.io.EncoderFactory;
+import org.apache.druid.java.util.common.Pair;
+import org.apache.druid.java.util.common.RetryUtils;
+import org.apache.druid.java.util.common.StringUtils;
+import org.apache.druid.testing.IntegrationTestingConfig;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.List;
+
+public class AvroSchemaRegistryEventSerializer extends AvroEventSerializer
+{
+ private static final int MAX_INITIALIZE_RETRIES = 10;
+ public static final String TYPE = "avro-schema-registry";
+
+ private final IntegrationTestingConfig config;
+ private final CachedSchemaRegistryClient client;
+ private int schemaId = -1;
+
+ private Schema fromRegistry;
+
+ @JsonCreator
+ public AvroSchemaRegistryEventSerializer(
+ @JacksonInject IntegrationTestingConfig config
+ )
+ {
+ this.config = config;
+ this.client = new CachedSchemaRegistryClient(
+ StringUtils.format("http://%s", config.getSchemaRegistryHost()),
+ Integer.MAX_VALUE,
+ ImmutableMap.of(
+ "basic.auth.credentials.source", "USER_INFO",
+ "basic.auth.user.info", "druid:diurd"
Review comment:
Is this meant to always be in sync with
`integration-tests/src/test/resources/stream/data/avro_schema_registry/parser/input_row_parser.json`?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]