  @Test
  public void testUnEcActionForFile() throws Exception {

    String testDir = "/test_dir";
    dfs.mkdirs(new Path(testDir));
    dfs.setErasureCodingPolicy(new Path(testDir), ecPolicy.getName());
    // create test file, its EC policy should be consistent with parent dir, i.e., ecPolicy.
    String srcPath = testDir + "/ec_file";
    createTestFile(srcPath, 1000);
    dfsClient.setStoragePolicy(srcPath, "COLD");
    HdfsFileStatus srcFileStatus = dfsClient.getFileInfo(srcPath);
    assertEquals(dfsClient.getErasureCodingPolicy(srcPath), ecPolicy);

    UnErasureCodingAction unEcAction = new UnErasureCodingAction();
    unEcAction.setContext(smartContext);
    String ecTmpPath = "/ssm/ec_tmp/tmp_file";
    Map<String, String> args = new HashMap<>();
    args.put(HdfsAction.FILE_PATH, srcPath);
    args.put(ErasureCodingBase.EC_TMP, ecTmpPath);
    unEcAction.init(args);
    unEcAction.run();
    assertTrue(unEcAction.getExpectedAfterRun());
    HdfsFileStatus fileStatus = dfsClient.getFileInfo(srcPath);
    assertNull(fileStatus.getErasureCodingPolicy());
    // Examine the consistency of file attributes.
    assertEquals(srcFileStatus.getLen(), fileStatus.getLen());
    assertEquals(srcFileStatus.getModificationTime(), fileStatus.getModificationTime());
    assertEquals(srcFileStatus.getAccessTime(), fileStatus.getAccessTime());
    assertEquals(srcFileStatus.getOwner(), fileStatus.getOwner());
    assertEquals(srcFileStatus.getGroup(), fileStatus.getGroup());
    assertEquals(srcFileStatus.getPermission(), fileStatus.getPermission());
    // UNDEF storage policy makes the converted file's storage type uncertain, so it is excluded.
    if (srcFileStatus.getStoragePolicy() != 0) {
      assertEquals(srcFileStatus.getStoragePolicy(), fileStatus.getStoragePolicy());
    }
  }