@Test(timeout = 100000) public void singleTabletTest() throws Exception { String tableName = TestRowErrors.class.getName() + "-" + System.currentTimeMillis(); harness.getClient().createTable(tableName, basicSchema, getBasicCreateTableOptions()); table = harness.getClient().openTable(tableName); AsyncKuduSession session = harness.getAsyncClient().newSession(); // Insert 3 rows to play with. for (int i = 0; i < 3; i++) { session.apply(createInsert(i)).join(DEFAULT_SLEEP); } // Try a single dupe row insert with AUTO_FLUSH_SYNC. Insert dupeForZero = createInsert(0); OperationResponse resp = session.apply(dupeForZero).join(DEFAULT_SLEEP); assertTrue(resp.hasRowError()); assertTrue(resp.getRowError().getOperation() == dupeForZero); // Now try inserting two dupes and one good row, make sure we get only two errors back. dupeForZero = createInsert(0); Insert dupeForTwo = createInsert(2); session.setFlushMode(AsyncKuduSession.FlushMode.MANUAL_FLUSH); session.apply(dupeForZero); session.apply(dupeForTwo); session.apply(createInsert(4)); List<OperationResponse> responses = session.flush().join(DEFAULT_SLEEP); List<RowError> errors = OperationResponse.collectErrors(responses); assertEquals(2, errors.size()); assertTrue(errors.get(0).getOperation() == dupeForZero); assertTrue(errors.get(1).getOperation() == dupeForTwo); }