use of io.cdap.cdap.proto.id.ApplicationId in project cdap by caskdata.
the class PreferencesHttpHandlerInternalTest method addApplication.
private void addApplication(String namespace, Application app) {
ApplicationSpecification appSpec = Specifications.from(app);
store.addApplication(new ApplicationId(namespace, appSpec.getName()), appSpec);
}
use of io.cdap.cdap.proto.id.ApplicationId in project cdap by caskdata.
the class RemotePermissionsTestBase method testVisibility.
@Test
public void testVisibility() throws Exception {
ApplicationId app1 = NS.app("app1");
ProgramId program1 = app1.program(ProgramType.SERVICE, "service1");
ApplicationId app2 = NS.app("app2");
ProgramId program2 = app2.program(ProgramType.MAPREDUCE, "service2");
DatasetId ds = NS.dataset("ds");
DatasetId ds1 = NS.dataset("ds1");
DatasetId ds2 = NS.dataset("ds2");
// Grant permissions on non-numbered entities to ALICE
permissionManager.grant(Authorizable.fromEntityId(PROGRAM), ALICE, Collections.singleton(ApplicationPermission.EXECUTE));
permissionManager.grant(Authorizable.fromEntityId(ds), ALICE, EnumSet.of(StandardPermission.GET, StandardPermission.UPDATE));
// Grant permissions on entities ending with 2 to BOB
permissionManager.grant(Authorizable.fromEntityId(program2), BOB, Collections.singleton(StandardPermission.UPDATE));
permissionManager.grant(Authorizable.fromEntityId(ds2), BOB, EnumSet.of(StandardPermission.GET, StandardPermission.UPDATE));
Set<? extends EntityId> allEntities = ImmutableSet.of(NS, APP, PROGRAM, ds, app1, program1, ds1, app2, program2, ds2);
Assert.assertEquals(ImmutableSet.of(NS, APP, PROGRAM, ds), accessEnforcer.isVisible(allEntities, ALICE));
Assert.assertEquals(ImmutableSet.of(NS, app2, program2, ds2), accessEnforcer.isVisible(allEntities, BOB));
Assert.assertEquals(ImmutableSet.of(), accessEnforcer.isVisible(allEntities, CAROL));
Assert.assertEquals(ImmutableSet.of(), accessEnforcer.isVisible(ImmutableSet.<EntityId>of(), ALICE));
Assert.assertEquals(ImmutableSet.of(ds, APP), accessEnforcer.isVisible(ImmutableSet.of(ds, APP), ALICE));
for (EntityId entityId : allEntities) {
permissionManager.revoke(Authorizable.fromEntityId(entityId));
}
}
use of io.cdap.cdap.proto.id.ApplicationId in project cdap by caskdata.
the class ProgramRunLimitTest method testConcurrentServiceLaunchingAndRunningLimit.
@Category(SlowTests.class)
@Test
public void testConcurrentServiceLaunchingAndRunningLimit() throws Exception {
// Launching/running a new service should NOT be controlled by flow-control mechanism.
// deploy, check the status
deploy(AppWithServicesAndWorker.class, 200, Constants.Gateway.API_VERSION_3_TOKEN, TEST_NAMESPACE1);
ApplicationId appId = new ApplicationId(TEST_NAMESPACE1, AppWithServicesAndWorker.NAME);
ProgramId noOpService = appId.service(AppWithServicesAndWorker.NO_OP_SERVICE);
ProgramId pingService = appId.service(AppWithServicesAndWorker.PING_SERVICE);
ProgramId noOpWorker = appId.worker(AppWithServicesAndWorker.NO_OP_WORKER);
// all programs are stopped initially
Assert.assertEquals(STOPPED, getProgramStatus(noOpService));
Assert.assertEquals(STOPPED, getProgramStatus(pingService));
Assert.assertEquals(STOPPED, getProgramStatus(noOpWorker));
// start both services and check the status
startProgram(noOpService);
waitState(noOpService, RUNNING);
startProgram(pingService);
waitState(pingService, RUNNING);
// starting the worker should succeed
startProgram(noOpWorker);
Tasks.waitFor(1, () -> getProgramRuns(noOpWorker, ProgramRunStatus.COMPLETED).size(), 10, TimeUnit.SECONDS);
// stop one service
stopProgram(noOpService);
waitState(noOpService, STOPPED);
// stop other service
stopProgram(pingService);
waitState(pingService, STOPPED);
}
use of io.cdap.cdap.proto.id.ApplicationId in project cdap by caskdata.
the class DefaultStoreTest method testLoadingProgram.
@Test
public void testLoadingProgram() throws Exception {
ApplicationSpecification appSpec = Specifications.from(new FooApp());
ApplicationId appId = NamespaceId.DEFAULT.app(appSpec.getName());
store.addApplication(appId, appSpec);
ProgramDescriptor descriptor = store.loadProgram(appId.mr("mrJob1"));
Assert.assertNotNull(descriptor);
MapReduceSpecification mrSpec = descriptor.getSpecification();
Assert.assertEquals("mrJob1", mrSpec.getName());
Assert.assertEquals(FooMapReduceJob.class.getName(), mrSpec.getClassName());
}
use of io.cdap.cdap.proto.id.ApplicationId in project cdap by caskdata.
the class DefaultStoreTest method testDeleteSuspendedWorkflow.
@Test
public void testDeleteSuspendedWorkflow() {
NamespaceId namespaceId = new NamespaceId("namespace1");
// Test delete application
ApplicationId appId1 = namespaceId.app("app1");
ProgramId programId1 = appId1.workflow("pgm1");
ArtifactId artifactId = namespaceId.artifact("testArtifact", "1.0").toApiArtifactId();
RunId run1 = RunIds.generate();
setStartAndRunning(programId1.run(run1.getId()), artifactId);
store.setSuspend(programId1.run(run1.getId()), AppFabricTestHelper.createSourceId(++sourceId), -1);
store.removeApplication(appId1);
Assert.assertTrue(store.getRuns(programId1, ProgramRunStatus.ALL, 0, Long.MAX_VALUE, Integer.MAX_VALUE).isEmpty());
// Test delete namespace
ProgramId programId2 = namespaceId.app("app2").workflow("pgm2");
RunId run2 = RunIds.generate();
setStartAndRunning(programId2.run(run2.getId()), artifactId);
store.setSuspend(programId2.run(run2.getId()), AppFabricTestHelper.createSourceId(++sourceId), -1);
store.removeAll(namespaceId);
nsStore.delete(namespaceId);
Assert.assertTrue(store.getRuns(programId2, ProgramRunStatus.ALL, 0, Long.MAX_VALUE, Integer.MAX_VALUE).isEmpty());
}
Aggregations