ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alejan...@apache.org
Subject ambari git commit: AMBARI-9773. RU - Unnecessary 'Upgrade Requirements Not Met' alert appears before rolling upgrade (alejandro)
Date Tue, 24 Feb 2015 21:54:28 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 382075dde -> 39775f41b


AMBARI-9773. RU - Unnecessary 'Upgrade Requirements Not Met' alert appears before rolling
upgrade (alejandro)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/39775f41
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/39775f41
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/39775f41

Branch: refs/heads/trunk
Commit: 39775f41b1405f5aa67f00c7794488672ec779a8
Parents: 382075d
Author: Alejandro Fernandez <afernandez@hortonworks.com>
Authored: Tue Feb 24 11:37:19 2015 -0800
Committer: Alejandro Fernandez <afernandez@hortonworks.com>
Committed: Tue Feb 24 13:54:22 2015 -0800

----------------------------------------------------------------------
 .../ServicesMapReduceDistributedCacheCheck.java |  40 +++++--
 .../ServicesOozieDistributedCacheCheck.java     |  74 ------------
 .../ServicesTezDistributedCacheCheck.java       |  49 +++++---
 .../PreUpgradeCheckResourceProvider.java        |   4 -
 ...vicesMapReduceDistributedCacheCheckTest.java |  35 +++++-
 .../ServicesOozieDistributedCacheCheckTest.java | 114 -------------------
 .../ServicesTezDistributedCacheCheckTest.java   |  51 ++++++++-
 7 files changed, 150 insertions(+), 217 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/39775f41/ambari-server/src/main/java/org/apache/ambari/server/checks/ServicesMapReduceDistributedCacheCheck.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/checks/ServicesMapReduceDistributedCacheCheck.java
b/ambari-server/src/main/java/org/apache/ambari/server/checks/ServicesMapReduceDistributedCacheCheck.java
index 1309406..c388a81 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/checks/ServicesMapReduceDistributedCacheCheck.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/checks/ServicesMapReduceDistributedCacheCheck.java
@@ -26,7 +26,10 @@ import org.apache.ambari.server.state.DesiredConfig;
 import org.apache.ambari.server.state.stack.PrereqCheckStatus;
 import org.apache.ambari.server.state.stack.PrerequisiteCheck;
 import org.apache.ambari.server.state.stack.PrereqCheckType;
+import org.apache.commons.lang.StringUtils;
 
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -57,18 +60,37 @@ public class ServicesMapReduceDistributedCacheCheck extends AbstractCheckDescrip
   public void perform(PrerequisiteCheck prerequisiteCheck, PrereqCheckRequest request) throws
