use of org.apache.jackrabbit.oak.segment.test.proxy.NetworkErrorProxy in project jackrabbit-oak by apache.
the class BrokenNetworkIT method useProxy.
private void useProxy(boolean ssl, int skipPosition, int skipBytes, int flipPosition, boolean intermediateChange) throws Exception {
FileStore serverStore = serverFileStore.fileStore();
FileStore clientStore = clientFileStore1.fileStore();
NodeStore store = SegmentNodeStoreBuilders.builder(serverStore).build();
addTestContent(store, "server");
serverStore.flush();
try (StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), serverStore, MB, ssl)) {
serverSync.start();
File spoolFolder = folder.newFolder();
try (NetworkErrorProxy ignored = new NetworkErrorProxy(proxyPort.getPort(), getServerHost(), serverPort.getPort(), flipPosition, skipPosition, skipBytes);
StandbyClientSync clientSync = new StandbyClientSync(getServerHost(), proxyPort.getPort(), clientStore, ssl, getClientTimeout(), false, spoolFolder)) {
clientSync.run();
}
assertFalse("stores are equal", serverStore.getHead().equals(clientStore.getHead()));
if (intermediateChange) {
addTestContent(store, "server2");
serverStore.flush();
}
try (StandbyClientSync clientSync = new StandbyClientSync(getServerHost(), serverPort.getPort(), clientStore, ssl, getClientTimeout(), false, spoolFolder)) {
clientSync.run();
}
}
assertEquals("stores are not equal", serverStore.getHead(), clientStore.getHead());
}
use of org.apache.jackrabbit.oak.segment.test.proxy.NetworkErrorProxy in project jackrabbit-oak by apache.
the class DataStoreTestBase method useProxy.
private void useProxy(int skipPosition, int skipBytes, int flipPosition, boolean intermediateChange) throws Exception {
int blobSize = 5 * MB;
FileStore primary = getPrimary();
FileStore secondary = getSecondary();
NodeStore store = SegmentNodeStoreBuilders.builder(primary).build();
byte[] data = addTestContent(store, "server", blobSize);
primary.flush();
try (StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), primary, MB)) {
serverSync.start();
File spoolFolder = folder.newFolder();
try (NetworkErrorProxy ignored = new NetworkErrorProxy(proxyPort.getPort(), getServerHost(), serverPort.getPort(), flipPosition, skipPosition, skipBytes);
StandbyClientSync clientSync = new StandbyClientSync(getServerHost(), proxyPort.getPort(), secondary, false, getClientTimeout(), false, spoolFolder)) {
clientSync.run();
}
if (storesShouldBeDifferent()) {
assertFalse("stores are equal", primary.getHead().equals(secondary.getHead()));
}
if (intermediateChange) {
blobSize = 2 * MB;
data = addTestContent(store, "server", blobSize);
primary.flush();
}
try (StandbyClientSync clientSync = new StandbyClientSync(getServerHost(), serverPort.getPort(), secondary, false, getClientTimeout(), false, spoolFolder)) {
clientSync.run();
}
}
assertEquals(primary.getHead(), secondary.getHead());
assertTrue(primary.getStats().getApproximateSize() < MB);
assertTrue(secondary.getStats().getApproximateSize() < MB);
PropertyState ps = secondary.getHead().getChildNode("root").getChildNode("server").getProperty("testBlob");
assertNotNull(ps);
assertEquals(Type.BINARY.tag(), ps.getType().tag());
Blob b = ps.getValue(Type.BINARY);
assertEquals(blobSize, b.length());
byte[] testData = new byte[blobSize];
try (InputStream blobInputStream = b.getNewStream()) {
ByteStreams.readFully(blobInputStream, testData);
assertArrayEquals(data, testData);
}
}
Aggregations