Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serde test for JdbcExtractionNamespace. #6186

Merged
merged 1 commit into from
Aug 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public int getPort()
return port;
}

@JsonProperty
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This missing JsonProperty looks a bug. Isn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's not fixing any production bug, since the @JsonProperty on the connectURI field will get used if this one on the getter isn't there. In production that field is always going to be set. So I think this is technically a bug but it only affects test.

public String getConnectURI()
{
if (connectURI == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
import io.druid.common.config.NullHandling;
import io.druid.java.util.common.concurrent.Execs;
import io.druid.java.util.common.StringUtils;
import io.druid.java.util.common.concurrent.Execs;
import io.druid.java.util.common.io.Closer;
import io.druid.java.util.common.lifecycle.Lifecycle;
import io.druid.java.util.common.logger.Logger;
import io.druid.metadata.TestDerbyConnector;
import io.druid.query.lookup.namespace.CacheGenerator;
import io.druid.query.lookup.namespace.ExtractionNamespace;
import io.druid.query.lookup.namespace.JdbcExtractionNamespace;
import io.druid.server.ServerTestHelper;
import io.druid.server.lookup.namespace.JdbcCacheGenerator;
import io.druid.server.lookup.namespace.NamespaceExtractionConfig;
import io.druid.server.metrics.NoopServiceEmitter;
Expand Down Expand Up @@ -225,7 +227,11 @@ public CacheScheduler.VersionedCache generateCache(
}
}
),
new OnHeapNamespaceExtractionCacheManager(lifecycle, noopServiceEmitter, new NamespaceExtractionConfig())
new OnHeapNamespaceExtractionCacheManager(
lifecycle,
noopServiceEmitter,
new NamespaceExtractionConfig()
)
);
try {
lifecycle.start();
Expand Down Expand Up @@ -382,7 +388,11 @@ public void testMappingWithoutFilter()
String key = e.getKey();
String[] val = e.getValue();
String field = val[0];
Assert.assertEquals("non-null check", NullHandling.emptyToNullIfNeeded(field), NullHandling.emptyToNullIfNeeded(map.get(key)));
Assert.assertEquals(
"non-null check",
NullHandling.emptyToNullIfNeeded(field),
NullHandling.emptyToNullIfNeeded(map.get(key))
);
}
Assert.assertEquals("null check", null, map.get("baz"));
}
Expand Down Expand Up @@ -412,7 +422,11 @@ public void testMappingWithFilter()
String filterVal = val[1];

if ("1".equals(filterVal)) {
Assert.assertEquals("non-null check", NullHandling.emptyToNullIfNeeded(field), NullHandling.emptyToNullIfNeeded(map.get(key)));
Assert.assertEquals(
"non-null check",
NullHandling.emptyToNullIfNeeded(field),
NullHandling.emptyToNullIfNeeded(map.get(key))
);
} else {
Assert.assertEquals("non-null check", null, NullHandling.emptyToNullIfNeeded(map.get(key)));
}
Expand Down Expand Up @@ -457,6 +471,27 @@ public void testIgnoresNullValues()
}
}

@Test
public void testSerde() throws IOException
{
final JdbcExtractionNamespace extractionNamespace = new JdbcExtractionNamespace(
derbyConnectorRule.getMetadataConnectorConfig(),
tableName,
keyName,
valName,
tsColumn,
"some filter",
new Period(10)
);

final ExtractionNamespace extractionNamespace2 = ServerTestHelper.MAPPER.readValue(
ServerTestHelper.MAPPER.writeValueAsBytes(extractionNamespace),
ExtractionNamespace.class
);

Assert.assertEquals(extractionNamespace, extractionNamespace2);
}

private CacheScheduler.Entry ensureEntry()
throws InterruptedException
{
Expand Down