use of org.apache.hadoop.test.TestDir in project hadoop by apache.
the class TestServer method nonSeteableStatus.
@Test(expected = IllegalArgumentException.class)
@TestDir
public void nonSeteableStatus() throws Exception {
Configuration conf = new Configuration(false);
Server server = createServer(conf);
server.init();
server.setStatus(Server.Status.SHUTDOWN);
}
use of org.apache.hadoop.test.TestDir in project hadoop by apache.
the class TestServer method changeStatus.
@Test
@TestDir
public void changeStatus() throws Exception {
TestService.LIFECYCLE.clear();
Configuration conf = new Configuration(false);
conf.set("server.services", TestService.class.getName());
Server server = createServer(conf);
server.init();
server.setStatus(Server.Status.ADMIN);
assertTrue(TestService.LIFECYCLE.contains("serverStatusChange"));
}
use of org.apache.hadoop.test.TestDir in project hadoop by apache.
the class TestServer method constructorsGetters.
@Test
@TestDir
public void constructorsGetters() throws Exception {
Server server = new Server("server", getAbsolutePath("/a"), getAbsolutePath("/b"), getAbsolutePath("/c"), getAbsolutePath("/d"), new Configuration(false));
assertEquals(server.getHomeDir(), getAbsolutePath("/a"));
assertEquals(server.getConfigDir(), getAbsolutePath("/b"));
assertEquals(server.getLogDir(), getAbsolutePath("/c"));
assertEquals(server.getTempDir(), getAbsolutePath("/d"));
assertEquals(server.getName(), "server");
assertEquals(server.getPrefix(), "server");
assertEquals(server.getPrefixedName("name"), "server.name");
assertNotNull(server.getConfig());
server = new Server("server", getAbsolutePath("/a"), getAbsolutePath("/b"), getAbsolutePath("/c"), getAbsolutePath("/d"));
assertEquals(server.getHomeDir(), getAbsolutePath("/a"));
assertEquals(server.getConfigDir(), getAbsolutePath("/b"));
assertEquals(server.getLogDir(), getAbsolutePath("/c"));
assertEquals(server.getTempDir(), getAbsolutePath("/d"));
assertEquals(server.getName(), "server");
assertEquals(server.getPrefix(), "server");
assertEquals(server.getPrefixedName("name"), "server.name");
assertNull(server.getConfig());
server = new Server("server", TestDirHelper.getTestDir().getAbsolutePath(), new Configuration(false));
assertEquals(server.getHomeDir(), TestDirHelper.getTestDir().getAbsolutePath());
assertEquals(server.getConfigDir(), TestDirHelper.getTestDir() + "/conf");
assertEquals(server.getLogDir(), TestDirHelper.getTestDir() + "/log");
assertEquals(server.getTempDir(), TestDirHelper.getTestDir() + "/temp");
assertEquals(server.getName(), "server");
assertEquals(server.getPrefix(), "server");
assertEquals(server.getPrefixedName("name"), "server.name");
assertNotNull(server.getConfig());
server = new Server("server", TestDirHelper.getTestDir().getAbsolutePath());
assertEquals(server.getHomeDir(), TestDirHelper.getTestDir().getAbsolutePath());
assertEquals(server.getConfigDir(), TestDirHelper.getTestDir() + "/conf");
assertEquals(server.getLogDir(), TestDirHelper.getTestDir() + "/log");
assertEquals(server.getTempDir(), TestDirHelper.getTestDir() + "/temp");
assertEquals(server.getName(), "server");
assertEquals(server.getPrefix(), "server");
assertEquals(server.getPrefixedName("name"), "server.name");
assertNull(server.getConfig());
}
use of org.apache.hadoop.test.TestDir in project hadoop by apache.
the class TestFileSystemAccessService method fileSystemExecutorNoNameNode.
@Test
@TestException(exception = FileSystemAccessException.class, msgRegExp = "H06.*")
@TestDir
@TestHdfs
public void fileSystemExecutorNoNameNode() throws Exception {
String dir = TestDirHelper.getTestDir().getAbsolutePath();
String services = StringUtils.join(",", Arrays.asList(InstrumentationService.class.getName(), SchedulerService.class.getName(), FileSystemAccessService.class.getName()));
Configuration hadoopConf = new Configuration(false);
hadoopConf.set(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY, TestHdfsHelper.getHdfsConf().get(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY));
createHadoopConf(hadoopConf);
Configuration conf = new Configuration(false);
conf.set("server.services", services);
Server server = new Server("server", dir, dir, dir, dir, conf);
server.init();
FileSystemAccess fsAccess = server.get(FileSystemAccess.class);
Configuration hdfsConf = fsAccess.getFileSystemConfiguration();
hdfsConf.set(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY, "");
fsAccess.execute("u", hdfsConf, new FileSystemAccess.FileSystemExecutor<Void>() {
@Override
public Void execute(FileSystem fs) throws IOException {
return null;
}
});
}
use of org.apache.hadoop.test.TestDir in project hadoop by apache.
the class TestHttpFSServer method testPutNoOperation.
@Test
@TestDir
@TestJetty
@TestHdfs
public void testPutNoOperation() throws Exception {
createHttpFSServer(false);
String user = HadoopUsersConfTestHelper.getHadoopUsers()[0];
URL url = new URL(TestJettyHelper.getJettyURL(), MessageFormat.format("/webhdfs/v1/foo?user.name={0}", user));
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoInput(true);
conn.setDoOutput(true);
conn.setRequestMethod("PUT");
Assert.assertEquals(conn.getResponseCode(), HttpURLConnection.HTTP_BAD_REQUEST);
}
Aggregations