@Test
  public void testSelectInactiveContainer() throws Exception {
    //generates store stats
    int accountCount = 1;
    int containerCount = 3;
    AggregatedAccountStorageStats aggregatedAccountStorageStats = new AggregatedAccountStorageStats(
        StorageStatsUtilTest.generateRandomAggregatedAccountStorageStats((short) 0, accountCount, containerCount,
            10000L, 2, 10));

    // a set that records the account ids that have already been taken.
    Set<Short> accountIdSet = new HashSet<>();
    // generate a single reference account and container that can be referenced by refAccount and refContainer respectively.
    refAccountId = Utils.getRandomShort(random);
    accountIdSet.add(refAccountId);
    generateRefAccounts(idToRefAccountMap, idToRefContainerMap, accountIdSet, 2, 3);
    accountService = mockHelixAccountServiceFactory.getAccountService();
    accountService.updateAccounts(idToRefAccountMap.values());
    assertAccountsInAccountService(idToRefAccountMap.values(), 2, accountService);

    Set<Container> expectContainerSet = new HashSet<>();
    List<Account> accountsToUpdate = new ArrayList<>();
    int accountId = 0;
    for (Account account : accountService.getAllAccounts()) {
      AccountBuilder accountBuilder =
          new AccountBuilder((short) accountId, "A[" + accountId + "]", AccountStatus.ACTIVE);
      int containerId = 0;
      for (Container container : account.getAllContainers()) {
        ContainerBuilder containerBuilder =
            new ContainerBuilder((short) containerId, "C[" + containerId + "]", ContainerStatus.DELETE_IN_PROGRESS,
                container.getDescription() + "--extra", (short) accountId);
        accountBuilder.addOrUpdateContainer(containerBuilder.build());

        containerId++;
      }
      accountsToUpdate.add(accountBuilder.build());
      if (accountId == 1) {
        expectContainerSet.addAll(accountsToUpdate.get(accountId).getAllContainers());
      }
      accountId++;
    }
    updateAccountsAndAssertAccountExistence(accountsToUpdate, 4, true);
    Set<Container> inactiveContainerSet = AccountUtils.selectInactiveContainerCandidates(aggregatedAccountStorageStats,
        accountService.getContainersByStatus(ContainerStatus.DELETE_IN_PROGRESS));
    assertEquals("Mismatch in container Set after detect", expectContainerSet, inactiveContainerSet);
    ((HelixAccountService) accountService).markContainersInactive(inactiveContainerSet);
    Account testAccount0 = accountService.getAccountById((short) 0);
    for (Container container : testAccount0.getAllContainers()) {
      assertEquals("Based on the stats report, container has not been compacted yet",
          ContainerStatus.DELETE_IN_PROGRESS, container.getStatus());
    }
    Account testAccount1 = accountService.getAccountById((short) 1);
    for (Container container : testAccount1.getAllContainers()) {
      assertEquals("Based on the stats report, inactive container status needs to be set as INACTIVE",
          ContainerStatus.INACTIVE, container.getStatus());
    }
  }
Tests select INACTIVE {@link Container}s from DELETE_IN_PROGRESS {@link Container}s.
ambry-account/src/test/java/com/github/ambry/account/HelixAccountServiceTest.java