Search in sources :

Example 11 with NamespaceAdmin

use of io.cdap.cdap.common.namespace.NamespaceAdmin in project cdap by caskdata.

the class TetheringClientHandlerTest method setup.

@BeforeClass
public static void setup() throws Exception {
    cConf = CConfiguration.create();
    injector = Guice.createInjector(new ConfigModule(cConf), RemoteAuthenticatorModules.getNoOpModule(), new SystemDatasetRuntimeModule().getInMemoryModules(), new TransactionModules().getInMemoryModules(), new TransactionExecutorModule(), new InMemoryDiscoveryModule(), new MessagingServerRuntimeModule().getInMemoryModules(), new StorageModule(), new AuthorizationTestModule(), new AuthorizationEnforcementModule().getInMemoryModules(), new AuthenticationContextModules().getMasterModule(), new NamespaceAdminTestModule(), new LocalLocationModule(), new PrivateModule() {

        @Override
        protected void configure() {
            bind(MetricsCollectionService.class).to(NoOpMetricsCollectionService.class).in(Scopes.SINGLETON);
            expose(MetricsCollectionService.class);
            bind(ProgramStateWriter.class).to(NoOpProgramStateWriter.class).in(Scopes.SINGLETON);
            expose(ProgramStateWriter.class);
            bind(ProgramRunRecordFetcher.class).to(StoreProgramRunRecordFetcher.class).in(Scopes.SINGLETON);
            expose(ProgramRunRecordFetcher.class);
            bind(MetricsSystemClient.class).toInstance(new NoOpMetricsSystemClient());
            expose(MetricsSystemClient.class);
        }
    });
    tetheringStore = new TetheringStore(injector.getInstance(TransactionRunner.class));
    txManager = injector.getInstance(TransactionManager.class);
    txManager.startAndWait();
    profileService = injector.getInstance(ProfileService.class);
    namespaceAdmin = injector.getInstance(NamespaceAdmin.class);
    namespaceAdmin.create(new NamespaceMeta.Builder().setName(NAMESPACE_1).build());
    namespaceAdmin.create(new NamespaceMeta.Builder().setName(NAMESPACE_2).build());
    namespaceAdmin.create(new NamespaceMeta.Builder().setName(NAMESPACE_3).build());
}
Also used : NoOpProgramStateWriter(io.cdap.cdap.app.runtime.NoOpProgramStateWriter) NoOpMetricsSystemClient(io.cdap.cdap.common.metrics.NoOpMetricsSystemClient) InMemoryDiscoveryModule(io.cdap.cdap.common.guice.InMemoryDiscoveryModule) StorageModule(io.cdap.cdap.data.runtime.StorageModule) NamespaceAdminTestModule(io.cdap.cdap.common.guice.NamespaceAdminTestModule) ConfigModule(io.cdap.cdap.common.guice.ConfigModule) AuthenticationContextModules(io.cdap.cdap.security.auth.context.AuthenticationContextModules) NamespaceAdmin(io.cdap.cdap.common.namespace.NamespaceAdmin) MessagingServerRuntimeModule(io.cdap.cdap.messaging.guice.MessagingServerRuntimeModule) StoreProgramRunRecordFetcher(io.cdap.cdap.internal.app.store.StoreProgramRunRecordFetcher) NoOpMetricsCollectionService(io.cdap.cdap.common.metrics.NoOpMetricsCollectionService) AuthorizationTestModule(io.cdap.cdap.security.authorization.AuthorizationTestModule) TransactionModules(org.apache.tephra.runtime.TransactionModules) TransactionExecutorModule(io.cdap.cdap.data.runtime.TransactionExecutorModule) ProfileService(io.cdap.cdap.internal.profile.ProfileService) LocalLocationModule(io.cdap.cdap.common.guice.LocalLocationModule) TransactionManager(org.apache.tephra.TransactionManager) NamespaceMeta(io.cdap.cdap.proto.NamespaceMeta) SystemDatasetRuntimeModule(io.cdap.cdap.data.runtime.SystemDatasetRuntimeModule) MetricsSystemClient(io.cdap.cdap.api.metrics.MetricsSystemClient) NoOpMetricsSystemClient(io.cdap.cdap.common.metrics.NoOpMetricsSystemClient) AuthorizationEnforcementModule(io.cdap.cdap.security.authorization.AuthorizationEnforcementModule) PrivateModule(com.google.inject.PrivateModule) BeforeClass(org.junit.BeforeClass)

