Search in sources :

Example 1 with AppWithWorker

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

the class DefaultStoreTest method testWorkerInstances.

@Test
public void testWorkerInstances() {
    ApplicationSpecification spec = Specifications.from(new AppWithWorker());
    ApplicationId appId = NamespaceId.DEFAULT.app(spec.getName());
    store.addApplication(appId, spec);
    ProgramId programId = appId.worker(AppWithWorker.WORKER);
    int instancesFromSpec = spec.getWorkers().get(AppWithWorker.WORKER).getInstances();
    Assert.assertEquals(1, instancesFromSpec);
    int instances = store.getWorkerInstances(programId);
    Assert.assertEquals(instancesFromSpec, instances);
    store.setWorkerInstances(programId, 9);
    instances = store.getWorkerInstances(programId);
    Assert.assertEquals(9, instances);
}
Also used : ApplicationSpecification(io.cdap.cdap.api.app.ApplicationSpecification) AppWithWorker(io.cdap.cdap.AppWithWorker) ApplicationId(io.cdap.cdap.proto.id.ApplicationId) ProgramId(io.cdap.cdap.proto.id.ProgramId) Test(org.junit.Test)

Aggregations

AppWithWorker (io.cdap.cdap.AppWithWorker)1 ApplicationSpecification (io.cdap.cdap.api.app.ApplicationSpecification)1 ApplicationId (io.cdap.cdap.proto.id.ApplicationId)1 ProgramId (io.cdap.cdap.proto.id.ProgramId)1 Test (org.junit.Test)1