HCOLL-246 added in the @Ignore back to the soak test

This commit is contained in:
Rob Austin
2014-12-16 15:39:31 +00:00
parent 72512df5c9
commit 86af5a3e8d
2 changed files with 55 additions and 58 deletions
@@ -1,22 +1,17 @@
package net.openhft.chronicle.map;
import junit.framework.Assert;
import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig;
import net.openhft.lang.io.ByteBufferBytes;
import net.openhft.lang.model.Byteable;
import net.openhft.lang.model.DataValueClasses;
import net.openhft.lang.values.IntValue;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.io.Closeable;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.TimeUnit;
@@ -25,16 +20,22 @@ import java.util.concurrent.TimeUnit;
*/
public class TcpReplicationLargeEntryTest {
private ChronicleMap<Integer, CharSequence> map1;
private ChronicleMap<Integer, CharSequence> map2;
private IntValue value;
static int s_port = 8010;
int valueSize = 1_00_000; // 1MB
char[] valueX = new char[valueSize - 100];
char[] valueY = new char[valueSize - 100];
@Before
public void setup() throws IOException {
value = DataValueClasses.newDirectReference(IntValue.class);
((Byteable) value).bytes(new ByteBufferBytes(ByteBuffer.allocateDirect(4)), 0);
Arrays.fill(valueX, 'X');
Arrays.fill(valueX, 'Y');
int keySize = 4;
int entrySize = keySize + valueSize;
final InetSocketAddress endpoint = new InetSocketAddress("localhost", s_port + 1);
@@ -46,7 +47,8 @@ public class TcpReplicationLargeEntryTest {
map1 = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
.entries(Builder.SIZE + Builder.SIZE)
.entrySize(entrySize)
.entries(2)
.actualSegments(1)
.replication((byte) 1, tcpConfig1)
.instance()
@@ -60,7 +62,8 @@ public class TcpReplicationLargeEntryTest {
.tcpBufferSize(1024 * 64);
map2 = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
.entries(Builder.SIZE + Builder.SIZE)
.entrySize(entrySize)
.entries(2)
.replication((byte) 2, tcpConfig2)
.instance()
.name("map2")
@@ -99,30 +102,20 @@ public class TcpReplicationLargeEntryTest {
@Test
public void testSoakTestWithRandomData() throws IOException, InterruptedException {
public void testLargeValues() throws IOException, InterruptedException {
System.out.print("SoakTesting ");
for (int j = 1; j < 2 * Builder.SIZE; j++) {
if (j % 100 == 0)
System.out.print(".");
Random rnd = new Random(j);
for (int i = 1; i < 10; i++) {
final int select = rnd.nextInt(2);
final ChronicleMap<Integer, CharSequence> map = select > 0 ? map1 : map2;
String xString = new String(valueX);
String yString = new String(valueY);
map1.put(1, xString);
map1.put(2, yString);
if (rnd.nextBoolean()) {
map.put(rnd.nextInt(Builder.SIZE), "test" + j);
} else {
map.remove(rnd.nextInt(Builder.SIZE));
}
}
}
Thread.sleep(1000);
System.out.println("\nwaiting till equal");
waitTillEqual(10000);
Assert.assertEquals(map1, map2);
Assert.assertEquals(xString, map2.get(1));
Assert.assertEquals(yString, map2.get(2));
}