Search in sources :

Example 1 with NoProgramsApp

use of io.cdap.cdap.NoProgramsApp in project cdap by caskdata.

the class DefaultStoreTest method testCheckDeletedProgramSpecs.

@Test
public void testCheckDeletedProgramSpecs() {
    // 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.getServices().keySet());
    specsToBeVerified.addAll(spec.getWorkers().keySet());
    specsToBeVerified.addAll(spec.getSpark().keySet());
    // Verify if there are 6 program specs in AllProgramsApp
    Assert.assertEquals(6, 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(6, 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(io.cdap.cdap.api.app.ApplicationSpecification) ProgramSpecification(io.cdap.cdap.api.ProgramSpecification) NoProgramsApp(io.cdap.cdap.NoProgramsApp) AllProgramsApp(io.cdap.cdap.AllProgramsApp) ApplicationId(io.cdap.cdap.proto.id.ApplicationId) Test(org.junit.Test)

Aggregations

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