use of co.cask.cdap.api.app.ApplicationSpecification 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.api.app.ApplicationSpecification 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.api.app.ApplicationSpecification in project cdap by caskdata.
the class DefaultStoreTest method testServiceInstances.
@Test
public void testServiceInstances() throws Exception {
ApplicationSpecification appSpec = Specifications.from(new AppWithServices());
ApplicationId appId = NamespaceId.DEFAULT.app(appSpec.getName());
store.addApplication(appId, appSpec);
// Test setting of service instances
ProgramId programId = appId.program(ProgramType.SERVICE, "NoOpService");
int count = store.getServiceInstances(programId);
Assert.assertEquals(1, count);
store.setServiceInstances(programId, 10);
count = store.getServiceInstances(programId);
Assert.assertEquals(10, count);
ApplicationSpecification newSpec = store.getApplication(appId);
Assert.assertNotNull(newSpec);
Map<String, ServiceSpecification> services = newSpec.getServices();
Assert.assertEquals(1, services.size());
ServiceSpecification serviceSpec = services.get("NoOpService");
Assert.assertEquals(10, serviceSpec.getInstances());
}
use of co.cask.cdap.api.app.ApplicationSpecification in project cdap by caskdata.
the class DefaultStoreTest method testServiceDeletion.
@Test
public void testServiceDeletion() throws Exception {
// Store the application specification
AbstractApplication app = new AppWithServices();
ApplicationSpecification appSpec = Specifications.from(app);
ApplicationId appId = NamespaceId.DEFAULT.app(appSpec.getName());
store.addApplication(appId, appSpec);
AbstractApplication newApp = new AppWithNoServices();
// get the delete program specs after deploying AppWithNoServices
List<ProgramSpecification> programSpecs = store.getDeletedProgramSpecifications(appId, Specifications.from(newApp));
// verify the result.
Assert.assertEquals(1, programSpecs.size());
Assert.assertEquals("NoOpService", programSpecs.get(0).getName());
}
use of co.cask.cdap.api.app.ApplicationSpecification 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));
}
Aggregations