@ParameterizedTest
  @MethodSource("generateBooleanArgs")
  public void testFailureScenariosCleanupCTAS(boolean isPartitioned,
                                         boolean isDirectInsertEnabled,
                                         boolean isLocklessReadsEnabled,
                                         boolean isLocationUsed,
                                         boolean isExclusiveCtas) throws Exception {
    String tableName = "atable";

    //Set configurations
    hiveConf.setBoolVar(HiveConf.ConfVars.HIVE_ACID_DIRECT_INSERT_ENABLED, isDirectInsertEnabled);
    hiveConf.setBoolVar(HiveConf.ConfVars.HIVE_ACID_LOCKLESS_READS_ENABLED, isLocklessReadsEnabled);
    hiveConf.setBoolVar(HiveConf.ConfVars.TXN_CTAS_X_LOCK, isExclusiveCtas);

    // Add a '1' at the end of table name for custom location.
    String querylocation = (isLocationUsed) ? " location '" + getWarehouseDir() + "/" + tableName + "1'" : "";
    String queryPartitions = (isPartitioned) ? " partitioned by (a)" : "";

    d.run("insert into " + Table.ACIDTBL + "(a,b) values (3,4)");
    d.run("drop table if exists " + tableName);
    d.compileAndRespond("create table " + tableName + queryPartitions + " stored as orc" + querylocation +
            " tblproperties ('transactional'='true') as select * from " + Table.ACIDTBL);
    long txnId = d.getQueryState().getTxnManager().getCurrentTxnId();
    mockTasksRecursively(d.getPlan().getRootTasks());
    int assertError = 0;
    try {
      d.run();
    } catch (Exception e) {
      assertError = 1;
    }

    runCleaner(hiveConf);

    Assert.assertEquals(assertError, 1);

    FileSystem fs = FileSystem.get(hiveConf);
    String assertLocation = (isLocationUsed) ? getWarehouseDir() + "/" + tableName + "1" :
            ((isLocklessReadsEnabled) ? getWarehouseDir() + "/" + tableName + AcidUtils.getPathSuffix(txnId)
                    : getWarehouseDir() + "/" + tableName);

    FileStatus[] fileStatuses = fs.globStatus(new Path(assertLocation + "/*"));
    for (FileStatus fileStatus : fileStatuses) {
      Assert.assertFalse(fileStatus.getPath().getName().startsWith(AcidUtils.DELTA_PREFIX));
    }
  }
Test cleaner for TXN_TO_WRITE_ID table.
@throws Exception
ql/src/test/org/apache/hadoop/hive/ql/TestTxnCommands2.java