Search in sources :

Example 21 with ValidationTaskResult

use of alluxio.cli.ValidationTaskResult in project alluxio by Alluxio.

the class HdfsConfValidationTaskTest method missingHdfsSiteXML.

@Test
public void missingHdfsSiteXML() {
    // Only prepare core-site.xml
    String coreSite = Paths.get(sTestDir.toPath().toString(), "core-site.xml").toString();
    ValidationTestUtils.writeXML(coreSite, ImmutableMap.of("key1", "value1"));
    sConf.set(PropertyKey.UNDERFS_HDFS_CONFIGURATION, coreSite);
    HdfsConfValidationTask task = new HdfsConfValidationTask("hdfs://namenode:9000/alluxio", sConf);
    ValidationTaskResult result = task.loadHdfsConfig();
    assertEquals(result.getState(), ValidationUtils.State.SKIPPED);
    assertThat(result.getResult(), containsString("hdfs-site.xml is not configured"));
    assertThat(result.getAdvice(), containsString("hdfs-site.xml"));
}
Also used : StringContains.containsString(org.hamcrest.core.StringContains.containsString) ValidationTaskResult(alluxio.cli.ValidationTaskResult) Test(org.junit.Test)

Example 22 with ValidationTaskResult

use of alluxio.cli.ValidationTaskResult in project alluxio by Alluxio.

the class HdfsConfValidationTaskTest method cannotParseCoreSiteXml.

@Test
public void cannotParseCoreSiteXml() throws IOException {
    String hdfsSite = Paths.get(sTestDir.toPath().toString(), "hdfs-site.xml").toString();
    ValidationTestUtils.writeXML(hdfsSite, ImmutableMap.of("key2", "value2"));
    RandomAccessFile hdfsFile = new RandomAccessFile(hdfsSite, "rw");
    hdfsFile.setLength(hdfsFile.length() - 10);
    String coreSite = Paths.get(sTestDir.toPath().toString(), "core-site.xml").toString();
    ValidationTestUtils.writeXML(coreSite, ImmutableMap.of("key1", "value1"));
    RandomAccessFile coreFile = new RandomAccessFile(coreSite, "rw");
    coreFile.setLength(coreFile.length() - 10);
    sConf.set(PropertyKey.UNDERFS_HDFS_CONFIGURATION, hdfsSite + HdfsConfValidationTask.SEPARATOR + coreSite);
    HdfsConfValidationTask task = new HdfsConfValidationTask("hdfs://namenode:9000/alluxio", sConf);
    ValidationTaskResult result = task.loadHdfsConfig();
    assertEquals(ValidationUtils.State.FAILED, result.getState());
    assertThat(result.getResult(), containsString(String.format("Failed to parse %s", hdfsSite)));
    assertThat(result.getResult(), containsString(String.format("Failed to parse %s", coreSite)));
    assertThat(result.getAdvice(), containsString(String.format("Failed to parse %s", hdfsSite)));
    assertThat(result.getAdvice(), containsString(String.format("Failed to parse %s", coreSite)));
}
Also used : RandomAccessFile(java.io.RandomAccessFile) StringContains.containsString(org.hamcrest.core.StringContains.containsString) ValidationTaskResult(alluxio.cli.ValidationTaskResult) Test(org.junit.Test)

Example 23 with ValidationTaskResult

use of alluxio.cli.ValidationTaskResult in project alluxio by Alluxio.

the class HdfsConfParityValidationTask method validateHdfsSettingParity.

private ValidationTaskResult validateHdfsSettingParity(Map<String, String> optionsMap) {
    String serverHadoopConfDirPath;
    if (optionsMap.containsKey(HADOOP_CONF_DIR_OPTION.getOpt())) {
        serverHadoopConfDirPath = optionsMap.get(HADOOP_CONF_DIR_OPTION.getOpt());
    } else {
        serverHadoopConfDirPath = System.getenv(HADOOP_CONF_DIR_ENV_VAR);
    }
    if (serverHadoopConfDirPath == null) {
        mMsg.append("Path to server-side hadoop configuration unspecified," + " skipping validation for HDFS properties.");
        return new ValidationTaskResult(ValidationUtils.State.SKIPPED, getName(), mMsg.toString(), mAdvice.toString());
    }
    String serverCoreSiteFilePath = PathUtils.concatPath(serverHadoopConfDirPath, "/core-site.xml");
    String serverHdfsSiteFilePath = PathUtils.concatPath(serverHadoopConfDirPath, "/hdfs-site.xml");
    // Load client core-site and hdfs-site config
    ValidationTaskResult loadConfig = loadHdfsConfig();
    if (loadConfig.getState() != ValidationUtils.State.OK) {
        // If failed to load config files, abort
        return loadConfig;
    }
    boolean ok = compareConfigurations(serverCoreSiteFilePath, "core-site.xml", mCoreConf) && compareConfigurations(serverHdfsSiteFilePath, "hdfs-site.xml", mHdfsConf);
    return new ValidationTaskResult(ok ? ValidationUtils.State.OK : ValidationUtils.State.FAILED, getName(), mMsg.toString(), mAdvice.toString());
}
Also used : ValidationTaskResult(alluxio.cli.ValidationTaskResult)

