Skip to content

Commit

Permalink
Fix flaky test KyuubiBeeLineTest.testKyuubiBeelineComment
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouyifan279 committed Mar 11, 2024
1 parent 29bf670 commit 935aa37
Showing 1 changed file with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ public void testKyuubiBeeLinePythonMode() {
}

@Test
public void testKyuubiBeelineComment() throws NoSuchFieldException {
KyuubiBeeLine kyuubiBeeLine =
public void testKyuubiBeelineComment() {
KyuubiBeeLine interceptedKyuubiBeeLine =
new KyuubiBeeLine() {
@Override
boolean dispatch(String line) {
Expand All @@ -103,26 +103,28 @@ boolean dispatch(String line) {
};

String[] cmd = new String[] {""};
KyuubiCommands commands =
new KyuubiCommands(kyuubiBeeLine) {
KyuubiCommands interceptedCommands =
new KyuubiCommands(interceptedKyuubiBeeLine) {
@Override
public boolean sql(String line, boolean entireLineAsCommand) {
cmd[0] = line;
return true;
}
};
kyuubiBeeLine.setCommands(commands);
interceptedKyuubiBeeLine.setCommands(interceptedCommands);

kyuubiBeeLine.initArgs(new String[] {"-u", "dummy_url", "-e", "--comment show database;"});
interceptedKyuubiBeeLine.initArgs(
new String[] {"-u", "dummy_url", "-e", "--comment show database;"});
assertEquals(0, cmd[0].length());

// Beeline#exit must be false to execute sql
kyuubiBeeLine.setExit(false);
kyuubiBeeLine.initArgs(new String[] {"-u", "dummy_url", "-e", "--comment\n show database;"});
interceptedKyuubiBeeLine.setExit(false);
interceptedKyuubiBeeLine.initArgs(
new String[] {"-u", "dummy_url", "-e", "--comment\n show database;"});
assertEquals("show database;", cmd[0]);

kyuubiBeeLine.setExit(false);
kyuubiBeeLine.initArgs(
interceptedKyuubiBeeLine.setExit(false);
interceptedKyuubiBeeLine.initArgs(
new String[] {
"-u", "dummy_url", "-e", "--comment line 1 \n --comment line 2 \n show database;"
});
Expand Down

0 comments on commit 935aa37

Please sign in to comment.