Search in sources :

Example 6 with ServiceConfiguration

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);
}
Also used : OfferBuilder(org.apache.myriad.scheduler.offer.OfferBuilder) NodeTask(org.apache.myriad.state.NodeTask) ResourceOfferContainer(org.apache.myriad.scheduler.resource.ResourceOfferContainer) ServiceConfiguration(org.apache.myriad.configuration.ServiceConfiguration) Protos(org.apache.mesos.Protos) Test(org.junit.Test) BaseConfigurableTest(org.apache.myriad.BaseConfigurableTest)

Aggregations

ServiceConfiguration (org.apache.myriad.configuration.ServiceConfiguration)6 Protos (org.apache.mesos.Protos)3 Map (java.util.Map)2 BaseConfigurableTest (org.apache.myriad.BaseConfigurableTest)2 MyriadConfiguration (org.apache.myriad.configuration.MyriadConfiguration)2 NodeTask (org.apache.myriad.state.NodeTask)2 Test (org.junit.Test)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 YAMLFactory (com.fasterxml.jackson.dataformat.yaml.YAMLFactory)1 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1 CommandInfo (org.apache.mesos.Protos.CommandInfo)1 MyriadBadConfigurationException (org.apache.myriad.configuration.MyriadBadConfigurationException)1 NMTaskFactory (org.apache.myriad.scheduler.NMTaskFactory)1 ServiceProfileManager (org.apache.myriad.scheduler.ServiceProfileManager)1 ServiceResourceProfile (org.apache.myriad.scheduler.ServiceResourceProfile)1 ServiceTaskFactory (org.apache.myriad.scheduler.ServiceTaskFactory)1 TaskFactory (org.apache.myriad.scheduler.TaskFactory)1 Constraint (org.apache.myriad.scheduler.constraints.Constraint)1 LikeConstraint (org.apache.myriad.scheduler.constraints.LikeConstraint)1