Search in sources :

Example 91 with Config

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);
}
Also used : Config(com.twitter.heron.spi.common.Config) LauncherUtils(com.twitter.heron.scheduler.utils.LauncherUtils)

Example 92 with Config

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);
}
Also used : V1Volume(io.kubernetes.client.models.V1Volume) Config(com.twitter.heron.spi.common.Config) Test(org.junit.Test)

Example 93 with Config

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();
}
Also used : Config(com.twitter.heron.spi.common.Config) PackingPlan(com.twitter.heron.spi.packing.PackingPlan) LauncherUtils(com.twitter.heron.scheduler.utils.LauncherUtils) IScheduler(com.twitter.heron.spi.scheduler.IScheduler) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 94 with Config

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]);
}
Also used : Config(com.twitter.heron.spi.common.Config) URI(java.net.URI) Test(org.junit.Test)

Example 95 with Config

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);
}
Also used : Config(com.twitter.heron.spi.common.Config) Before(org.junit.Before)

Aggregations

Config (com.twitter.heron.spi.common.Config)211 Test (org.junit.Test)125 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)60 PackingPlan (com.twitter.heron.spi.packing.PackingPlan)53 TopologyAPI (com.twitter.heron.api.generated.TopologyAPI)43 SchedulerStateManagerAdaptor (com.twitter.heron.spi.statemgr.SchedulerStateManagerAdaptor)35 LauncherUtils (com.twitter.heron.scheduler.utils.LauncherUtils)19 IStateManager (com.twitter.heron.spi.statemgr.IStateManager)18 IScheduler (com.twitter.heron.spi.scheduler.IScheduler)17 HashMap (java.util.HashMap)16 Before (org.junit.Before)16 ILauncher (com.twitter.heron.spi.scheduler.ILauncher)14 IOException (java.io.IOException)13 Resource (com.twitter.heron.spi.packing.Resource)12 URI (java.net.URI)12 HashSet (java.util.HashSet)11 CommandLine (org.apache.commons.cli.CommandLine)10 ByteAmount (com.twitter.heron.common.basics.ByteAmount)9 ISchedulerClient (com.twitter.heron.scheduler.client.ISchedulerClient)9 File (java.io.File)9