Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
JNSimba committed Sep 9, 2024
1 parent e9234f3 commit 81c41ac
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,16 @@ private static void closeDorisContainer() {
// ------------------------------------------------------------------------
// test utilities
// ------------------------------------------------------------------------
public static void assertEqualsInAnyOrder(List<String> expected, List<String> actual) {
public static void assertEqualsInAnyOrder(List<Object> expected, List<Object> actual) {
assertTrue(expected != null && actual != null);
assertEqualsInOrder(
expected.stream().sorted().collect(Collectors.toList()),
actual.stream().sorted().collect(Collectors.toList()));
}

public static void assertEqualsInOrder(List<String> expected, List<String> actual) {
public static void assertEqualsInOrder(List<Object> expected, List<Object> actual) {
assertTrue(expected != null && actual != null);
assertEquals(expected.size(), actual.size());
assertArrayEquals(expected.toArray(new String[0]), actual.toArray(new String[0]));
assertArrayEquals(expected.toArray(new Object[0]), actual.toArray(new Object[0]));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,9 @@

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import java.util.Set;

/** DorisSource ITCase. */
public class DorisSourceITCase extends AbstractITCaseService {
Expand Down Expand Up @@ -89,7 +87,7 @@ public void testSource() throws Exception {
}
}
List<String> expected = Arrays.asList("[doris, 18]", "[flink, 10]", "[apache, 12]");
checkResult("testSource", expected.toArray(), actual.toArray());
checkResultInAnyOrder("testSource", expected.toArray(), actual.toArray());
}

@Test
Expand All @@ -115,7 +113,7 @@ options, new SimpleListDeserializationSchema()))
}
}
List<String> expected = Arrays.asList("[doris, 18]", "[flink, 10]", "[apache, 12]");
checkResult("testOldSourceApi", expected.toArray(), actual.toArray());
checkResultInAnyOrder("testOldSourceApi", expected.toArray(), actual.toArray());
}

@Test
Expand Down Expand Up @@ -164,7 +162,7 @@ public void testTableSource() throws Exception {
}
}
String[] expectedFilter = new String[] {"+I[doris, 18]"};
checkResult("testTableSource", expectedFilter, actualFilter.toArray());
checkResultInAnyOrder("testTableSource", expectedFilter, actualFilter.toArray());
}

@Test
Expand Down Expand Up @@ -201,7 +199,7 @@ public void testTableSourceOldApi() throws Exception {
}
}
String[] expected = new String[] {"+I[doris, 18]", "+I[flink, 10]", "+I[apache, 12]"};
checkResult("testTableSourceOldApi", expected, actual.toArray());
checkResultInAnyOrder("testTableSourceOldApi", expected, actual.toArray());
}

@Test
Expand Down Expand Up @@ -247,7 +245,7 @@ public void testTableSourceAllOptions() throws Exception {
}
}
String[] expected = new String[] {"+I[doris, 18]", "+I[flink, 10]", "+I[apache, 12]"};
checkResult("testTableSourceAllOptions", expected, actual.toArray());
checkResultInAnyOrder("testTableSourceAllOptions", expected, actual.toArray());
}

@Test
Expand Down Expand Up @@ -285,7 +283,8 @@ public void testTableSourceFilterAndProjectionPushDown() throws Exception {
}
}
String[] expected = new String[] {"+I[18]"};
checkResult("testTableSourceFilterAndProjectionPushDown", expected, actual.toArray());
checkResultInAnyOrder(
"testTableSourceFilterAndProjectionPushDown", expected, actual.toArray());
}

@Test
Expand Down Expand Up @@ -328,10 +327,8 @@ public void testTableSourceFilterWithUnionAll() {
LOG.error("Failed to execute sql. sql={}", querySql, e);
throw new DorisRuntimeException(e);
}
Set<String> expected = new HashSet<>(Arrays.asList("+I[flink, 10]", "+I[doris, 18]"));
for (String a : actual) {
Assert.assertTrue(expected.contains(a));
}
String[] expected = new String[] {"+I[flink, 10]", "+I[doris, 18]"};
checkResultInAnyOrder("testTableSourceFilterWithUnionAll", expected, actual.toArray());
}

@Test
Expand Down Expand Up @@ -376,8 +373,10 @@ public void testJobManagerFailoverSource() throws Exception {
() -> sleepMs(100));
}

assertEqualsInAnyOrder(
expectedSnapshotData, fetchRows(iterator, expectedSnapshotData.size()));
checkResultInAnyOrder(
"testJobManagerFailoverSource",
expectedSnapshotData.toArray(),
fetchRows(iterator, expectedSnapshotData.size()).toArray());
}

@Test
Expand Down Expand Up @@ -422,8 +421,10 @@ public void testTaskManagerFailoverSink() throws Exception {
() -> sleepMs(100));
}

assertEqualsInAnyOrder(
expectedSnapshotData, fetchRows(iterator, expectedSnapshotData.size()));
checkResultInAnyOrder(
"testTaskManagerFailoverSink",
expectedSnapshotData.toArray(),
fetchRows(iterator, expectedSnapshotData.size()).toArray());
}

private void checkResult(String testName, Object[] expected, Object[] actual) {
Expand All @@ -435,6 +436,15 @@ private void checkResult(String testName, Object[] expected, Object[] actual) {
Assert.assertArrayEquals(expected, actual);
}

private void checkResultInAnyOrder(String testName, Object[] expected, Object[] actual) {
LOG.info(
"Checking DorisSourceITCase result. testName={}, actual={}, expected={}",
testName,
actual,
expected);
assertEqualsInAnyOrder(Arrays.asList(expected), Arrays.asList(actual));
}

private void initializeTable(String table) {
ContainerUtils.executeSQLStatement(
getDorisQueryConnection(),
Expand Down

0 comments on commit 81c41ac

Please sign in to comment.