Search in sources :

Example 1 with NoProgramsApp

use of co.cask.cdap.NoProgramsApp 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());
}
Also used : ApplicationSpecification(co.cask.cdap.api.app.ApplicationSpecification) ProgramSpecification(co.cask.cdap.api.ProgramSpecification) NoProgramsApp(co.cask.cdap.NoProgramsApp) AllProgramsApp(co.cask.cdap.AllProgramsApp) ApplicationId(co.cask.cdap.proto.id.ApplicationId) Test(org.junit.Test)

Aggregations

AllProgramsApp (co.cask.cdap.AllProgramsApp)1 NoProgramsApp (co.cask.cdap.NoProgramsApp)1 ProgramSpecification (co.cask.cdap.api.ProgramSpecification)1 ApplicationSpecification (co.cask.cdap.api.app.ApplicationSpecification)1 ApplicationId (co.cask.cdap.proto.id.ApplicationId)1 Test (org.junit.Test)1