Example 12 with NamespaceAdmin

use of io.cdap.cdap.common.namespace.NamespaceAdmin in project cdap by caskdata.

the class NamespaceHttpHandlerTest method testNamespaceClient.

@Test
public void testNamespaceClient() throws Exception {
    // tests the NamespaceClient's ability to interact with Namespace service/handlers.
    NamespaceAdmin namespaceClient = getInjector().getInstance(NamespaceAdmin.class);
    // test setup creates two namespaces in @BeforeClass, apart from the default namespace which always exists.
    List<NamespaceMeta> namespaces = namespaceClient.list();
    Assert.assertEquals(3, namespaces.size());
    Set<NamespaceMeta> expectedNamespaces = ImmutableSet.of(NamespaceMeta.DEFAULT, TEST_NAMESPACE_META1, TEST_NAMESPACE_META2);
    for (NamespaceMeta actual : namespaces) {
        actual = new NamespaceMeta.Builder(actual).setGeneration(0L).build();
        Assert.assertTrue(expectedNamespaces.contains(actual));
    }
    NamespaceMeta namespaceMeta = namespaceClient.get(new NamespaceId(TEST_NAMESPACE1));
    namespaceMeta = new NamespaceMeta.Builder(namespaceMeta).setGeneration(0L).build();
    Assert.assertEquals(TEST_NAMESPACE_META1, namespaceMeta);
    try {
        namespaceClient.get(new NamespaceId("nonExistentNamespace"));
        Assert.fail("Did not expect namespace 'nonExistentNamespace' to exist.");
    } catch (NotFoundException expected) {
    // expected
    }
    // test create and get
    NamespaceId fooNamespace = new NamespaceId("fooNamespace");
    NamespaceMeta toCreate = new NamespaceMeta.Builder().setName(fooNamespace).build();
    namespaceClient.create(toCreate);
    NamespaceMeta receivedMeta = namespaceClient.get(fooNamespace);
    Assert.assertNotNull(receivedMeta);
    Assert.assertEquals(toCreate, new NamespaceMeta.Builder(receivedMeta).setGeneration(0L).build());
    waitForAndCheckNamespaceCount(4);
    namespaceClient.delete(fooNamespace);
    try {
        namespaceClient.get(fooNamespace);
        Assert.fail("Did not expect namespace '" + fooNamespace + "' to exist after deleting it.");
    } catch (NotFoundException expected) {
    // expected
    }
    waitForAndCheckNamespaceCount(3);
}
Also used : NamespaceMeta(io.cdap.cdap.proto.NamespaceMeta) NamespaceAdmin(io.cdap.cdap.common.namespace.NamespaceAdmin) NotFoundException(io.cdap.cdap.common.NotFoundException) NamespaceId(io.cdap.cdap.proto.id.NamespaceId) AppForUnrecoverableResetTest(io.cdap.cdap.AppForUnrecoverableResetTest) Test(org.junit.Test)

Example 13 with NamespaceAdmin

use of io.cdap.cdap.common.namespace.NamespaceAdmin in project cdap by caskdata.

the class DefaultNamespaceCreatorTest method setupClass.

@BeforeClass
public static void setupClass() {
    Injector injector = AppFabricTestHelper.getInjector();
    defaultNamespaceCreator = injector.getInstance(DefaultNamespaceCreator.class);
    namespaceAdmin = injector.getInstance(NamespaceAdmin.class);
}
Also used : Injector(com.google.inject.Injector) NamespaceAdmin(io.cdap.cdap.common.namespace.NamespaceAdmin) BeforeClass(org.junit.BeforeClass)

Example 14 with NamespaceAdmin

use of io.cdap.cdap.common.namespace.NamespaceAdmin in project cdap by caskdata.

the class RemoteNamespaceQueryTest method setup.

