use of com.palantir.atlasdb.memory.InMemoryAtlasDbConfig in project atlasdb by palantir.
the class AtlasDbConfigDeserializationTest method canDeserializeAtlasDbConfig.
@Test
public void canDeserializeAtlasDbConfig() throws IOException {
AtlasDbConfig config = AtlasDbConfigs.load(TEST_CONFIG_FILE, AtlasDbConfig.class);
assertThat(config.namespace().get()).isEqualTo("brian");
assertThat(config.keyValueService()).isEqualTo(new InMemoryAtlasDbConfig());
assertThat(config.timelock().isPresent()).isTrue();
assertTimeLockConfigDeserializedCorrectly(config.timelock().get());
assertThat(config.leader().isPresent()).isFalse();
assertThat(config.enableSweep()).isTrue();
}
use of com.palantir.atlasdb.memory.InMemoryAtlasDbConfig in project atlasdb by palantir.
the class AtlasDbConfigTest method inMemoryConfigCannotHaveEmptyNamespaceWithEmptyTimelockClient.
@Test
public void inMemoryConfigCannotHaveEmptyNamespaceWithEmptyTimelockClient() {
InMemoryAtlasDbConfig kvsConfig = new InMemoryAtlasDbConfig();
assertFalse("This test assumes the InMemoryAtlasDbConfig has no namespace by default", kvsConfig.namespace().isPresent());
assertThatThrownBy(() -> ImmutableAtlasDbConfig.builder().namespace(Optional.empty()).keyValueService(kvsConfig).timelock(TIMELOCK_CONFIG_WITH_OPTIONAL_EMPTY_CLIENT).build()).isInstanceOf(IllegalStateException.class).satisfies((exception) -> assertThat(exception.getMessage(), containsString("TimeLock client should not be empty")));
}
use of com.palantir.atlasdb.memory.InMemoryAtlasDbConfig in project atlasdb by palantir.
the class AtlasDbConfigTest method inMemoryConfigCanHaveEmptyNamespace.
@Test
public void inMemoryConfigCanHaveEmptyNamespace() {
InMemoryAtlasDbConfig kvsConfig = new InMemoryAtlasDbConfig();
assertFalse("This test assumes the InMemoryAtlasDbConfig has no namespace by default", kvsConfig.namespace().isPresent());
ImmutableAtlasDbConfig config = ImmutableAtlasDbConfig.builder().namespace(Optional.empty()).keyValueService(kvsConfig).build();
assertThat(config.getNamespaceString(), equalTo(AtlasDbConfig.UNSPECIFIED_NAMESPACE));
}
use of com.palantir.atlasdb.memory.InMemoryAtlasDbConfig in project atlasdb by palantir.
the class TransactionManagersTest method setup.
@Before
public void setup() throws JsonProcessingException {
// Change code to run synchronously, but with a timeout in case something's gone horribly wrong
originalAsyncMethod = TransactionManagers.runAsync;
TransactionManagers.runAsync = task -> Awaitility.await().atMost(10, TimeUnit.SECONDS).untilAsserted(task::run);
availableServer.stubFor(LEADER_UUID_MAPPING.willReturn(aResponse().withStatus(200).withBody(("\"" + UUID.randomUUID().toString() + "\"").getBytes())));
availableServer.stubFor(TIMESTAMP_MAPPING.willReturn(aResponse().withStatus(200).withBody("1")));
availableServer.stubFor(LOCK_MAPPING.willReturn(aResponse().withStatus(200).withBody("2")));
availableServer.stubFor(TIMELOCK_TIMESTAMP_MAPPING.willReturn(aResponse().withStatus(200).withBody("3")));
availableServer.stubFor(TIMELOCK_ONE_TIMESTAMP_MAPPING.willReturn(aResponse().withStatus(200).withBody(new ObjectMapper().writeValueAsString(TimestampRange.createInclusiveRange(88, 88)))));
availableServer.stubFor(TIMELOCK_LOCK_MAPPING.willReturn(aResponse().withStatus(200).withBody("4")));
availableServer.stubFor(TIMELOCK_PING_MAPPING.willReturn(aResponse().withStatus(200).withBody(TimestampManagementService.PING_RESPONSE).withHeader("Content-Type", "text/plain")));
availableServer.stubFor(TIMELOCK_FF_MAPPING.willReturn(aResponse().withStatus(204)));
config = mock(AtlasDbConfig.class);
when(config.leader()).thenReturn(Optional.empty());
when(config.timestamp()).thenReturn(Optional.empty());
when(config.lock()).thenReturn(Optional.empty());
when(config.timelock()).thenReturn(Optional.empty());
when(config.keyValueService()).thenReturn(new InMemoryAtlasDbConfig());
when(config.initializeAsync()).thenReturn(false);
runtimeConfig = mock(AtlasDbRuntimeConfig.class);
when(runtimeConfig.timestampClient()).thenReturn(ImmutableTimestampClientConfig.of(false));
when(runtimeConfig.qos()).thenReturn(QosClientConfig.DEFAULT);
when(runtimeConfig.timelockRuntime()).thenReturn(Optional.empty());
environment = mock(Consumer.class);
invalidator = mock(TimestampStoreInvalidator.class);
when(invalidator.backupAndInvalidate()).thenReturn(EMBEDDED_BOUND);
availablePort = availableServer.port();
mockClientConfig = getTimelockConfigForServers(ImmutableList.of(getUriForPort(availablePort)));
rawRemoteServerConfig = ImmutableServerListConfig.builder().addServers(getUriForPort(availablePort)).build();
configSupplier = () -> Optional.of(runtimeConfig);
}
use of com.palantir.atlasdb.memory.InMemoryAtlasDbConfig in project atlasdb by palantir.
the class TransactionManagersTest method setsGlobalDefaultLockTimeout.
@Test
public void setsGlobalDefaultLockTimeout() {
TimeDuration expectedTimeout = SimpleTimeDuration.of(47, TimeUnit.SECONDS);
AtlasDbConfig atlasDbConfig = ImmutableAtlasDbConfig.builder().keyValueService(new InMemoryAtlasDbConfig()).defaultLockTimeoutSeconds((int) expectedTimeout.getTime()).build();
TransactionManagers.builder().config(atlasDbConfig).userAgent("test").globalMetricsRegistry(new MetricRegistry()).globalTaggedMetricRegistry(DefaultTaggedMetricRegistry.getDefault()).registrar(environment).build().serializable();
assertEquals(expectedTimeout, LockRequest.getDefaultLockTimeout());
LockRequest lockRequest = LockRequest.builder(ImmutableSortedMap.of(StringLockDescriptor.of("foo"), LockMode.WRITE)).build();
assertEquals(expectedTimeout, lockRequest.getLockTimeout());
}
Aggregations