@Override
  public ValidationTaskResult validateImpl(Map<String, String> optionMap)
          throws InterruptedException {
    String hadoopVersion;
    try {
      hadoopVersion = getHadoopVersion();
    } catch (IOException e) {
      return new ValidationTaskResult(ValidationUtils.State.FAILED, getName(),
              String.format("Failed to get hadoop version:%n%s.", ExceptionUtils.asPlainText(e)),
              "Please check if hadoop is on your PATH.");
    }

    String version = mConf.getString(PropertyKey.UNDERFS_VERSION);
    for (String prefix : new String[] {CDH_PREFIX, HADOOP_PREFIX}) {
      if (version.startsWith(prefix)) {
        version = version.substring(prefix.length());
        break;
      }
    }
    if (hadoopVersion.contains(version)) {
      return new ValidationTaskResult(ValidationUtils.State.OK, getName(),
              String.format("Hadoop version %s contains UFS version defined in alluxio %s=%s.",
                      hadoopVersion, PropertyKey.UNDERFS_VERSION, version),
              "");
    }

    return new ValidationTaskResult(ValidationUtils.State.FAILED, getName(),
            String.format("Hadoop version %s does not match %s=%s.",
                    hadoopVersion, PropertyKey.UNDERFS_VERSION, version),
            String.format("Please configure %s to match the HDFS version.",
                    PropertyKey.UNDERFS_VERSION));
  }
@Test
  public void versionNotMatchedDefault() throws Exception {
    PowerMockito.mockStatic(ShellUtils.class);
    String[] cmd = new String[]{"hadoop", "version"};
    BDDMockito.given(ShellUtils.execCommand(cmd)).willReturn("Hadoop 2.2");

    HdfsVersionValidationTask task = new HdfsVersionValidationTask(CONF);
    ValidationTaskResult result = task.validateImpl(ImmutableMap.of());
    assertEquals(ValidationUtils.State.FAILED, result.getState());
    assertThat(result.getResult(), containsString("2.2 does not match alluxio.underfs.version"));
    assertThat(result.getAdvice(), containsString("configure alluxio.underfs.version"));
  }