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

abolish scala. make test harnesses java, avoid any link-time dependency on scala #65

Merged
merged 3 commits into from
Sep 28, 2017

Conversation

radai-rosenblatt
Copy link
Contributor

No description provided.

@@ -17,12 +17,13 @@
public interface UUIDFactory<K, V> extends Configurable {

/**
* Get a random UUID.
* @return a random UUID
Copy link
Contributor

Choose a reason for hiding this comment

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

If you are cleaning up documentation then you might as well change this to something like "a non-null UUID". The UUID does not need to be random.

@@ -1052,6 +1055,14 @@ private void produceSyntheticMessages(String topic) {
producer.close();
}

//TODO - remove / refactor
private Producer<byte[], byte[]> createKafkaProducer() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we default all tests to SSL?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no. this method is rather hacky and creates an ad-hoc producer<byte[], byte[]> where the rest of the harness code creates <string, string>, and so should be cleaned up somehow.
however, our tests currently rely on this heavily nd i didnt want ot make this PR any bogger.

@Override
public void tearDown() {
try {
//TODO - something here ?
Copy link
Contributor

Choose a reason for hiding this comment

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

Eh?


//apply overrides
if (overrides != null) {
overrides.forEach(result::put);
Copy link
Contributor

Choose a reason for hiding this comment

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

result.putAll(overrides)?

}


protected List<Map<Object, Object>> buildBrokerConfigs() {
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be useful to add documentation about this return value so the user knows that returnValue.get(i) is a config for the ith broker.

package com.linkedin.kafka.clients.utils.tests;

public abstract class AbstractZookeeperTestHarness {
protected EmbeddedZookeeper zookeeper = null;
Copy link
Contributor

Choose a reason for hiding this comment

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

zookeeper -> _zookeeper

@@ -2,7 +2,7 @@
# Copyright 2017 LinkedIn Corp. Licensed under the BSD 2-Clause License (the "License").
 See License in the project root for license information.
#

log4j.rootLogger=OFF, stdout
log4j.rootLogger=DEBUG, stdout
Copy link
Contributor

Choose a reason for hiding this comment

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

Accidental change?

@@ -0,0 +1,26 @@
/*
Copy link
Contributor

Choose a reason for hiding this comment

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

This test is really weird....

@@ -50,7 +47,7 @@ public int clusterSize() {
@Override
public Properties overridingProps() {
Properties props = new Properties();
props.setProperty(KafkaConfig.NumPartitionsProp(), Integer.toString(NUM_PARTITIONS));
props.setProperty("num.partitions", Integer.toString(NUM_PARTITIONS));
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems safer to use the method instead of hard coding 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.

that prop is in scala code. it is unclean ...

try {
FileUtils.forceDelete(toCleanUp);
} catch (IOException issue) {
issue.printStackTrace(System.err);
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe rethrow the exception to let the uncaught exception handler handle it.

return consumer;
}

public static int getAvailableTcpPort() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we reuse the KafkaServer.boundPort() method and ZookeeperServer.getClientPort() instead of writing our own method?

}
} else {
if (trustStoreFile() != null) {
throw new AssertionError("security protocol not yet yet trust store file provided");
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand this error message.

private final static Method SHUTDOWN_METHOD;
private final static Method AWAIT_SHUTDOWN_METHOD;
private final static Object EMPTY_OPTION;
private final static Pattern LISTENER_PATTERN = Pattern.compile("\\s*(\\w+)://([\\w\\d]+):(\\d+)\\s*");
Copy link
Contributor

Choose a reason for hiding this comment

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

This won't match IPv6 addresses which someone might want to use if they were testing that IPv6 worked.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

@smccauliff smccauliff Sep 28, 2017

Choose a reason for hiding this comment

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

Probably the \s* at the beginning and end is not needed if matcher.find() is used.

return this;
}

public EmbeddedBrokerBuilder trustStore(File trustStore) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do the trust stores need to be files or can they be resources so that you can package truststores in the source code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the scala harness uses a File as a trust store, and i matched it.
also, this is test code, i see no use case for packaging trust stores into the artifacts ?

private final static List<File> FILES_TO_CLEAN_UP = Collections.synchronizedList(new ArrayList<>());

static {
SHUTDOWN_HOOK = new Thread(() -> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this just here just in case tear down does not work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no. closable test classes (like embeddable brokers and zk) should delete their files on close, but other tests may need files/folders

Copy link
Contributor

@becketqin becketqin left a comment

Choose a reason for hiding this comment

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

LGTM.

@radai-rosenblatt radai-rosenblatt merged commit a473282 into linkedin:master Sep 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants