use of org.apache.flink.configuration.Configuration in project flink by apache.
the class RpcConnectionTest method testConnectFailure.
@Test
public void testConnectFailure() {
ActorSystem actorSystem = null;
RpcService rpcService = null;
try {
actorSystem = AkkaUtils.createActorSystem(new Configuration(), Option.apply(new Tuple2<String, Object>("localhost", 0)));
// we start the RPC service with a very long timeout to ensure that the test
// can only pass if the connection problem is not recognized merely via a timeout
rpcService = new AkkaRpcService(actorSystem, Time.of(10000000, TimeUnit.SECONDS));
Future<TaskExecutorGateway> future = rpcService.connect("foo.bar.com.test.invalid", TaskExecutorGateway.class);
future.get(10000000, TimeUnit.SECONDS);
fail("should never complete normally");
} catch (TimeoutException e) {
fail("should not fail with a generic timeout exception");
} catch (ExecutionException e) {
// that is what we want
assertTrue(e.getCause() instanceof RpcConnectionException);
assertTrue("wrong error message", e.getCause().getMessage().contains("foo.bar.com.test.invalid"));
} catch (Throwable t) {
fail("wrong exception: " + t);
} finally {
if (rpcService != null) {
rpcService.stopService();
}
if (actorSystem != null) {
actorSystem.shutdown();
}
}
}
use of org.apache.flink.configuration.Configuration in project flink by apache.
the class StateBackendLoadingTest method testInstantiateMemoryBackendByDefault.
@Test
public void testInstantiateMemoryBackendByDefault() throws Exception {
StateBackend backend = AbstractStateBackend.loadStateBackendFromConfigOrCreateDefault(new Configuration(), cl, null);
assertTrue(backend instanceof MemoryStateBackend);
}
use of org.apache.flink.configuration.Configuration in project flink by apache.
the class StateBackendLoadingTest method testLoadingFails.
/**
* This test makes sure that failures properly manifest when the state backend could not be loaded.
*/
@Test
public void testLoadingFails() throws Exception {
final Configuration config = new Configuration();
// try a value that is neither recognized as a name, nor corresponds to a class
config.setString(backendKey, "does.not.exist");
try {
AbstractStateBackend.loadStateBackendFromConfigOrCreateDefault(config, cl, null);
fail("should fail with an exception");
} catch (DynamicCodeLoadingException ignored) {
// expected
}
// try a class that is not a factory
config.setString(backendKey, java.io.File.class.getName());
try {
AbstractStateBackend.loadStateBackendFromConfigOrCreateDefault(config, cl, null);
fail("should fail with an exception");
} catch (DynamicCodeLoadingException ignored) {
// expected
}
// a factory that fails
config.setString(backendKey, FailingFactory.class.getName());
try {
AbstractStateBackend.loadStateBackendFromConfigOrCreateDefault(config, cl, null);
fail("should fail with an exception");
} catch (IOException ignored) {
// expected
}
}
use of org.apache.flink.configuration.Configuration in project flink by apache.
the class StateBackendLoadingTest method testLoadMemoryStateBackend.
@Test
public void testLoadMemoryStateBackend() throws Exception {
// we configure with the explicit string (rather than AbstractStateBackend#X_STATE_BACKEND_NAME)
// to guard against config-breaking changes of the name
final Configuration config = new Configuration();
config.setString(backendKey, "jobmanager");
StateBackend backend = AbstractStateBackend.loadStateBackendFromConfigOrCreateDefault(new Configuration(), cl, null);
assertTrue(backend instanceof MemoryStateBackend);
}
use of org.apache.flink.configuration.Configuration in project flink by apache.
the class SecurityUtilsTest method testSecurityContext.
@Test
public void testSecurityContext() throws Exception {
SecurityUtils.SecurityConfiguration sc = new SecurityUtils.SecurityConfiguration(new Configuration(), new org.apache.hadoop.conf.Configuration(), Collections.singletonList(TestSecurityModule.class));
SecurityUtils.install(sc);
assertEquals(HadoopSecurityContext.class, SecurityUtils.getInstalledContext().getClass());
SecurityUtils.uninstall();
assertEquals(NoOpSecurityContext.class, SecurityUtils.getInstalledContext().getClass());
}
Aggregations