use of io.cdap.cdap.api.app.ApplicationSpecification in project cdap by caskdata.
the class DistributedWorkerProgramRunner method setupLaunchConfig.
@Override
protected void setupLaunchConfig(ProgramLaunchConfig launchConfig, Program program, ProgramOptions options, CConfiguration cConf, Configuration hConf, File tempDir) {
ApplicationSpecification appSpec = program.getApplicationSpecification();
WorkerSpecification workerSpec = appSpec.getWorkers().get(program.getName());
String instances = options.getArguments().getOption(ProgramOptionConstants.INSTANCES, String.valueOf(workerSpec.getInstances()));
launchConfig.addRunnable(workerSpec.getName(), new WorkerTwillRunnable(workerSpec.getName()), Integer.parseInt(instances), options.getUserArguments().asMap(), workerSpec.getResources());
}
use of io.cdap.cdap.api.app.ApplicationSpecification in project cdap by caskdata.
the class ProgramLifecycleHttpHandlerTest method testProgramList.
/**
* Tests for program list calls
*/
@Test
public void testProgramList() throws Exception {
// test initial state
testListInitialState(TEST_NAMESPACE2, ProgramType.MAPREDUCE);
testListInitialState(TEST_NAMESPACE1, ProgramType.WORKFLOW);
testListInitialState(TEST_NAMESPACE2, ProgramType.SPARK);
testListInitialState(TEST_NAMESPACE1, ProgramType.SERVICE);
// deploy AllProgramsApp in namespace1 and verify
deploy(AllProgramsApp.class, 200, Constants.Gateway.API_VERSION_3_TOKEN, TEST_NAMESPACE1);
// deploy AppWithServices in namespace2 and verify
deploy(AppWithServices.class, 200, Constants.Gateway.API_VERSION_3_TOKEN, TEST_NAMESPACE2);
ApplicationSpecification allProgramSpec = Specifications.from(new AllProgramsApp());
// verify list by namespace
for (io.cdap.cdap.api.app.ProgramType type : io.cdap.cdap.api.app.ProgramType.values()) {
Set<String> programsByType = allProgramSpec.getProgramsByType(type);
verifyProgramList(TEST_NAMESPACE1, ProgramType.valueOf(type.name()), programsByType.size());
}
verifyProgramList(TEST_NAMESPACE2, ProgramType.SERVICE, 1);
// verify list by app
for (io.cdap.cdap.api.app.ProgramType type : io.cdap.cdap.api.app.ProgramType.values()) {
Set<String> programsByType = allProgramSpec.getProgramsByType(type);
verifyProgramList(TEST_NAMESPACE1, AllProgramsApp.NAME, ProgramType.valueOf(type.name()), programsByType.size());
}
verifyProgramList(TEST_NAMESPACE2, AppWithServices.NAME, ProgramType.SERVICE, 1);
// verify invalid namespace
Assert.assertEquals(404, getAppFDetailResponseCode(TEST_NAMESPACE1, AppWithServices.SERVICE_NAME));
// verify invalid app
Assert.assertEquals(404, getAppFDetailResponseCode(TEST_NAMESPACE1, "random"));
}
use of io.cdap.cdap.api.app.ApplicationSpecification in project cdap by caskdata.
the class ApplicationVerificationTest method testGoodApplication.
/**
* Good test
*/
@Test
public void testGoodApplication() {
ApplicationSpecification appSpec = Specifications.from(new AllProgramsApp());
ApplicationSpecificationAdapter adapter = ApplicationSpecificationAdapter.create();
ApplicationSpecification newSpec = adapter.fromJson(adapter.toJson(appSpec));
ApplicationVerification app = new ApplicationVerification();
VerifyResult result = app.verify(new ApplicationId("test", newSpec.getName()), newSpec);
Assert.assertSame(result.getMessage(), result.getStatus(), VerifyResult.Status.SUCCESS);
}
use of io.cdap.cdap.api.app.ApplicationSpecification in project cdap by caskdata.
the class PreferencesHttpHandlerInternalTest method addApplication.
private void addApplication(String namespace, Application app) {
ApplicationSpecification appSpec = Specifications.from(app);
store.addApplication(new ApplicationId(namespace, appSpec.getName()), appSpec);
}
use of io.cdap.cdap.api.app.ApplicationSpecification in project cdap by caskdata.
the class WorkflowVerificationTest method testGoodWorkflow.
@Test
public void testGoodWorkflow() throws Exception {
ApplicationSpecification appSpec = Specifications.from(new GoodWorkflowApp());
verifyGoodWorkflowSpecifications(appSpec);
verifyAnotherGoodWorkflowSpecification(appSpec);
verifyWorkflowWithLocalDatasetSpecification(appSpec);
ApplicationSpecificationAdapter adapter = ApplicationSpecificationAdapter.create();
ApplicationSpecification newSpec = adapter.fromJson(adapter.toJson(appSpec));
verifyGoodWorkflowSpecifications(newSpec);
verifyAnotherGoodWorkflowSpecification(newSpec);
verifyWorkflowWithLocalDatasetSpecification(newSpec);
}
Aggregations