Search in sources :

Example 6 with ApplicationId

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);
}
Also used : ApplicationSpecification(io.cdap.cdap.api.app.ApplicationSpecification) ApplicationId(io.cdap.cdap.proto.id.ApplicationId)

Example 7 with ApplicationId

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));
    }
}
Also used : EntityId(io.cdap.cdap.proto.id.EntityId) ApplicationId(io.cdap.cdap.proto.id.ApplicationId) ProgramId(io.cdap.cdap.proto.id.ProgramId) DatasetId(io.cdap.cdap.proto.id.DatasetId) Test(org.junit.Test)

Example 8 with ApplicationId

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);
}
Also used : ApplicationId(io.cdap.cdap.proto.id.ApplicationId) ProgramId(io.cdap.cdap.proto.id.ProgramId) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Example 9 with ApplicationId

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());
}
Also used : ApplicationSpecification(io.cdap.cdap.api.app.ApplicationSpecification) MapReduceSpecification(io.cdap.cdap.api.mapreduce.MapReduceSpecification) ProgramDescriptor(io.cdap.cdap.app.program.ProgramDescriptor) ApplicationId(io.cdap.cdap.proto.id.ApplicationId) Test(org.junit.Test)

Example 10 with ApplicationId

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());
}
Also used : ArtifactId(io.cdap.cdap.api.artifact.ArtifactId) NamespaceId(io.cdap.cdap.proto.id.NamespaceId) ApplicationId(io.cdap.cdap.proto.id.ApplicationId) ProgramId(io.cdap.cdap.proto.id.ProgramId) RunId(org.apache.twill.api.RunId) ProgramRunId(io.cdap.cdap.proto.id.ProgramRunId) Test(org.junit.Test)

Aggregations

ApplicationId (io.cdap.cdap.proto.id.ApplicationId)789 Test (org.junit.Test)410 AppRequest (io.cdap.cdap.proto.artifact.AppRequest)279 ProgramId (io.cdap.cdap.proto.id.ProgramId)263 ApplicationManager (io.cdap.cdap.test.ApplicationManager)225 ETLStage (io.cdap.cdap.etl.proto.v2.ETLStage)223 ETLBatchConfig (io.cdap.cdap.etl.proto.v2.ETLBatchConfig)196 StructuredRecord (io.cdap.cdap.api.data.format.StructuredRecord)180 Table (io.cdap.cdap.api.dataset.table.Table)178 WorkflowManager (io.cdap.cdap.test.WorkflowManager)169 NamespaceId (io.cdap.cdap.proto.id.NamespaceId)154 Schema (io.cdap.cdap.api.data.schema.Schema)147 ArrayList (java.util.ArrayList)129 HashSet (java.util.HashSet)126 ApplicationSpecification (io.cdap.cdap.api.app.ApplicationSpecification)124 HashMap (java.util.HashMap)109 KeyValueTable (io.cdap.cdap.api.dataset.lib.KeyValueTable)107 ArtifactSummary (io.cdap.cdap.api.artifact.ArtifactSummary)88 ProgramRunId (io.cdap.cdap.proto.id.ProgramRunId)88 Path (javax.ws.rs.Path)75