INT-3860: TCP - Fix Port Conflicts
JIRA: https://jira.spring.io/browse/INT-3860 Similar to INT-3794, if some other process is bound to all adapters $ lsof -i tcp -nP | grep 9000 java 6604 grussell 380u IPv6 0x407e749ec47fa337 0t0 TCP *:9000 (LISTEN) The socket utils reports that the localhost is available for binding; however, the test then binds to all adapters. 1. Where (easily) possible, change tests to use port=0 and let the OS choose. 2. For other tests, use high-numbered ports. 3. Change tests to explicitly bind to localhost (like the utility did). 4. Fix `tcpOutboundGatewayInsideChain` test to use the correct port. Polishing - Fix Travis Bind SOLingerTests to localhost. Since we're using port 0, we have to wait until listening before calling getPort().
This commit is contained in:
committed by
Artem Bilan
parent
b3571a1705
commit
3118596427
@@ -7,11 +7,10 @@
|
||||
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<bean id="tcpIpUtils" class="org.springframework.integration.test.util.SocketUtils" />
|
||||
|
||||
<ip:tcp-connection-factory id="cfS1"
|
||||
type="server"
|
||||
port="#{tcpIpUtils.findAvailableServerSocket(15200)}"
|
||||
port="0"
|
||||
local-address="localhost"
|
||||
lookup-host="false"
|
||||
/>
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
type="server"
|
||||
using-nio="true"
|
||||
port="#{tcpIpUtils.findAvailableServerSocket(12000)}"
|
||||
local-address="localhost"
|
||||
lookup-host="false"
|
||||
so-timeout="20000"
|
||||
/>
|
||||
|
||||
@@ -26,7 +26,8 @@
|
||||
|
||||
<ip:tcp-connection-factory id="crLfServer2"
|
||||
type="server"
|
||||
port="#{tcpIpUtils.findAvailableServerSocket(7400)}"
|
||||
port="#{tcpIpUtils.findAvailableServerSocket(27900)}"
|
||||
local-address="localhost"
|
||||
serializer="crLfSerializer"
|
||||
deserializer="crLfSerializer"/>
|
||||
|
||||
@@ -37,6 +38,9 @@
|
||||
serializer="crLfSerializer"
|
||||
deserializer="crLfSerializer"/>
|
||||
|
||||
<ip:tcp-inbound-gateway id="gatewayCrLf2"
|
||||
connection-factory="crLfServer2"
|
||||
request-channel="toSA" />
|
||||
|
||||
<int:chain input-channel="tcpOutboundGatewayInsideChain" output-channel="replyChannel">
|
||||
<ip:tcp-outbound-gateway id="tcp-outbound-gateway-within-chain" connection-factory="crLfClient2"/>
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
type="server"
|
||||
so-timeout="60000"
|
||||
deserializer=""
|
||||
port="#{tcpIpUtils.findAvailableServerSocket(7000)}"/>
|
||||
port="#{tcpIpUtils.findAvailableServerSocket(27800)}"
|
||||
local-address="localhost"/>
|
||||
|
||||
<int-ip:tcp-inbound-channel-adapter
|
||||
connection-factory="scf"
|
||||
|
||||
@@ -20,25 +20,29 @@
|
||||
|
||||
<ip:tcp-connection-factory id="crLfServer"
|
||||
type="server"
|
||||
port="#{tcpIpUtils.findAvailableServerSocket(7000)}"
|
||||
port="#{tcpIpUtils.findAvailableServerSocket(27000)}"
|
||||
local-address="localhost"
|
||||
serializer="crLfSerializer"
|
||||
deserializer="crLfSerializer"/>
|
||||
|
||||
<ip:tcp-connection-factory id="stxEtxServer"
|
||||
type="server"
|
||||
port="#{tcpIpUtils.findAvailableServerSocket(7100)}"
|
||||
port="#{tcpIpUtils.findAvailableServerSocket(27100)}"
|
||||
local-address="localhost"
|
||||
serializer="stxEtxSerializer"
|
||||
deserializer="stxEtxSerializer"/>
|
||||
|
||||
<ip:tcp-connection-factory id="lengthHeaderServer"
|
||||
type="server"
|
||||
port="#{tcpIpUtils.findAvailableServerSocket(7200)}"
|
||||
port="#{tcpIpUtils.findAvailableServerSocket(27200)}"
|
||||
local-address="localhost"
|
||||
serializer="lengthHeaderSerializer"
|
||||
deserializer="lengthHeaderSerializer"/>
|
||||
|
||||
<ip:tcp-connection-factory id="javaSerialServer"
|
||||
type="server"
|
||||
port="#{tcpIpUtils.findAvailableServerSocket(7300)}"
|
||||
port="#{tcpIpUtils.findAvailableServerSocket(27300)}"
|
||||
local-address="localhost"
|
||||
serializer="javaSerializer"
|
||||
deserializer="javaDeserializer"/>
|
||||
|
||||
@@ -72,28 +76,32 @@
|
||||
|
||||
<ip:tcp-connection-factory id="crLfServerNio"
|
||||
type="server"
|
||||
port="#{tcpIpUtils.findAvailableServerSocket(7400)}"
|
||||
port="#{tcpIpUtils.findAvailableServerSocket(27400)}"
|
||||
local-address="localhost"
|
||||
serializer="crLfSerializer"
|
||||
deserializer="crLfSerializer"
|
||||
using-nio="true"/>
|
||||
|
||||
<ip:tcp-connection-factory id="stxEtxServerNio"
|
||||
type="server"
|
||||
port="#{tcpIpUtils.findAvailableServerSocket(7500)}"
|
||||
port="#{tcpIpUtils.findAvailableServerSocket(17500)}"
|
||||
local-address="localhost"
|
||||
serializer="stxEtxSerializer"
|
||||
deserializer="stxEtxSerializer"
|
||||
using-nio="true"/>
|
||||
|
||||
<ip:tcp-connection-factory id="lengthHeaderServerNio"
|
||||
type="server"
|
||||
port="#{tcpIpUtils.findAvailableServerSocket(7600)}"
|
||||
port="#{tcpIpUtils.findAvailableServerSocket(27600)}"
|
||||
local-address="localhost"
|
||||
serializer="lengthHeaderSerializer"
|
||||
deserializer="lengthHeaderSerializer"
|
||||
using-nio="true"/>
|
||||
|
||||
<ip:tcp-connection-factory id="javaSerialServerNio"
|
||||
type="server"
|
||||
port="#{tcpIpUtils.findAvailableServerSocket(7700)}"
|
||||
port="#{tcpIpUtils.findAvailableServerSocket(27700)}"
|
||||
local-address="localhost"
|
||||
serializer="javaSerializer"
|
||||
deserializer="javaDeserializer"
|
||||
using-nio="true"/>
|
||||
|
||||
@@ -7,11 +7,10 @@
|
||||
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/integration/ip http://www.springframework.org/schema/integration/ip/spring-integration-ip.xsd">
|
||||
|
||||
<bean id="tcpIpUtils" class="org.springframework.integration.test.util.SocketUtils" />
|
||||
|
||||
<int-ip:tcp-connection-factory id="inCFNet"
|
||||
type="server"
|
||||
port="#{tcpIpUtils.findAvailableServerSocket(9000)}"
|
||||
port="0"
|
||||
local-address="localhost"
|
||||
so-timeout="1000"
|
||||
single-use="true"
|
||||
/>
|
||||
@@ -21,7 +20,8 @@
|
||||
|
||||
<int-ip:tcp-connection-factory id="inCFNio"
|
||||
type="server"
|
||||
port="#{tcpIpUtils.findAvailableServerSocket(9100)}"
|
||||
port="0"
|
||||
local-address="localhost"
|
||||
so-timeout="1000"
|
||||
single-use="true"
|
||||
using-nio="true"
|
||||
@@ -32,7 +32,8 @@
|
||||
|
||||
<int-ip:tcp-connection-factory id="inCFNetRst"
|
||||
type="server"
|
||||
port="#{tcpIpUtils.findAvailableServerSocket(9200)}"
|
||||
port="0"
|
||||
local-address="localhost"
|
||||
so-timeout="1000"
|
||||
single-use="true"
|
||||
so-linger="0"
|
||||
@@ -43,7 +44,8 @@
|
||||
|
||||
<int-ip:tcp-connection-factory id="inCFNioRst"
|
||||
type="server"
|
||||
port="#{tcpIpUtils.findAvailableServerSocket(9300)}"
|
||||
port="0"
|
||||
local-address="localhost"
|
||||
so-timeout="1000"
|
||||
single-use="true"
|
||||
using-nio="true"
|
||||
@@ -55,7 +57,8 @@
|
||||
|
||||
<int-ip:tcp-connection-factory id="inCFNetLinger"
|
||||
type="server"
|
||||
port="#{tcpIpUtils.findAvailableServerSocket(9400)}"
|
||||
port="0"
|
||||
local-address="localhost"
|
||||
so-timeout="1000"
|
||||
single-use="true"
|
||||
so-linger="10000"
|
||||
@@ -66,7 +69,8 @@
|
||||
|
||||
<int-ip:tcp-connection-factory id="inCFNioLinger"
|
||||
type="server"
|
||||
port="#{tcpIpUtils.findAvailableServerSocket(9500)}"
|
||||
port="0"
|
||||
local-address="localhost"
|
||||
so-timeout="1000"
|
||||
single-use="true"
|
||||
using-nio="true"
|
||||
|
||||
@@ -100,8 +100,8 @@ public class SOLingerTests {
|
||||
* Default (no linger) means the OS may still deliver everything before the
|
||||
* FIN, but it's not guaranteed.
|
||||
*/
|
||||
int port = inCF.getPort();
|
||||
TestingUtilities.waitListening(inCF, null);
|
||||
int port = inCF.getPort();
|
||||
try {
|
||||
Socket socket = SocketFactory.getDefault().createSocket("localhost", port);
|
||||
socket.setSoTimeout(10000);
|
||||
@@ -132,8 +132,8 @@ public class SOLingerTests {
|
||||
}
|
||||
|
||||
private void rstReceived(AbstractServerConnectionFactory inCF) {
|
||||
int port = inCF.getPort();
|
||||
TestingUtilities.waitListening(inCF, null);
|
||||
int port = inCF.getPort();
|
||||
try {
|
||||
Socket socket = SocketFactory.getDefault().createSocket("localhost", port);
|
||||
socket.setSoTimeout(10000);
|
||||
|
||||
Reference in New Issue
Block a user