Skip to content

Commit

Permalink
[FLINK-30316][statebackend] Migrate tests to JUnit5
Browse files Browse the repository at this point in the history
  • Loading branch information
snuyanzin authored and XComp committed Dec 7, 2022
1 parent a798e52 commit a0a5c71
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 12 deletions.
21 changes: 21 additions & 0 deletions flink-state-backends/flink-statebackend-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,25 @@ under the License.

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
<configuration>
<excludes>
<!-- test-jar is still used by JUnit4 modules -->
<exclude>META-INF/services/org.junit.jupiter.api.extension.Extension</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,19 @@
import org.apache.flink.runtime.mailbox.SyncMailboxExecutor;
import org.apache.flink.runtime.metrics.groups.UnregisteredMetricGroups;
import org.apache.flink.state.common.PeriodicMaterializationManager.MaterializationTarget;
import org.apache.flink.util.TestLogger;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.apache.flink.shaded.guava30.com.google.common.collect.Iterators.getOnlyElement;
import static org.apache.flink.util.concurrent.Executors.newDirectExecutorService;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.lessThanOrEqualTo;
import static org.assertj.core.api.Assertions.assertThat;

/** {@link PeriodicMaterializationManager} test. */
public class PeriodicMaterializationManagerTest extends TestLogger {
class PeriodicMaterializationManagerTest {

@Test
public void testInitialDelay() {
void testInitialDelay() {
ManuallyTriggeredScheduledExecutorService scheduledExecutorService =
new ManuallyTriggeredScheduledExecutorService();
long periodicMaterializeDelay = 10_000L;
Expand All @@ -56,12 +54,16 @@ public void testInitialDelay() {
test.start();

assertThat(
String.format(
"task for initial materialization should be scheduled with a 0..%d delay",
periodicMaterializeDelay),
getOnlyElement(scheduledExecutorService.getAllScheduledTasks().iterator())
.getDelay(MILLISECONDS),
lessThanOrEqualTo(periodicMaterializeDelay));
getOnlyElement(
scheduledExecutorService
.getAllScheduledTasks()
.iterator())
.getDelay(MILLISECONDS))
.as(
String.format(
"task for initial materialization should be scheduled with a 0..%d delay",
periodicMaterializeDelay))
.isLessThanOrEqualTo(periodicMaterializeDelay);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http:https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

org.apache.flink.util.TestLoggerExtension

0 comments on commit a0a5c71

Please sign in to comment.