reswqa commented on code in PR #20351:
URL: https://github.com/apache/flink/pull/20351#discussion_r932475298


##########
flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/BlockingResultPartitionReleaseTest.java:
##########
@@ -0,0 +1,152 @@
+/*
+ * 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://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.
+ */
+
+package org.apache.flink.runtime.executiongraph;
+
+import org.apache.flink.api.common.JobID;
+import org.apache.flink.runtime.blob.TestingBlobWriter;
+import org.apache.flink.runtime.concurrent.ComponentMainThreadExecutor;
+import 
org.apache.flink.runtime.concurrent.ComponentMainThreadExecutorServiceAdapter;
+import 
org.apache.flink.runtime.concurrent.ManuallyTriggeredScheduledExecutorService;
+import 
org.apache.flink.runtime.io.network.partition.NoOpJobMasterPartitionTracker;
+import org.apache.flink.runtime.io.network.partition.ResultPartitionID;
+import org.apache.flink.runtime.jobgraph.DistributionPattern;
+import org.apache.flink.runtime.jobgraph.JobVertex;
+import org.apache.flink.runtime.scheduler.SchedulerBase;
+import org.apache.flink.testutils.TestingUtils;
+import org.apache.flink.testutils.executor.TestExecutorExtension;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+
+import static 
org.apache.flink.runtime.executiongraph.ExecutionGraphTestUtils.createSchedulerAndDeploy;
+import static 
org.apache.flink.runtime.executiongraph.ExecutionGraphTestUtils.transitionTasksToFinished;
+import static org.apache.flink.util.Preconditions.checkNotNull;
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Tests that blocking result partitions are properly released. */
+public class BlockingResultPartitionReleaseTest {

Review Comment:
   ```suggestion
   class BlockingResultPartitionReleaseTest {
   ```
   Test class should package-private also.



##########
flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/DefaultExecutionGraphConstructionTest.java:
##########
@@ -351,9 +355,42 @@ public void testAttachToDynamicGraph() throws Exception {
         ExecutionGraph eg = createDynamicExecutionGraph(ordered);
         eg.attachJobGraph(ordered);
 
-        assertThat(eg.getAllVertices().size(), is(2));
+        Assertions.assertThat(eg.getAllVertices().size()).isEqualTo(2);

Review Comment:
   ```suggestion
           Assertions.assertThat(eg.getAllVertices()).hasSize(2);
   ```



##########
flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/adapter/DefaultExecutionTopologyTest.java:
##########
@@ -300,17 +292,15 @@ private static void assertGraphEquals(
             assertPartitionsEquals(originalProducedPartitions, 
adaptedProducedPartitions);
         }
 
-        assertFalse(
-                "Number of adapted vertices exceeds number of original 
vertices.",
-                adaptedVertices.hasNext());
+        Assertions.assertThat(adaptedVertices.hasNext()).isFalse();
     }
 
     private static void assertPartitionsEquals(
             Iterable<IntermediateResultPartition> originalResultPartitions,
             Iterable<DefaultResultPartition> adaptedResultPartitions) {
 
-        assertEquals(
-                Iterables.size(originalResultPartitions), 
Iterables.size(adaptedResultPartitions));
+        Assertions.assertThat(Iterables.size(adaptedResultPartitions))
+                .isEqualTo(Iterables.size(originalResultPartitions));

Review Comment:
   ```suggestion
            
Assertions.assertThat(originalResultPartitions).hasSameSizeAs(adaptedResultPartitions);
   ```



##########
flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/adapter/DefaultResultPartitionTest.java:
##########
@@ -52,42 +51,46 @@ public class DefaultResultPartitionTest extends TestLogger {
 
     private DefaultResultPartition resultPartition;
 
-    private final Map<IntermediateResultPartitionID, ConsumerVertexGroup> 
consumerVertexGroups =
-            new HashMap<>();
+    private final Map<IntermediateResultPartitionID, List<ConsumerVertexGroup>>
+            consumerVertexGroups = new HashMap<>();
 
-    @Before
-    public void setUp() {
+    @BeforeEach
+    void setUp() {
         resultPartition =
                 new DefaultResultPartition(
                         resultPartitionId,
                         intermediateResultId,
                         BLOCKING,
                         resultPartitionState,
-                        () -> consumerVertexGroups.get(resultPartitionId),
+                        () ->
+                                consumerVertexGroups.computeIfAbsent(
+                                        resultPartitionId, ignored -> new 
ArrayList<>()),
                         () -> {
                             throw new UnsupportedOperationException();
                         });
     }
 
     @Test
-    public void testGetPartitionState() {
+    void testGetPartitionState() {
         for (ResultPartitionState state : ResultPartitionState.values()) {
             resultPartitionState.setResultPartitionState(state);
-            assertEquals(state, resultPartition.getState());
+            Assertions.assertThat(resultPartition.getState()).isEqualTo(state);
         }
     }
 
     @Test
-    public void testGetConsumerVertexGroup() {
+    void testGetConsumerVertexGroup() {
 
-        assertFalse(resultPartition.getConsumerVertexGroup().isPresent());
+        
Assertions.assertThat(resultPartition.getConsumerVertexGroups().isEmpty()).isTrue();

Review Comment:
   ```suggestion
           
Assertions.assertThat(resultPartition.getConsumerVertexGroups()).isEmpty();
   ```



##########
flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/adapter/DefaultExecutionTopologyTest.java:
##########
@@ -300,17 +292,15 @@ private static void assertGraphEquals(
             assertPartitionsEquals(originalProducedPartitions, 
adaptedProducedPartitions);
         }
 
-        assertFalse(
-                "Number of adapted vertices exceeds number of original 
vertices.",
-                adaptedVertices.hasNext());
+        Assertions.assertThat(adaptedVertices.hasNext()).isFalse();

Review Comment:
   ```suggestion
           Assertions.assertThat(adaptedVertices)
                   .as("Number of adapted vertices exceeds number of original 
vertices.")
                   .isExhausted();
   ```



##########
flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/adapter/DefaultExecutionTopologyTest.java:
##########
@@ -328,19 +318,28 @@ private static void assertPartitionsEquals(
 
             assertPartitionEquals(originalPartition, adaptedPartition);
 
-            ConsumerVertexGroup consumerVertexGroup = 
originalPartition.getConsumerVertexGroup();
-            Optional<ConsumerVertexGroup> adaptedConsumers =
-                    adaptedPartition.getConsumerVertexGroup();
-            assertTrue(adaptedConsumers.isPresent());
-            for (ExecutionVertexID originalId : consumerVertexGroup) {
+            List<ExecutionVertexID> originalConsumerIds = new ArrayList<>();
+            for (ConsumerVertexGroup consumerVertexGroup :
+                    originalPartition.getConsumerVertexGroups()) {
+                for (ExecutionVertexID executionVertexId : 
consumerVertexGroup) {
+                    originalConsumerIds.add(executionVertexId);
+                }
+            }
+            List<ConsumerVertexGroup> adaptedConsumers = 
adaptedPartition.getConsumerVertexGroups();
+            Assertions.assertThat(adaptedConsumers.isEmpty()).isFalse();

Review Comment:
   ```suggestion
               Assertions.assertThat(adaptedConsumers).isNotEmpty();
   ```



##########
flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionJobVertexTest.java:
##########
@@ -29,164 +29,132 @@
 import org.apache.flink.runtime.scheduler.VertexParallelismStore;
 import org.apache.flink.runtime.scheduler.adaptivebatch.AdaptiveBatchScheduler;
 import org.apache.flink.testutils.TestingUtils;
-import org.apache.flink.testutils.executor.TestExecutorResource;
+import org.apache.flink.testutils.executor.TestExecutorExtension;
 
-import org.junit.Assert;
-import org.junit.ClassRule;
-import org.junit.Test;
+import org.assertj.core.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
 import java.util.Collections;
 import java.util.concurrent.ScheduledExecutorService;
 
-import static org.apache.flink.core.testutils.CommonTestUtils.assertThrows;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
 /** Test for {@link ExecutionJobVertex} */
 public class ExecutionJobVertexTest {
-    @ClassRule
-    public static final TestExecutorResource<ScheduledExecutorService> 
EXECUTOR_RESOURCE =
-            TestingUtils.defaultExecutorResource();
+    @RegisterExtension
+    static final TestExecutorExtension<ScheduledExecutorService> 
EXECUTOR_RESOURCE =
+            TestingUtils.defaultExecutorExtension();
 
     @Test
-    public void testParallelismGreaterThanMaxParallelism() {
+    void testParallelismGreaterThanMaxParallelism() {
         JobVertex jobVertex = new JobVertex("testVertex");
         jobVertex.setInvokableClass(AbstractInvokable.class);
         // parallelism must be smaller than the max parallelism
         jobVertex.setParallelism(172);
         jobVertex.setMaxParallelism(4);
 
-        assertThrows(
-                "higher than the max parallelism",
-                JobException.class,
-                () -> 
ExecutionGraphTestUtils.getExecutionJobVertex(jobVertex));
+        Assertions.assertThatThrownBy(
+                        () -> 
ExecutionGraphTestUtils.getExecutionJobVertex(jobVertex))
+                .isInstanceOf(JobException.class)
+                .hasMessageContaining("higher than the max parallelism");
     }
 
     @Test
-    public void testLazyInitialization() throws Exception {
+    void testLazyInitialization() throws Exception {
         final int parallelism = 3;
         final int configuredMaxParallelism = 12;
         final ExecutionJobVertex ejv =
                 createDynamicExecutionJobVertex(parallelism, 
configuredMaxParallelism, -1);
 
-        assertThat(ejv.getParallelism(), is(parallelism));
-        assertThat(ejv.getMaxParallelism(), is(configuredMaxParallelism));
-        assertThat(ejv.isInitialized(), is(false));
+        Assertions.assertThat(ejv.getParallelism()).isEqualTo(parallelism);
+        
Assertions.assertThat(ejv.getMaxParallelism()).isEqualTo(configuredMaxParallelism);
+        Assertions.assertThat(ejv.isInitialized()).isFalse();
 
-        assertThat(ejv.getTaskVertices().length, is(0));
+        Assertions.assertThat(ejv.getTaskVertices().length).isEqualTo(0);

Review Comment:
   ```suggestion
           Assertions.assertThat(ejv.getTaskVertices()).isEmpty();
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to