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);
}
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));
}
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);
}
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);
}
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();
}
Aggregations