You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by tr...@apache.org on 2020/05/20 09:27:23 UTC

[flink] branch release-1.11 updated: [FLINK-17725][tests] Disable OkHttpClient timeouts for FileUploadHandlerTest

This is an automated email from the ASF dual-hosted git repository.

trohrmann pushed a commit to branch release-1.11
in repository https://gitbox.apache.org/repos/asf/flink.git


The following commit(s) were added to refs/heads/release-1.11 by this push:
     new 1b0d7fd  [FLINK-17725][tests] Disable OkHttpClient timeouts for FileUploadHandlerTest
1b0d7fd is described below

commit 1b0d7fddfb5e948fe9c6fa8b17f6c00569addd02
Author: Till Rohrmann <tr...@apache.org>
AuthorDate: Tue May 19 14:45:56 2020 +0200

    [FLINK-17725][tests] Disable OkHttpClient timeouts for FileUploadHandlerTest
    
    In order to harden the test case FileUploadHandlerTest, this commit disables the timeouts
    of the used OkHttpClient.
    
    This closes #12248.
---
 .../flink/runtime/rest/FileUploadHandlerTest.java  | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/rest/FileUploadHandlerTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/rest/FileUploadHandlerTest.java
index 80fa4b9..74c0ee3 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/rest/FileUploadHandlerTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/rest/FileUploadHandlerTest.java
@@ -40,6 +40,7 @@ import java.io.IOException;
 import java.io.StringWriter;
 import java.lang.reflect.Field;
 import java.util.LinkedHashSet;
+import java.util.concurrent.TimeUnit;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
@@ -130,7 +131,7 @@ public class FileUploadHandlerTest extends TestLogger {
 
 	@Test
 	public void testUploadDirectoryRegeneration() throws Exception {
-		OkHttpClient client = new OkHttpClient();
+		OkHttpClient client = createOkHttpClientWithNoTimeouts();
 
 		MultipartUploadResource.MultipartFileHandler fileHandler = MULTIPART_UPLOAD_RESOURCE.getFileHandler();
 
@@ -146,7 +147,7 @@ public class FileUploadHandlerTest extends TestLogger {
 
 	@Test
 	public void testMixedMultipart() throws Exception {
-		OkHttpClient client = new OkHttpClient();
+		OkHttpClient client = createOkHttpClientWithNoTimeouts();
 
 		MultipartUploadResource.MultipartMixedHandler mixedHandler = MULTIPART_UPLOAD_RESOURCE.getMixedHandler();
 
@@ -174,7 +175,7 @@ public class FileUploadHandlerTest extends TestLogger {
 
 	@Test
 	public void testJsonMultipart() throws Exception {
-		OkHttpClient client = new OkHttpClient();
+		OkHttpClient client = createOkHttpClientWithNoTimeouts();
 
 		MultipartUploadResource.MultipartJsonHandler jsonHandler = MULTIPART_UPLOAD_RESOURCE.getJsonHandler();
 
@@ -202,7 +203,7 @@ public class FileUploadHandlerTest extends TestLogger {
 
 	@Test
 	public void testFileMultipart() throws Exception {
-		OkHttpClient client = new OkHttpClient();
+		OkHttpClient client = createOkHttpClientWithNoTimeouts();
 
 		MultipartUploadResource.MultipartFileHandler fileHandler = MULTIPART_UPLOAD_RESOURCE.getFileHandler();
 
@@ -228,7 +229,7 @@ public class FileUploadHandlerTest extends TestLogger {
 
 	@Test
 	public void testUploadCleanupOnUnknownAttribute() throws IOException {
-		OkHttpClient client = new OkHttpClient();
+		OkHttpClient client = createOkHttpClientWithNoTimeouts();
 
 		Request request = buildMixedRequestWithUnknownAttribute(MULTIPART_UPLOAD_RESOURCE.getMixedHandler().getMessageHeaders().getTargetRestEndpointURL());
 		try (Response response = client.newCall(request).execute()) {
@@ -244,7 +245,7 @@ public class FileUploadHandlerTest extends TestLogger {
 	 */
 	@Test
 	public void testUploadCleanupOnFailure() throws IOException {
-		OkHttpClient client = new OkHttpClient();
+		OkHttpClient client = createOkHttpClientWithNoTimeouts();
 
 		Request request = buildMalformedRequest(MULTIPART_UPLOAD_RESOURCE.getMixedHandler().getMessageHeaders().getTargetRestEndpointURL());
 		try (Response response = client.newCall(request).execute()) {
@@ -256,6 +257,15 @@ public class FileUploadHandlerTest extends TestLogger {
 		verifyNoFileIsRegisteredToDeleteOnExitHook();
 	}
 
+	private OkHttpClient createOkHttpClientWithNoTimeouts() {
+		// don't fail if some OkHttpClient operations take longer. See FLINK-17725
+		return new OkHttpClient.Builder()
+			.connectTimeout(0, TimeUnit.MILLISECONDS)
+			.writeTimeout(0, TimeUnit.MILLISECONDS)
+			.readTimeout(0, TimeUnit.MILLISECONDS)
+			.build();
+	}
+
 	/**
 	 * DiskAttribute and DiskFileUpload class of netty store post chunks and file chunks as temp files on local disk.
 	 * By default, netty will register these temp files to java.io.DeleteOnExitHook which may lead to memory leak.