@Test
  public void testRetriesExhaustedBatchSize() 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, 0);
    } 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);
    // there should be 5 calls to create partitions with batch sizes of 17, 15, 7, 3, 1
    ArgumentCaptor<Boolean> ifNotExistsArg = ArgumentCaptor.forClass(Boolean.class);
    ArgumentCaptor<Boolean> needResultsArg = ArgumentCaptor.forClass(Boolean.class);
    ArgumentCaptor<List<Partition>> argParts = ArgumentCaptor.forClass(List.class);
    // there should be 5 calls to create partitions with batch sizes of 17, 15, 7, 3, 1
    verify(spyDb, times(5)).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());
    Assert.assertEquals(
        String.format("Unexpected batch size in retry attempt %d ", retryAttempt++), 7,
        apds.get(2).size());
    Assert.assertEquals(
        String.format("Unexpected batch size in retry attempt %d ", retryAttempt++), 3,
        apds.get(3).size());
    Assert.assertEquals(
        String.format("Unexpected batch size in retry attempt %d ", retryAttempt++), 1,
        apds.get(4).size());
    assertTrue(ifNotExistsArg.getValue());
    assertFalse(needResultsArg.getValue());
  }
Tests the retries exhausted case when Hive.createPartitions method call always keep throwing
HiveException. The batch sizes should exponentially decreased based on the decaying factor and
ultimately give up when it reaches 0

@throws Exception
ql/src/test/org/apache/hadoop/hive/ql/exec/TestMsckCreatePartitionsInBatches.java