use of io.cdap.cdap.proto.id.ArtifactId in project cdap by cdapio.
the class AppLifecycleHttpHandlerTest method testDeployWithExtraConfig.
@Test
public void testDeployWithExtraConfig() throws Exception {
Id.Artifact artifactId = Id.Artifact.from(Id.Namespace.DEFAULT, "extraConfig", "1.0.0-SNAPSHOT");
Id.Application appId = Id.Application.from(Id.Namespace.DEFAULT, "ExtraConfigApp");
HttpResponse response = addAppArtifact(artifactId, AppWithNoServices.class);
Assert.assertEquals(200, response.getResponseCode());
response = deploy(appId, new AppRequest<>(ArtifactSummary.from(artifactId.toArtifactId()), new ExtraConfig()));
Assert.assertEquals(200, response.getResponseCode());
deleteApp(appId, 200);
deleteArtifact(artifactId, 200);
}
use of io.cdap.cdap.proto.id.ArtifactId in project cdap by cdapio.
the class AppLifecycleHttpHandlerTest method testDeployUsingArtifact.
@Test
public void testDeployUsingArtifact() throws Exception {
Id.Artifact artifactId = Id.Artifact.from(Id.Namespace.DEFAULT, "configapp", "1.0.0");
addAppArtifact(artifactId, ConfigTestApp.class);
Id.Application appId = Id.Application.from(Id.Namespace.DEFAULT, "cfgApp");
ConfigTestApp.ConfigClass config = new ConfigTestApp.ConfigClass("abc", "def");
AppRequest<ConfigTestApp.ConfigClass> request = new AppRequest<>(new ArtifactSummary(artifactId.getName(), artifactId.getVersion().getVersion()), config);
Assert.assertEquals(200, deploy(appId, request).getResponseCode());
JsonObject appDetails = getAppDetails(Id.Namespace.DEFAULT.getId(), appId.getId());
Assert.assertEquals(GSON.toJson(config), appDetails.get("configuration").getAsString());
Assert.assertEquals(200, doDelete(getVersionedAPIPath("apps/" + appId.getId(), appId.getNamespaceId())).getResponseCode());
}
use of io.cdap.cdap.proto.id.ArtifactId in project cdap by cdapio.
the class AppLifecycleHttpHandlerTest method testAppWithConfig.
@Test
public void testAppWithConfig() throws Exception {
Id.Application appId = Id.Application.from(Id.Namespace.DEFAULT, "ConfigApp");
Id.Artifact artifactId = Id.Artifact.from(Id.Namespace.DEFAULT, "appWithConfig", "1.0.0-SNAPSHOT");
HttpResponse response = addAppArtifact(artifactId, ConfigTestApp.class);
Assert.assertEquals(200, response.getResponseCode());
ConfigTestApp.ConfigClass config = new ConfigTestApp.ConfigClass("abc", "def");
response = deploy(appId, new AppRequest<>(ArtifactSummary.from(artifactId.toArtifactId()), config));
Assert.assertEquals(200, response.getResponseCode());
JsonObject appDetails = getAppDetails(Id.Namespace.DEFAULT.getId(), "ConfigApp");
Assert.assertEquals(GSON.toJson(config), appDetails.get("configuration").getAsString());
deleteApp(appId, 200);
deleteArtifact(artifactId, 200);
}
use of io.cdap.cdap.proto.id.ArtifactId in project cdap by cdapio.
the class ArtifactHttpHandlerInternalTest method testListArtifacts.
@Test
public void testListArtifacts() throws Exception {
List<ArtifactInfo> artifactInfoList = null;
ArtifactInfo artifactInfo = null;
// Add a system artifact
String systemArtfiactName = "sysApp";
String systemArtifactVeresion = "1.0.0";
ArtifactId systemArtifactId = NamespaceId.SYSTEM.artifact(systemArtfiactName, systemArtifactVeresion);
addAppAsSystemArtifacts(systemArtifactId);
// Listing all artifacts in default namespace, should include system artifacts
artifactInfoList = listArtifactsInternal(NamespaceId.DEFAULT.getNamespace());
Assert.assertEquals(1, artifactInfoList.size());
artifactInfo = artifactInfoList.stream().filter(info -> info.getScope().equals(ArtifactScope.SYSTEM)).findAny().orElse(null);
Assert.assertNotNull(artifactInfo);
Assert.assertEquals(ArtifactScope.SYSTEM, artifactInfo.getScope());
Assert.assertEquals(systemArtfiactName, artifactInfo.getName());
Assert.assertEquals(systemArtifactVeresion, artifactInfo.getVersion());
Assert.assertTrue(artifactInfo.getClasses().getApps().size() > 0);
// Add a user artifact, in addition to the above system artifact
String userArtifactName = "userApp";
String userArtifactVersion = "2.0.0";
ArtifactId userArtifactId = NamespaceId.DEFAULT.artifact(userArtifactName, userArtifactVersion);
addAppAsUserArtifacts(userArtifactId);
// Listing all artifacts in default namespace, should include both user and system artifacts
artifactInfoList = listArtifactsInternal(NamespaceId.DEFAULT.getNamespace());
Assert.assertEquals(2, artifactInfoList.size());
artifactInfo = artifactInfoList.stream().filter(info -> info.getScope().equals(ArtifactScope.USER)).findAny().orElse(null);
Assert.assertNotNull(artifactInfo);
Assert.assertEquals(ArtifactScope.USER, artifactInfo.getScope());
Assert.assertEquals(userArtifactName, artifactInfo.getName());
Assert.assertEquals(userArtifactVersion, artifactInfo.getVersion());
Assert.assertTrue(artifactInfo.getClasses().getApps().size() > 0);
artifactInfo = artifactInfoList.stream().filter(info -> info.getScope().equals(ArtifactScope.SYSTEM)).findAny().orElse(null);
Assert.assertNotNull(artifactInfo);
Assert.assertEquals(ArtifactScope.SYSTEM, artifactInfo.getScope());
Assert.assertEquals(systemArtfiactName, artifactInfo.getName());
Assert.assertEquals(systemArtifactVeresion, artifactInfo.getVersion());
Assert.assertTrue(artifactInfo.getClasses().getApps().size() > 0);
}
use of io.cdap.cdap.proto.id.ArtifactId in project cdap by cdapio.
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