Search in sources :

Example 1 with Server

use of org.apache.hadoop.lib.server.Server in project hadoop by apache.

the class TestFileSystemAccessService method kerberosInitializationFailure.

@Test
@TestException(exception = ServiceException.class, msgRegExp = "H02.*")
@TestDir
public void kerberosInitializationFailure() 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.authentication.type", "kerberos");
    conf.set("server.hadoop.authentication.kerberos.keytab", "/tmp/foo");
    conf.set("server.hadoop.authentication.kerberos.principal", "foo@FOO");
    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) TestException(org.apache.hadoop.test.TestException) TestDir(org.apache.hadoop.test.TestDir) Test(org.junit.Test)

Example 2 with Server

use of org.apache.hadoop.lib.server.Server in project hadoop by apache.

the class TestFileSystemAccessService method invalidSecurity.

@Test
@TestException(exception = ServiceException.class, msgRegExp = "H09.*")
@TestDir
public void invalidSecurity() 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.authentication.type", "foo");
    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) TestException(org.apache.hadoop.test.TestException) TestDir(org.apache.hadoop.test.TestDir) Test(org.junit.Test)

Example 3 with Server

use of org.apache.hadoop.lib.server.Server in project hadoop by apache.

the class TestFileSystemAccessService method serviceHadoopConfCustomDir.

@Test
@TestDir
public void serviceHadoopConfCustomDir() throws Exception {
    String dir = TestDirHelper.getTestDir().getAbsolutePath();
    String hadoopConfDir = new File(dir, "confx").getAbsolutePath();
    new File(hadoopConfDir).mkdirs();
    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.config.dir", hadoopConfDir);
    File hdfsSite = new File(hadoopConfDir, "hdfs-site.xml");
    OutputStream os = new FileOutputStream(hdfsSite);
    Configuration hadoopConf = new Configuration(false);
    hadoopConf.set("foo", "BAR");
    hadoopConf.writeXml(os);
    os.close();
    Server server = new Server("server", dir, dir, dir, dir, conf);
    server.init();
    FileSystemAccessService fsAccess = (FileSystemAccessService) server.get(FileSystemAccess.class);
    Assert.assertEquals(fsAccess.serviceHadoopConf.get("foo"), "BAR");
    server.destroy();
}
Also used : FileSystemAccess(org.apache.hadoop.lib.service.FileSystemAccess) Configuration(org.apache.hadoop.conf.Configuration) Server(org.apache.hadoop.lib.server.Server) 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 4 with Server

use of org.apache.hadoop.lib.server.Server in project hadoop by apache.

the class TestFileSystemAccessService method serviceHadoopConf.

@Test
@TestDir
public void serviceHadoopConf() 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);
    Server server = new Server("server", dir, dir, dir, dir, conf);
    server.init();
    FileSystemAccessService fsAccess = (FileSystemAccessService) server.get(FileSystemAccess.class);
    Assert.assertEquals(fsAccess.serviceHadoopConf.get("foo"), "FOO");
    server.destroy();
}
Also used : FileSystemAccess(org.apache.hadoop.lib.service.FileSystemAccess) Configuration(org.apache.hadoop.conf.Configuration) Server(org.apache.hadoop.lib.server.Server) TestDir(org.apache.hadoop.test.TestDir) Test(org.junit.Test)

Example 5 with Server

use of org.apache.hadoop.lib.server.Server in project hadoop by apache.

the class TestFileSystemAccessService method simpleSecurity.

@Test
@TestDir
public void simpleSecurity() 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);
    Server server = new Server("server", dir, dir, dir, dir, conf);
    server.init();
    Assert.assertNotNull(server.get(FileSystemAccess.class));
    server.destroy();
}
Also used : FileSystemAccess(org.apache.hadoop.lib.service.FileSystemAccess) Configuration(org.apache.hadoop.conf.Configuration) Server(org.apache.hadoop.lib.server.Server) TestDir(org.apache.hadoop.test.TestDir) Test(org.junit.Test)

Aggregations

Configuration (org.apache.hadoop.conf.Configuration)19 Server (org.apache.hadoop.lib.server.Server)19 TestDir (org.apache.hadoop.test.TestDir)19 Test (org.junit.Test)19 FileSystemAccess (org.apache.hadoop.lib.service.FileSystemAccess)10 TestException (org.apache.hadoop.test.TestException)10 IOException (java.io.IOException)5 FileSystem (org.apache.hadoop.fs.FileSystem)5 TestHdfs (org.apache.hadoop.test.TestHdfs)5 Path (org.apache.hadoop.fs.Path)4 ServiceException (org.apache.hadoop.lib.server.ServiceException)4 FileSystemAccessException (org.apache.hadoop.lib.service.FileSystemAccessException)4 Map (java.util.Map)2 Instrumentation (org.apache.hadoop.lib.service.Instrumentation)2 JSONObject (org.json.simple.JSONObject)2 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 OutputStream (java.io.OutputStream)1 StringWriter (java.io.StringWriter)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1