use of org.apache.myriad.configuration.ServiceConfiguration in project incubator-myriad by apache.
the class TestServiceTaskFactory method testServiceTaskFactory.
@Test
public void testServiceTaskFactory() {
ServiceCommandLineGenerator clGenerator = new ServiceCommandLineGenerator(cfgWithDocker);
TaskUtils taskUtils = new TaskUtils(cfgWithDocker);
Protos.Offer offer = new OfferBuilder("test.com").addScalarResource("cpus", 10.0).addScalarResource("mem", 16000).addRangeResource("ports", 3400, 3410).build();
Map<String, ServiceConfiguration> stringServiceConfigurationMap = cfgWithDocker.getServiceConfigurations();
System.out.print(stringServiceConfigurationMap);
ServiceConfiguration serviceConfiguration = cfgWithDocker.getServiceConfigurations().get("jobhistory");
ServiceResourceProfile profile = new ServiceResourceProfile("jobhistory", serviceConfiguration.getCpus(), serviceConfiguration.getJvmMaxMemoryMB(), serviceConfiguration.getPorts());
NodeTask nodeTask = new NodeTask(profile, null);
nodeTask.setTaskPrefix("jobhistory");
ResourceOfferContainer roc = new ResourceOfferContainer(offer, profile, null);
System.out.print(roc.getPorts());
ServiceTaskFactory taskFactory = new ServiceTaskFactory(cfgWithDocker, taskUtils, clGenerator);
Protos.TaskInfo taskInfo = taskFactory.createTask(roc, frameworkId, makeTaskId("jobhistory"), nodeTask);
assertTrue("taskInfo should have a container", taskInfo.hasContainer());
assertFalse("The container should not have an executor", taskInfo.hasExecutor());
Protos.ContainerInfo containerInfo = taskInfo.getContainer();
assertTrue("There should be two volumes", containerInfo.getVolumesCount() == 2);
assertTrue("The first volume should be read only", containerInfo.getVolumes(0).getMode().equals(Protos.Volume.Mode.RO));
assertTrue("The first volume should be read write", containerInfo.getVolumes(1).getMode().equals(Protos.Volume.Mode.RW));
assertTrue("There should be a docker image", containerInfo.getDocker().hasImage());
assertTrue("The docker image should be mesos/myraid", containerInfo.getDocker().getImage().equals("mesos/myriad"));
assertTrue("Should be using host networking", containerInfo.getDocker().getNetwork().equals(Protos.ContainerInfo.DockerInfo.Network.HOST));
assertTrue("There should be two parameters", containerInfo.getDocker().getParametersList().size() == 2);
assertTrue("Privledged mode should be false", containerInfo.getDocker().getPrivileged() == false);
}
Aggregations