Search in sources :

Example 31 with TestDir

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);
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) TestDir(org.apache.hadoop.test.TestDir) Test(org.junit.Test)

Example 32 with TestDir

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"));
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) TestDir(org.apache.hadoop.test.TestDir) Test(org.junit.Test)

Example 33 with TestDir

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());
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) TestDir(org.apache.hadoop.test.TestDir) Test(org.junit.Test)

Example 34 with TestDir

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;
        }
    });
}
Also used : FileSystemAccess(org.apache.hadoop.lib.service.FileSystemAccess) Configuration(org.apache.hadoop.conf.Configuration) Server(org.apache.hadoop.lib.server.Server) FileSystem(org.apache.hadoop.fs.FileSystem) IOException(java.io.IOException) TestHdfs(org.apache.hadoop.test.TestHdfs) TestException(org.apache.hadoop.test.TestException) TestDir(org.apache.hadoop.test.TestDir) Test(org.junit.Test)

Example 35 with TestDir

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);
}
Also used : HttpURLConnection(java.net.HttpURLConnection) URL(java.net.URL) AuthenticatedURL(org.apache.hadoop.security.authentication.client.AuthenticatedURL) TestJetty(org.apache.hadoop.test.TestJetty) TestHdfs(org.apache.hadoop.test.TestHdfs) TestDir(org.apache.hadoop.test.TestDir) Test(org.junit.Test)

Aggregations

TestDir (org.apache.hadoop.test.TestDir)67 Test (org.junit.Test)67 Configuration (org.apache.hadoop.conf.Configuration)46 TestException (org.apache.hadoop.test.TestException)25 TestHdfs (org.apache.hadoop.test.TestHdfs)21 Server (org.apache.hadoop.lib.server.Server)19 TestJetty (org.apache.hadoop.test.TestJetty)18 FileSystem (org.apache.hadoop.fs.FileSystem)14 File (java.io.File)13 Path (org.apache.hadoop.fs.Path)13 FileOutputStream (java.io.FileOutputStream)10 FileSystemAccess (org.apache.hadoop.lib.service.FileSystemAccess)10 HttpURLConnection (java.net.HttpURLConnection)9 URL (java.net.URL)9 AuthenticatedURL (org.apache.hadoop.security.authentication.client.AuthenticatedURL)9 IOException (java.io.IOException)6 OutputStream (java.io.OutputStream)6 InputStreamReader (java.io.InputStreamReader)5 ServiceException (org.apache.hadoop.lib.server.ServiceException)4 FileSystemAccessException (org.apache.hadoop.lib.service.FileSystemAccessException)4