Skip to content

Commit

Permalink
probe test servers
Browse files Browse the repository at this point in the history
  • Loading branch information
myronkscott committed Feb 2, 2023
1 parent 67e8a9b commit d4c100a
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 7 deletions.
12 changes: 6 additions & 6 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,41 +28,41 @@ jobs:
parameters:
jdkVersion: '1.8'
jobName: 'LinuxJava8'
gradleTasks: ':clustered:integration-test:test --tests=org.ehcache.clustered.replication.BasicClusteredCacheOpsReplicationMultiThreadedTest'
gradleTasks: ':clustered:integration-test:test --info --tests=org.ehcache.clustered.replication.BasicClusteredCacheOpsReplicationMultiThreadedTest'

- template: build-templates/gradle-common.yml@templates
parameters:
jdkVersion: '1.8'
options: '-PtestVM=java11Home'
jobName: 'LinuxJava11'
gradleTasks: ':clustered:integration-test:test --tests=org.ehcache.clustered.replication.BasicClusteredCacheOpsReplicationMultiThreadedTest'
gradleTasks: ':clustered:integration-test:test --info --tests=org.ehcache.clustered.replication.BasicClusteredCacheOpsReplicationMultiThreadedTest'

- template: build-templates/gradle-common.yml@templates
parameters:
jdkVersion: '1.8'
options: '-PtestVM=java17Home'
jobName: 'LinuxJava17'
gradleTasks: ':clustered:integration-test:test --tests=org.ehcache.clustered.replication.BasicClusteredCacheOpsReplicationMultiThreadedTest'
gradleTasks: ':clustered:integration-test:test --info --tests=org.ehcache.clustered.replication.BasicClusteredCacheOpsReplicationMultiThreadedTest'

- template: build-templates/gradle-common.yml@templates
parameters:
vmImage: 'windows-latest'
jdkVersion: '1.8'
jobName: 'WindowsJava8'
gradleTasks: ':clustered:integration-test:test --tests=org.ehcache.clustered.replication.BasicClusteredCacheOpsReplicationMultiThreadedTest'
gradleTasks: ':clustered:integration-test:test --info --tests=org.ehcache.clustered.replication.BasicClusteredCacheOpsReplicationMultiThreadedTest'

- template: build-templates/gradle-common.yml@templates
parameters:
vmImage: 'windows-latest'
jdkVersion: '1.8'
options: '-PtestVM=java11Home'
jobName: 'WindowsJava11'
gradleTasks: ':clustered:integration-test:test --tests=org.ehcache.clustered.replication.BasicClusteredCacheOpsReplicationMultiThreadedTest'
gradleTasks: ':clustered:integration-test:test --info --tests=org.ehcache.clustered.replication.BasicClusteredCacheOpsReplicationMultiThreadedTest'

- template: build-templates/gradle-common.yml@templates
parameters:
vmImage: 'windows-latest'
jdkVersion: '1.8'
options: '-PtestVM=java17Home'
jobName: 'WindowsJava17'
gradleTasks: ':clustered:integration-test:test --tests=org.ehcache.clustered.replication.BasicClusteredCacheOpsReplicationMultiThreadedTest'
gradleTasks: ':clustered:integration-test:test --info --tests=org.ehcache.clustered.replication.BasicClusteredCacheOpsReplicationMultiThreadedTest'
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@
import org.slf4j.LoggerFactory;

import java.io.Serializable;
import java.net.InetSocketAddress;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
Expand All @@ -69,6 +71,9 @@
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.fail;
import org.terracotta.connection.ConnectionException;
import org.terracotta.connection.Diagnostics;
import org.terracotta.connection.DiagnosticsFactory;


/**
Expand Down Expand Up @@ -98,7 +103,7 @@ public static Consistency[] data() {

@ClassRule @Rule
public static final ParallelTestCluster CLUSTER = new ParallelTestCluster(newCluster(2).in(clusterPath())
.withServiceFragment(offheapResource("primary-server-resource", 24)).build());
.withServiceFragment(offheapResource("primary-server-resource", 24)).withTcProperty("tc.messages.grouping.enabled", "false").build());

@Rule
public final TestName testName = new TestName();
Expand All @@ -110,6 +115,8 @@ public static Consistency[] data() {
private final ThreadLocalRandom random = ThreadLocalRandom.current();

private final ExecutorService executorService = Executors.newWorkStealingPool(NUM_OF_THREADS);

private final Probe probe = new Probe();

@Before
public void startServers() throws Exception {
Expand All @@ -134,6 +141,7 @@ public void startServers() throws Exception {
cache2 = cacheManager2.createCache(testName.getMethodName(), config);

caches = Arrays.asList(cache1, cache2);
probe.loop();
}

@After
Expand All @@ -148,6 +156,7 @@ public void tearDown() throws Exception {
if(cacheManager2 != null && cacheManager2.getStatus() != Status.UNINITIALIZED) {
cacheManager2.close();
}

}

@Test(timeout=180000)
Expand Down Expand Up @@ -287,4 +296,44 @@ private static class BlobValue implements Serializable {
private final byte[] data = new byte[10 * 1024];
}

public class Probe {

/**
* @param args the command line arguments
*/
public void loop() {
String[] servers = CLUSTER.getClusterHostPorts();
for (String hostPort : servers) {
String[] hp = hostPort.split("[:]");
InetSocketAddress inet = InetSocketAddress.createUnresolved(hp[0], Integer.parseInt(hp[1]));
log.info("starting probe for " + hostPort);
new Thread(()->{
while (!executorService.isShutdown()) {

try (Diagnostics d = DiagnosticsFactory.connect(inet, new Properties())) {
while (!executorService.isShutdown()) {
try {
probe(d);
log.info("sleeping for 10 sec.");
Thread.sleep(10_000L);
} catch (InterruptedException ie) {
ie.printStackTrace();
}
}
} catch (ConnectionException e) {
e.printStackTrace();
}
}

}).start();
}
}

private void probe(Diagnostics d) {
log.info("===== PROBE =====");
log.info(d.getClusterState());
log.info(d.getThreadDump());
}
}

}

0 comments on commit d4c100a

Please sign in to comment.