@Test
  public void testMaxRetriesReached() throws Exception {
    Set<PartitionResult> partsNotInMs = PartitionUtil.createPartsNotInMs(17);
    IMetaStoreClient spyDb = spy(db);
    doThrow(MetaException.class).when(spyDb)
      .add_partitions(any(), anyBoolean(), anyBoolean());
    // batch size of 5 and decaying factor of 2
    Exception ex = null;
    try {
      msck.createPartitionsInBatches(spyDb, repairOutput, partsNotInMs, table, 30, 2, 2);
    } catch (Exception retryEx) {
      ex = retryEx;
    }
    assertFalse("Exception was expected but was not thrown", ex == null);
    Assert.assertTrue("Unexpected class of exception thrown", ex instanceof RetryUtilities.RetryException);
    ArgumentCaptor<Boolean> ifNotExistsArg = ArgumentCaptor.forClass(Boolean.class);
    ArgumentCaptor<Boolean> needResultsArg = ArgumentCaptor.forClass(Boolean.class);
    ArgumentCaptor<List<Partition>> argParts = ArgumentCaptor.forClass(List.class);
    verify(spyDb, times(2)).add_partitions(argParts.capture(), ifNotExistsArg.capture(), needResultsArg.capture());
    List<List<Partition>> apds = argParts.getAllValues();
    int retryAttempt = 1;
    Assert.assertEquals(
        String.format("Unexpected batch size in retry attempt %d ", retryAttempt++), 17,
        apds.get(0).size());
    Assert.assertEquals(
        String.format("Unexpected batch size in retry attempt %d ", retryAttempt++), 15,
        apds.get(1).size());
    assertTrue(ifNotExistsArg.getValue());
    assertFalse(needResultsArg.getValue());
  }
Tests the maximum retry attempts provided by configuration
@throws Exception
ql/src/test/org/apache/hadoop/hive/ql/exec/TestMsckCreatePartitionsInBatches.java