zentol commented on a change in pull request #8316: [FLINK-12369] 
[coordination] Implement a region failover strategy regarding the next version 
FailoverStrategy interfaces
URL: https://github.com/apache/flink/pull/8316#discussion_r282032304
 
 

 ##########
 File path: 
flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/failover/flip1/PipelinedFailoverRegionBuildingTest.java
 ##########
 @@ -0,0 +1,552 @@
+/*
+ * 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.failover.flip1;
+
+import org.apache.flink.runtime.io.network.partition.ResultPartitionType;
+import org.apache.flink.util.TestLogger;
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Tests that make sure that the building of pipelined connected failover 
regions works
+ * correctly.
+ */
+public class PipelinedFailoverRegionBuildingTest extends TestLogger {
+
+       /**
+        * Tests that validates that a graph with single unconnected vertices 
works correctly.
+        *
+        * <pre>
+        *     (v1)
+        *
+        *     (v2)
+        *
+        *     (v3)
+        * </pre>
+        */
+       @Test
+       public void testIndividualVertices() throws Exception {
+               TestFailoverTopology.Builder topologyBuilder = new 
TestFailoverTopology.Builder();
+
+               TestFailoverTopology.TestFailoverVertex v1 = 
topologyBuilder.newVertex();
+               TestFailoverTopology.TestFailoverVertex v2 = 
topologyBuilder.newVertex();
+               TestFailoverTopology.TestFailoverVertex v3 = 
topologyBuilder.newVertex();
+
+               FailoverTopology build = topologyBuilder.build();
+
+               RestartPipelinedRegionStrategy strategy = new 
RestartPipelinedRegionStrategy(build);
+
+               FailoverRegion r1 = 
strategy.getFailoverRegion(v1.getExecutionVertexID());
+               FailoverRegion r2 = 
strategy.getFailoverRegion(v2.getExecutionVertexID());
+               FailoverRegion r3 = 
strategy.getFailoverRegion(v3.getExecutionVertexID());
+
+               assertTrue(r1 != r2);
+               assertTrue(r1 != r3);
+               assertTrue(r2 != r3);
+       }
+
+       /**
+        * Tests that validates that embarrassingly parallel chains of vertices 
work correctly.
+        *
+        * <pre>
+        *     (a1) --> (b1)
+        *
+        *     (a2) --> (b2)
+        *
+        *     (a3) --> (b3)
+        * </pre>
+        */
+       @Test
+       public void testEmbarrassinglyParallelCase() throws Exception {
+               TestFailoverTopology.Builder topologyBuilder = new 
TestFailoverTopology.Builder();
+
+               TestFailoverTopology.TestFailoverVertex va1 = 
topologyBuilder.newVertex();
+               TestFailoverTopology.TestFailoverVertex va2 = 
topologyBuilder.newVertex();
+               TestFailoverTopology.TestFailoverVertex va3 = 
topologyBuilder.newVertex();
+               TestFailoverTopology.TestFailoverVertex vb1 = 
topologyBuilder.newVertex();
+               TestFailoverTopology.TestFailoverVertex vb2 = 
topologyBuilder.newVertex();
+               TestFailoverTopology.TestFailoverVertex vb3 = 
topologyBuilder.newVertex();
+
+               topologyBuilder
+                       .connect(va1, vb1, ResultPartitionType.PIPELINED)
+                       .connect(va2, vb2, ResultPartitionType.PIPELINED)
+                       .connect(va3, vb3, ResultPartitionType.PIPELINED);
+
+               FailoverTopology build = topologyBuilder.build();
+
+               RestartPipelinedRegionStrategy strategy = new 
RestartPipelinedRegionStrategy(build);
+
+               FailoverRegion ra1 = 
strategy.getFailoverRegion(va1.getExecutionVertexID());
+               FailoverRegion ra2 = 
strategy.getFailoverRegion(va2.getExecutionVertexID());
+               FailoverRegion ra3 = 
strategy.getFailoverRegion(va3.getExecutionVertexID());
+               FailoverRegion rb1 = 
strategy.getFailoverRegion(vb1.getExecutionVertexID());
+               FailoverRegion rb2 = 
strategy.getFailoverRegion(vb2.getExecutionVertexID());
+               FailoverRegion rb3 = 
strategy.getFailoverRegion(vb3.getExecutionVertexID());
+
+               assertTrue(ra1 == rb1);
+               assertTrue(ra2 == rb2);
+               assertTrue(ra3 == rb3);
 
 Review comment:
   we could make these checks more readable by introducing 
`assertSameRegion(FailoverRegion ... regions)` and 
`assertDistinctRegions(FailoverRegions ... regions)`

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to