wanglijie95 commented on a change in pull request #18050:
URL: https://github.com/apache/flink/pull/18050#discussion_r782054114
##########
File path:
flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/IntermediateResultPartitionTest.java
##########
@@ -140,6 +150,126 @@ public void testBlockingPartitionResetting() throws
Exception {
assertFalse(consumedPartitionGroup.areAllPartitionsFinished());
}
+ @Test
+ public void testGetNumberOfSubpartitionsForNonDynamicAllToAllGraph()
throws Exception {
+ testGetNumberOfSubpartitions(7, DistributionPattern.ALL_TO_ALL, false,
Arrays.asList(7, 7));
+ }
+
+ @Test
+ public void testGetNumberOfSubpartitionsForNonDynamicPointWiseGraph()
throws Exception {
+ testGetNumberOfSubpartitions(7, DistributionPattern.POINTWISE, false,
Arrays.asList(4, 3));
+ }
+
+ @Test
+ public void
testGetNumberOfSubpartitionsFromConsumerParallelismForDynamicAllToAllGraph()
+ throws Exception {
+ testGetNumberOfSubpartitions(7, DistributionPattern.ALL_TO_ALL, true,
Arrays.asList(7, 7));
+ }
+
+ @Test
+ public void
testGetNumberOfSubpartitionsFromConsumerParallelismForDynamicPointWiseGraph()
+ throws Exception {
+ testGetNumberOfSubpartitions(7, DistributionPattern.POINTWISE, true,
Arrays.asList(4, 4));
+ }
+
+ @Test
+ public void
testGetNumberOfSubpartitionsFromConsumerMaxParallelismForDynamicAllToAllGraph()
+ throws Exception {
+ testGetNumberOfSubpartitions(
+ -1, DistributionPattern.ALL_TO_ALL, true, Arrays.asList(13,
13));
+ }
+
+ @Test
+ public void
testGetNumberOfSubpartitionsFromConsumerMaxParallelismForDynamicPointWiseGraph()
+ throws Exception {
+ testGetNumberOfSubpartitions(-1, DistributionPattern.POINTWISE, true,
Arrays.asList(7, 7));
+ }
+
+ private void testGetNumberOfSubpartitions(
+ int consumerParallelism,
+ DistributionPattern distributionPattern,
+ boolean isDynamicGraph,
+ Collection<Integer> expectedNumSubpartitions)
+ throws Exception {
+
+ final int producerParallelism = 2;
+ final int consumerMaxParallelism = 13;
+
+ final ExecutionGraph eg =
+ createExecutionGraph(
+ producerParallelism,
+ consumerParallelism,
+ consumerMaxParallelism,
+ distributionPattern,
+ isDynamicGraph);
+
+ final Iterator<ExecutionJobVertex> vertexIterator =
+ eg.getVerticesTopologically().iterator();
+ final ExecutionJobVertex producer = vertexIterator.next();
+
+ if (isDynamicGraph) {
+ ExecutionJobVertexTest.initializeVertex(producer);
+ }
+
+ final IntermediateResult result = producer.getProducedDataSets()[0];
+
+ assertThat(expectedNumSubpartitions.size(), is(producerParallelism));
+ assertThat(
+ Arrays.stream(result.getPartitions())
+
.map(IntermediateResultPartition::getNumberOfSubpartitions)
+ .collect(Collectors.toList()),
+ equalTo(expectedNumSubpartitions));
+ }
+
+ private static ExecutionGraph createExecutionGraph(
+ int producerParallelism,
+ int consumerParallelism,
+ int consumerMaxParallelism,
+ DistributionPattern distributionPattern,
+ boolean isDynamicGraph)
+ throws Exception {
+
+ final JobVertex v1 = new JobVertex("v1");
+ v1.setInvokableClass(NoOpInvokable.class);
+ v1.setParallelism(producerParallelism);
+
+ final JobVertex v2 = new JobVertex("v2");
+ v2.setInvokableClass(NoOpInvokable.class);
+ if (consumerParallelism > 0) {
+ v2.setParallelism(consumerParallelism);
+ }
+ if (consumerMaxParallelism > 0) {
+ v2.setMaxParallelism(consumerMaxParallelism);
+ }
+
+ v2.connectNewDataSetAsInput(v1, distributionPattern,
ResultPartitionType.BLOCKING);
+
+ final JobGraph jobGraph =
+ JobGraphBuilder.newBatchJobGraphBuilder()
+ .addJobVertices(Arrays.asList(v1, v2))
+ .build();
+
+ final Configuration configuration = new Configuration();
+
+ return TestingDefaultExecutionGraphBuilder.newBuilder()
+ .setJobGraph(jobGraph)
+ .setJobMasterConfig(configuration)
+ .setVertexParallelismStore(
+ computeVertexParallelismStoreConsideringDynamicGraph(
+ jobGraph.getVertices(), isDynamicGraph,
consumerMaxParallelism))
+ .buildDynamicGraph();
Review comment:
Thanks for pointing that out, and the
`testGetNumberOfSubpartitionsForNonDynamicAllToAllGraph` and
`testGetNumberOfSubpartitionsForNonDynamicPointwiseGraph` don't pass in
73c2ecd546c2ad9be7ee20382716edc9f6c6c574. I will fix it.
--
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]