use of com.twitter.heron.spi.common.Config in project heron by twitter.
the class SlurmSchedulerTest method createRunnerConfig.
private static Config createRunnerConfig() {
Config config = Mockito.mock(Config.class);
Mockito.when(config.getStringValue(Key.TOPOLOGY_NAME)).thenReturn(TOPOLOGY_NAME);
Mockito.when(config.getStringValue(Key.CLUSTER)).thenReturn(CLUSTER);
Mockito.when(config.getStringValue(Key.ROLE)).thenReturn(ROLE);
Mockito.when(config.getStringValue(Key.ENVIRON)).thenReturn(ENVIRON);
return config;
}
use of com.twitter.heron.spi.common.Config in project heron by twitter.
the class ZkUtilsTest method testSetupZkTunnel.
/**
* Test setupZkTunnel
*/
@Test
public void testSetupZkTunnel() throws Exception {
String host0 = "host0";
int port0 = 12;
InetSocketAddress address0 = NetworkUtils.getInetSocketAddress(String.format("%s:%d", host0, port0));
String host1 = "host1";
int port1 = 13;
InetSocketAddress address1 = NetworkUtils.getInetSocketAddress(String.format("%s:%d", host1, port1));
String host2 = "host2";
int port2 = 9049;
InetSocketAddress address2 = NetworkUtils.getInetSocketAddress(String.format("%s:%d", host2, port2));
String tunnelHost = "tunnelHost";
int tunnelPort = 9519;
InetSocketAddress tunnelAddress = NetworkUtils.getInetSocketAddress(String.format("%s:%d", tunnelHost, tunnelPort));
// Original connection String
String connectionString = String.format("%s:%d, %s:%d, %s:%d ", host0, port0, host1, port1, host2, port2);
Config config = mock(Config.class);
when(config.getStringValue(Key.STATEMGR_CONNECTION_STRING)).thenReturn(connectionString);
NetworkUtils.TunnelConfig tunnelConfig = NetworkUtils.TunnelConfig.build(config, NetworkUtils.HeronSystem.STATE_MANAGER);
Process process = mock(Process.class);
// Mock the invocation of establishSSHTunnelIfNeeded
// address0 and address1 are directly reachable
// address2 are reachable after tunneling
PowerMockito.spy(NetworkUtils.class);
PowerMockito.doReturn(new Pair<>(address0, process)).when(NetworkUtils.class, "establishSSHTunnelIfNeeded", eq(address0), anyString(), any(NetworkUtils.TunnelType.class), anyInt(), anyInt(), anyInt(), anyInt());
PowerMockito.doReturn(new Pair<>(address1, process)).when(NetworkUtils.class, "establishSSHTunnelIfNeeded", eq(address1), anyString(), any(NetworkUtils.TunnelType.class), anyInt(), anyInt(), anyInt(), anyInt());
PowerMockito.doReturn(new Pair<>(tunnelAddress, process)).when(NetworkUtils.class, "establishSSHTunnelIfNeeded", eq(address2), anyString(), any(NetworkUtils.TunnelType.class), anyInt(), anyInt(), anyInt(), anyInt());
Pair<String, List<Process>> ret = ZkUtils.setupZkTunnel(config, tunnelConfig);
// Assert with expected results
String expectedConnectionString = String.format("%s,%s,%s", address0.toString(), address1.toString(), tunnelAddress.toString());
assertEquals(expectedConnectionString, ret.first);
assertEquals(3, ret.second.size());
for (Process p : ret.second) {
assertEquals(process, p);
}
}
use of com.twitter.heron.spi.common.Config in project heron by twitter.
the class LocalFileSystemConfigTest method testOverrideTopologyDirectory.
@Test
public void testOverrideTopologyDirectory() throws Exception {
LocalFileSystemUploader uploader = new LocalFileSystemUploader();
String overrideDirectory = "/users/twitter";
Config config = Config.toLocalMode(Config.newBuilder().putAll(getDefaultConfig()).put(LocalFileSystemKey.FILE_SYSTEM_DIRECTORY.value(), overrideDirectory).build());
uploader.initialize(config);
Assert.assertEquals(uploader.getTopologyDirectory(), overrideDirectory);
}
use of com.twitter.heron.spi.common.Config in project heron by twitter.
the class LocalFileSystemConfigTest method testTopologyFile.
@Test
public void testTopologyFile() throws Exception {
Config config = Config.toLocalMode(getDefaultConfig());
LocalFileSystemUploader uploader = new LocalFileSystemUploader();
uploader.initialize(config);
Assert.assertEquals(Paths.get(uploader.getTopologyFile()).getParent().toString(), LocalFileSystemContext.fileSystemDirectory(config));
}
use of com.twitter.heron.spi.common.Config in project heron by twitter.
the class LocalFileSystemConfigTest method testOverrideTopologyFile.
@Test
public void testOverrideTopologyFile() throws Exception {
LocalFileSystemUploader uploader = new LocalFileSystemUploader();
String overrideDirectory = "/users/twitter";
Config config = Config.toLocalMode(Config.newBuilder().putAll(getDefaultConfig()).put(LocalFileSystemKey.FILE_SYSTEM_DIRECTORY.value(), overrideDirectory).build());
uploader.initialize(config);
Assert.assertEquals(Paths.get(uploader.getTopologyFile()).getParent().toString(), overrideDirectory);
}
Aggregations