|
18 | 18 |
|
19 | 19 | import static com.google.cloud.bigtable.hbase.replication.metrics.HBaseToCloudBigtableReplicationMetrics.DROPPED_INCOMPATIBLE_MUTATION_METRIC_KEY; |
20 | 20 | import static com.google.cloud.bigtable.hbase.replication.metrics.HBaseToCloudBigtableReplicationMetrics.INCOMPATIBLE_MUTATION_METRIC_KEY; |
| 21 | +import static com.google.cloud.bigtable.hbase.replication.metrics.HBaseToCloudBigtableReplicationMetrics.PUTS_IN_FUTURE_METRIC_KEY; |
21 | 22 | import static org.mockito.Mockito.reset; |
22 | 23 | import static org.mockito.Mockito.times; |
23 | 24 | import static org.mockito.Mockito.verify; |
24 | 25 | import static org.mockito.Mockito.verifyNoInteractions; |
| 26 | +import static org.mockito.Mockito.verifyNoMoreInteractions; |
25 | 27 |
|
26 | 28 | import com.google.cloud.bigtable.hbase.replication.metrics.MetricsExporter; |
27 | 29 | import java.nio.charset.StandardCharsets; |
|
35 | 37 | import org.apache.hadoop.conf.Configuration; |
36 | 38 | import org.apache.hadoop.hbase.Cell; |
37 | 39 | import org.apache.hadoop.hbase.KeyValue; |
| 40 | +import org.apache.hadoop.hbase.KeyValue.Type; |
38 | 41 | import org.apache.hadoop.hbase.client.Connection; |
39 | 42 | import org.junit.After; |
40 | 43 | import org.junit.Assert; |
@@ -226,4 +229,23 @@ public void testIncompatibleDeletesAreDropped() { |
226 | 229 | verify(metricsExporter, times(1)).incCounters(INCOMPATIBLE_MUTATION_METRIC_KEY, 1); |
227 | 230 | verify(metricsExporter, times(1)).incCounters(DROPPED_INCOMPATIBLE_MUTATION_METRIC_KEY, 1); |
228 | 231 | } |
| 232 | + |
| 233 | + @Test |
| 234 | + public void testFuturePutAreFlagged() { |
| 235 | + ArrayList<Cell> walEntryCells = new ArrayList<>(); |
| 236 | + Cell put1 = new KeyValue(rowKey, cf, qual, 900, Type.Put); |
| 237 | + Cell put2 = new KeyValue(rowKey, cf, qual, 1005L, Type.Put); |
| 238 | + walEntryCells.add(put1); |
| 239 | + walEntryCells.add(put2); |
| 240 | + BigtableWALEntry walEntry = new BigtableWALEntry(1000L, walEntryCells, tableName); |
| 241 | + |
| 242 | + Assert.assertEquals( |
| 243 | + Arrays.asList(put1, put2), |
| 244 | + incompatibleMutationAdapter.adaptIncompatibleMutations(walEntry)); |
| 245 | + |
| 246 | + verify(metricsExporter).incCounters(INCOMPATIBLE_MUTATION_METRIC_KEY, 0); |
| 247 | + verify(metricsExporter).incCounters(DROPPED_INCOMPATIBLE_MUTATION_METRIC_KEY, 0); |
| 248 | + verify(metricsExporter, times(1)).incCounters(PUTS_IN_FUTURE_METRIC_KEY, 1); |
| 249 | + verifyNoMoreInteractions(metricsExporter); |
| 250 | + } |
229 | 251 | } |
0 commit comments