Skip to content

Commit

Permalink
Add list of actual results to CLITest output when it fails (#494)
Browse files Browse the repository at this point in the history
This patch adds logging to the `CLITest` so that we know the actual results we got when it fails. It could be that no results are ever returned, or it could be that there is another error and error strings are returned. This patch will learn the cause of the failures.
  • Loading branch information
apurvam authored Dec 1, 2017
1 parent 0371a08 commit bd9bd58
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ksql-cli/src/test/java/io/confluent/ksql/TestRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Objects;

import static junit.framework.TestCase.fail;
Expand Down Expand Up @@ -56,11 +59,15 @@ protected static void test(String command, TestResult.OrderedResult expectedResu

protected static void test(String command, TestResult expectedResult, boolean requireOrder) {
run(command, requireOrder);
final Collection<List<String>> finalResults = new ArrayList<>();
try {
TestUtils.waitForCondition(() -> {
TestResult actualResult = testTerminal.getTestResult();
finalResults.clear();
finalResults.addAll(actualResult.data);
return actualResult.data.containsAll(expectedResult.data);
}, 10000, "Did not get the expected result '" + expectedResult.toString() + ", in a timely fashion.");
}, 10000, "Did not get the expected result '" + expectedResult + ", in a timely fashion. Received " +
"following results instead: " + finalResults);
} catch (InterruptedException e) {
fail("Test got interrutped when waiting for result " + expectedResult.toString());
}
Expand Down

0 comments on commit bd9bd58

Please sign in to comment.