zhijiangW commented on a change in pull request #10375: [FLINK-14845][runtime] Introduce data compression to reduce disk and network IO of shuffle. URL: https://github.com/apache/flink/pull/10375#discussion_r353628288
########## File path: flink-tests/src/test/java/org/apache/flink/test/runtime/ShuffleCompressionITCase.java ########## @@ -0,0 +1,110 @@ +/* + * 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.test.runtime; + +import org.apache.flink.api.common.ExecutionMode; +import org.apache.flink.api.common.JobID; +import org.apache.flink.api.common.functions.FilterFunction; +import org.apache.flink.api.java.DataSet; +import org.apache.flink.api.java.ExecutionEnvironment; +import org.apache.flink.api.java.functions.KeySelector; +import org.apache.flink.client.program.MiniClusterClient; +import org.apache.flink.configuration.Configuration; +import org.apache.flink.configuration.NettyShuffleEnvironmentOptions; +import org.apache.flink.core.fs.FileSystem; +import org.apache.flink.optimizer.Optimizer; +import org.apache.flink.optimizer.plan.OptimizedPlan; +import org.apache.flink.optimizer.plantranslate.JobGraphGenerator; +import org.apache.flink.runtime.jobgraph.JobGraph; +import org.apache.flink.runtime.jobmaster.JobResult; +import org.apache.flink.runtime.minicluster.MiniCluster; +import org.apache.flink.runtime.minicluster.MiniClusterConfiguration; +import org.apache.flink.streaming.api.datastream.DataStreamSource; +import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment; +import org.apache.flink.streaming.api.functions.sink.DiscardingSink; +import org.apache.flink.streaming.api.graph.StreamingJobGraphGenerator; + +import org.junit.Test; + +import java.util.concurrent.CompletableFuture; + +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; + +/** + * Tests pipeline/blocking shuffle when data compression is enabled. + */ +public class ShuffleCompressionITCase { + + @Test + public void testDataCompressionForPipelineShuffle() throws Exception { + JobGraph jobGraph = createStreamJobGraph(); + executeTest(jobGraph); + } + + @Test + public void testDataCompressionForBlockingShuffle() throws Exception { + JobGraph jobGraph = createBatchJobGraph(); + executeTest(jobGraph); + } + + private void executeTest(JobGraph jobGraph) throws Exception { + Configuration configuration = new Configuration(); + configuration.setBoolean(NettyShuffleEnvironmentOptions.DATA_COMPRESS_ENABLED, true); + + final MiniClusterConfiguration miniClusterConfiguration = new MiniClusterConfiguration.Builder() + .setConfiguration(configuration) + .setNumTaskManagers(2) + .setNumSlotsPerTaskManager(1) + .build(); + + try (MiniCluster miniCluster = new MiniCluster(miniClusterConfiguration)) { + miniCluster.start(); + + MiniClusterClient miniClusterClient = new MiniClusterClient(configuration, miniCluster); + // wait for the submission to succeed + JobID jobID = miniClusterClient.submitJob(jobGraph).get(); + + CompletableFuture<JobResult> resultFuture = miniClusterClient.requestJobResult(jobID); + assertThat(resultFuture.get().getSerializedThrowable().isPresent(), is(false)); Review comment: I think it is better to further verify the results if possible because I wonder it might cause some data consistent issue during compression. ---------------------------------------------------------------- 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
