Search in sources :

Example 21 with TestDir

use of org.apache.hadoop.test.TestDir in project hadoop by apache.

the class TestGroupsService method invalidGroupsMapping.

@Test(expected = RuntimeException.class)
@TestDir
public void invalidGroupsMapping() throws Exception {
    String dir = TestDirHelper.getTestDir().getAbsolutePath();
    Configuration conf = new Configuration(false);
    conf.set("server.services", StringUtils.join(",", Arrays.asList(GroupsService.class.getName())));
    conf.set("server.groups.hadoop.security.group.mapping", String.class.getName());
    Server server = new Server("server", dir, dir, dir, dir, conf);
    server.init();
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) Server(org.apache.hadoop.lib.server.Server) TestDir(org.apache.hadoop.test.TestDir) Test(org.junit.Test)

Example 22 with TestDir

use of org.apache.hadoop.test.TestDir in project hadoop by apache.

the class TestServer method log4jFile.

@Test
@TestDir
public void log4jFile() throws Exception {
    InputStream is = Server.getResource("default-log4j.properties");
    OutputStream os = new FileOutputStream(new File(TestDirHelper.getTestDir(), "server-log4j.properties"));
    IOUtils.copyBytes(is, os, 1024, true);
    Configuration conf = new Configuration(false);
    Server server = createServer(conf);
    server.init();
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) File(java.io.File) TestDir(org.apache.hadoop.test.TestDir) Test(org.junit.Test)

Example 23 with TestDir

use of org.apache.hadoop.test.TestDir in project hadoop by apache.

the class TestServer method initLogDirNotDir.

@Test
@TestException(exception = ServerException.class, msgRegExp = "S02.*")
@TestDir
public void initLogDirNotDir() throws Exception {
    File homeDir = new File(TestDirHelper.getTestDir(), "home");
    assertTrue(homeDir.mkdir());
    assertTrue(new File(homeDir, "conf").mkdir());
    assertTrue(new File(homeDir, "temp").mkdir());
    File logDir = new File(homeDir, "log");
    new FileOutputStream(logDir).close();
    Configuration conf = new Configuration(false);
    conf.set("server.services", TestService.class.getName());
    Server server = new Server("server", homeDir.getAbsolutePath(), conf);
    server.init();
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) FileOutputStream(java.io.FileOutputStream) File(java.io.File) TestException(org.apache.hadoop.test.TestException) TestDir(org.apache.hadoop.test.TestDir) Test(org.junit.Test)

Example 24 with TestDir

use of org.apache.hadoop.test.TestDir in project hadoop by apache.

the class TestServer method serviceLifeCycle.

@Test
@TestDir
public void serviceLifeCycle() throws Exception {
    TestService.LIFECYCLE.clear();
    Configuration conf = new Configuration(false);
    conf.set("server.services", TestService.class.getName());
    Server server = createServer(conf);
    server.init();
    assertNotNull(server.get(TestService.class));
    server.destroy();
    assertEquals(TestService.LIFECYCLE, Arrays.asList("init", "postInit", "serverStatusChange", "destroy"));
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) TestDir(org.apache.hadoop.test.TestDir) Test(org.junit.Test)

Example 25 with TestDir

use of org.apache.hadoop.test.TestDir in project hadoop by apache.

the class TestFileSystemAccessService method NameNodeNotinWhitelists.

@Test
@TestException(exception = FileSystemAccessException.class, msgRegExp = "H05.*")
@TestDir
public void NameNodeNotinWhitelists() throws Exception {
    String dir = TestDirHelper.getTestDir().getAbsolutePath();
    String services = StringUtils.join(",", Arrays.asList(InstrumentationService.class.getName(), SchedulerService.class.getName(), FileSystemAccessService.class.getName()));
    Configuration conf = new Configuration(false);
    conf.set("server.services", services);
    conf.set("server.hadoop.name.node.whitelist", "NN");
    Server server = new Server("server", dir, dir, dir, dir, conf);
    server.init();
    FileSystemAccessService fsAccess = (FileSystemAccessService) server.get(FileSystemAccess.class);
    fsAccess.validateNamenode("NNx");
}
Also used : FileSystemAccess(org.apache.hadoop.lib.service.FileSystemAccess) Configuration(org.apache.hadoop.conf.Configuration) Server(org.apache.hadoop.lib.server.Server) TestException(org.apache.hadoop.test.TestException) 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