default SweepTableResponse sweepTableFully(String tableName) { return sweepTable(tableName, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); }
@Test public void sweepsEntireTableByDefault() { List<byte[]> startRows = ImmutableList.of( PtBytes.EMPTY_BYTE_ARRAY, new byte[] {0x10}, new byte[] {0x50}); for (int i = 0; i < startRows.size(); i++) { byte[] currentRow = startRows.get(i); Optional<byte[]> nextRow = (i + 1) == startRows.size() ? Optional.empty() : Optional.of(startRows.get(i + 1)); SweepResults results = SweepResults.createEmptySweepResult(nextRow); when(sweepTaskRunner.run(any(), any(), eq(currentRow))).thenReturn(results); } sweeperService.sweepTableFully(TABLE_REF.getQualifiedName()); startRows.forEach(row -> verify(sweepTaskRunner).run(any(), any(), eq(row))); verifyNoMoreInteractions(sweepTaskRunner); }
@Test public void sweepTableFromStartRowShouldAcceptLowercaseBase16Encodings() { when(kvs.getAllTableNames()).thenReturn(ImmutableSet.of(TABLE_REF)); sweeperService.sweepTableFrom(TABLE_REF.getQualifiedName(), LOWERCASE_BUT_VALID_START_ROW); }
@Override @Test public void smokeTest() throws Exception { createTable(TABLE_1, SweepStrategy.CONSERVATIVE); putManyCells(TABLE_1, 100, 110); putManyCells(TABLE_1, 103, 113); putManyCells(TABLE_1, 105, 115); sweeperService.sweepTableFully(TABLE_1.getQualifiedName()); verifyTableSwept(TABLE_1, 75, true); }
@Test public void testWriteProgressAndPriorityNotUpdatedAfterSweepRunsSuccessfully_butMetricsAre() { sweeperService.sweepTableFrom(TABLE_REF.getQualifiedName(), encodeStartRow(new byte[] {1, 2, 3})); ArgumentCaptor<Long> sweepTime = ArgumentCaptor.forClass(Long.class); ArgumentCaptor<Long> totalTimeElapsed = ArgumentCaptor.forClass(Long.class); Mockito.verify(sweepMetrics, times(1)).updateSweepTime(sweepTime.capture(), totalTimeElapsed.capture()); verifyExpectedArgument(sweepTime.getValue(), totalTimeElapsed.getValue()); }
default SweepTableResponse sweepTableFrom(String tableName, String startRow) { return sweepTable(tableName, Optional.of(startRow), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); }
@Test public void sweepingNonExistingTableShouldNotBeSuccessful() { assertThatExceptionOfType(RemoteException.class) .isThrownBy(() -> sweeperService.sweepTableFully("ns.non_existing_table")) .matches(ex -> ex.getStatus() == Response.Status.BAD_REQUEST.getStatusCode()); }
@Test public void sweepTableFromStartRowShouldAcceptMixedCaseBase16Encodings() { when(kvs.getAllTableNames()).thenReturn(ImmutableSet.of(TABLE_REF)); sweeperService.sweepTableFrom(TABLE_REF.getQualifiedName(), MIXED_CASE_START_ROW); }
@Test public void sweepTableFromStartRowWithBatchConfigWithNullStartRowShouldBeSuccessful() { sweeperService.sweepTable(TABLE_REF.getQualifiedName(), Optional.empty(), Optional.empty(), Optional.of(1000), Optional.of(1000), Optional.of(500)); }
@Test public void sweepingNonFullyTableShouldNotBeSuccessful() { assertThatExceptionOfType(RemoteException.class) .isThrownBy(() -> sweeperService.sweepTableFully("non_fully_qualified_name")) .matches(ex -> ex.getStatus() == Response.Status.BAD_REQUEST.getStatusCode()); }
@Test public void sweepTableFromStartRowWithValidStartRowShouldBeSuccessful() { sweeperService.sweepTableFrom(TABLE_REF.getQualifiedName(), VALID_START_ROW); }
@Test public void runsOneIterationIfRequested() { setupTaskRunner(RESULTS_MORE_TO_SWEEP); sweeperService.sweepTable(TABLE_REF.getQualifiedName(), Optional.empty(), Optional.of(false), Optional.empty(), Optional.empty(), Optional.empty()); verify(sweepTaskRunner, times(1)).run(any(), any(), any()); verifyNoMoreInteractions(sweepTaskRunner); }
@Override @Test public void smokeTest() throws Exception { createTable(TABLE_1, SweepStrategy.CONSERVATIVE); putManyCells(TABLE_1, 100, 110); putManyCells(TABLE_1, 103, 113); putManyCells(TABLE_1, 105, 115); sweeperService.sweepTableFully(TABLE_1.getQualifiedName()); verifyTableSwept(TABLE_1, 75, true); }
@Test public void sweepTableFromStartRowWithInValidStartRowShouldThrow() { assertThatExceptionOfType(RemoteException.class) .isThrownBy(() -> sweeperService.sweepTableFrom(TABLE_REF.getQualifiedName(), INVALID_START_ROW)) .matches(ex -> ex.getStatus() == Response.Status.BAD_REQUEST.getStatusCode()); }
@Test public void sweepTableFromStartRowWithBatchConfigWithExactlyOneNonNullBatchConfigShouldBeSuccessful() { sweeperService.sweepTable(TABLE_REF.getQualifiedName(), Optional.of(encodeStartRow(new byte[] {1, 2, 3})), Optional.empty(), Optional.of(10), Optional.empty(), Optional.empty()); }
default SweepTableResponse sweepTableFully(String tableName) { return sweepTable(tableName, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); }
default SweepTableResponse sweepTableFrom(String tableName, String startRow) { return sweepTable(tableName, Optional.of(startRow), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); }