AmbariException {
     final String clusterName = request.getClusterName();
     final Cluster cluster = clustersProvider.get().getCluster(clusterName);
-    final String configType = "mapred-site";
+    final String mrConfigType = "mapred-site";
+    final String coreSiteConfigType = "core-site";
     final Map<String, DesiredConfig> desiredConfigs = cluster.getDesiredConfigs();
-    final DesiredConfig desiredConfig = desiredConfigs.get(configType);
-    final Config config = cluster.getConfig(configType, desiredConfig.getTag());
-    final String frameworkPath = config.getProperties().get("mapreduce.application.framework.path");
-    final String applicationClasspath = config.getProperties().get("mapreduce.application.classpath");
-    if (frameworkPath == null || applicationClasspath == null || !frameworkPath.startsWith("hdfs:/"))
{
+    final DesiredConfig mrDesiredConfig = desiredConfigs.get(mrConfigType);
+    final DesiredConfig coreSiteDesiredConfig = desiredConfigs.get(coreSiteConfigType);
+    final Config mrConfig = cluster.getConfig(mrConfigType, mrDesiredConfig.getTag());
+    final Config coreSiteConfig = cluster.getConfig(coreSiteConfigType, coreSiteDesiredConfig.getTag());
+    final String applicationClasspath = mrConfig.getProperties().get("mapreduce.application.classpath");
+    final String frameworkPath = mrConfig.getProperties().get("mapreduce.application.framework.path");
+    final String defaultFS = coreSiteConfig.getProperties().get("fs.defaultFS");
+
+    List<String> errorMessages = new ArrayList<String>();
+    if (applicationClasspath == null || applicationClasspath.isEmpty()) {
+      errorMessages.add("Property mapreduce.application.classpath is missing from mapred-site,
please add it.");
+    }
+
+    if (frameworkPath == null || frameworkPath.isEmpty()) {
+      errorMessages.add("Property mapreduce.application.framework.path is missing from mapred-site,
please add it.");
+    }
+
+    if (!errorMessages.isEmpty()) {
+      prerequisiteCheck.getFailedOn().add("MAP_REDUCE");
+      prerequisiteCheck.setStatus(PrereqCheckStatus.FAIL);
+      prerequisiteCheck.setFailReason(StringUtils.join(errorMessages, " "));
+      return;
+    }
+
+    if (!frameworkPath.matches("^[^:]*dfs:.*") && (defaultFS == null || !defaultFS.matches("^[^:]*dfs:.*")))
{
       prerequisiteCheck.getFailedOn().add("MAP_REDUCE");
       prerequisiteCheck.setStatus(PrereqCheckStatus.FAIL);
-      prerequisiteCheck.setFailReason("MapReduce should reference hadoop libraries from the
distributed cache. Make sure that "
-          + "mapreduce.application.framework.path and mapreduce.application.classpath properties
are present in mapred.site.xml "
-          + "and point to hdfs:/... urls");
+      prerequisiteCheck.setFailReason("MapReduce should reference hadoop libraries from the
distributed cache. Please make sure that either mapred-site's mapreduce.application.framework.path
or core-site's fs.defaultFS begins with *dfs:");
     }
   }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/39775f41/ambari-server/src/main/java/org/apache/ambari/server/checks/ServicesOozieDistributedCacheCheck.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/checks/ServicesOozieDistributedCacheCheck.java
b/ambari-server/src/main/java/org/apache/ambari/server/checks/ServicesOozieDistributedCacheCheck.java
deleted file mode 100644
index e87767b..0000000
--- a/ambari-server/src/main/java/org/apache/ambari/server/checks/ServicesOozieDistributedCacheCheck.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.ambari.server.checks;
-
-import org.apache.ambari.server.AmbariException;
-import org.apache.ambari.server.ServiceNotFoundException;
-import org.apache.ambari.server.controller.PrereqCheckRequest;
-import org.apache.ambari.server.state.Cluster;
-import org.apache.ambari.server.state.stack.PrereqCheckStatus;
-import org.apache.ambari.server.state.stack.PrereqCheckType;
-import org.apache.ambari.server.state.stack.PrerequisiteCheck;
-
-import com.google.inject.Inject;
-import com.google.inject.Provider;
-
-/**
- * Checks that Oozie jobs reference hadoop libraries from the distributed cache.
- */
-public class ServicesOozieDistributedCacheCheck extends AbstractCheckDescriptor {
-
-  @Inject
-  Provider<ServicesMapReduceDistributedCacheCheck> mapReduceCheck;
-
-  @Override
-  public boolean isApplicable(PrereqCheckRequest request)
-    throws AmbariException {
-    final Cluster cluster = clustersProvider.get().getCluster(request.getClusterName());
-    try {
-      cluster.getService("OOZIE");
-    } catch (ServiceNotFoundException ex) {
-      return false;
-    }
-    return true;
-  }
-
-  /**
-   * Constructor.
-   */
-  public ServicesOozieDistributedCacheCheck() {
-    super("SERVICES_OOZIE_DISTRIBUTED_CACHE", PrereqCheckType.SERVICE, "Oozie should reference
hadoop libraries from the distributed cache");
-  }
-
-  @Override
-  public void perform(PrerequisiteCheck prerequisiteCheck, PrereqCheckRequest request) throws
AmbariException {
-    // since Oozie does talk to multiple clusters, all clusters need to have MapReduce configured
for Distributed Cache
-    for (String clusterName: clustersProvider.get().getClusters().keySet()) {
-      final PrereqCheckRequest clusterRequest = new PrereqCheckRequest(clusterName);
-      mapReduceCheck.get().perform(prerequisiteCheck, clusterRequest);
-      if (prerequisiteCheck.getStatus() == PrereqCheckStatus.FAIL) {
-        prerequisiteCheck.getFailedOn().clear();
-        prerequisiteCheck.getFailedOn().add("OOZIE");
-        prerequisiteCheck.setFailReason("MapReduce on cluster " + clusterName + " should
reference hadoop libraries from the distributed cache. "
-            + "Make sure that mapreduce.application.framework.path and mapreduce.application.classpath
properties are present in mapred.site.xml"
-            + "and point to hdfs:/... urls");
-        break;
-      }
-    }
-  }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/39775f41/ambari-server/src/main/java/org/apache/ambari/server/checks/ServicesTezDistributedCacheCheck.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/checks/ServicesTezDistributedCacheCheck.java
b/ambari-server/src/main/java/org/apache/ambari/server/checks/ServicesTezDistributedCacheCheck.java
index 5f50761..8859370 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/checks/ServicesTezDistributedCacheCheck.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/checks/ServicesTezDistributedCacheCheck.java
@@ -26,7 +26,10 @@ import org.apache.ambari.server.state.DesiredConfig;
 import org.apache.ambari.server.state.stack.PrereqCheckStatus;
 import org.apache.ambari.server.state.stack.PrerequisiteCheck;
 import org.apache.ambari.server.state.stack.PrereqCheckType;
+import org.apache.commons.lang.StringUtils;
 
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -57,29 +60,47 @@ public class ServicesTezDistributedCacheCheck extends AbstractCheckDescriptor
{
   public void perform(PrerequisiteCheck prerequisiteCheck, PrereqCheckRequest request) throws
AmbariException {
     final String clusterName = request.getClusterName();
     final Cluster cluster = clustersProvider.get().getCluster(clusterName);
-    final String configType = "tez-site";
+    final String tezConfigType = "tez-site";
+    final String coreSiteConfigType = "core-site";
     final Map<String, DesiredConfig> desiredConfigs = cluster.getDesiredConfigs();
-    final DesiredConfig desiredConfig = desiredConfigs.get(configType);
-    final Config config = cluster.getConfig(configType, desiredConfig.getTag());
-    final String libUris = config.getProperties().get("tez.lib.uris");
-    final String useHadoopLibs = config.getProperties().get("tez.use.cluster.hadoop-libs");
-    if (libUris == null || useHadoopLibs == null) {
-      prerequisiteCheck.getFailedOn().add("TEZ");
-      prerequisiteCheck.setStatus(PrereqCheckStatus.FAIL);
-      prerequisiteCheck.setFailReason("tez-site should have properties tez.lib.uris and tez.use.cluster.hadoop-libs");
-      return;
+    final DesiredConfig tezDesiredConfig = desiredConfigs.get(tezConfigType);
+    final Config tezConfig = cluster.getConfig(tezConfigType, tezDesiredConfig.getTag());
+    final DesiredConfig coreSiteDesiredConfig = desiredConfigs.get(coreSiteConfigType);
+    final Config coreSiteConfig = cluster.getConfig(coreSiteConfigType, coreSiteDesiredConfig.getTag());
+    final String libUris = tezConfig.getProperties().get("tez.lib.uris");
+    final String useHadoopLibs = tezConfig.getProperties().get("tez.use.cluster.hadoop-libs");
+    final String defaultFS = coreSiteConfig.getProperties().get("fs.defaultFS");
+
+    List<String> errorMessages = new ArrayList<String>();
+    if (libUris == null || libUris.isEmpty()) {
+      errorMessages.add("Property tez.lib.uris is missing from tez-site, please add it.");
     }
-    if (!libUris.startsWith("hdfs:/") || !libUris.contains("tar.gz")) {
+
+    if (useHadoopLibs == null || useHadoopLibs.isEmpty()) {
+      errorMessages.add("Property tez.use.cluster.hadoop-libs is missing from tez-site, please
add it.");
+    }
+
+    if (!errorMessages.isEmpty()) {
       prerequisiteCheck.getFailedOn().add("TEZ");
       prerequisiteCheck.setStatus(PrereqCheckStatus.FAIL);
-      prerequisiteCheck.setFailReason("tez-site property tez.lib.uris should point to hdfs:/...
url with .tar.gz archive of TEZ binaries");
+      prerequisiteCheck.setFailReason(StringUtils.join(errorMessages, " "));
       return;
     }
+
+    if (!libUris.matches("^[^:]*dfs:.*") && (defaultFS == null || !defaultFS.matches("^[^:]*dfs:.*")))
{
+      errorMessages.add("Property tez.lib.uris in tez-site should use a distributed file
system. Please make sure that either tez-site's tez.lib.uris or core-site's fs.defaultFS begins
with *dfs:");
+    }
+    if (!libUris.contains("tar.gz")) {
+      errorMessages.add("Property tez.lib.uris in tez-site should end in tar.gz");
+    }
     if (Boolean.parseBoolean(useHadoopLibs)) {
+      errorMessages.add("Property tez.use.cluster.hadoop-libs in tez-site should be set to
false");
+    }
+
+    if (!errorMessages.isEmpty()) {
       prerequisiteCheck.getFailedOn().add("TEZ");
       prerequisiteCheck.setStatus(PrereqCheckStatus.FAIL);
-      prerequisiteCheck.setFailReason("tez-site property tez.use.cluster.hadoop-libs should
be set to false");
-      return;
+      prerequisiteCheck.setFailReason(StringUtils.join(errorMessages, " "));
     }
   }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/39775f41/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/PreUpgradeCheckResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/PreUpgradeCheckResourceProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/PreUpgradeCheckResourceProvider.java
index 46c2238..2220b2b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/PreUpgradeCheckResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/PreUpgradeCheckResourceProvider.java
@@ -34,7 +34,6 @@ import org.apache.ambari.server.checks.ServicesMapReduceDistributedCacheCheck;
 import org.apache.ambari.server.checks.ServicesMaintenanceModeCheck;
 import org.apache.ambari.server.checks.ServicesNamenodeHighAvailabilityCheck;
 import org.apache.ambari.server.checks.SecondaryNamenodeDeletedCheck;
-import org.apache.ambari.server.checks.ServicesOozieDistributedCacheCheck;
 import org.apache.ambari.server.checks.ServicesTezDistributedCacheCheck;
 import org.apache.ambari.server.checks.ServicesUpCheck;
 import org.apache.ambari.server.checks.ServicesYarnWorkPreservingCheck;
@@ -92,8 +91,6 @@ public class PreUpgradeCheckResourceProvider extends ReadOnlyResourceProvider
{
   @Inject
   private static ServicesUpCheck servicesUpCheck;
   @Inject
-  private static ServicesOozieDistributedCacheCheck servicesOozieDistributedCacheCheck;
-  @Inject
   private static ServicesTezDistributedCacheCheck servicesTezDistributedCacheCheck;
 
   /**
@@ -112,7 +109,6 @@ public class PreUpgradeCheckResourceProvider extends ReadOnlyResourceProvider
{
       add(servicesJobsDistributedCacheCheck);
       add(heartbeatCheck);
       add(servicesUpCheck);
-      add(servicesOozieDistributedCacheCheck);
       add(servicesTezDistributedCacheCheck);
     }
   };

http://git-wip-us.apache.org/repos/asf/ambari/blob/39775f41/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesMapReduceDistributedCacheCheckTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesMapReduceDistributedCacheCheckTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesMapReduceDistributedCacheCheckTest.java
index ef8740b..a8a09bd 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesMapReduceDistributedCacheCheckTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesMapReduceDistributedCacheCheckTest.java
@@ -79,7 +79,10 @@ public class ServicesMapReduceDistributedCacheCheckTest {
 
     final DesiredConfig desiredConfig = Mockito.mock(DesiredConfig.class);
     Mockito.when(desiredConfig.getTag()).thenReturn("tag");
-    Mockito.when(cluster.getDesiredConfigs()).thenReturn(Collections.singletonMap("mapred-site",
desiredConfig));
+    Map<String, DesiredConfig> configMap = new HashMap<String, DesiredConfig>();
+    configMap.put("mapred-site", desiredConfig);
+    configMap.put("core-site", desiredConfig);
+    Mockito.when(cluster.getDesiredConfigs()).thenReturn(configMap);
     final Config config = Mockito.mock(Config.class);
     Mockito.when(cluster.getConfig(Mockito.anyString(), Mockito.anyString())).thenReturn(config);
     final Map<String, String> properties = new HashMap<String, String>();
@@ -89,10 +92,40 @@ public class ServicesMapReduceDistributedCacheCheckTest {
     servicesMapReduceDistributedCacheCheck.perform(check, new PrereqCheckRequest("cluster"));
     Assert.assertEquals(PrereqCheckStatus.FAIL, check.getStatus());
 
+    properties.put("fs.defaultFS", "anything");
     properties.put("mapreduce.application.framework.path", "hdfs://some/path");
     properties.put("mapreduce.application.classpath", "anything");
     check = new PrerequisiteCheck(null, null, null, null);
     servicesMapReduceDistributedCacheCheck.perform(check, new PrereqCheckRequest("cluster"));
     Assert.assertEquals(PrereqCheckStatus.PASS, check.getStatus());
+
+    properties.put("fs.defaultFS", "anything");
+    properties.put("mapreduce.application.framework.path", "dfs://some/path");
+    properties.put("mapreduce.application.classpath", "anything");
+    check = new PrerequisiteCheck(null, null, null, null);
+    servicesMapReduceDistributedCacheCheck.perform(check, new PrereqCheckRequest("cluster"));
+    Assert.assertEquals(PrereqCheckStatus.PASS, check.getStatus());
+
+    properties.put("fs.defaultFS", "hdfs://ha");
+    properties.put("mapreduce.application.framework.path", "/some/path");
+    properties.put("mapreduce.application.classpath", "anything");
+    check = new PrerequisiteCheck(null, null, null, null);
+    servicesMapReduceDistributedCacheCheck.perform(check, new PrereqCheckRequest("cluster"));
+    Assert.assertEquals(PrereqCheckStatus.PASS, check.getStatus());
+
+    properties.put("fs.defaultFS", "dfs://ha");
+    properties.put("mapreduce.application.framework.path", "/some/path");
+    properties.put("mapreduce.application.classpath", "anything");
+    check = new PrerequisiteCheck(null, null, null, null);
+    servicesMapReduceDistributedCacheCheck.perform(check, new PrereqCheckRequest("cluster"));
+    Assert.assertEquals(PrereqCheckStatus.PASS, check.getStatus());
+
+    // Fail due to no dfs
+    properties.put("fs.defaultFS", "anything");
+    properties.put("mapreduce.application.framework.path", "/some/path");
+    properties.put("mapreduce.application.classpath", "anything");
+    check = new PrerequisiteCheck(null, null, null, null);
+    servicesMapReduceDistributedCacheCheck.perform(check, new PrereqCheckRequest("cluster"));
+    Assert.assertEquals(PrereqCheckStatus.FAIL, check.getStatus());
   }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/39775f41/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesOozieDistributedCacheCheckTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesOozieDistributedCacheCheckTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesOozieDistributedCacheCheckTest.java
deleted file mode 100644
index 5b0687a..0000000
--- a/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesOozieDistributedCacheCheckTest.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.ambari.server.checks;
-
-import java.util.Collections;
-
-import org.apache.ambari.server.AmbariException;
-import org.apache.ambari.server.ServiceNotFoundException;
-import org.apache.ambari.server.controller.PrereqCheckRequest;
-import org.apache.ambari.server.state.Cluster;
-import org.apache.ambari.server.state.Clusters;
-import org.apache.ambari.server.state.Service;
-import org.apache.ambari.server.state.stack.PrereqCheckStatus;
-import org.apache.ambari.server.state.stack.PrerequisiteCheck;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-
-import com.google.inject.Provider;
-
-/**
- * Unit tests for ServicesOozieDistributedCacheCheck
- *
- */
-public class ServicesOozieDistributedCacheCheckTest {
-  private final Clusters clusters = Mockito.mock(Clusters.class);
-
-  private final ServicesOozieDistributedCacheCheck servicesOozieDistributedCacheCheck = new
ServicesOozieDistributedCacheCheck();
-
-  @Before
-  public void setup() {
-    servicesOozieDistributedCacheCheck.clustersProvider = new Provider<Clusters>()
{
-
-      @Override
-      public Clusters get() {
-        return clusters;
-      }
-    };
-  }
-
-  @Test
-  public void testIsApplicable() throws Exception {
-    final Cluster cluster = Mockito.mock(Cluster.class);
-    Mockito.when(cluster.getClusterId()).thenReturn(1L);
-    Mockito.when(clusters.getCluster("cluster")).thenReturn(cluster);
-
-    final Service service = Mockito.mock(Service.class);
-    Mockito.when(cluster.getService("OOZIE")).thenReturn(service);
-    Assert.assertTrue(servicesOozieDistributedCacheCheck.isApplicable(new PrereqCheckRequest("cluster")));
-
-    Mockito.when(cluster.getService("OOZIE")).thenThrow(new ServiceNotFoundException("no",
"service"));
-    Assert.assertFalse(servicesOozieDistributedCacheCheck.isApplicable(new PrereqCheckRequest("cluster")));
-  }
-
-  @Test
-  public void testPerform() throws Exception {
-    final Cluster cluster = Mockito.mock(Cluster.class);
-    Mockito.when(cluster.getClusterId()).thenReturn(1L);
-    Mockito.when(clusters.getClusters()).thenReturn(Collections.singletonMap("cluster", cluster));
-
-    servicesOozieDistributedCacheCheck.mapReduceCheck = new Provider<ServicesMapReduceDistributedCacheCheck>()
{
-      @Override
-      public ServicesMapReduceDistributedCacheCheck get() {
-        final ServicesMapReduceDistributedCacheCheck check = Mockito.mock(ServicesMapReduceDistributedCacheCheck.class);
-        return check;
-      }
-    };
-
-    PrerequisiteCheck check = new PrerequisiteCheck(null, null, null, null);
-    servicesOozieDistributedCacheCheck.perform(check, new PrereqCheckRequest("cluster"));
-    Assert.assertEquals(PrereqCheckStatus.PASS, check.getStatus());
-
-    servicesOozieDistributedCacheCheck.mapReduceCheck = new Provider<ServicesMapReduceDistributedCacheCheck>()
{
-      @Override
-      public ServicesMapReduceDistributedCacheCheck get() {
-        final ServicesMapReduceDistributedCacheCheck check = Mockito.mock(ServicesMapReduceDistributedCacheCheck.class);
-        try {
-          Mockito.doAnswer(new Answer<Void>() {
-            @Override
-            public Void answer(InvocationOnMock invocation) throws Throwable {
-              PrerequisiteCheck check = (PrerequisiteCheck) invocation.getArguments()[0];
-              check.setStatus(PrereqCheckStatus.FAIL);
-              return null;
-            }
-          }).when(check).perform(Mockito.<PrerequisiteCheck> anyObject(), Mockito.<PrereqCheckRequest>
anyObject());
-        } catch (AmbariException e) {
-        }
-        return check;
-      }
-    };
-
-    check = new PrerequisiteCheck(null, null, null, null);
-    servicesOozieDistributedCacheCheck.perform(check, new PrereqCheckRequest("cluster"));
-    Assert.assertEquals(PrereqCheckStatus.FAIL, check.getStatus());
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/39775f41/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesTezDistributedCacheCheckTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesTezDistributedCacheCheckTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesTezDistributedCacheCheckTest.java
index 222ad00..c4dcc5e 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesTezDistributedCacheCheckTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesTezDistributedCacheCheckTest.java
@@ -79,7 +79,10 @@ public class ServicesTezDistributedCacheCheckTest {
 
     final DesiredConfig desiredConfig = Mockito.mock(DesiredConfig.class);
     Mockito.when(desiredConfig.getTag()).thenReturn("tag");
-    Mockito.when(cluster.getDesiredConfigs()).thenReturn(Collections.singletonMap("tez-site",
desiredConfig));
+    Map<String, DesiredConfig> configMap = new HashMap<String, DesiredConfig>();
+    configMap.put("tez-site", desiredConfig);
+    configMap.put("core-site", desiredConfig);
+    Mockito.when(cluster.getDesiredConfigs()).thenReturn(configMap);
     final Config config = Mockito.mock(Config.class);
     Mockito.when(cluster.getConfig(Mockito.anyString(), Mockito.anyString())).thenReturn(config);
     final Map<String, String> properties = new HashMap<String, String>();
@@ -89,10 +92,56 @@ public class ServicesTezDistributedCacheCheckTest {
     servicesTezDistributedCacheCheck.perform(check, new PrereqCheckRequest("cluster"));
     Assert.assertEquals(PrereqCheckStatus.FAIL, check.getStatus());
 
+    properties.put("fs.defaultFS", "anything");
     properties.put("tez.lib.uris", "hdfs://some/path/to/archive.tar.gz");
     properties.put("tez.use.cluster.hadoop-libs", "false");
     check = new PrerequisiteCheck(null, null, null, null);
     servicesTezDistributedCacheCheck.perform(check, new PrereqCheckRequest("cluster"));
     Assert.assertEquals(PrereqCheckStatus.PASS, check.getStatus());
+
+    properties.put("fs.defaultFS", "anything");
+    properties.put("tez.lib.uris", "dfs://some/path/to/archive.tar.gz");
+    properties.put("tez.use.cluster.hadoop-libs", "false");
+    check = new PrerequisiteCheck(null, null, null, null);
+    servicesTezDistributedCacheCheck.perform(check, new PrereqCheckRequest("cluster"));
+    Assert.assertEquals(PrereqCheckStatus.PASS, check.getStatus());
+
+    properties.put("fs.defaultFS", "dfs://ha");
+    properties.put("tez.lib.uris", "/some/path/to/archive.tar.gz");
+    properties.put("tez.use.cluster.hadoop-libs", "false");
+    check = new PrerequisiteCheck(null, null, null, null);
+    servicesTezDistributedCacheCheck.perform(check, new PrereqCheckRequest("cluster"));
+    Assert.assertEquals(PrereqCheckStatus.PASS, check.getStatus());
+
+    properties.put("fs.defaultFS", "hdfs://ha");
+    properties.put("tez.lib.uris", "/some/path/to/archive.tar.gz");
+    properties.put("tez.use.cluster.hadoop-libs", "false");
+    check = new PrerequisiteCheck(null, null, null, null);
+    servicesTezDistributedCacheCheck.perform(check, new PrereqCheckRequest("cluster"));
+    Assert.assertEquals(PrereqCheckStatus.PASS, check.getStatus());
+
+    // Fail due to no DFS
+    properties.put("fs.defaultFS", "anything");
+    properties.put("tez.lib.uris", "/some/path/to/archive.tar.gz");
+    properties.put("tez.use.cluster.hadoop-libs", "false");
+    check = new PrerequisiteCheck(null, null, null, null);
+    servicesTezDistributedCacheCheck.perform(check, new PrereqCheckRequest("cluster"));
+    Assert.assertEquals(PrereqCheckStatus.FAIL, check.getStatus());
+
+    // Fail due to no tar.gz
+    properties.put("fs.defaultFS", "hdfs://ha");
+    properties.put("tez.lib.uris", "/some/path/to/archive.log");
+    properties.put("tez.use.cluster.hadoop-libs", "false");
+    check = new PrerequisiteCheck(null, null, null, null);
+    servicesTezDistributedCacheCheck.perform(check, new PrereqCheckRequest("cluster"));
+    Assert.assertEquals(PrereqCheckStatus.FAIL, check.getStatus());
+
+    // Fail due to property set to true
+    properties.put("fs.defaultFS", "hdfs://ha");
+    properties.put("tez.lib.uris", "/some/path/to/archive.tar.gz");
+    properties.put("tez.use.cluster.hadoop-libs", "true");
+    check = new PrerequisiteCheck(null, null, null, null);
+    servicesTezDistributedCacheCheck.perform(check, new PrereqCheckRequest("cluster"));
+    Assert.assertEquals(PrereqCheckStatus.FAIL, check.getStatus());
   }
 }


Mime
View raw message