Search in sources :

Example 6 with AtlasClient

use of org.apache.atlas.AtlasClient in project incubator-atlas by apache.

the class BaseResourceIT method setUp.

@BeforeClass
public void setUp() throws Exception {
    //set high timeouts so that tests do not fail due to read timeouts while you
    //are stepping through the code in a debugger
    ApplicationProperties.get().setProperty("atlas.client.readTimeoutMSecs", "100000000");
    ApplicationProperties.get().setProperty("atlas.client.connectTimeoutMSecs", "100000000");
    Configuration configuration = ApplicationProperties.get();
    atlasUrls = configuration.getStringArray(ATLAS_REST_ADDRESS);
    if (atlasUrls == null || atlasUrls.length == 0) {
        atlasUrls = new String[] { "http://localhost:21000/" };
    }
    if (!AuthenticationUtil.isKerberosAuthenticationEnabled()) {
        atlasClientV1 = new AtlasClient(atlasUrls, new String[] { "admin", "admin" });
        atlasClientV2 = new AtlasClientV2(atlasUrls, new String[] { "admin", "admin" });
    } else {
        atlasClientV1 = new AtlasClient(atlasUrls);
        atlasClientV2 = new AtlasClientV2(atlasUrls);
    }
}
Also used : AtlasClientV2(org.apache.atlas.AtlasClientV2) Configuration(org.apache.commons.configuration.Configuration) AtlasClient(org.apache.atlas.AtlasClient) BeforeClass(org.testng.annotations.BeforeClass)

Example 7 with AtlasClient

use of org.apache.atlas.AtlasClient in project incubator-atlas by apache.

the class FalconHookIT method setUp.

@BeforeClass
public void setUp() throws Exception {
    Configuration atlasProperties = ApplicationProperties.get();
    if (!AuthenticationUtil.isKerberosAuthenticationEnabled()) {
        atlasClient = new AtlasClient(atlasProperties.getStringArray(HiveMetaStoreBridge.ATLAS_ENDPOINT), new String[] { "admin", "admin" });
    } else {
        atlasClient = new AtlasClient(atlasProperties.getStringArray(HiveMetaStoreBridge.ATLAS_ENDPOINT));
    }
    AtlasService service = new AtlasService();
    service.init();
    STORE.registerListener(service);
    CurrentUser.authenticate(System.getProperty("user.name"));
}
Also used : AtlasService(org.apache.atlas.falcon.service.AtlasService) Configuration(org.apache.commons.configuration.Configuration) AtlasClient(org.apache.atlas.AtlasClient) BeforeClass(org.testng.annotations.BeforeClass)

Example 8 with AtlasClient

use of org.apache.atlas.AtlasClient in project incubator-atlas by apache.

the class NegativeSSLAndKerberosTest method setUp.

@BeforeClass
public void setUp() throws Exception {
    jksPath = new Path(Files.createTempDirectory("tempproviders").toString(), "test.jks");
    providerUrl = JavaKeyStoreProvider.SCHEME_NAME + "://file/" + jksPath.toUri();
    String persistDir = TestUtils.getTempDirectory();
    setupKDCAndPrincipals();
    setupCredentials();
    // client will actually only leverage subset of these properties
    final PropertiesConfiguration configuration = getSSLConfiguration(providerUrl);
    persistSSLClientConfiguration(configuration);
    TestUtils.writeConfiguration(configuration, persistDir + File.separator + ApplicationProperties.APPLICATION_PROPERTIES);
    String confLocation = System.getProperty("atlas.conf");
    URL url;
    if (confLocation == null) {
        url = NegativeSSLAndKerberosTest.class.getResource("/" + ApplicationProperties.APPLICATION_PROPERTIES);
    } else {
        url = new File(confLocation, ApplicationProperties.APPLICATION_PROPERTIES).toURI().toURL();
    }
    configuration.load(url);
    configuration.setProperty(TLS_ENABLED, true);
    configuration.setProperty("atlas.authentication.method.kerberos", "true");
    configuration.setProperty("atlas.authentication.keytab", userKeytabFile.getAbsolutePath());
    configuration.setProperty("atlas.authentication.principal", "dgi/localhost@" + kdc.getRealm());
    configuration.setProperty("atlas.authentication.method.file", "false");
    configuration.setProperty("atlas.authentication.method.kerberos", "true");
    configuration.setProperty("atlas.authentication.method.kerberos.principal", "HTTP/localhost@" + kdc.getRealm());
    configuration.setProperty("atlas.authentication.method.kerberos.keytab", httpKeytabFile.getAbsolutePath());
    configuration.setProperty("atlas.authentication.method.kerberos.name.rules", "RULE:[1:$1@$0](.*@EXAMPLE.COM)s/@.*//\nDEFAULT");
    configuration.setProperty("atlas.authentication.method.file", "true");
    configuration.setProperty("atlas.authentication.method.file.filename", persistDir + "/users-credentials");
    configuration.setProperty("atlas.auth.policy.file", persistDir + "/policy-store.txt");
    TestUtils.writeConfiguration(configuration, persistDir + File.separator + ApplicationProperties.APPLICATION_PROPERTIES);
    setupUserCredential(persistDir);
    setUpPolicyStore(persistDir);
    // save original setting
    originalConf = System.getProperty("atlas.conf");
    System.setProperty("atlas.conf", persistDir);
    dgiClient = new AtlasClient(configuration, DGI_URL);
    secureEmbeddedServer = new TestSecureEmbeddedServer(21443, getWarPath()) {

        @Override
        public Configuration getConfiguration() {
            return configuration;
        }
    };
    secureEmbeddedServer.getServer().start();
}
Also used : Path(org.apache.hadoop.fs.Path) Configuration(org.apache.commons.configuration.Configuration) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) AtlasClient(org.apache.atlas.AtlasClient) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) File(java.io.File) URL(java.net.URL) BeforeClass(org.testng.annotations.BeforeClass)

