Skip to content

Commit

Permalink
OAK-6829 - Fix initialization order of test primary, standby, and proxy
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/jackrabbit/oak/trunk@1813318 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
francescomari committed Oct 25, 2017
1 parent ad3ac7e commit 6d73a06
Showing 1 changed file with 20 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ public abstract class DataStoreTestBase extends TestBase {

static final long GB = 1024 * 1024 * 1024;

private NetworkErrorProxy proxy;

@Rule
public TemporaryPort serverPort = new TemporaryPort();

Expand Down Expand Up @@ -129,12 +127,10 @@ protected void addTestContentOnTheFly(NodeStore store, String child, long size,
@Before
public void before() {
logger.info("Test begin: {}", testName.getMethodName());
proxy = new NetworkErrorProxy(proxyPort.getPort(), getServerHost(), serverPort.getPort());
}

@After
public void after() {
proxy.close();
logger.info("Test end: {}", testName.getMethodName());
}

Expand Down Expand Up @@ -342,32 +338,30 @@ private void useProxy(int skipPosition, int skipBytes, int flipPosition, boolean

NodeStore store = SegmentNodeStoreBuilders.builder(primary).build();
byte[] data = addTestContent(store, "server", blobSize);
try (
StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), primary, 1 * MB);
StandbyClientSync clientSync = newStandbyClientSync(secondary, proxyPort.getPort())
) {
proxy.skipBytes(skipPosition, skipBytes);
proxy.flipByte(flipPosition);
proxy.connect();

try (StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), primary, MB)) {
serverSync.start();
primary.flush();

clientSync.run();

if (skipBytes > 0 || flipPosition >= 0) {
if (!storesShouldBeEqual()) {
assertFalse("stores are not expected to be equal", primary.getHead().equals(secondary.getHead()));
}
proxy.reset();
if (intermediateChange) {
blobSize = 2 * MB;
data = addTestContent(store, "server", blobSize);
try (NetworkErrorProxy proxy = new NetworkErrorProxy(proxyPort.getPort(), getServerHost(), serverPort.getPort())) {
proxy.skipBytes(skipPosition, skipBytes);
proxy.flipByte(flipPosition);
proxy.connect();
try (StandbyClientSync clientSync = newStandbyClientSync(secondary, proxyPort.getPort())) {
primary.flush();
clientSync.run();
if (skipBytes > 0 || flipPosition >= 0) {
if (!storesShouldBeEqual()) {
assertFalse("stores are not expected to be equal", primary.getHead().equals(secondary.getHead()));
}
proxy.reset();
if (intermediateChange) {
blobSize = 2 * MB;
data = addTestContent(store, "server", blobSize);
primary.flush();
}
clientSync.run();
}
assertEquals(primary.getHead(), secondary.getHead());
}
clientSync.run();
}
assertEquals(primary.getHead(), secondary.getHead());
}

assertTrue(primary.getStats().getApproximateSize() < MB);
Expand Down

0 comments on commit 6d73a06

Please sign in to comment.