private static Function<ServerListConfig, ServerListConfig> addSslConfigurationToServerListFunction( Optional<SslConfiguration> sslConfiguration) { return serverList -> ImmutableServerListConfig.builder() .from(serverList) .sslConfiguration(getFirstPresentOptional(serverList.sslConfiguration(), sslConfiguration)) .build(); }
@Test public void preservesSslOnConversionToNamespacedServerListIfPresent() { ServerListConfig namespacedConfig = CLIENT_CONFIG.toNamespacedServerList(); assertThat(namespacedConfig.sslConfiguration(), equalTo(Optional.of(SSL_CONFIGURATION))); }
private void assertTimeLockConfigDeserializedCorrectly(TimeLockClientConfig timeLockClientConfig) { assertThat(timeLockClientConfig.getClientOrThrow()).isEqualTo("brian"); assertThat(timeLockClientConfig.serversList().servers()).containsExactlyInAnyOrder( "timelock1:8080", "timelock2:8080", "timelock3:8080"); assertThat(timeLockClientConfig.serversList().sslConfiguration().isPresent()).isTrue(); SslConfiguration sslConfiguration = timeLockClientConfig.serversList().sslConfiguration().get(); assertSslConfigDeserializedCorrectly(sslConfiguration); }
@Test public void canDeserializeRuntimeConfigWithZeroServers() throws IOException { AtlasDbRuntimeConfig runtimeConfig = AtlasDbConfigs.OBJECT_MAPPER.readValue(TEST_RUNTIME_CONFIG_NO_SERVERS_FILE, AtlasDbRuntimeConfig.class); assertThat(runtimeConfig.timestampClient().enableTimestampBatching()).isTrue(); assertThat(runtimeConfig.timelockRuntime()).isPresent(); assertThat(runtimeConfig.timelockRuntime().get().serversList().servers()).isEmpty(); assertThat(runtimeConfig.timelockRuntime().get().serversList().sslConfiguration()).isEmpty(); } }
@Test public void preservesAbsenceOfSslOnConversionToNamespacedServerListIfAbsent() { ImmutableServerListConfig serversListWithoutSsl = ImmutableServerListConfig.copyOf(SERVERS_LIST) .withSslConfiguration(Optional.empty()); TimeLockClientConfig config = ImmutableTimeLockClientConfig.copyOf(CLIENT_CONFIG) .withServersList(serversListWithoutSsl); assertThat(config.toNamespacedServerList().sslConfiguration(), equalTo(Optional.empty())); }
@Test public void canDeserializeRuntimeConfig() throws IOException { AtlasDbRuntimeConfig runtimeConfig = AtlasDbConfigs.OBJECT_MAPPER.readValue(TEST_RUNTIME_CONFIG_FILE, AtlasDbRuntimeConfig.class); assertThat(runtimeConfig.timestampClient().enableTimestampBatching()).isTrue(); assertThat(runtimeConfig.timelockRuntime()).isPresent(); assertThat(runtimeConfig.timelockRuntime().get().serversList().servers()) .containsExactlyInAnyOrder( "https://foo1:12345", "https://foo2:8421", "https://foo3:9421"); assertThat(runtimeConfig.timelockRuntime().get().serversList().sslConfiguration()).satisfies( sslConfiguration -> sslConfiguration.ifPresent(this::assertSslConfigDeserializedCorrectly)); assertThat(runtimeConfig.streamStorePersistence()).satisfies( persistenceConfig -> { assertThat(persistenceConfig.numBlocksToWriteBeforePause()).isEqualTo(7); assertThat(persistenceConfig.writePauseDurationMillis()).isEqualTo(77); }); assertThat(runtimeConfig.sweep().sweepPriorityOverrides()).satisfies( overrides -> { assertThat(overrides.priorityTables()).containsExactlyInAnyOrder("atlas.mission_critical_table"); assertThat(overrides.blacklistTables()).containsExactlyInAnyOrder( "atlas.bad_table", "atlas2.immutable_log"); }); }
@Test public void addingFallbackSslAddsItToTimestampBlock() { AtlasDbConfig withoutSsl = ImmutableAtlasDbConfig.builder() .keyValueService(KVS_CONFIG_WITH_NAMESPACE) .lock(SINGLETON_SERVER_LIST) .timestamp(SINGLETON_SERVER_LIST) .build(); AtlasDbConfig withSsl = AtlasDbConfigs.addFallbackSslConfigurationToAtlasDbConfig(withoutSsl, SSL_CONFIG); assertThat(withSsl.timestamp().get().sslConfiguration(), is(SSL_CONFIG)); }
@Test public void addingFallbackSslAddsItToLockBlock() { AtlasDbConfig withoutSsl = ImmutableAtlasDbConfig.builder() .keyValueService(KVS_CONFIG_WITH_NAMESPACE) .lock(SINGLETON_SERVER_LIST) .timestamp(SINGLETON_SERVER_LIST) .build(); AtlasDbConfig withSsl = AtlasDbConfigs.addFallbackSslConfigurationToAtlasDbConfig(withoutSsl, SSL_CONFIG); assertThat(withSsl.lock().get().sslConfiguration(), is(SSL_CONFIG)); assertThat(withoutSsl.getNamespaceString(), equalTo(TEST_NAMESPACE)); }
@Test public void addingFallbackSslAddsItToTimelockServersBlock() { AtlasDbConfig withoutSsl = ImmutableAtlasDbConfig.builder() .keyValueService(KVS_CONFIG_WITH_NAMESPACE) .timelock(TIMELOCK_CONFIG) .build(); AtlasDbConfig withSsl = AtlasDbConfigs.addFallbackSslConfigurationToAtlasDbConfig(withoutSsl, SSL_CONFIG); assertThat(withSsl.timelock().get().serversList().sslConfiguration(), is(SSL_CONFIG)); }
if (serverListConfig.hasAtLeastOneServer()) { return createProxyWithFailover( serverListConfig.sslConfiguration().map(trustContextCreator), serverListConfig.proxyConfiguration().map(proxySelectorCreator), serverListConfig.servers(),
private static Function<ServerListConfig, ServerListConfig> addSslConfigurationToServerListFunction( Optional<SslConfiguration> sslConfiguration) { return serverList -> ImmutableServerListConfig.builder() .from(serverList) .sslConfiguration(getFirstPresentOptional(serverList.sslConfiguration(), sslConfiguration)) .build(); }
if (serverListConfig.hasAtLeastOneServer()) { return createProxyWithFailover( serverListConfig.sslConfiguration().map(trustContextCreator), serverListConfig.proxyConfiguration().map(proxySelectorCreator), serverListConfig.servers(),