Implement Bootstrap.toString() and use it in the testsuite
By implementing Bootstrap.toString() and printing it for each test case helps us figure out which transport is causing a trouble.
This commit is contained in:
parent
089d022e03
commit
74749ec15d
@ -22,6 +22,8 @@ import io.netty.logging.InternalLoggerFactory;
|
|||||||
import io.netty.testsuite.transport.socket.SocketTestPermutation.Factory;
|
import io.netty.testsuite.transport.socket.SocketTestPermutation.Factory;
|
||||||
import io.netty.testsuite.util.TestUtils;
|
import io.netty.testsuite.util.TestUtils;
|
||||||
import io.netty.util.NetworkConstants;
|
import io.netty.util.NetworkConstants;
|
||||||
|
import org.junit.Rule;
|
||||||
|
import org.junit.rules.TestName;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
@ -29,9 +31,6 @@ import java.net.InetSocketAddress;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.junit.Rule;
|
|
||||||
import org.junit.rules.TestName;
|
|
||||||
|
|
||||||
public abstract class AbstractDatagramTest {
|
public abstract class AbstractDatagramTest {
|
||||||
|
|
||||||
private static final List<Entry<Factory<Bootstrap>, Factory<Bootstrap>>> COMBO =
|
private static final List<Entry<Factory<Bootstrap>, Factory<Bootstrap>>> COMBO =
|
||||||
@ -57,7 +56,7 @@ public abstract class AbstractDatagramTest {
|
|||||||
cb.localAddress(0).remoteAddress(addr);
|
cb.localAddress(0).remoteAddress(addr);
|
||||||
|
|
||||||
logger.info(String.format(
|
logger.info(String.format(
|
||||||
"Running: %s %d of %d", testName.getMethodName(), ++ i, COMBO.size()));
|
"Running: %s %d of %d (%s + %s)", testName.getMethodName(), ++ i, COMBO.size(), sb, cb));
|
||||||
try {
|
try {
|
||||||
Method m = getClass().getDeclaredMethod(
|
Method m = getClass().getDeclaredMethod(
|
||||||
testName.getMethodName(), AbstractBootstrap.class, AbstractBootstrap.class);
|
testName.getMethodName(), AbstractBootstrap.class, AbstractBootstrap.class);
|
||||||
|
@ -58,7 +58,7 @@ public abstract class AbstractSctpTest {
|
|||||||
cb.remoteAddress(addr);
|
cb.remoteAddress(addr);
|
||||||
|
|
||||||
logger.info(String.format(
|
logger.info(String.format(
|
||||||
"Running: %s %d of %d", testName.getMethodName(), ++ i, COMBO.size()));
|
"Running: %s %d of %d (%s + %s)", testName.getMethodName(), ++ i, COMBO.size(), sb, cb));
|
||||||
try {
|
try {
|
||||||
Method m = getClass().getDeclaredMethod(
|
Method m = getClass().getDeclaredMethod(
|
||||||
testName.getMethodName(), ServerBootstrap.class, Bootstrap.class);
|
testName.getMethodName(), ServerBootstrap.class, Bootstrap.class);
|
||||||
|
@ -21,15 +21,14 @@ import io.netty.logging.InternalLoggerFactory;
|
|||||||
import io.netty.testsuite.transport.socket.SocketTestPermutation.Factory;
|
import io.netty.testsuite.transport.socket.SocketTestPermutation.Factory;
|
||||||
import io.netty.testsuite.util.TestUtils;
|
import io.netty.testsuite.util.TestUtils;
|
||||||
import io.netty.util.NetworkConstants;
|
import io.netty.util.NetworkConstants;
|
||||||
|
import org.junit.Rule;
|
||||||
|
import org.junit.rules.TestName;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.junit.Rule;
|
|
||||||
import org.junit.rules.TestName;
|
|
||||||
|
|
||||||
public abstract class AbstractServerSocketTest {
|
public abstract class AbstractServerSocketTest {
|
||||||
|
|
||||||
private static final List<Factory<ServerBootstrap>> COMBO = SocketTestPermutation.serverSocket();
|
private static final List<Factory<ServerBootstrap>> COMBO = SocketTestPermutation.serverSocket();
|
||||||
@ -51,7 +50,7 @@ public abstract class AbstractServerSocketTest {
|
|||||||
sb.localAddress(addr);
|
sb.localAddress(addr);
|
||||||
|
|
||||||
logger.info(String.format(
|
logger.info(String.format(
|
||||||
"Running: %s %d of %d", testName.getMethodName(), ++ i, COMBO.size()));
|
"Running: %s %d of %d (%s)", testName.getMethodName(), ++ i, COMBO.size(), sb));
|
||||||
try {
|
try {
|
||||||
Method m = getClass().getDeclaredMethod(
|
Method m = getClass().getDeclaredMethod(
|
||||||
testName.getMethodName(), ServerBootstrap.class);
|
testName.getMethodName(), ServerBootstrap.class);
|
||||||
|
@ -22,6 +22,8 @@ import io.netty.logging.InternalLoggerFactory;
|
|||||||
import io.netty.testsuite.transport.socket.SocketTestPermutation.Factory;
|
import io.netty.testsuite.transport.socket.SocketTestPermutation.Factory;
|
||||||
import io.netty.testsuite.util.TestUtils;
|
import io.netty.testsuite.util.TestUtils;
|
||||||
import io.netty.util.NetworkConstants;
|
import io.netty.util.NetworkConstants;
|
||||||
|
import org.junit.Rule;
|
||||||
|
import org.junit.rules.TestName;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
@ -29,9 +31,6 @@ import java.net.InetSocketAddress;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.junit.Rule;
|
|
||||||
import org.junit.rules.TestName;
|
|
||||||
|
|
||||||
public abstract class AbstractSocketTest {
|
public abstract class AbstractSocketTest {
|
||||||
|
|
||||||
private static final List<Entry<Factory<ServerBootstrap>, Factory<Bootstrap>>> COMBO =
|
private static final List<Entry<Factory<ServerBootstrap>, Factory<Bootstrap>>> COMBO =
|
||||||
@ -59,7 +58,7 @@ public abstract class AbstractSocketTest {
|
|||||||
cb.remoteAddress(addr);
|
cb.remoteAddress(addr);
|
||||||
|
|
||||||
logger.info(String.format(
|
logger.info(String.format(
|
||||||
"Running: %s %d of %d", testName.getMethodName(), ++ i, COMBO.size()));
|
"Running: %s %d of %d (%s + %s)", testName.getMethodName(), ++ i, COMBO.size(), sb, cb));
|
||||||
try {
|
try {
|
||||||
Method m = getClass().getDeclaredMethod(
|
Method m = getClass().getDeclaredMethod(
|
||||||
testName.getMethodName(), ServerBootstrap.class, Bootstrap.class);
|
testName.getMethodName(), ServerBootstrap.class, Bootstrap.class);
|
||||||
|
@ -25,10 +25,10 @@ import io.netty.channel.socket.aio.AioServerSocketChannel;
|
|||||||
import io.netty.channel.socket.aio.AioSocketChannel;
|
import io.netty.channel.socket.aio.AioSocketChannel;
|
||||||
import io.netty.channel.socket.nio.NioDatagramChannel;
|
import io.netty.channel.socket.nio.NioDatagramChannel;
|
||||||
import io.netty.channel.socket.nio.NioEventLoopGroup;
|
import io.netty.channel.socket.nio.NioEventLoopGroup;
|
||||||
import io.netty.channel.socket.nio.NioServerSocketChannel;
|
|
||||||
import io.netty.channel.socket.nio.NioSctpServerChannel;
|
|
||||||
import io.netty.channel.socket.nio.NioSocketChannel;
|
|
||||||
import io.netty.channel.socket.nio.NioSctpChannel;
|
import io.netty.channel.socket.nio.NioSctpChannel;
|
||||||
|
import io.netty.channel.socket.nio.NioSctpServerChannel;
|
||||||
|
import io.netty.channel.socket.nio.NioServerSocketChannel;
|
||||||
|
import io.netty.channel.socket.nio.NioSocketChannel;
|
||||||
import io.netty.channel.socket.oio.OioDatagramChannel;
|
import io.netty.channel.socket.oio.OioDatagramChannel;
|
||||||
import io.netty.channel.socket.oio.OioEventLoopGroup;
|
import io.netty.channel.socket.oio.OioEventLoopGroup;
|
||||||
import io.netty.channel.socket.oio.OioServerSocketChannel;
|
import io.netty.channel.socket.oio.OioServerSocketChannel;
|
||||||
@ -97,6 +97,11 @@ final class SocketTestPermutation {
|
|||||||
public Channel newChannel() {
|
public Channel newChannel() {
|
||||||
return new NioDatagramChannel(InternetProtocolFamily.IPv4);
|
return new NioDatagramChannel(InternetProtocolFamily.IPv4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return NioDatagramChannel.class.getSimpleName() + ".class";
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -188,13 +193,7 @@ final class SocketTestPermutation {
|
|||||||
public ServerBootstrap newInstance() {
|
public ServerBootstrap newInstance() {
|
||||||
final AioEventLoopGroup parentGroup = new AioEventLoopGroup();
|
final AioEventLoopGroup parentGroup = new AioEventLoopGroup();
|
||||||
final AioEventLoopGroup childGroup = new AioEventLoopGroup();
|
final AioEventLoopGroup childGroup = new AioEventLoopGroup();
|
||||||
return new ServerBootstrap().group(parentGroup, childGroup).channelFactory(new ChannelFactory() {
|
return new ServerBootstrap().group(parentGroup, childGroup).channel(AioServerSocketChannel.class);
|
||||||
|
|
||||||
@Override
|
|
||||||
public Channel newChannel() {
|
|
||||||
return new AioServerSocketChannel(parentGroup, childGroup);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
list.add(new Factory<ServerBootstrap>() {
|
list.add(new Factory<ServerBootstrap>() {
|
||||||
@ -221,12 +220,7 @@ final class SocketTestPermutation {
|
|||||||
@Override
|
@Override
|
||||||
public Bootstrap newInstance() {
|
public Bootstrap newInstance() {
|
||||||
final AioEventLoopGroup loop = new AioEventLoopGroup();
|
final AioEventLoopGroup loop = new AioEventLoopGroup();
|
||||||
return new Bootstrap().group(loop).channelFactory(new ChannelFactory() {
|
return new Bootstrap().group(loop).channel(AioSocketChannel.class);
|
||||||
@Override
|
|
||||||
public Channel newChannel() {
|
|
||||||
return new AioSocketChannel(loop);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
list.add(new Factory<Bootstrap>() {
|
list.add(new Factory<Bootstrap>() {
|
||||||
|
@ -247,6 +247,49 @@ public abstract class AbstractBootstrap<B extends AbstractBootstrap<?>> {
|
|||||||
return attrs;
|
return attrs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder buf = new StringBuilder();
|
||||||
|
buf.append(getClass().getSimpleName());
|
||||||
|
buf.append('(');
|
||||||
|
if (group != null) {
|
||||||
|
buf.append("group: ");
|
||||||
|
buf.append(group.getClass().getSimpleName());
|
||||||
|
buf.append(", ");
|
||||||
|
}
|
||||||
|
if (factory != null) {
|
||||||
|
buf.append("factory: ");
|
||||||
|
buf.append(factory);
|
||||||
|
buf.append(", ");
|
||||||
|
}
|
||||||
|
if (localAddress != null) {
|
||||||
|
buf.append("localAddress: ");
|
||||||
|
buf.append(localAddress);
|
||||||
|
buf.append(", ");
|
||||||
|
}
|
||||||
|
if (options != null && !options.isEmpty()) {
|
||||||
|
buf.append("options: ");
|
||||||
|
buf.append(options);
|
||||||
|
buf.append(", ");
|
||||||
|
}
|
||||||
|
if (attrs != null && !attrs.isEmpty()) {
|
||||||
|
buf.append("attrs: ");
|
||||||
|
buf.append(attrs);
|
||||||
|
buf.append(", ");
|
||||||
|
}
|
||||||
|
if (handler != null) {
|
||||||
|
buf.append("handler: ");
|
||||||
|
buf.append(handler);
|
||||||
|
buf.append(", ");
|
||||||
|
}
|
||||||
|
if (buf.charAt(buf.length() - 1) == '(') {
|
||||||
|
buf.append(')');
|
||||||
|
} else {
|
||||||
|
buf.setCharAt(buf.length() - 2, ')');
|
||||||
|
buf.setLength(buf.length() - 1);
|
||||||
|
}
|
||||||
|
return buf.toString();
|
||||||
|
}
|
||||||
|
|
||||||
private static final class BootstrapChannelFactory implements ChannelFactory {
|
private static final class BootstrapChannelFactory implements ChannelFactory {
|
||||||
private final Class<? extends Channel> clazz;
|
private final Class<? extends Channel> clazz;
|
||||||
|
|
||||||
@ -263,6 +306,9 @@ public abstract class AbstractBootstrap<B extends AbstractBootstrap<?>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return clazz.getSimpleName() + ".class";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -191,10 +191,30 @@ public class Bootstrap extends AbstractBootstrap<Bootstrap> {
|
|||||||
return super.channel(channelClass);
|
return super.channel(channelClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
if (remoteAddress == null) {
|
||||||
|
return super.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder buf = new StringBuilder(super.toString());
|
||||||
|
buf.setLength(buf.length() - 1);
|
||||||
|
buf.append(", remoteAddress: ");
|
||||||
|
buf.append(remoteAddress);
|
||||||
|
buf.append(')');
|
||||||
|
|
||||||
|
return buf.toString();
|
||||||
|
}
|
||||||
|
|
||||||
private final class AioSocketChannelFactory implements ChannelFactory {
|
private final class AioSocketChannelFactory implements ChannelFactory {
|
||||||
@Override
|
@Override
|
||||||
public Channel newChannel() {
|
public Channel newChannel() {
|
||||||
return new AioSocketChannel((AioEventLoopGroup) group());
|
return new AioSocketChannel((AioEventLoopGroup) group());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return AioSocketChannel.class.getSimpleName() + ".class";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -271,6 +271,41 @@ public class ServerBootstrap extends AbstractBootstrap<ServerBootstrap> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder buf = new StringBuilder(super.toString());
|
||||||
|
buf.setLength(buf.length() - 1);
|
||||||
|
buf.append(", ");
|
||||||
|
if (childGroup != null) {
|
||||||
|
buf.append("childGroup: ");
|
||||||
|
buf.append(childGroup.getClass().getSimpleName());
|
||||||
|
buf.append(", ");
|
||||||
|
}
|
||||||
|
if (childOptions != null && !childOptions.isEmpty()) {
|
||||||
|
buf.append("childOptions: ");
|
||||||
|
buf.append(childOptions);
|
||||||
|
buf.append(", ");
|
||||||
|
}
|
||||||
|
if (childAttrs != null && !childAttrs.isEmpty()) {
|
||||||
|
buf.append("childAttrs: ");
|
||||||
|
buf.append(childAttrs);
|
||||||
|
buf.append(", ");
|
||||||
|
}
|
||||||
|
if (childHandler != null) {
|
||||||
|
buf.append("childHandler: ");
|
||||||
|
buf.append(childHandler);
|
||||||
|
buf.append(", ");
|
||||||
|
}
|
||||||
|
if (buf.charAt(buf.length() - 1) == '(') {
|
||||||
|
buf.append(')');
|
||||||
|
} else {
|
||||||
|
buf.setCharAt(buf.length() - 2, ')');
|
||||||
|
buf.setLength(buf.length() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return buf.toString();
|
||||||
|
}
|
||||||
|
|
||||||
private final class AioServerSocketChannelFactory implements ChannelFactory {
|
private final class AioServerSocketChannelFactory implements ChannelFactory {
|
||||||
@Override
|
@Override
|
||||||
public Channel newChannel() {
|
public Channel newChannel() {
|
||||||
|
Loading…
Reference in New Issue
Block a user