use of co.cask.cdap.proto.id.ApplicationId in project cdap by caskdata.
the class DefaultStoreTest method testRemoveAll.
@Test
public void testRemoveAll() throws Exception {
ApplicationSpecification spec = Specifications.from(new WordCountApp());
NamespaceId namespaceId = new NamespaceId("account1");
ApplicationId appId = namespaceId.app("application1");
store.addApplication(appId, spec);
Assert.assertNotNull(store.getApplication(appId));
// removing flow
store.removeAll(namespaceId);
Assert.assertNull(store.getApplication(appId));
}
use of co.cask.cdap.proto.id.ApplicationId in project cdap by caskdata.
the class DefaultStoreTest method testRemoveApplication.
@Test
public void testRemoveApplication() throws Exception {
ApplicationSpecification spec = Specifications.from(new WordCountApp());
NamespaceId namespaceId = new NamespaceId("account1");
ApplicationId appId = namespaceId.app(spec.getName());
store.addApplication(appId, spec);
Assert.assertNotNull(store.getApplication(appId));
// removing application
store.removeApplication(appId);
Assert.assertNull(store.getApplication(appId));
}
use of co.cask.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");
RunId run1 = RunIds.generate();
store.setStart(programId1, run1.getId(), runIdToSecs(run1));
store.setSuspend(programId1, run1.getId());
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();
store.setStart(programId2, run2.getId(), runIdToSecs(run2));
store.setSuspend(programId2, run2.getId());
store.removeAll(namespaceId);
nsStore.delete(namespaceId);
Assert.assertTrue(store.getRuns(programId2, ProgramRunStatus.ALL, 0, Long.MAX_VALUE, Integer.MAX_VALUE).isEmpty());
}
use of co.cask.cdap.proto.id.ApplicationId in project cdap by caskdata.
the class DefaultStoreTest method testCheckDeletedProgramSpecs.
@Test
public void testCheckDeletedProgramSpecs() throws Exception {
//Deploy program with all types of programs.
ApplicationSpecification spec = Specifications.from(new AllProgramsApp());
ApplicationId appId = NamespaceId.DEFAULT.app(spec.getName());
store.addApplication(appId, spec);
Set<String> specsToBeVerified = Sets.newHashSet();
specsToBeVerified.addAll(spec.getMapReduce().keySet());
specsToBeVerified.addAll(spec.getWorkflows().keySet());
specsToBeVerified.addAll(spec.getFlows().keySet());
specsToBeVerified.addAll(spec.getServices().keySet());
specsToBeVerified.addAll(spec.getWorkers().keySet());
specsToBeVerified.addAll(spec.getSpark().keySet());
//Verify if there are 6 program specs in AllProgramsApp
Assert.assertEquals(7, specsToBeVerified.size());
// Check the diff with the same app - re-deployment scenario where programs are not removed.
List<ProgramSpecification> deletedSpecs = store.getDeletedProgramSpecifications(appId, spec);
Assert.assertEquals(0, deletedSpecs.size());
//Get the spec for app that contains no programs.
spec = Specifications.from(new NoProgramsApp());
//Get the deleted program specs by sending a spec with same name as AllProgramsApp but with no programs
deletedSpecs = store.getDeletedProgramSpecifications(appId, spec);
Assert.assertEquals(7, deletedSpecs.size());
for (ProgramSpecification specification : deletedSpecs) {
//Remove the spec that is verified, to check the count later.
specsToBeVerified.remove(specification.getName());
}
//All the 6 specs should have been deleted.
Assert.assertEquals(0, specsToBeVerified.size());
}
use of co.cask.cdap.proto.id.ApplicationId in project cdap by caskdata.
the class DefaultStoreTest method testUpdateChangedApplication.
@Test
public void testUpdateChangedApplication() throws Exception {
ApplicationId id = new ApplicationId("account1", "application1");
store.addApplication(id, Specifications.from(new FooApp()));
// update
store.addApplication(id, Specifications.from(new ChangedFooApp()));
ApplicationSpecification stored = store.getApplication(id);
assertChangedFooAppSpecAndInMetadataStore(stored);
}
Aggregations