提交 f5824499 编写于 作者: H Henry Saputra

[FLINK-1651] Fix test case at JobManagerStartupTest to avoid hang on certain users

JobManagerStartupTest should not assume user could not create /does-not-exist-no-sir dir.

Sometimes, user that run tests could have write access to root directory so creating /does-not-exist-no-sir is possible,
hence no exception thrown.

Need to construct a Flink test directory under directory specified under "java.io.tmpdir" and change the permission
to not allow create new directory.

Author: Henry Saputra <henry.saputra@gmail.com>

Closes #460 from hsaputra/FLINK-1651_fix_jobmanager_fail_test and squashes the following commits:

5d46716 [Henry Saputra] [FLINK-1651] Fix test case at JobManagerStartupTest should not assume user could not create /does-not-exist-no-sir dir.
上级 5242e966
......@@ -20,12 +20,18 @@ package org.apache.flink.runtime.jobmanager;
import static org.junit.Assert.*;
import java.io.File;
import java.net.InetAddress;
import java.net.ServerSocket;
import com.google.common.io.Files;
import org.apache.flink.configuration.ConfigConstants;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.runtime.net.NetUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
/**
......@@ -34,6 +40,26 @@ import org.junit.Test;
*/
public class JobManagerStartupTest {
private final static String DOES_NOT_EXISTS_NO_SIR = "does-not-exist-no-sir";
private File blobStorageDirectory;
@Before
public void before() {
// Prepare test directory
blobStorageDirectory = Files.createTempDir();
assertTrue(blobStorageDirectory.setExecutable(true, false));
assertTrue(blobStorageDirectory.setReadable(true, false));
assertTrue(blobStorageDirectory.setWritable(false, false));
}
@After
public void after() {
// Cleanup test directory
assertTrue(blobStorageDirectory.delete());
}
/**
* Verifies that the JobManager fails fast (and with expressive error message)
* when the port to listen is already in use.
......@@ -87,7 +113,8 @@ public class JobManagerStartupTest {
return;
}
Configuration failConfig = new Configuration();
failConfig.setString(ConfigConstants.BLOB_STORAGE_DIRECTORY_KEY, "/does-not-exist-no-sir");
String nonExistDirectory = new File(blobStorageDirectory, DOES_NOT_EXISTS_NO_SIR).getAbsolutePath();
failConfig.setString(ConfigConstants.BLOB_STORAGE_DIRECTORY_KEY, nonExistDirectory);
try {
JobManager.runJobManager(failConfig, ExecutionMode.CLUSTER(), "localhost", portNum);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册