Example 24 with ValidationTaskResult

use of alluxio.cli.ValidationTaskResult in project alluxio by Alluxio.

the class HdfsConfValidationTask method checkNameservice.

protected ValidationTaskResult checkNameservice() {
    ValidationUtils.State state;
    String nsKey = "dfs.nameservices";
    String nameservices = mCoreConf.get(nsKey);
    if (nameservices == null) {
        nameservices = mHdfsConf.get(nsKey);
    }
    if (nameservices == null) {
        return new ValidationTaskResult(ValidationUtils.State.OK, getName(), "No nameservice " + "detected", "");
    }
    List<String> nsList = Arrays.stream(nameservices.split(",")).map(String::trim).collect(Collectors.toList());
    try {
        URI u = URI.create(mPath);
        String uriHost = u.getHost().toLowerCase();
        long nsCount = nsList.stream().filter(s -> uriHost.equals(s.toLowerCase())).count();
        state = ValidationUtils.State.OK;
        if (nsCount < 1) {
            state = ValidationUtils.State.FAILED;
            mAdvice.append(String.format("One or more nameservices (%s) were detected in the HDFS " + "configuration, but not used in the URI to connect to HDFS.", nameservices));
            mMsg.append(String.format("Could not find any of the configured nameservices (%s) in the " + "given HDFS connection URI (%s)", nameservices, u));
        }
    } catch (IllegalArgumentException e) {
        state = ValidationUtils.State.FAILED;
        mMsg.append("HDFS path not parsable as a URI.");
        mMsg.append(ValidationUtils.getErrorInfo(e));
        mAdvice.append("Make sure the HDFS URI is in a valid format.");
    }
    return new ValidationTaskResult(state, getName(), mMsg.toString(), mAdvice.toString());
}
Also used : Arrays(java.util.Arrays) ValidationUtils(alluxio.cli.ValidationUtils) Files(java.nio.file.Files) IOException(java.io.IOException) AbstractValidationTask(alluxio.cli.AbstractValidationTask) Pair(alluxio.collections.Pair) ValidationTaskResult(alluxio.cli.ValidationTaskResult) PropertyKey(alluxio.conf.PropertyKey) Collectors(java.util.stream.Collectors) ApplicableUfsType(alluxio.cli.ApplicableUfsType) PathUtils(alluxio.util.io.PathUtils) List(java.util.List) InvalidPathException(alluxio.exception.InvalidPathException) Paths(java.nio.file.Paths) Map(java.util.Map) AlluxioConfiguration(alluxio.conf.AlluxioConfiguration) URI(java.net.URI) Path(java.nio.file.Path) Nullable(javax.annotation.Nullable) ValidationTaskResult(alluxio.cli.ValidationTaskResult) URI(java.net.URI) ValidationUtils(alluxio.cli.ValidationUtils)

Example 25 with ValidationTaskResult

use of alluxio.cli.ValidationTaskResult in project alluxio by Alluxio.

the class HdfsProxyUserValidationTaskTest method skipped.

@Test
public void skipped() {
    mConf.set(PropertyKey.SECURITY_AUTHENTICATION_TYPE, AuthType.NOSASL.getAuthName());
    HdfsProxyUserValidationTask task = new HdfsProxyUserValidationTask("hdfs://namenode:9000/alluxio", mConf);
    ValidationTaskResult result = task.validateImpl(ImmutableMap.of());
    assertEquals(ValidationUtils.State.SKIPPED, result.getState());
}
Also used : ValidationTaskResult(alluxio.cli.ValidationTaskResult) Test(org.junit.Test)

Aggregations

ValidationTaskResult (alluxio.cli.ValidationTaskResult)28 Test (org.junit.Test)19 StringContains.containsString (org.hamcrest.core.StringContains.containsString)16 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)5 Pair (alluxio.collections.Pair)4 IOException (java.io.IOException)3 IMetaStoreClient (org.apache.hadoop.hive.metastore.IMetaStoreClient)3 List (java.util.List)2 AbstractValidationTask (alluxio.cli.AbstractValidationTask)1 ApplicableUfsType (alluxio.cli.ApplicableUfsType)1 ValidationUtils (alluxio.cli.ValidationUtils)1 AlluxioConfiguration (alluxio.conf.AlluxioConfiguration)1 PropertyKey (alluxio.conf.PropertyKey)1 InvalidPathException (alluxio.exception.InvalidPathException)1 ValidationResult (alluxio.hub.proto.ValidationResult)1 BaseHubTest (alluxio.hub.test.BaseHubTest)1 PathUtils (alluxio.util.io.PathUtils)1 RandomAccessFile (java.io.RandomAccessFile)1 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)1 URI (java.net.URI)1