Skip to content

Commit

Permalink
[FLINK-1651] Fix test case at JobManagerStartupTest to avoid hang on …
Browse files Browse the repository at this point in the history
…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 <[email protected]>

Closes apache#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.
  • Loading branch information
hsaputra committed Mar 9, 2015
1 parent 5242e96 commit f582449
Showing 1 changed file with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,18 @@

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;

/**
Expand All @@ -34,6 +40,26 @@
*/
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.
Expand Down Expand Up @@ -87,7 +113,8 @@ public void testJobManagerStartupFails() {
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);
Expand Down

0 comments on commit f582449

Please sign in to comment.