use of com.twitter.heron.spi.common.Config in project incubator-heron by apache.
the class MarathonLauncher method launch.
@Override
public boolean launch(PackingPlan packing) {
LauncherUtils launcherUtils = LauncherUtils.getInstance();
Config ytruntime = launcherUtils.createConfigWithPackingDetails(runtime, packing);
return launcherUtils.onScheduleAsLibrary(config, ytruntime, getScheduler(), packing);
}
use of com.twitter.heron.spi.common.Config in project incubator-heron by apache.
the class VolumesTests method testAwsEbsVolume.
@Test
public void testAwsEbsVolume() {
final String volumeId = "aws-ebs-1";
final String fsType = "ext4";
final Config config = Config.newBuilder().put(KubernetesContext.HERON_KUBERNETES_VOLUME_TYPE, "awsElasticBlockStore").put(KubernetesContext.HERON_KUBERNETES_VOLUME_AWS_EBS_VOLUME_ID, volumeId).put(KubernetesContext.HERON_KUBERNETES_VOLUME_AWS_EBS_FS_TYPE, fsType).build();
final V1Volume volume = Volumes.get().create(config);
Assert.assertNotNull(volume);
Assert.assertNotNull(volume.getAwsElasticBlockStore());
Assert.assertEquals(volume.getAwsElasticBlockStore().getVolumeID(), volumeId);
Assert.assertEquals(volume.getAwsElasticBlockStore().getFsType(), fsType);
}
use of com.twitter.heron.spi.common.Config in project incubator-heron by apache.
the class MarathonLauncherTest method testLaunch.
@Test
public void testLaunch() throws Exception {
Config config = Config.newBuilder().build();
MarathonLauncher launcher = Mockito.spy(MarathonLauncher.class);
launcher.initialize(config, config);
LauncherUtils mockLauncherUtils = Mockito.mock(LauncherUtils.class);
PowerMockito.spy(LauncherUtils.class);
PowerMockito.doReturn(mockLauncherUtils).when(LauncherUtils.class, "getInstance");
// Launched successfully
Mockito.when(mockLauncherUtils.onScheduleAsLibrary(Mockito.any(Config.class), Mockito.any(Config.class), Mockito.any(IScheduler.class), Mockito.any(PackingPlan.class))).thenReturn(true);
Assert.assertTrue(launcher.launch(Mockito.mock(PackingPlan.class)));
Mockito.verify(mockLauncherUtils).onScheduleAsLibrary(Mockito.any(Config.class), Mockito.any(Config.class), Mockito.any(IScheduler.class), Mockito.any(PackingPlan.class));
// Failed to launch
Mockito.when(mockLauncherUtils.onScheduleAsLibrary(Mockito.any(Config.class), Mockito.any(Config.class), Mockito.any(IScheduler.class), Mockito.any(PackingPlan.class))).thenReturn(false);
Assert.assertFalse(launcher.launch(Mockito.mock(PackingPlan.class)));
Mockito.verify(mockLauncherUtils, Mockito.times(2)).onScheduleAsLibrary(Mockito.any(Config.class), Mockito.any(Config.class), Mockito.any(IScheduler.class), Mockito.any(PackingPlan.class));
launcher.close();
}
use of com.twitter.heron.spi.common.Config in project incubator-heron by apache.
the class MesosLauncherTest method testGetSchedulerCommand.
@Test
@SuppressWarnings("unchecked")
public void testGetSchedulerCommand() throws Exception {
final String JAVA_HOME = "java_home";
final String NATIVE_LIBRARY_PATH = "native_library_path";
final URI mockURI = TypeUtils.getURI("file:///mock/uri");
Config config = Mockito.mock(Config.class);
Mockito.when(config.getStringValue(MesosContext.SCHEDULER_WORKING_DIRECTORY)).thenReturn("working-dir");
Mockito.when(config.getStringValue(MesosContext.HERON_MESOS_NATIVE_LIBRARY_PATH)).thenReturn(NATIVE_LIBRARY_PATH);
Mockito.when(config.getStringValue(Key.JAVA_HOME)).thenReturn(JAVA_HOME);
Config runtime = Mockito.mock(Config.class);
Mockito.when(runtime.get(Key.TOPOLOGY_PACKAGE_URI)).thenReturn(mockURI);
MesosLauncher launcher = Mockito.spy(MesosLauncher.class);
String[] mockCommand = new String[] { "mock", "scheduler", "command" };
Mockito.doReturn(mockCommand).when(launcher).schedulerCommandArgs(Mockito.anyList());
launcher.initialize(config, runtime);
String[] command = launcher.getSchedulerCommand();
// Assert the content of command
Assert.assertEquals(String.format("%s/bin/java", JAVA_HOME), command[0]);
Assert.assertEquals(String.format("-Djava.library.path=%s", NATIVE_LIBRARY_PATH), command[1]);
Assert.assertEquals("-cp", command[2]);
Assert.assertEquals(String.format("-Pheron.package.topology.uri=%s", mockURI.toString()), command[5]);
Assert.assertEquals(mockCommand[0], command[6]);
Assert.assertEquals(mockCommand[1], command[7]);
Assert.assertEquals(mockCommand[2], command[8]);
}
use of com.twitter.heron.spi.common.Config in project incubator-heron by apache.
the class NomadSchedulerTest method setUp.
@Before
public void setUp() throws Exception {
Config config = Config.newBuilder().put(Key.TOPOLOGY_NAME, TOPOLOGY_NAME).put(Key.TOPOLOGY_ID, TOPOLOGY_ID).put(NomadContext.HERON_NOMAD_SCHEDULER_URI, SCHEDULER_URI).put(NomadContext.HERON_NOMAD_CORE_FREQ_MAPPING, HERON_NOMAD_CORE_FREQ_MAPPING).put(Key.CORE_PACKAGE_URI, CORE_PACKAGE_URI).put(Key.USE_CORE_PACKAGE_URI, USE_CORE_PACKAGE_URI).put(Key.EXECUTOR_BINARY, EXECUTOR_BINARY).put(NomadContext.HERON_NOMAD_DRIVER, NomadConstants.NomadDriver.RAW_EXEC.getName()).build();
this.mockRuntime = config;
this.mockConfig = config;
scheduler = Mockito.spy(NomadScheduler.class);
}
Aggregations