Search in sources :

Example 61 with Config

use of org.apache.heron.spi.common.Config in project heron by twitter.

the class AuroraSchedulerTest method testOnRestart.

@Test
public void testOnRestart() throws Exception {
    Config mockConfig = Mockito.mock(Config.class);
    PowerMockito.mockStatic(Config.class);
    when(Config.toClusterMode(mockConfig)).thenReturn(mockConfig);
    AuroraController controller = Mockito.mock(AuroraController.class);
    doReturn(controller).when(scheduler).getController();
    scheduler.initialize(mockConfig, Mockito.mock(Config.class));
    // Construct the RestartTopologyRequest
    int containerToRestart = 1;
    Scheduler.RestartTopologyRequest restartTopologyRequest = Scheduler.RestartTopologyRequest.newBuilder().setTopologyName(TOPOLOGY_NAME).setContainerIndex(containerToRestart).build();
    // Failed to kill job via controller
    doReturn(false).when(controller).restart(containerToRestart);
    Assert.assertFalse(scheduler.onRestart(restartTopologyRequest));
    Mockito.verify(controller).restart(containerToRestart);
    // Happy path
    doReturn(true).when(controller).restart(containerToRestart);
    assertTrue(scheduler.onRestart(restartTopologyRequest));
    Mockito.verify(controller, Mockito.times(2)).restart(containerToRestart);
}
Also used : Config(org.apache.heron.spi.common.Config) Scheduler(org.apache.heron.proto.scheduler.Scheduler) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 62 with Config

use of org.apache.heron.spi.common.Config in project heron by twitter.

the class KubernetesSchedulerTest method testGetJobLinks.

@Test
public void testGetJobLinks() throws Exception {
    final String SCHEDULER_URI = "http://k8s.uri";
    final String JOB_LINK = SCHEDULER_URI + KubernetesConstants.JOB_LINK;
    Config c = Config.newBuilder().put(KubernetesContext.HERON_KUBERNETES_SCHEDULER_URI, SCHEDULER_URI).build();
    scheduler.initialize(c, mockRuntime);
    List<String> links = scheduler.getJobLinks();
    Assert.assertEquals(1, links.size());
    System.out.println(links.get(0));
    System.out.println(JOB_LINK);
    Assert.assertTrue(links.get(0).equals(JOB_LINK));
}
Also used : Config(org.apache.heron.spi.common.Config) Test(org.junit.Test)

Example 63 with Config

use of org.apache.heron.spi.common.Config in project heron by twitter.

the class HdfsUploaderTest method setUp.

@Before
public void setUp() throws Exception {
    Config config = Mockito.mock(Config.class);
    // Insert mock HdfsController
    uploader = Mockito.spy(new HdfsUploader());
    controller = Mockito.mock(HdfsController.class);
    Mockito.doReturn(controller).when(uploader).getHdfsController();
    uploader.initialize(config);
}
Also used : Config(org.apache.heron.spi.common.Config) Before(org.junit.Before)

Example 64 with Config

use of org.apache.heron.spi.common.Config in project heron by twitter.

the class LocalFileSystemConfigTest method testOverrideConfig.

@Test
public void testOverrideConfig() throws Exception {
    String overrideDirectory = "/users/twitter";
    Config config = Config.toLocalMode(Config.newBuilder().putAll(getDefaultConfig()).put(LocalFileSystemKey.FILE_SYSTEM_DIRECTORY.value(), overrideDirectory).build());
    Assert.assertEquals(LocalFileSystemContext.getFileSystemDirectory(config), overrideDirectory);
}
Also used : Config(org.apache.heron.spi.common.Config) Test(org.junit.Test)

Example 65 with Config

use of org.apache.heron.spi.common.Config in project heron by twitter.

the class ConfigurationResource method release.

@Path("version")
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response release() throws JsonProcessingException {
    final Config configuration = getBaseConfiguration();
    final ObjectMapper mapper = new ObjectMapper();
    final ObjectNode node = mapper.createObjectNode();
    final Set<Map.Entry<String, Object>> sortedConfig = new TreeSet<>(Map.Entry.comparingByKey());
    sortedConfig.addAll(configuration.getEntrySet());
    for (Map.Entry<String, Object> entry : sortedConfig) {
        if (entry.getKey().contains("heron.build")) {
            node.put(entry.getKey(), entry.getValue().toString());
        }
    }
    return Response.ok().type(MediaType.APPLICATION_JSON).entity(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(node)).build();
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Config(org.apache.heron.spi.common.Config) TreeSet(java.util.TreeSet) Map(java.util.Map) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

Config (org.apache.heron.spi.common.Config)140 Test (org.junit.Test)75 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)29 PackingPlan (org.apache.heron.spi.packing.PackingPlan)22 HashMap (java.util.HashMap)18 SchedulerStateManagerAdaptor (org.apache.heron.spi.statemgr.SchedulerStateManagerAdaptor)18 Pair (org.apache.heron.common.basics.Pair)16 TopologyAPI (org.apache.heron.api.generated.TopologyAPI)15 IOException (java.io.IOException)11 LauncherUtils (org.apache.heron.scheduler.utils.LauncherUtils)11 Map (java.util.Map)10 V1Volume (io.kubernetes.client.openapi.models.V1Volume)9 URI (java.net.URI)9 IScheduler (org.apache.heron.spi.scheduler.IScheduler)9 IStateManager (org.apache.heron.spi.statemgr.IStateManager)9 Before (org.junit.Before)9 File (java.io.File)7 LinkedList (java.util.LinkedList)7 Resource (org.apache.heron.spi.packing.Resource)7 CommandLine (org.apache.commons.cli.CommandLine)6