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());
}
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);
}
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);
}
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);
}
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();
}
}
Aggregations