You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2018/09/02 13:24:55 UTC
[GitHub] egor-ryashin commented on a change in pull request #6263: Add
ability to specify list of task ports
egor-ryashin commented on a change in pull request #6263: Add ability to specify list of task ports
URL: https://github.com/apache/incubator-druid/pull/6263#discussion_r214540821
##########
File path: indexing-service/src/test/java/org/apache/druid/indexing/overlord/PortFinderTest.java
##########
@@ -19,35 +19,76 @@
package org.apache.druid.indexing.overlord;
+import com.google.common.collect.ImmutableList;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
import java.net.ServerSocket;
public class PortFinderTest
{
- private final PortFinder finder = new PortFinder(1200);
+ private PortFinder finderUseStartPort;
+ private PortFinder finderUseCandidatePorts;
+
+ @Before
+ public void setUp()
+ {
+ finderUseStartPort = new PortFinder(1200, ImmutableList.of());
+ // find two unused port for 'finderUseCandidatePorts'
+ for (int i = 1024; i <= 0xFFFF; ++i) {
+ try {
+ new ServerSocket(i).close();
Review comment:
I would avoid environment dependent code in unit tests, it can interfere with another process or test. It's better to mock `canBind`, ie if you want to check the class doesn't provide occupied *1024* port, make the method stub of `canBind(1024)` return `false`.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org