@BeforeClass
public static void setup() throws Exception {
    CConfiguration cConf = CConfiguration.create();
    cConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMPORARY_FOLDER.newFolder().getAbsolutePath());
    Injector injector = AppFabricTestHelper.getInjector(cConf);
    txManager = injector.getInstance(TransactionManager.class);
    txManager.startAndWait();
    datasetService = injector.getInstance(DatasetService.class);
    datasetService.startAndWait();
    appFabricServer = injector.getInstance(AppFabricServer.class);
    appFabricServer.startAndWait();
    DiscoveryServiceClient discoveryServiceClient = injector.getInstance(DiscoveryServiceClient.class);
    waitForService(discoveryServiceClient, Constants.Service.DATASET_MANAGER);
    waitForService(discoveryServiceClient, Constants.Service.APP_FABRIC_HTTP);
    namespaceAdmin = injector.getInstance(NamespaceAdmin.class);
    queryClient = injector.getInstance(RemoteNamespaceQueryClient.class);
    namespacePathLocator = injector.getInstance(NamespacePathLocator.class);
}
Also used : DiscoveryServiceClient(org.apache.twill.discovery.DiscoveryServiceClient) Injector(com.google.inject.Injector) TransactionManager(org.apache.tephra.TransactionManager) AppFabricServer(io.cdap.cdap.internal.app.services.AppFabricServer) NamespaceAdmin(io.cdap.cdap.common.namespace.NamespaceAdmin) DatasetService(io.cdap.cdap.data2.datafabric.dataset.service.DatasetService) RemoteNamespaceQueryClient(io.cdap.cdap.common.namespace.RemoteNamespaceQueryClient) NamespacePathLocator(io.cdap.cdap.common.namespace.NamespacePathLocator) CConfiguration(io.cdap.cdap.common.conf.CConfiguration) BeforeClass(org.junit.BeforeClass)

Example 15 with NamespaceAdmin

use of io.cdap.cdap.common.namespace.NamespaceAdmin in project cdap by cdapio.

the class SystemMetadataAuditPublishTest method setup.

@BeforeClass
public static void setup() {
    cConf = CConfiguration.create();
    cConf.setBoolean(Constants.Audit.ENABLED, true);
    Injector injector = AppFabricTestHelper.getInjector(cConf, new AbstractModule() {

        @Override
        protected void configure() {
            install(new AuditTestModule());
        }
    });
    auditPublisher = injector.getInstance(InMemoryAuditPublisher.class);
    namespaceAdmin = injector.getInstance(NamespaceAdmin.class);
    scheduler = injector.getInstance(Scheduler.class);
    if (scheduler instanceof Service) {
        ((Service) scheduler).startAndWait();
    }
}
Also used : InMemoryAuditPublisher(io.cdap.cdap.data2.audit.InMemoryAuditPublisher) Injector(com.google.inject.Injector) Scheduler(io.cdap.cdap.scheduler.Scheduler) NamespaceAdmin(io.cdap.cdap.common.namespace.NamespaceAdmin) Service(com.google.common.util.concurrent.Service) AuditTestModule(io.cdap.cdap.data2.audit.AuditTestModule) AbstractModule(com.google.inject.AbstractModule) BeforeClass(org.junit.BeforeClass)

Aggregations

NamespaceAdmin (io.cdap.cdap.common.namespace.NamespaceAdmin)38 BeforeClass (org.junit.BeforeClass)24 CConfiguration (io.cdap.cdap.common.conf.CConfiguration)22 TransactionManager (org.apache.tephra.TransactionManager)18 AbstractModule (com.google.inject.AbstractModule)16 Injector (com.google.inject.Injector)16 NamespaceMeta (io.cdap.cdap.proto.NamespaceMeta)16 ConfigModule (io.cdap.cdap.common.guice.ConfigModule)14 DatasetService (io.cdap.cdap.data2.datafabric.dataset.service.DatasetService)14 StructuredTableAdmin (io.cdap.cdap.spi.data.StructuredTableAdmin)14 InMemoryDiscoveryModule (io.cdap.cdap.common.guice.InMemoryDiscoveryModule)12 NamespaceAdminTestModule (io.cdap.cdap.common.guice.NamespaceAdminTestModule)12 NamespacePathLocator (io.cdap.cdap.common.namespace.NamespacePathLocator)12 DatasetOpExecutorService (io.cdap.cdap.data2.datafabric.dataset.service.executor.DatasetOpExecutorService)12 AuthorizationEnforcementModule (io.cdap.cdap.security.authorization.AuthorizationEnforcementModule)12 NonCustomLocationUnitTestModule (io.cdap.cdap.common.guice.NonCustomLocationUnitTestModule)10 AuthenticationContextModules (io.cdap.cdap.security.auth.context.AuthenticationContextModules)10 AuthorizationTestModule (io.cdap.cdap.security.authorization.AuthorizationTestModule)10 Configuration (org.apache.hadoop.conf.Configuration)10 DiscoveryServiceClient (org.apache.twill.discovery.DiscoveryServiceClient)10