GJL commented on a change in pull request #9271: [FLINK-13384][runtime] Fix 
back pressure sampling for SourceStreamTask
URL: https://github.com/apache/flink/pull/9271#discussion_r309168203
 
 

 ##########
 File path: 
flink-tests/src/test/java/org/apache/flink/test/streaming/runtime/BackPressureITCase.java
 ##########
 @@ -0,0 +1,165 @@
+/*
+ * 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.streaming.runtime;
+
+import org.apache.flink.api.common.JobID;
+import org.apache.flink.api.common.time.Deadline;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.configuration.NettyShuffleEnvironmentOptions;
+import org.apache.flink.configuration.TaskManagerOptions;
+import org.apache.flink.configuration.WebOptions;
+import org.apache.flink.runtime.dispatcher.DispatcherGateway;
+import org.apache.flink.runtime.jobgraph.JobGraph;
+import org.apache.flink.runtime.jobgraph.JobVertex;
+import org.apache.flink.runtime.minicluster.TestingMiniCluster;
+import org.apache.flink.runtime.minicluster.TestingMiniClusterConfiguration;
+import 
org.apache.flink.runtime.rest.handler.legacy.backpressure.OperatorBackPressureStats;
+import 
org.apache.flink.runtime.rest.handler.legacy.backpressure.OperatorBackPressureStatsResponse;
+import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
+import org.apache.flink.test.util.BlockingSink;
+import org.apache.flink.test.util.IdentityMapFunction;
+import org.apache.flink.test.util.InfiniteIntegerSource;
+import org.apache.flink.util.TestLogger;
+import org.apache.flink.util.function.SupplierWithException;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.time.Duration;
+import java.util.List;
+import java.util.concurrent.TimeoutException;
+
+import static 
org.apache.flink.runtime.testutils.CommonTestUtils.waitUntilCondition;
+
+/**
+ * Integration test for operator back pressure tracking.
+ */
+public class BackPressureITCase extends TestLogger {
+
+       private static final JobID TEST_JOB_ID = new JobID();
+       private static final int NUM_TASKS = 3;
+       private static final int BACK_PRESSURE_REQUEST_INTERVAL_MS = 5;
+       private static final int TASKS_BECOMING_BACK_PRESSURED_TIMEOUT_MS = 15 
* 1000;
+       private static final int MAX_BACK_PRESSURE_RATIO = 1;
+
+       private TestingMiniCluster testingMiniCluster;
+       private DispatcherGateway dispatcherGateway;
+
+       @Before
+       public void setUp() throws Exception {
+               final Configuration configuration = new Configuration();
+               configuration.addAll(createBackPressureSamplingConfiguration());
+               configuration.addAll(createNetworkBufferConfiguration());
+
+               final TestingMiniClusterConfiguration 
testingMiniClusterConfiguration = new TestingMiniClusterConfiguration.Builder()
+                       .setNumSlotsPerTaskManager(NUM_TASKS)
+                       .setConfiguration(configuration)
+                       .build();
+
+               testingMiniCluster = new 
TestingMiniCluster(testingMiniClusterConfiguration);
+               testingMiniCluster.start();
+               dispatcherGateway = 
testingMiniCluster.getDispatcherGatewayFuture().get();
+       }
+
+       private static Configuration createBackPressureSamplingConfiguration() {
+               final Configuration configuration = new Configuration();
+               
configuration.setInteger(WebOptions.BACKPRESSURE_REFRESH_INTERVAL, 1000);
+               configuration.setInteger(WebOptions.BACKPRESSURE_NUM_SAMPLES, 
1);
+               
configuration.setInteger(WebOptions.BACKPRESSURE_CLEANUP_INTERVAL, 
Integer.MAX_VALUE);
+               return configuration;
+       }
+
+       private static Configuration createNetworkBufferConfiguration() {
+               final Configuration configuration = new Configuration();
+
+               final int memorySegmentSizeKb = 32;
+               final String networkBuffersMemory = (memorySegmentSizeKb * 
NUM_TASKS) + "kb";
+
+               configuration.setString(TaskManagerOptions.MEMORY_SEGMENT_SIZE, 
memorySegmentSizeKb + "kb");
+               
configuration.setString(NettyShuffleEnvironmentOptions.NETWORK_BUFFERS_MEMORY_MIN,
 networkBuffersMemory);
+               
configuration.setString(NettyShuffleEnvironmentOptions.NETWORK_BUFFERS_MEMORY_MAX,
 networkBuffersMemory);
+               return configuration;
+       }
+
+       @Test
 
 Review comment:
   yes it fails without my fix

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to