mirror of https://github.com/apache/druid.git
Make KafkaLookupExtractorFactoryTest fast (#4466)
* Make KafkaLookupExtractorFactoryTest fast * Use list * Use Bytes
This commit is contained in:
parent
0f99467cfb
commit
5fec619284
|
@ -26,6 +26,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.primitives.Bytes;
|
||||
import io.druid.jackson.DefaultObjectMapper;
|
||||
import io.druid.java.util.common.StringUtils;
|
||||
import io.druid.server.lookup.namespace.cache.CacheHandler;
|
||||
|
@ -47,11 +48,12 @@ import org.powermock.core.classloader.annotations.PowerMockIgnore;
|
|||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
@ -129,18 +131,15 @@ public class KafkaLookupExtractorFactoryTest
|
|||
TOPIC,
|
||||
DEFAULT_PROPERTIES
|
||||
);
|
||||
factory.getMapRef().set(ImmutableMap.<String, String>of());
|
||||
factory.getMapRef().set(ImmutableMap.of());
|
||||
final AtomicLong events = factory.getDoubleEventCount();
|
||||
|
||||
final LookupExtractor extractor = factory.get();
|
||||
|
||||
final List<byte[]> byteArrays = new ArrayList<>(n);
|
||||
final Set<List<Byte>> byteArrays = new HashSet<>(n);
|
||||
for (int i = 0; i < n; ++i) {
|
||||
final byte[] myKey = extractor.getCacheKey();
|
||||
// Not terribly efficient.. but who cares
|
||||
for (byte[] byteArray : byteArrays) {
|
||||
Assert.assertFalse(Arrays.equals(byteArray, myKey));
|
||||
}
|
||||
final List<Byte> myKey = Bytes.asList(extractor.getCacheKey());
|
||||
Assert.assertFalse(byteArrays.contains(myKey));
|
||||
byteArrays.add(myKey);
|
||||
events.incrementAndGet();
|
||||
}
|
||||
|
@ -156,17 +155,14 @@ public class KafkaLookupExtractorFactoryTest
|
|||
TOPIC,
|
||||
DEFAULT_PROPERTIES
|
||||
);
|
||||
factory.getMapRef().set(ImmutableMap.<String, String>of());
|
||||
factory.getMapRef().set(ImmutableMap.of());
|
||||
final AtomicLong events = factory.getDoubleEventCount();
|
||||
|
||||
final List<byte[]> byteArrays = new ArrayList<>(n);
|
||||
final Set<List<Byte>> byteArrays = new HashSet<>(n);
|
||||
for (int i = 0; i < n; ++i) {
|
||||
final LookupExtractor extractor = factory.get();
|
||||
final byte[] myKey = extractor.getCacheKey();
|
||||
// Not terribly efficient.. but who cares
|
||||
for (byte[] byteArray : byteArrays) {
|
||||
Assert.assertFalse(Arrays.equals(byteArray, myKey));
|
||||
}
|
||||
final List<Byte> myKey = Bytes.asList(extractor.getCacheKey());
|
||||
Assert.assertFalse(byteArrays.contains(myKey));
|
||||
byteArrays.add(myKey);
|
||||
events.incrementAndGet();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue