You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by fr...@apache.org on 2017/01/18 13:31:24 UTC
svn commit: r1779324 - in /jackrabbit/oak/trunk/oak-segment-tar: ./
src/test/java/org/apache/jackrabbit/oak/segment/standby/
src/test/java/org/apache/jackrabbit/oak/segment/test/
Author: frm
Date: Wed Jan 18 13:31:24 2017
New Revision: 1779324
URL: http://svn.apache.org/viewvc?rev=1779324&view=rev
Log:
OAK-5474 - Use random ports when running Cold Standby tests
Instead of relying on ports being reserved by the Build Helper Maven Plugin,
the tests now use JUnit rules to allocate a new random port when needed.
Tipically, random ports are allocated at the beginning of every test.
Added:
jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/test/TemporaryPort.java (with props)
Modified:
jackrabbit/oak/trunk/oak-segment-tar/pom.xml
jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/BrokenNetworkIT.java
jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/DataStoreTestBase.java
jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/FailoverIPRangeIT.java
jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/FailoverMultipleClientsTestIT.java
jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/FailoverSslTestIT.java
jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/MBeanIT.java
jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/RecoverTestIT.java
jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/StandbyTestIT.java
jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/TestBase.java
jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/test/TemporaryFileStore.java
Modified: jackrabbit/oak/trunk/oak-segment-tar/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/pom.xml?rev=1779324&r1=1779323&r2=1779324&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-tar/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-segment-tar/pom.xml Wed Jan 18 13:31:24 2017
@@ -71,25 +71,6 @@
<artifactId>maven-scr-plugin</artifactId>
</plugin>
<plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <version>1.12</version>
- <executions>
- <execution>
- <goals>
- <goal>reserve-network-port</goal>
- </goals>
- <phase>pre-integration-test</phase>
- <configuration>
- <portNames>
- <portName>standby.server.port</portName>
- <portName>standby.proxy.port</portName>
- </portNames>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
@@ -102,10 +83,6 @@
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.19.1</version>
<configuration>
- <systemPropertyVariables>
- <standby.server.port>${standby.server.port}</standby.server.port>
- <standby.proxy.port>${standby.proxy.port}</standby.proxy.port>
- </systemPropertyVariables>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
</configuration>
</plugin>
Modified: jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/BrokenNetworkIT.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/BrokenNetworkIT.java?rev=1779324&r1=1779323&r2=1779324&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/BrokenNetworkIT.java (original)
+++ jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/BrokenNetworkIT.java Wed Jan 18 13:31:24 2017
@@ -30,10 +30,11 @@ import org.apache.jackrabbit.oak.segment
import org.apache.jackrabbit.oak.segment.standby.client.StandbyClientSync;
import org.apache.jackrabbit.oak.segment.standby.server.StandbyServerSync;
import org.apache.jackrabbit.oak.segment.test.TemporaryFileStore;
+import org.apache.jackrabbit.oak.segment.test.TemporaryPort;
import org.apache.jackrabbit.oak.segment.test.proxy.NetworkErrorProxy;
import org.apache.jackrabbit.oak.spi.state.NodeStore;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.RuleChain;
@@ -49,7 +50,7 @@ public class BrokenNetworkIT extends Tes
private TemporaryFileStore clientFileStore2 = new TemporaryFileStore(folder, true);
- private static NetworkErrorProxy proxy;
+ private NetworkErrorProxy proxy;
@Rule
public RuleChain chain = RuleChain.outerRule(folder)
@@ -57,13 +58,19 @@ public class BrokenNetworkIT extends Tes
.around(clientFileStore1)
.around(clientFileStore2);
- @BeforeClass
- public static void beforeClass() {
- proxy = new NetworkErrorProxy(getProxyPort(), getServerHost(), getServerPort());
+ @Rule
+ public TemporaryPort serverPort = new TemporaryPort();
+
+ @Rule
+ public TemporaryPort proxyPort = new TemporaryPort();
+
+ @Before
+ public void beforeClass() {
+ proxy = new NetworkErrorProxy(proxyPort.getPort(), getServerHost(), serverPort.getPort());
}
- @AfterClass
- public static void afterClass() {
+ @After
+ public void afterClass() {
proxy.close();
}
@@ -147,8 +154,8 @@ public class BrokenNetworkIT extends Tes
storeS.flush(); // this speeds up the test a little bit...
try (
- StandbyServerSync serverSync = new StandbyServerSync(getServerPort(), storeS, ssl);
- StandbyClientSync clientSync = newStandbyClientSync(storeC, getProxyPort(), ssl);
+ StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), storeS, ssl);
+ StandbyClientSync clientSync = newStandbyClientSync(storeC, proxyPort.getPort(), ssl);
) {
proxy.skipBytes(skipPosition, skipBytes);
proxy.flipByte(flipPosition);
Modified: jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/DataStoreTestBase.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/DataStoreTestBase.java?rev=1779324&r1=1779323&r2=1779324&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/DataStoreTestBase.java (original)
+++ jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/DataStoreTestBase.java Wed Jan 18 13:31:24 2017
@@ -38,20 +38,28 @@ import org.apache.jackrabbit.oak.segment
import org.apache.jackrabbit.oak.segment.file.FileStore;
import org.apache.jackrabbit.oak.segment.standby.client.StandbyClientSync;
import org.apache.jackrabbit.oak.segment.standby.server.StandbyServerSync;
+import org.apache.jackrabbit.oak.segment.test.TemporaryPort;
import org.apache.jackrabbit.oak.segment.test.proxy.NetworkErrorProxy;
import org.apache.jackrabbit.oak.spi.commit.CommitInfo;
import org.apache.jackrabbit.oak.spi.commit.EmptyHook;
import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
import org.apache.jackrabbit.oak.spi.state.NodeStore;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
public abstract class DataStoreTestBase extends TestBase {
private static final int MB = 1024 * 1024;
- private static NetworkErrorProxy proxy;
+ private NetworkErrorProxy proxy;
+
+ @Rule
+ public TemporaryPort serverPort = new TemporaryPort();
+
+ @Rule
+ public TemporaryPort proxyPort = new TemporaryPort();
abstract FileStore getPrimary();
@@ -74,13 +82,13 @@ public abstract class DataStoreTestBase
return data;
}
- @BeforeClass
- public static void beforeClass() {
- proxy = new NetworkErrorProxy(getProxyPort(), getServerHost(), getServerPort());
+ @Before
+ public void before() {
+ proxy = new NetworkErrorProxy(proxyPort.getPort(), getServerHost(), serverPort.getPort());
}
- @AfterClass
- public static void afterClass() {
+ @After
+ public void after() {
proxy.close();
}
@@ -93,8 +101,8 @@ public abstract class DataStoreTestBase
NodeStore store = SegmentNodeStoreBuilders.builder(primary).build();
byte[] data = addTestContent(store, "server", blobSize);
try (
- StandbyServerSync serverSync = new StandbyServerSync(getServerPort(), primary);
- StandbyClientSync cl = newStandbyClientSync(secondary)
+ StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), primary);
+ StandbyClientSync cl = newStandbyClientSync(secondary, serverPort.getPort())
) {
serverSync.start();
primary.flush();
@@ -128,8 +136,8 @@ public abstract class DataStoreTestBase
NodeStore store = SegmentNodeStoreBuilders.builder(primary).build();
try (
- StandbyServerSync serverSync = new StandbyServerSync(getServerPort(), primary);
- StandbyClientSync clientSync = newStandbyClientSync(secondary)
+ StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), primary);
+ StandbyClientSync clientSync = newStandbyClientSync(secondary, serverPort.getPort())
) {
serverSync.start();
@@ -188,8 +196,8 @@ public abstract class DataStoreTestBase
NodeStore store = SegmentNodeStoreBuilders.builder(primary).build();
byte[] data = addTestContent(store, "server", blobSize);
try (
- StandbyServerSync serverSync = new StandbyServerSync(getServerPort(), primary);
- StandbyClientSync clientSync = newStandbyClientSync(secondary, getProxyPort())
+ StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), primary);
+ StandbyClientSync clientSync = newStandbyClientSync(secondary, proxyPort.getPort())
) {
proxy.skipBytes(skipPosition, skipBytes);
proxy.flipByte(flipPosition);
Modified: jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/FailoverIPRangeIT.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/FailoverIPRangeIT.java?rev=1779324&r1=1779323&r2=1779324&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/FailoverIPRangeIT.java (original)
+++ jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/FailoverIPRangeIT.java Wed Jan 18 13:31:24 2017
@@ -32,6 +32,7 @@ import org.apache.jackrabbit.oak.segment
import org.apache.jackrabbit.oak.segment.standby.client.StandbyClientSync;
import org.apache.jackrabbit.oak.segment.standby.server.StandbyServerSync;
import org.apache.jackrabbit.oak.segment.test.TemporaryFileStore;
+import org.apache.jackrabbit.oak.segment.test.TemporaryPort;
import org.apache.jackrabbit.oak.spi.state.NodeStore;
import org.junit.Rule;
import org.junit.Test;
@@ -47,6 +48,9 @@ public class FailoverIPRangeIT extends T
private TemporaryFileStore clientFileStore = new TemporaryFileStore(folder, true);
@Rule
+ public TemporaryPort serverPort = new TemporaryPort();
+
+ @Rule
public RuleChain chain = RuleChain.outerRule(folder)
.around(serverFileStore)
.around(clientFileStore);
@@ -153,8 +157,8 @@ public class FailoverIPRangeIT extends T
NodeStore store = SegmentNodeStoreBuilders.builder(storeS).build();
try (
- StandbyServerSync serverSync = new StandbyServerSync(getServerPort(), storeS, ipRanges);
- StandbyClientSync clientSync = new StandbyClientSync(host, getServerPort(), storeC, false, getClientTimeout(), false)
+ StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), storeS, ipRanges);
+ StandbyClientSync clientSync = new StandbyClientSync(host, serverPort.getPort(), storeC, false, getClientTimeout(), false)
) {
serverSync.start();
addTestContent(store, "server");
Modified: jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/FailoverMultipleClientsTestIT.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/FailoverMultipleClientsTestIT.java?rev=1779324&r1=1779323&r2=1779324&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/FailoverMultipleClientsTestIT.java (original)
+++ jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/FailoverMultipleClientsTestIT.java Wed Jan 18 13:31:24 2017
@@ -29,6 +29,7 @@ import org.apache.jackrabbit.oak.segment
import org.apache.jackrabbit.oak.segment.standby.client.StandbyClientSync;
import org.apache.jackrabbit.oak.segment.standby.server.StandbyServerSync;
import org.apache.jackrabbit.oak.segment.test.TemporaryFileStore;
+import org.apache.jackrabbit.oak.segment.test.TemporaryPort;
import org.apache.jackrabbit.oak.spi.state.NodeStore;
import org.junit.Rule;
import org.junit.Test;
@@ -46,6 +47,9 @@ public class FailoverMultipleClientsTest
private TemporaryFileStore clientFileStore2 = new TemporaryFileStore(folder, true);
@Rule
+ public TemporaryPort serverPort = new TemporaryPort();
+
+ @Rule
public RuleChain chain = RuleChain.outerRule(folder)
.around(serverFileStore)
.around(clientFileStore1)
@@ -59,9 +63,9 @@ public class FailoverMultipleClientsTest
NodeStore store = SegmentNodeStoreBuilders.builder(storeS).build();
try (
- StandbyServerSync serverSync = new StandbyServerSync(getServerPort(), storeS);
- StandbyClientSync cl1 = newStandbyClientSync(storeC);
- StandbyClientSync cl2 = newStandbyClientSync(storeC2)
+ StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), storeS);
+ StandbyClientSync cl1 = newStandbyClientSync(storeC, serverPort.getPort());
+ StandbyClientSync cl2 = newStandbyClientSync(storeC2, serverPort.getPort())
) {
serverSync.start();
SegmentTestUtils.addTestContent(store, "server");
Modified: jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/FailoverSslTestIT.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/FailoverSslTestIT.java?rev=1779324&r1=1779323&r2=1779324&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/FailoverSslTestIT.java (original)
+++ jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/FailoverSslTestIT.java Wed Jan 18 13:31:24 2017
@@ -30,6 +30,7 @@ import org.apache.jackrabbit.oak.segment
import org.apache.jackrabbit.oak.segment.standby.client.StandbyClientSync;
import org.apache.jackrabbit.oak.segment.standby.server.StandbyServerSync;
import org.apache.jackrabbit.oak.segment.test.TemporaryFileStore;
+import org.apache.jackrabbit.oak.segment.test.TemporaryPort;
import org.apache.jackrabbit.oak.spi.state.NodeStore;
import org.junit.Rule;
import org.junit.Test;
@@ -45,6 +46,9 @@ public class FailoverSslTestIT extends T
private TemporaryFileStore clientFileStore = new TemporaryFileStore(folder, true);
@Rule
+ public TemporaryPort serverPort = new TemporaryPort();
+
+ @Rule
public RuleChain chain = RuleChain.outerRule(folder)
.around(serverFileStore)
.around(clientFileStore);
@@ -54,8 +58,8 @@ public class FailoverSslTestIT extends T
FileStore storeS = serverFileStore.fileStore();
FileStore storeC = clientFileStore.fileStore();
try (
- StandbyServerSync serverSync = new StandbyServerSync(getServerPort(), storeS, true);
- StandbyClientSync clientSync = newStandbyClientSync(storeC, getServerPort(), true);
+ StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), storeS, true);
+ StandbyClientSync clientSync = newStandbyClientSync(storeC, serverPort.getPort(), true);
) {
assertTrue(synchronizeAndCompareHead(serverSync, clientSync));
}
@@ -66,8 +70,8 @@ public class FailoverSslTestIT extends T
FileStore storeS = serverFileStore.fileStore();
FileStore storeC = clientFileStore.fileStore();
try (
- StandbyServerSync serverSync = new StandbyServerSync(getServerPort(), storeS, true);
- StandbyClientSync clientSync = newStandbyClientSync(storeC);
+ StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), storeS, true);
+ StandbyClientSync clientSync = newStandbyClientSync(storeC, serverPort.getPort());
) {
assertFalse(synchronizeAndCompareHead(serverSync, clientSync));
}
@@ -78,8 +82,8 @@ public class FailoverSslTestIT extends T
FileStore storeS = serverFileStore.fileStore();
FileStore storeC = clientFileStore.fileStore();
try (
- StandbyServerSync serverSync = new StandbyServerSync(getServerPort(), storeS);
- StandbyClientSync clientSync = newStandbyClientSync(storeC, getServerPort(), true);
+ StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), storeS);
+ StandbyClientSync clientSync = newStandbyClientSync(storeC, serverPort.getPort(), true);
) {
assertFalse(synchronizeAndCompareHead(serverSync, clientSync));
}
Modified: jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/MBeanIT.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/MBeanIT.java?rev=1779324&r1=1779323&r2=1779324&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/MBeanIT.java (original)
+++ jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/MBeanIT.java Wed Jan 18 13:31:24 2017
@@ -35,6 +35,7 @@ import org.apache.jackrabbit.oak.segment
import org.apache.jackrabbit.oak.segment.standby.jmx.StandbyStatusMBean;
import org.apache.jackrabbit.oak.segment.standby.server.StandbyServerSync;
import org.apache.jackrabbit.oak.segment.test.TemporaryFileStore;
+import org.apache.jackrabbit.oak.segment.test.TemporaryPort;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.RuleChain;
@@ -49,6 +50,9 @@ public class MBeanIT extends TestBase {
private TemporaryFileStore clientFileStore = new TemporaryFileStore(folder, true);
@Rule
+ public TemporaryPort serverPort = new TemporaryPort();
+
+ @Rule
public RuleChain chain = RuleChain.outerRule(folder)
.around(serverFileStore)
.around(clientFileStore);
@@ -57,7 +61,7 @@ public class MBeanIT extends TestBase {
public void testServerEmptyConfig() throws Exception {
MBeanServer jmxServer = ManagementFactory.getPlatformMBeanServer();
ObjectName status = new ObjectName(StandbyStatusMBean.JMX_NAME + ",id=*");
- try (StandbyServerSync serverSync = new StandbyServerSync(TestBase.getServerPort(), serverFileStore.fileStore())) {
+ try (StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), serverFileStore.fileStore())) {
serverSync.start();
Set<ObjectName> instances = jmxServer.queryNames(status, null);
@@ -89,7 +93,7 @@ public class MBeanIT extends TestBase {
public void testClientEmptyConfigNoServer() throws Exception {
MBeanServer jmxServer = ManagementFactory.getPlatformMBeanServer();
ObjectName status = new ObjectName(StandbyStatusMBean.JMX_NAME + ",id=*");
- try (StandbyClientSync clientSync = newStandbyClientSync(clientFileStore.fileStore())) {
+ try (StandbyClientSync clientSync = newStandbyClientSync(clientFileStore.fileStore(), serverPort.getPort())) {
clientSync.start();
clientSync.run();
@@ -126,7 +130,7 @@ public class MBeanIT extends TestBase {
System.setProperty(StandbyClientSync.CLIENT_ID_PROPERTY_NAME, "Foo");
MBeanServer jmxServer = ManagementFactory.getPlatformMBeanServer();
ObjectName status;
- try (StandbyClientSync clientSync = newStandbyClientSync(clientFileStore.fileStore())) {
+ try (StandbyClientSync clientSync = newStandbyClientSync(clientFileStore.fileStore(), serverPort.getPort())) {
clientSync.start();
clientSync.run();
@@ -149,8 +153,8 @@ public class MBeanIT extends TestBase {
MBeanServer jmxServer = ManagementFactory.getPlatformMBeanServer();
ObjectName clientStatus, serverStatus;
try (
- StandbyServerSync serverSync = new StandbyServerSync(getServerPort(), serverFileStore.fileStore());
- StandbyClientSync clientSync = newStandbyClientSync(clientFileStore.fileStore())
+ StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), serverFileStore.fileStore());
+ StandbyClientSync clientSync = newStandbyClientSync(clientFileStore.fileStore(), serverPort.getPort())
) {
serverSync.start();
Modified: jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/RecoverTestIT.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/RecoverTestIT.java?rev=1779324&r1=1779323&r2=1779324&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/RecoverTestIT.java (original)
+++ jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/RecoverTestIT.java Wed Jan 18 13:31:24 2017
@@ -30,6 +30,7 @@ import org.apache.jackrabbit.oak.segment
import org.apache.jackrabbit.oak.segment.standby.client.StandbyClientSync;
import org.apache.jackrabbit.oak.segment.standby.server.StandbyServerSync;
import org.apache.jackrabbit.oak.segment.test.TemporaryFileStore;
+import org.apache.jackrabbit.oak.segment.test.TemporaryPort;
import org.apache.jackrabbit.oak.spi.state.NodeStore;
import org.junit.Rule;
import org.junit.Test;
@@ -45,6 +46,9 @@ public class RecoverTestIT extends TestB
private TemporaryFileStore clientFileStore = new TemporaryFileStore(folder, true);
@Rule
+ public TemporaryPort serverPort = new TemporaryPort();
+
+ @Rule
public RuleChain chain = RuleChain.outerRule(folder)
.around(serverFileStore)
.around(clientFileStore);
@@ -58,8 +62,8 @@ public class RecoverTestIT extends TestB
addTestContent(store, "client");
try (
- StandbyServerSync serverSync = new StandbyServerSync(getServerPort(), storeS);
- StandbyClientSync cl = newStandbyClientSync(storeC)
+ StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), storeS);
+ StandbyClientSync cl = newStandbyClientSync(storeC, serverPort.getPort())
) {
serverSync.start();
store = SegmentNodeStoreBuilders.builder(storeS).build();
Modified: jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/StandbyTestIT.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/StandbyTestIT.java?rev=1779324&r1=1779323&r2=1779324&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/StandbyTestIT.java (original)
+++ jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/StandbyTestIT.java Wed Jan 18 13:31:24 2017
@@ -37,6 +37,7 @@ import org.apache.jackrabbit.oak.segment
import org.apache.jackrabbit.oak.segment.standby.client.StandbyClientSync;
import org.apache.jackrabbit.oak.segment.standby.server.StandbyServerSync;
import org.apache.jackrabbit.oak.segment.test.TemporaryFileStore;
+import org.apache.jackrabbit.oak.segment.test.TemporaryPort;
import org.apache.jackrabbit.oak.spi.commit.CommitInfo;
import org.apache.jackrabbit.oak.spi.commit.EmptyHook;
import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
@@ -55,6 +56,9 @@ public class StandbyTestIT extends TestB
private TemporaryFileStore clientFileStore = new TemporaryFileStore(folder, true);
@Rule
+ public TemporaryPort serverPort = new TemporaryPort();
+
+ @Rule
public RuleChain chain = RuleChain.outerRule(folder)
.around(serverFileStore)
.around(clientFileStore);
@@ -68,8 +72,8 @@ public class StandbyTestIT extends TestB
NodeStore store = SegmentNodeStoreBuilders.builder(primary).build();
try (
- StandbyServerSync serverSync = new StandbyServerSync(getServerPort(), primary);
- StandbyClientSync clientSync = newStandbyClientSync(secondary)
+ StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), primary);
+ StandbyClientSync clientSync = newStandbyClientSync(secondary, serverPort.getPort())
) {
serverSync.start();
byte[] data = addTestContent(store, "server", blobSize, 150);
@@ -108,8 +112,8 @@ public class StandbyTestIT extends TestB
NodeStore store = SegmentNodeStoreBuilders.builder(primary).build();
try (
- StandbyServerSync serverSync = new StandbyServerSync(getServerPort(), primary);
- StandbyClientSync clientSync = newStandbyClientSync(secondary)
+ StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), primary);
+ StandbyClientSync clientSync = newStandbyClientSync(secondary, serverPort.getPort())
) {
serverSync.start();
byte[] data = addTestContent(store, "server", blobSize, dataNodes);
Modified: jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/TestBase.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/TestBase.java?rev=1779324&r1=1779323&r2=1779324&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/TestBase.java (original)
+++ jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/TestBase.java Wed Jan 18 13:31:24 2017
@@ -29,10 +29,6 @@ import org.junit.BeforeClass;
public class TestBase {
- private static final int port = Integer.getInteger("standby.server.port", 52800);
-
- private static final int proxyPort = Integer.getInteger("standby.proxy.port", 51913);
-
private static final int timeout = Integer.getInteger("standby.test.timeout", 500);
// Java 6 on Windows doesn't support dual IP stacks, so we will skip our
@@ -44,26 +40,14 @@ public class TestBase {
assumeTrue(!CIHelper.travis());
}
- public static int getServerPort() {
- return port;
- }
-
- public static int getProxyPort() {
- return proxyPort;
- }
-
- public static String getServerHost() {
+ static String getServerHost() {
return "127.0.0.1";
}
- public static int getClientTimeout() {
+ static int getClientTimeout() {
return timeout;
}
- public StandbyClientSync newStandbyClientSync(FileStore store) throws Exception {
- return newStandbyClientSync(store, getServerPort(), false);
- }
-
public StandbyClientSync newStandbyClientSync(FileStore store, int port) throws Exception {
return newStandbyClientSync(store, port, false);
}
Modified: jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/test/TemporaryFileStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/test/TemporaryFileStore.java?rev=1779324&r1=1779323&r2=1779324&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/test/TemporaryFileStore.java (original)
+++ jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/test/TemporaryFileStore.java Wed Jan 18 13:31:24 2017
@@ -65,9 +65,9 @@ public class TemporaryFileStore extends
.withStringCacheSize(0)
.withTemplateCacheSize(0)
.withStatisticsProvider(new DefaultStatisticsProvider(executor));
-
- if (standby) builder.withSnfeListener(SegmentNotFoundExceptionListener.IGNORE_SNFE);
-
+ if (standby) {
+ builder.withSnfeListener(SegmentNotFoundExceptionListener.IGNORE_SNFE);
+ }
if (blobStore != null) {
builder.withBlobStore(blobStore.blobStore());
}
Added: jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/test/TemporaryPort.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/test/TemporaryPort.java?rev=1779324&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/test/TemporaryPort.java (added)
+++ jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/test/TemporaryPort.java Wed Jan 18 13:31:24 2017
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jackrabbit.oak.segment.test;
+
+import java.net.ServerSocket;
+
+import org.junit.rules.ExternalResource;
+
+public class TemporaryPort extends ExternalResource {
+
+ private int port;
+
+ @Override
+ protected void before() throws Throwable {
+ try (ServerSocket socket = new ServerSocket(0)) {
+ port = socket.getLocalPort();
+ }
+ }
+
+ public int getPort() {
+ return port;
+ }
+
+}
Propchange: jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/test/TemporaryPort.java
------------------------------------------------------------------------------
svn:eol-style = native
Re: svn commit: r1779324 - in /jackrabbit/oak/trunk/oak-segment-tar:
./ src/test/java/org/apache/jackrabbit/oak/segment/standby/ src/test/java/org/apache/jackrabbit/oak/segment/test/
Posted by Francesco Mari <ma...@gmail.com>.
Good suggestion. I opened OAK-5483 to track this.
2017-01-19 5:26 GMT+01:00 Chetan Mehrotra <ch...@gmail.com>:
> Hi Francesco,
>
> On Wed, Jan 18, 2017 at 7:01 PM, <fr...@apache.org> wrote:
>> +package org.apache.jackrabbit.oak.segment.test;
>> +
>> +import java.net.ServerSocket;
>> +
>> +import org.junit.rules.ExternalResource;
>> +
>> +public class TemporaryPort extends ExternalResource {
>> +
>> + private int port;
>> +
>> + @Override
>> + protected void before() throws Throwable {
>> + try (ServerSocket socket = new ServerSocket(0)) {
>> + port = socket.getLocalPort();
>> + }
>> + }
>> +
>> + public int getPort() {
>> + return port;
>> + }
>> +
>> +}
>
> This looks useful and can be used in other places also like in [1].
> Would be good if we can move it to oak-commons in
> org.apache.jackrabbit.oak.commons.junit package.
>
> Chetan Mehrotra
> [1] https://issues.apache.org/jira/browse/OAK-5441?focusedCommentId=15823491&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-15823491
Re: svn commit: r1779324 - in /jackrabbit/oak/trunk/oak-segment-tar:
./ src/test/java/org/apache/jackrabbit/oak/segment/standby/ src/test/java/org/apache/jackrabbit/oak/segment/test/
Posted by Chetan Mehrotra <ch...@gmail.com>.
Hi Francesco,
On Wed, Jan 18, 2017 at 7:01 PM, <fr...@apache.org> wrote:
> +package org.apache.jackrabbit.oak.segment.test;
> +
> +import java.net.ServerSocket;
> +
> +import org.junit.rules.ExternalResource;
> +
> +public class TemporaryPort extends ExternalResource {
> +
> + private int port;
> +
> + @Override
> + protected void before() throws Throwable {
> + try (ServerSocket socket = new ServerSocket(0)) {
> + port = socket.getLocalPort();
> + }
> + }
> +
> + public int getPort() {
> + return port;
> + }
> +
> +}
This looks useful and can be used in other places also like in [1].
Would be good if we can move it to oak-commons in
org.apache.jackrabbit.oak.commons.junit package.
Chetan Mehrotra
[1] https://issues.apache.org/jira/browse/OAK-5441?focusedCommentId=15823491&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-15823491