use of com.palantir.nexus.db.sql.SqlConnection in project atlasdb by palantir.
the class PostgresDdlTableTest method shouldNotCompactIfVacuumWasPerformedWithinCompactInterval.
@Test
public void shouldNotCompactIfVacuumWasPerformedWithinCompactInterval() {
SqlConnection sqlConnection = setUpSqlConnection(NOW_MILLIS - COMPACT_INTERVAL_MILLIS / SMALL_POSITIVE_FACTOR, NOW_MILLIS);
assertThatVacuumWasNotPerformed(sqlConnection);
}
use of com.palantir.nexus.db.sql.SqlConnection in project atlasdb by palantir.
the class PostgresDdlTableTest method setUpSqlConnection.
private SqlConnection setUpSqlConnection(Long lastVacuumTimestamp, Long currentTimestamp) {
SqlConnection sqlConnection = mock(SqlConnection.class);
when(connectionSupplier.get()).thenReturn(sqlConnection);
List<List<Object>> selectResults = new ArrayList<>();
selectResults.add(Arrays.asList(new Object[] { lastVacuumTimestamp, currentTimestamp }));
Mockito.when(sqlConnection.selectResultSetUnregisteredQuery(startsWith("SELECT FLOOR"), any())).thenReturn(new AgnosticResultSetImpl(selectResults, DBType.POSTGRESQL, // upper-case and lower-case, as postgres allows the query to have either of them.
new ImmutableMap.Builder<String, Integer>().put("last", 0).put("LAST", 0).put("current", 1).put("CURRENT", 1).build()));
return sqlConnection;
}
use of com.palantir.nexus.db.sql.SqlConnection in project atlasdb by palantir.
the class PostgresDdlTableTest method shouldCompactIfCompactMillisIsSetToZero.
@Test
public void shouldCompactIfCompactMillisIsSetToZero() throws Exception {
postgresDdlTable = new PostgresDdlTable(TEST_TABLE, connectionSupplier, ImmutablePostgresDdlConfig.builder().compactInterval(HumanReadableDuration.valueOf("0 ms")).build());
SqlConnection sqlConnection = setUpSqlConnection(NOW_MILLIS - SMALL_POSITIVE_FACTOR, NOW_MILLIS);
assertThatVacuumWasPerformed(sqlConnection, false);
verify(sqlConnection, never()).selectResultSetUnregisteredQuery(startsWith("SELECT FLOOR"), any());
}
use of com.palantir.nexus.db.sql.SqlConnection in project atlasdb by palantir.
the class PostgresDdlTableTest method shouldCompactIfVacuumWasPerformedBeforeCompactInterval.
@Test
public void shouldCompactIfVacuumWasPerformedBeforeCompactInterval() throws Exception {
SqlConnection sqlConnection = setUpSqlConnection(NOW_MILLIS - COMPACT_INTERVAL_MILLIS * SMALL_POSITIVE_FACTOR, NOW_MILLIS);
assertThatVacuumWasPerformed(sqlConnection);
}
use of com.palantir.nexus.db.sql.SqlConnection in project atlasdb by palantir.
the class PostgresDdlTableTest method shouldNotCompactIfVacuumTimestampExceedsNowTimestampByLessThanCompactInterval.
@Test
public void shouldNotCompactIfVacuumTimestampExceedsNowTimestampByLessThanCompactInterval() {
SqlConnection sqlConnection = setUpSqlConnection(NOW_MILLIS + COMPACT_INTERVAL_MILLIS / SMALL_POSITIVE_FACTOR, NOW_MILLIS);
assertThatVacuumWasNotPerformed(sqlConnection);
}
Aggregations