Search in sources :

Example 1 with CommandStatement

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());
    });
}
Also used : CommandStatement(org.apache.geode.management.cli.CommandStatement) CommandStringBuilder(org.apache.geode.management.internal.cli.util.CommandStringBuilder) CommandProcessor(org.apache.geode.management.internal.cli.remote.CommandProcessor) IOException(java.io.IOException) File(java.io.File) Result(org.apache.geode.management.cli.Result) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Aggregations

File (java.io.File)1 IOException (java.io.IOException)1 CommandStatement (org.apache.geode.management.cli.CommandStatement)1 Result (org.apache.geode.management.cli.Result)1 CommandProcessor (org.apache.geode.management.internal.cli.remote.CommandProcessor)1 CommandStringBuilder (org.apache.geode.management.internal.cli.util.CommandStringBuilder)1 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)1 Test (org.junit.Test)1