use of io.cdap.cdap.internal.app.deploy.ProgramTerminator in project cdap by caskdata.
the class ApplicationLifecycleServiceTest method testMissingDependency.
@Test
public void testMissingDependency() throws Exception {
// tests the fix for CDAP-2543, by having programs which fail to start up due to missing dependency jars
ArtifactId artifactId = NamespaceId.DEFAULT.artifact("missing-guava-dependency", "1.0.0-SNAPSHOT");
Location appJar = createDeploymentJar(locationFactory, AppWithProgramsUsingGuava.class);
File appJarFile = new File(tmpFolder.newFolder(), String.format("%s-%s.jar", artifactId.getArtifact(), artifactId.getVersion()));
Locations.linkOrCopyOverwrite(appJar, appJarFile);
appJar.delete();
applicationLifecycleService.deployAppAndArtifact(NamespaceId.DEFAULT, "appName", Id.Artifact.fromEntityId(artifactId), appJarFile, null, null, new ProgramTerminator() {
@Override
public void stop(ProgramId programId) throws Exception {
// no-op
}
}, true);
ApplicationId appId = NamespaceId.DEFAULT.app("appName");
// run records for programs that have missing dependencies should be FAILED, instead of hanging in RUNNING
// fail the Worker#initialize
ProgramId worker = appId.worker(AppWithProgramsUsingGuava.NoOpWorker.NAME);
startProgram(Id.Program.fromEntityId(worker));
waitForRuns(1, worker, ProgramRunStatus.FAILED);
// fail the MapReduce#initialize
ProgramId mapreduce = appId.mr(AppWithProgramsUsingGuava.NoOpMR.NAME);
startProgram(Id.Program.fromEntityId(mapreduce));
waitForRuns(1, mapreduce, ProgramRunStatus.FAILED);
// fail the CustomAction#initialize
ProgramId workflow = appId.workflow(AppWithProgramsUsingGuava.NoOpWorkflow.NAME);
startProgram(Id.Program.fromEntityId(workflow));
waitForRuns(1, workflow, ProgramRunStatus.FAILED);
// fail the Workflow#initialize
appId.workflow(AppWithProgramsUsingGuava.NoOpWorkflow.NAME);
startProgram(Id.Program.fromEntityId(workflow), ImmutableMap.of("fail.in.workflow.initialize", "true"));
waitForRuns(1, workflow, ProgramRunStatus.FAILED);
}
Aggregations