use of org.apache.geode.management.cli.CommandStatement in project geode by apache.
the class ShowDeadlockDUnitTest method testDistributedDeadlockWithFunction.
@Test
public void testDistributedDeadlockWithFunction() throws Exception {
// Have two threads lock locks on different members in different orders.
// This thread locks the lock member0 first, then member1.
lockTheLocks(vm0, member1);
// This thread locks the lock member1 first, then member0.
lockTheLocks(vm1, member0);
File outputFile = new File(temporaryFolder.getRoot(), "dependency.txt");
String showDeadlockCommand = new CommandStringBuilder(CliStrings.SHOW_DEADLOCK).addOption(CliStrings.SHOW_DEADLOCK__DEPENDENCIES__FILE, outputFile.getName()).toString();
CommandStatement showDeadlocksCommand = new CommandProcessor().createCommandStatement(showDeadlockCommand, Collections.emptyMap());
Awaitility.await().atMost(1, TimeUnit.MINUTES).until(() -> {
Result result = showDeadlocksCommand.process();
try {
result.saveIncomingFiles(temporaryFolder.getRoot().getAbsolutePath());
} catch (IOException e) {
throw new RuntimeException(e);
}
String commandOutput = getResultAsString(result);
assertEquals(true, commandOutput.startsWith(CliStrings.SHOW_DEADLOCK__DEADLOCK__DETECTED));
assertEquals(true, result.getStatus().equals(Status.OK));
assertTrue(outputFile.exists());
});
}
Aggregations