Example 9 with AtlasClient

use of org.apache.atlas.AtlasClient in project incubator-atlas by apache.

the class HiveITBase method setUp.

@BeforeClass
public void setUp() throws Exception {
    //Set-up hive session
    conf = new HiveConf();
    conf.setClassLoader(Thread.currentThread().getContextClassLoader());
    driver = new Driver(conf);
    ss = new SessionState(conf);
    ss = SessionState.start(ss);
    SessionState.setCurrentSessionState(ss);
    Configuration configuration = ApplicationProperties.get();
    String[] atlasEndPoint = configuration.getStringArray(HiveMetaStoreBridge.ATLAS_ENDPOINT);
    if (atlasEndPoint == null || atlasEndPoint.length == 0) {
        atlasEndPoint = new String[] { DGI_URL };
    }
    if (!AuthenticationUtil.isKerberosAuthenticationEnabled()) {
        atlasClient = new AtlasClient(atlasEndPoint, new String[] { "admin", "admin" });
    } else {
        atlasClient = new AtlasClient(atlasEndPoint);
    }
    hiveMetaStoreBridge = new HiveMetaStoreBridge(configuration, conf, atlasClient);
    HiveConf conf = new HiveConf();
    conf.set("hive.exec.post.hooks", "");
    SessionState ss = new SessionState(conf);
    ss = SessionState.start(ss);
    SessionState.setCurrentSessionState(ss);
    driverWithoutContext = new Driver(conf);
}
Also used : SessionState(org.apache.hadoop.hive.ql.session.SessionState) HiveMetaStoreBridge(org.apache.atlas.hive.bridge.HiveMetaStoreBridge) Configuration(org.apache.commons.configuration.Configuration) Driver(org.apache.hadoop.hive.ql.Driver) HiveConf(org.apache.hadoop.hive.conf.HiveConf) AtlasClient(org.apache.atlas.AtlasClient) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

AtlasClient (org.apache.atlas.AtlasClient)9 BeforeClass (org.testng.annotations.BeforeClass)7 Configuration (org.apache.commons.configuration.Configuration)6 PropertiesConfiguration (org.apache.commons.configuration.PropertiesConfiguration)3 Path (org.apache.hadoop.fs.Path)3 File (java.io.File)2 URL (java.net.URL)2 HiveConf (org.apache.hadoop.hive.conf.HiveConf)2 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)2 PrivilegedExceptionAction (java.security.PrivilegedExceptionAction)1 AtlasClientV2 (org.apache.atlas.AtlasClientV2)1 AtlasServiceException (org.apache.atlas.AtlasServiceException)1 EntityAuditEvent (org.apache.atlas.EntityAuditEvent)1 AtlasService (org.apache.atlas.falcon.service.AtlasService)1 HiveMetaStoreBridge (org.apache.atlas.hive.bridge.HiveMetaStoreBridge)1 AtlasHookException (org.apache.atlas.hook.AtlasHookException)1 Referenceable (org.apache.atlas.typesystem.Referenceable)1 BasicParser (org.apache.commons.cli.BasicParser)1 CommandLine (org.apache.commons.cli.CommandLine)1 CommandLineParser (org.apache.commons.cli.CommandLineParser)1