Skip to content

Commit

Permalink
[test] Replace Awaitility with CommonTestUtils to reduce dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
yuzelin committed Apr 9, 2024
1 parent 62016e4 commit fe38a57
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.paimon.types.DataField;
import org.apache.paimon.types.DataTypes;
import org.apache.paimon.utils.BlockingIterator;
import org.apache.paimon.utils.CommonTestUtils;

import org.apache.flink.configuration.RestartStrategyOptions;
import org.apache.flink.table.api.config.ExecutionConfigOptions;
Expand All @@ -35,18 +36,17 @@
import org.apache.flink.types.RowKind;
import org.apache.flink.util.CloseableIterator;
import org.assertj.core.api.Assertions;
import org.awaitility.Awaitility;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -126,25 +126,21 @@ public void testForeignKeyJoin() throws Exception {

batchSql("INSERT INTO ods_orders VALUES (1, 2, 3)");
batchSql("INSERT INTO dim_persons VALUES (3, 'snow', 'jon', 23)");
Awaitility.await()
.pollInSameThread()
.atMost(5, TimeUnit.SECONDS)
.untilAsserted(
() ->
assertThat(rowsToList(batchSql("SELECT * FROM dwd_orders")))
.containsExactly(
Arrays.asList(1, 2, 3, "snow", "jon", 23)));
CommonTestUtils.waitUtil(
() ->
rowsToList(batchSql("SELECT * FROM dwd_orders"))
.contains(Arrays.asList(1, 2, 3, "snow", "jon", 23)),
Duration.ofSeconds(5),
Duration.ofMillis(200));

batchSql("INSERT INTO ods_orders VALUES (1, 4, 3)");
batchSql("INSERT INTO dim_persons VALUES (3, 'snow', 'targaryen', 23)");
Awaitility.await()
.pollInSameThread()
.atMost(5, TimeUnit.SECONDS)
.untilAsserted(
() ->
assertThat(rowsToList(batchSql("SELECT * FROM dwd_orders")))
.containsExactly(
Arrays.asList(1, 4, 3, "snow", "targaryen", 23)));
CommonTestUtils.waitUtil(
() ->
rowsToList(batchSql("SELECT * FROM dwd_orders"))
.contains(Arrays.asList(1, 4, 3, "snow", "targaryen", 23)),
Duration.ofSeconds(5),
Duration.ofMillis(200));

iter.close();
}
Expand Down
8 changes: 0 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ under the License.
<flink.forkCount>1C</flink.forkCount>
<flink.reuseForks>true</flink.reuseForks>
<testcontainers.version>1.19.1</testcontainers.version>
<awaitility.version>4.2.0</awaitility.version>

<!-- Can be set to any value to reproduce a specific build. -->
<test.randomization.seed/>
Expand Down Expand Up @@ -192,13 +191,6 @@ under the License.
<artifactId>log4j-1.2-api</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>${awaitility.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<dependencyManagement>
Expand Down

0 comments on commit fe38a57

Please sign in to comment.