You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by dm...@apache.org on 2015/02/18 13:23:45 UTC
ambari git commit: AMBARI-9639. Unit Tests for PreUpgradeChecks
(dlysnichenko)
Repository: ambari
Updated Branches:
refs/heads/trunk 45716f162 -> 53241b914
AMBARI-9639. Unit Tests for PreUpgradeChecks (dlysnichenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/53241b91
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/53241b91
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/53241b91
Branch: refs/heads/trunk
Commit: 53241b914dbb2dc6d967f22cc18ee51217bec18c
Parents: 45716f1
Author: Lisnichenko Dmitro <dl...@hortonworks.com>
Authored: Wed Feb 18 14:21:58 2015 +0200
Committer: Lisnichenko Dmitro <dl...@hortonworks.com>
Committed: Wed Feb 18 14:21:58 2015 +0200
----------------------------------------------------------------------
.../checks/SecondaryNamenodeDeletedCheck.java | 9 +-
.../ServicesJobsDistributedCacheCheck.java | 72 -----------
.../ServicesMapReduceDistributedCacheCheck.java | 74 ++++++++++++
.../ServicesNamenodeHighAvailabilityCheck.java | 8 +-
.../ServicesOozieDistributedCacheCheck.java | 74 ++++++++++++
.../ServicesTezDistributedCacheCheck.java | 85 +++++++++++++
.../PreUpgradeCheckResourceProvider.java | 13 +-
.../server/upgrade/UpgradeCatalog200.java | 7 ++
.../2.2/services/TEZ/configuration/tez-site.xml | 6 +
.../server/checks/HostsHeartbeatCheckTest.java | 96 +++++++++++++++
.../checks/HostsMasterMaintenanceCheckTest.java | 120 +++++++++++++++++++
.../checks/HostsRepositoryVersionCheckTest.java | 115 ++++++++++++++++++
.../SecondaryNamenodeDeletedCheckTest.java | 97 +++++++++++++++
.../checks/ServicesDecommissionCheckTest.java | 90 ++++++++++++++
.../ServicesMaintenanceModeCheckTest.java | 74 ++++++++++++
...vicesMapReduceDistributedCacheCheckTest.java | 98 +++++++++++++++
...rvicesNamenodeHighAvailabilityCheckTest.java | 97 +++++++++++++++
.../ServicesOozieDistributedCacheCheckTest.java | 114 ++++++++++++++++++
.../ServicesTezDistributedCacheCheckTest.java | 98 +++++++++++++++
.../server/checks/ServicesUpCheckTest.java | 74 ++++++++++++
.../ServicesYarnWorkPreservingCheckTest.java | 97 +++++++++++++++
.../server/upgrade/UpgradeCatalog200Test.java | 5 +
22 files changed, 1446 insertions(+), 77 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/53241b91/ambari-server/src/main/java/org/apache/ambari/server/checks/SecondaryNamenodeDeletedCheck.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/checks/SecondaryNamenodeDeletedCheck.java b/ambari-server/src/main/java/org/apache/ambari/server/checks/SecondaryNamenodeDeletedCheck.java
index 86ab7fa..6ba28f1 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/checks/SecondaryNamenodeDeletedCheck.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/checks/SecondaryNamenodeDeletedCheck.java
@@ -18,8 +18,10 @@
package org.apache.ambari.server.checks;
import com.google.inject.Inject;
+
import org.apache.ambari.server.AmbariException;
import org.apache.ambari.server.ServiceComponentNotFoundException;
+import org.apache.ambari.server.ServiceNotFoundException;
import org.apache.ambari.server.controller.PrereqCheckRequest;
import org.apache.ambari.server.orm.dao.HostComponentStateDAO;
import org.apache.ambari.server.orm.entities.HostComponentStateEntity;
@@ -51,7 +53,12 @@ public class SecondaryNamenodeDeletedCheck extends AbstractCheckDescriptor {
@Override
public boolean isApplicable(PrereqCheckRequest request) throws AmbariException {
final Cluster cluster = clustersProvider.get().getCluster(request.getClusterName());
- return cluster.getService(MasterHostResolver.Service.HDFS.name()) != null;
+ try {
+ cluster.getService("HDFS");
+ } catch (ServiceNotFoundException ex) {
+ return false;
+ }
+ return true;
}
@Override
http://git-wip-us.apache.org/repos/asf/ambari/blob/53241b91/ambari-server/src/main/java/org/apache/ambari/server/checks/ServicesJobsDistributedCacheCheck.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/checks/ServicesJobsDistributedCacheCheck.java b/ambari-server/src/main/java/org/apache/ambari/server/checks/ServicesJobsDistributedCacheCheck.java
deleted file mode 100644
index d7dec99..0000000
--- a/ambari-server/src/main/java/org/apache/ambari/server/checks/ServicesJobsDistributedCacheCheck.java
+++ /dev/null
@@ -1,72 +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.Config;
-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 java.util.Map;
-
-/**
- * Checks that MR, Oozie and Tez jobs reference hadoop libraries from the distributed cache.
- */
-public class ServicesJobsDistributedCacheCheck extends AbstractCheckDescriptor {
-
- @Override
- public boolean isApplicable(PrereqCheckRequest request)
- throws AmbariException {
- final Cluster cluster = clustersProvider.get().getCluster(request.getClusterName());
- try {
- cluster.getService("YARN");
- } catch (ServiceNotFoundException ex) {
- return false;
- }
- return true;
- }
-
- /**
- * Constructor.
- */
- public ServicesJobsDistributedCacheCheck() {
- super("SERVICES_JOBS_DISTRIBUTED_CACHE", PrereqCheckType.SERVICE, "Jobs should reference hadoop libraries from the distributed cache");
- }
-
- @Override
- 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 Map<String, DesiredConfig> desiredConfigs = cluster.getDesiredConfigs();
- final DesiredConfig desiredConfig = desiredConfigs.get(configType);
- final Config config = cluster.getConfig(configType, desiredConfig.getTag());
- if (!config.getProperties().containsKey("mapreduce.application.framework.path") || !config.getProperties().containsKey("mapreduce.application.classpath")) {
- // TODO actually it is needed to validate that these properties contain proper values but the tickets for these changes are still open, so it will cause
- // prerequisite checks to fail
- prerequisiteCheck.getFailedOn().add("MR");
- prerequisiteCheck.setStatus(PrereqCheckStatus.FAIL);
- prerequisiteCheck.setFailReason("mapreduce.application.framework.path and mapreduce.application.classpath should reference distributed cache");
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/53241b91/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
new file mode 100644
index 0000000..1309406
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/checks/ServicesMapReduceDistributedCacheCheck.java
@@ -0,0 +1,74 @@
+/*
+ * 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.Config;
+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 java.util.Map;
+
+/**
+ * Checks that MR jobs reference hadoop libraries from the distributed cache.
+ */
+public class ServicesMapReduceDistributedCacheCheck extends AbstractCheckDescriptor {
+
+ @Override
+ public boolean isApplicable(PrereqCheckRequest request)
+ throws AmbariException {
+ final Cluster cluster = clustersProvider.get().getCluster(request.getClusterName());
+ try {
+ cluster.getService("YARN");
+ } catch (ServiceNotFoundException ex) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Constructor.
+ */
+ public ServicesMapReduceDistributedCacheCheck() {
+ super("SERVICES_MR_DISTRIBUTED_CACHE", PrereqCheckType.SERVICE, "MapReduce should reference hadoop libraries from the distributed cache");
+ }
+
+ @Override
+ 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 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:/")) {
+ 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");
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/53241b91/ambari-server/src/main/java/org/apache/ambari/server/checks/ServicesNamenodeHighAvailabilityCheck.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/checks/ServicesNamenodeHighAvailabilityCheck.java b/ambari-server/src/main/java/org/apache/ambari/server/checks/ServicesNamenodeHighAvailabilityCheck.java
index 8ab503c..d9f8704 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/checks/ServicesNamenodeHighAvailabilityCheck.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/checks/ServicesNamenodeHighAvailabilityCheck.java
@@ -18,6 +18,7 @@
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.Config;
@@ -43,7 +44,12 @@ public class ServicesNamenodeHighAvailabilityCheck extends AbstractCheckDescript
@Override
public boolean isApplicable(PrereqCheckRequest request) throws AmbariException {
final Cluster cluster = clustersProvider.get().getCluster(request.getClusterName());
- return cluster.getService("HDFS") != null;
+ try {
+ cluster.getService("HDFS");
+ } catch (ServiceNotFoundException ex) {
+ return false;
+ }
+ return true;
}
@Override
http://git-wip-us.apache.org/repos/asf/ambari/blob/53241b91/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
new file mode 100644
index 0000000..e87767b
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/checks/ServicesOozieDistributedCacheCheck.java
@@ -0,0 +1,74 @@
+/*
+ * 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/53241b91/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
new file mode 100644
index 0000000..5f50761
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/checks/ServicesTezDistributedCacheCheck.java
@@ -0,0 +1,85 @@
+/*
+ * 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.Config;
+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 java.util.Map;
+
+/**
+ * Checks that Tez jobs reference hadoop libraries from the distributed cache.
+ */
+public class ServicesTezDistributedCacheCheck extends AbstractCheckDescriptor {
+
+ @Override
+ public boolean isApplicable(PrereqCheckRequest request)
+ throws AmbariException {
+ final Cluster cluster = clustersProvider.get().getCluster(request.getClusterName());
+ try {
+ cluster.getService("TEZ");
+ } catch (ServiceNotFoundException ex) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Constructor.
+ */
+ public ServicesTezDistributedCacheCheck() {
+ super("SERVICES_TEZ_DISTRIBUTED_CACHE", PrereqCheckType.SERVICE, "TEZ should reference hadoop libraries from the distributed cache");
+ }
+
+ @Override
+ 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 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;
+ }
+ if (!libUris.startsWith("hdfs:/") || !libUris.contains("tar.gz")) {
+ 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");
+ return;
+ }
+ if (Boolean.parseBoolean(useHadoopLibs)) {
+ prerequisiteCheck.getFailedOn().add("TEZ");
+ prerequisiteCheck.setStatus(PrereqCheckStatus.FAIL);
+ prerequisiteCheck.setFailReason("tez-site property tez.use.cluster.hadoop-libs should be set to false");
+ return;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/53241b91/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 784254c..46c2238 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
@@ -30,10 +30,12 @@ import org.apache.ambari.server.checks.HostsHeartbeatCheck;
import org.apache.ambari.server.checks.HostsMasterMaintenanceCheck;
import org.apache.ambari.server.checks.HostsRepositoryVersionCheck;
import org.apache.ambari.server.checks.ServicesDecommissionCheck;
-import org.apache.ambari.server.checks.ServicesJobsDistributedCacheCheck;
+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;
import org.apache.ambari.server.state.CheckHelper;
@@ -84,12 +86,15 @@ public class PreUpgradeCheckResourceProvider extends ReadOnlyResourceProvider {
@Inject
private static ServicesDecommissionCheck servicesDecommissionCheck;
@Inject
- private static ServicesJobsDistributedCacheCheck servicesJobsDistributedCacheCheck;
+ private static ServicesMapReduceDistributedCacheCheck servicesJobsDistributedCacheCheck;
@Inject
private static HostsHeartbeatCheck heartbeatCheck;
@Inject
private static ServicesUpCheck servicesUpCheck;
-
+ @Inject
+ private static ServicesOozieDistributedCacheCheck servicesOozieDistributedCacheCheck;
+ @Inject
+ private static ServicesTezDistributedCacheCheck servicesTezDistributedCacheCheck;
/**
* List of the registered upgrade checks
@@ -107,6 +112,8 @@ 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/53241b91/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog200.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog200.java b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog200.java
index 9b647fd..f5dbd38 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog200.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog200.java
@@ -21,6 +21,7 @@ package org.apache.ambari.server.upgrade;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -69,6 +70,7 @@ public class UpgradeCatalog200 extends AbstractUpgradeCatalog {
private static final String ARTIFACT_TABLE = "artifact";
private static final String KERBEROS_PRINCIPAL_TABLE = "kerberos_principal";
private static final String KERBEROS_PRINCIPAL_HOST_TABLE = "kerberos_principal_host";
+ private static final String TEZ_USE_CLUSTER_HADOOP_LIBS_PROPERTY = "tez.use.cluster.hadoop-libs";
/**
* {@inheritDoc}
@@ -305,9 +307,14 @@ public class UpgradeCatalog200 extends AbstractUpgradeCatalog {
addNewConfigurationsFromXml();
updateHiveDatabaseType();
setSecurityType();
+ updateTezConfiguration();
addMissingConfigs();
}
+ protected void updateTezConfiguration() throws AmbariException {
+ updateConfigurationProperties("tez-site", Collections.singletonMap(TEZ_USE_CLUSTER_HADOOP_LIBS_PROPERTY, String.valueOf(false)), false, false);
+ }
+
protected void updateHiveDatabaseType() throws AmbariException {
final String PROPERTY_NAME = "hive_database_type";
final String PROPERTY_VALUE_OLD = "postgresql";
http://git-wip-us.apache.org/repos/asf/ambari/blob/53241b91/ambari-server/src/main/resources/stacks/HDP/2.2/services/TEZ/configuration/tez-site.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.2/services/TEZ/configuration/tez-site.xml b/ambari-server/src/main/resources/stacks/HDP/2.2/services/TEZ/configuration/tez-site.xml
index b85df9d..24c14bb 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.2/services/TEZ/configuration/tez-site.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.2/services/TEZ/configuration/tez-site.xml
@@ -313,6 +313,12 @@
<value>false</value>
<description>Whether to publish configuration information to History logger</description>
</property>
+
+ <property>
+ <name>tez.use.cluster.hadoop-libs</name>
+ <value>false</value>
+ <description>This being true implies that the deployment is relying on hadoop jars being available on the cluster on all nodes.</description>
+ </property>
<property>
<name>tez.am.tez-ui.history-url.template</name>
http://git-wip-us.apache.org/repos/asf/ambari/blob/53241b91/ambari-server/src/test/java/org/apache/ambari/server/checks/HostsHeartbeatCheckTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/checks/HostsHeartbeatCheckTest.java b/ambari-server/src/test/java/org/apache/ambari/server/checks/HostsHeartbeatCheckTest.java
new file mode 100644
index 0000000..fa20373
--- /dev/null
+++ b/ambari-server/src/test/java/org/apache/ambari/server/checks/HostsHeartbeatCheckTest.java
@@ -0,0 +1,96 @@
+/*
+ * 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.HashMap;
+import java.util.Map;
+
+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.Host;
+import org.apache.ambari.server.state.HostHealthStatus;
+import org.apache.ambari.server.state.HostHealthStatus.HealthStatus;
+import org.apache.ambari.server.state.MaintenanceState;
+import org.apache.ambari.server.state.stack.PrereqCheckStatus;
+import org.apache.ambari.server.state.stack.PrerequisiteCheck;
+import org.junit.Assert;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import com.google.inject.Provider;
+
+/**
+ * Unit tests for HostsHeartbeatCheck
+ *
+ */
+public class HostsHeartbeatCheckTest {
+ private final Clusters clusters = Mockito.mock(Clusters.class);
+
+ @Test
+ public void testIsApplicable() throws Exception {
+ Assert.assertTrue(new HostsHeartbeatCheck().isApplicable(null));
+ }
+
+ @Test
+ public void testPerform() throws Exception {
+ final HostsHeartbeatCheck hostHeartbeatCheck = new HostsHeartbeatCheck();
+ hostHeartbeatCheck.clustersProvider = new Provider<Clusters>() {
+
+ @Override
+ public Clusters get() {
+ return clusters;
+ }
+ };
+
+ final Cluster cluster = Mockito.mock(Cluster.class);
+ Mockito.when(cluster.getClusterId()).thenReturn(1L);
+ Mockito.when(clusters.getCluster("cluster")).thenReturn(cluster);
+ final Map<String, Host> hosts = new HashMap<String, Host>();
+ final Host host1 = Mockito.mock(Host.class);
+ final Host host2 = Mockito.mock(Host.class);
+ final Host host3 = Mockito.mock(Host.class);
+ final HostHealthStatus status1 = Mockito.mock(HostHealthStatus.class);
+ final HostHealthStatus status2 = Mockito.mock(HostHealthStatus.class);
+ final HostHealthStatus status3 = Mockito.mock(HostHealthStatus.class);
+ Mockito.when(host1.getMaintenanceState(1L)).thenReturn(MaintenanceState.OFF);
+ Mockito.when(host2.getMaintenanceState(1L)).thenReturn(MaintenanceState.OFF);
+ Mockito.when(host3.getMaintenanceState(1L)).thenReturn(MaintenanceState.OFF);
+ Mockito.when(host1.getHealthStatus()).thenReturn(status1);
+ Mockito.when(host2.getHealthStatus()).thenReturn(status2);
+ Mockito.when(host3.getHealthStatus()).thenReturn(status3);
+ Mockito.when(status1.getHealthStatus()).thenReturn(HealthStatus.HEALTHY);
+ Mockito.when(status2.getHealthStatus()).thenReturn(HealthStatus.HEALTHY);
+ Mockito.when(status3.getHealthStatus()).thenReturn(HealthStatus.UNKNOWN);
+ hosts.put("host1", host1);
+ hosts.put("host2", host2);
+ hosts.put("host3", host3);
+ Mockito.when(clusters.getHostsForCluster("cluster")).thenReturn(hosts);
+
+ PrerequisiteCheck check = new PrerequisiteCheck(null, null, null, null);
+ hostHeartbeatCheck.perform(check, new PrereqCheckRequest("cluster"));
+ Assert.assertEquals(PrereqCheckStatus.FAIL, check.getStatus());
+
+ Mockito.when(status3.getHealthStatus()).thenReturn(HealthStatus.HEALTHY);
+ check = new PrerequisiteCheck(null, null, null, null);
+ hostHeartbeatCheck.perform(check, new PrereqCheckRequest("cluster"));
+ Assert.assertEquals(PrereqCheckStatus.PASS, check.getStatus());
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/53241b91/ambari-server/src/test/java/org/apache/ambari/server/checks/HostsMasterMaintenanceCheckTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/checks/HostsMasterMaintenanceCheckTest.java b/ambari-server/src/test/java/org/apache/ambari/server/checks/HostsMasterMaintenanceCheckTest.java
new file mode 100644
index 0000000..9444aa3
--- /dev/null
+++ b/ambari-server/src/test/java/org/apache/ambari/server/checks/HostsMasterMaintenanceCheckTest.java
@@ -0,0 +1,120 @@
+/*
+ * 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.HashMap;
+import java.util.Map;
+
+import org.apache.ambari.server.api.services.AmbariMetaInfo;
+import org.apache.ambari.server.controller.PrereqCheckRequest;
+import org.apache.ambari.server.orm.dao.RepositoryVersionDAO;
+import org.apache.ambari.server.state.Cluster;
+import org.apache.ambari.server.state.Clusters;
+import org.apache.ambari.server.state.Host;
+import org.apache.ambari.server.state.Service;
+import org.apache.ambari.server.state.StackId;
+import org.apache.ambari.server.state.stack.PrereqCheckStatus;
+import org.apache.ambari.server.state.stack.PrerequisiteCheck;
+import org.apache.ambari.server.state.stack.UpgradePack;
+import org.apache.ambari.server.state.stack.UpgradePack.ProcessingComponent;
+import org.apache.ambari.server.state.stack.upgrade.RepositoryVersionHelper;
+import org.junit.Assert;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import com.google.inject.Provider;
+
+/**
+ * Unit tests for HostsMasterMaintenanceCheck
+ *
+ */
+public class HostsMasterMaintenanceCheckTest {
+ private final Clusters clusters = Mockito.mock(Clusters.class);
+ private final RepositoryVersionDAO repositoryVersionDAO = Mockito.mock(RepositoryVersionDAO.class);
+ private final RepositoryVersionHelper repositoryVersionHelper = Mockito.mock(RepositoryVersionHelper.class);
+ private final AmbariMetaInfo ambariMetaInfo = Mockito.mock(AmbariMetaInfo.class);
+
+ @Test
+ public void testIsApplicable() throws Exception {
+ final PrereqCheckRequest request = new PrereqCheckRequest("cluster");
+ request.setRepositoryVersion("not null");
+ Assert.assertTrue(new HostsMasterMaintenanceCheck().isApplicable(request));
+
+ request.setRepositoryVersion(null);
+ Assert.assertFalse(new HostsMasterMaintenanceCheck().isApplicable(request));
+ }
+
+ @Test
+ public void testPerform() throws Exception {
+ final HostsMasterMaintenanceCheck hostsMasterMaintenanceCheck = new HostsMasterMaintenanceCheck();
+ hostsMasterMaintenanceCheck.clustersProvider = new Provider<Clusters>() {
+
+ @Override
+ public Clusters get() {
+ return clusters;
+ }
+ };
+ hostsMasterMaintenanceCheck.repositoryVersionDaoProvider = new Provider<RepositoryVersionDAO>() {
+ @Override
+ public RepositoryVersionDAO get() {
+ return repositoryVersionDAO;
+ }
+ };
+ hostsMasterMaintenanceCheck.repositoryVersionHelper = new Provider<RepositoryVersionHelper>() {
+ @Override
+ public RepositoryVersionHelper get() {
+ return repositoryVersionHelper;
+ }
+ };
+ hostsMasterMaintenanceCheck.ambariMetaInfo = new Provider<AmbariMetaInfo>() {
+ @Override
+ public AmbariMetaInfo get() {
+ return ambariMetaInfo;
+ }
+ };
+
+ final Cluster cluster = Mockito.mock(Cluster.class);
+ Mockito.when(cluster.getClusterId()).thenReturn(1L);
+ Mockito.when(clusters.getCluster("cluster")).thenReturn(cluster);
+ Mockito.when(cluster.getDesiredStackVersion()).thenReturn(new StackId("HDP", "1.0"));
+ Mockito.when(repositoryVersionHelper.getUpgradePackageName(Mockito.anyString(), Mockito.anyString(), Mockito.anyString())).thenReturn(null);
+
+ PrerequisiteCheck check = new PrerequisiteCheck(null, null, null, null);
+ hostsMasterMaintenanceCheck.perform(check, new PrereqCheckRequest("cluster"));
+ Assert.assertEquals(PrereqCheckStatus.FAIL, check.getStatus());
+
+ Mockito.when(repositoryVersionHelper.getUpgradePackageName(Mockito.anyString(), Mockito.anyString(), Mockito.anyString())).thenReturn("upgrade pack");
+ Mockito.when(ambariMetaInfo.getUpgradePacks(Mockito.anyString(), Mockito.anyString())).thenReturn(new HashMap<String, UpgradePack>());
+
+ check = new PrerequisiteCheck(null, null, null, null);
+ hostsMasterMaintenanceCheck.perform(check, new PrereqCheckRequest("cluster"));
+ Assert.assertEquals(PrereqCheckStatus.FAIL, check.getStatus());
+
+ final Map<String, UpgradePack> upgradePacks = new HashMap<String, UpgradePack>();
+ final UpgradePack upgradePack = Mockito.mock(UpgradePack.class);
+ upgradePacks.put("upgrade pack", upgradePack);
+ Mockito.when(ambariMetaInfo.getUpgradePacks(Mockito.anyString(), Mockito.anyString())).thenReturn(upgradePacks);
+ Mockito.when(upgradePack.getTasks()).thenReturn(new HashMap<String, Map<String,ProcessingComponent>>());
+ Mockito.when(cluster.getServices()).thenReturn(new HashMap<String, Service>());
+ Mockito.when(clusters.getHostsForCluster(Mockito.anyString())).thenReturn(new HashMap<String, Host>());
+
+ check = new PrerequisiteCheck(null, null, null, null);
+ hostsMasterMaintenanceCheck.perform(check, new PrereqCheckRequest("cluster"));
+ Assert.assertEquals(PrereqCheckStatus.PASS, check.getStatus());
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/53241b91/ambari-server/src/test/java/org/apache/ambari/server/checks/HostsRepositoryVersionCheckTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/checks/HostsRepositoryVersionCheckTest.java b/ambari-server/src/test/java/org/apache/ambari/server/checks/HostsRepositoryVersionCheckTest.java
new file mode 100644
index 0000000..02fd01e
--- /dev/null
+++ b/ambari-server/src/test/java/org/apache/ambari/server/checks/HostsRepositoryVersionCheckTest.java
@@ -0,0 +1,115 @@
+/*
+ * 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.HashMap;
+import java.util.Map;
+
+import org.apache.ambari.server.controller.PrereqCheckRequest;
+import org.apache.ambari.server.orm.dao.HostVersionDAO;
+import org.apache.ambari.server.orm.dao.RepositoryVersionDAO;
+import org.apache.ambari.server.orm.entities.HostVersionEntity;
+import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
+import org.apache.ambari.server.state.Cluster;
+import org.apache.ambari.server.state.Clusters;
+import org.apache.ambari.server.state.Host;
+import org.apache.ambari.server.state.MaintenanceState;
+import org.apache.ambari.server.state.RepositoryVersionState;
+import org.apache.ambari.server.state.StackId;
+import org.apache.ambari.server.state.stack.PrereqCheckStatus;
+import org.apache.ambari.server.state.stack.PrerequisiteCheck;
+import org.junit.Assert;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import com.google.inject.Provider;
+
+/**
+ * Unit tests for HostsRepositoryVersionCheck
+ *
+ */
+public class HostsRepositoryVersionCheckTest {
+ private final Clusters clusters = Mockito.mock(Clusters.class);
+ private final HostVersionDAO hostVersionDAO = Mockito.mock(HostVersionDAO.class);
+ private final RepositoryVersionDAO repositoryVersionDAO = Mockito.mock(RepositoryVersionDAO.class);
+
+ @Test
+ public void testIsApplicable() throws Exception {
+ final PrereqCheckRequest request = new PrereqCheckRequest("cluster");
+ request.setRepositoryVersion("not null");
+ Assert.assertTrue(new HostsMasterMaintenanceCheck().isApplicable(request));
+
+ request.setRepositoryVersion(null);
+ Assert.assertFalse(new HostsMasterMaintenanceCheck().isApplicable(request));
+ }
+
+ @Test
+ public void testPerform() throws Exception {
+ final HostsRepositoryVersionCheck hostsRepositoryVersionCheck = new HostsRepositoryVersionCheck();
+ hostsRepositoryVersionCheck.clustersProvider = new Provider<Clusters>() {
+
+ @Override
+ public Clusters get() {
+ return clusters;
+ }
+ };
+ hostsRepositoryVersionCheck.repositoryVersionDaoProvider = new Provider<RepositoryVersionDAO>() {
+ @Override
+ public RepositoryVersionDAO get() {
+ return repositoryVersionDAO;
+ }
+ };
+ hostsRepositoryVersionCheck.hostVersionDaoProvider = new Provider<HostVersionDAO>() {
+ @Override
+ public HostVersionDAO get() {
+ return hostVersionDAO;
+ }
+ };
+
+ final Cluster cluster = Mockito.mock(Cluster.class);
+ Mockito.when(cluster.getClusterId()).thenReturn(1L);
+ Mockito.when(cluster.getDesiredStackVersion()).thenReturn(new StackId());
+ Mockito.when(clusters.getCluster("cluster")).thenReturn(cluster);
+ final Map<String, Host> hosts = new HashMap<String, Host>();
+ final Host host1 = Mockito.mock(Host.class);
+ final Host host2 = Mockito.mock(Host.class);
+ final Host host3 = Mockito.mock(Host.class);
+ Mockito.when(host1.getMaintenanceState(1L)).thenReturn(MaintenanceState.OFF);
+ Mockito.when(host2.getMaintenanceState(1L)).thenReturn(MaintenanceState.OFF);
+ Mockito.when(host3.getMaintenanceState(1L)).thenReturn(MaintenanceState.OFF);
+ hosts.put("host1", host1);
+ hosts.put("host2", host2);
+ hosts.put("host3", host3);
+ Mockito.when(clusters.getHostsForCluster("cluster")).thenReturn(hosts);
+ Mockito.when(repositoryVersionDAO.findByStackAndVersion(Mockito.anyString(), Mockito.anyString())).thenReturn(null);
+
+ PrerequisiteCheck check = new PrerequisiteCheck(null, null, null, null);
+ hostsRepositoryVersionCheck.perform(check, new PrereqCheckRequest("cluster"));
+ Assert.assertEquals(PrereqCheckStatus.FAIL, check.getStatus());
+
+ final RepositoryVersionEntity repositoryVersion = new RepositoryVersionEntity();
+ Mockito.when(repositoryVersionDAO.findByStackAndVersion(Mockito.anyString(), Mockito.anyString())).thenReturn(repositoryVersion);
+ final HostVersionEntity hostVersion = new HostVersionEntity();
+ hostVersion.setState(RepositoryVersionState.INSTALLED);
+ Mockito.when(hostVersionDAO.findByClusterStackVersionAndHost(Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString())).thenReturn(hostVersion);
+
+ check = new PrerequisiteCheck(null, null, null, null);
+ hostsRepositoryVersionCheck.perform(check, new PrereqCheckRequest("cluster"));
+ Assert.assertEquals(PrereqCheckStatus.PASS, check.getStatus());
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/53241b91/ambari-server/src/test/java/org/apache/ambari/server/checks/SecondaryNamenodeDeletedCheckTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/checks/SecondaryNamenodeDeletedCheckTest.java b/ambari-server/src/test/java/org/apache/ambari/server/checks/SecondaryNamenodeDeletedCheckTest.java
new file mode 100644
index 0000000..4938468
--- /dev/null
+++ b/ambari-server/src/test/java/org/apache/ambari/server/checks/SecondaryNamenodeDeletedCheckTest.java
@@ -0,0 +1,97 @@
+/*
+ * 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.ServiceNotFoundException;
+import org.apache.ambari.server.controller.PrereqCheckRequest;
+import org.apache.ambari.server.orm.dao.HostComponentStateDAO;
+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.ServiceComponent;
+import org.apache.ambari.server.state.ServiceComponentHost;
+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 com.google.inject.Provider;
+
+/**
+ * Unit tests for SecondaryNamenodeDeletedCheck
+ *
+ */
+public class SecondaryNamenodeDeletedCheckTest {
+ private final Clusters clusters = Mockito.mock(Clusters.class);
+ private final HostComponentStateDAO hostComponentStateDAO = Mockito.mock(HostComponentStateDAO.class);
+
+ private final SecondaryNamenodeDeletedCheck secondaryNamenodeDeletedCheck = new SecondaryNamenodeDeletedCheck();
+
+ @Before
+ public void setup() {
+ secondaryNamenodeDeletedCheck.clustersProvider = new Provider<Clusters>() {
+
+ @Override
+ public Clusters get() {
+ return clusters;
+ }
+ };
+
+ secondaryNamenodeDeletedCheck.hostComponentStateDao = hostComponentStateDAO;
+ }
+
+ @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("HDFS")).thenReturn(service);
+ Assert.assertTrue(secondaryNamenodeDeletedCheck.isApplicable(new PrereqCheckRequest("cluster")));
+
+ Mockito.when(cluster.getService("HDFS")).thenThrow(new ServiceNotFoundException("no", "service"));
+ Assert.assertFalse(secondaryNamenodeDeletedCheck.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.getCluster("cluster")).thenReturn(cluster);
+
+ final Service service = Mockito.mock(Service.class);
+ final ServiceComponent serviceComponent = Mockito.mock(ServiceComponent.class);
+ Mockito.when(cluster.getService("HDFS")).thenReturn(service);
+ Mockito.when(service.getServiceComponent("SECONDARY_NAMENODE")).thenReturn(serviceComponent);
+ Mockito.when(serviceComponent.getServiceComponentHosts()).thenReturn(Collections.<String, ServiceComponentHost>singletonMap("host", null));
+
+ PrerequisiteCheck check = new PrerequisiteCheck(null, null, null, null);
+ secondaryNamenodeDeletedCheck.perform(check, new PrereqCheckRequest("cluster"));
+ Assert.assertEquals(PrereqCheckStatus.FAIL, check.getStatus());
+
+ Mockito.when(serviceComponent.getServiceComponentHosts()).thenReturn(Collections.<String, ServiceComponentHost> emptyMap());
+ check = new PrerequisiteCheck(null, null, null, null);
+ secondaryNamenodeDeletedCheck.perform(check, new PrereqCheckRequest("cluster"));
+ Assert.assertEquals(PrereqCheckStatus.PASS, check.getStatus());
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/53241b91/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesDecommissionCheckTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesDecommissionCheckTest.java b/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesDecommissionCheckTest.java
new file mode 100644
index 0000000..71e61e2
--- /dev/null
+++ b/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesDecommissionCheckTest.java
@@ -0,0 +1,90 @@
+/*
+ * 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 java.util.HashMap;
+import java.util.Map;
+
+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.HostComponentAdminState;
+import org.apache.ambari.server.state.Service;
+import org.apache.ambari.server.state.ServiceComponent;
+import org.apache.ambari.server.state.ServiceComponentHost;
+import org.apache.ambari.server.state.stack.PrereqCheckStatus;
+import org.apache.ambari.server.state.stack.PrerequisiteCheck;
+import org.junit.Assert;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import com.google.inject.Provider;
+
+/**
+ * Unit tests for ServicesDecommissionCheck
+ *
+ */
+public class ServicesDecommissionCheckTest {
+ private final Clusters clusters = Mockito.mock(Clusters.class);
+
+ @Test
+ public void testIsApplicable() throws Exception {
+ Assert.assertTrue(new ServicesDecommissionCheck().isApplicable(null));
+ }
+
+ @Test
+ public void testPerform() throws Exception {
+ final ServicesDecommissionCheck servicesDecommissionCheck = new ServicesDecommissionCheck();
+ servicesDecommissionCheck.clustersProvider = new Provider<Clusters>() {
+
+ @Override
+ public Clusters get() {
+ return clusters;
+ }
+ };
+ 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.getServices()).thenReturn(Collections.singletonMap("service", service));
+ final ServiceComponent serviceComponent1 = Mockito.mock(ServiceComponent.class);
+ final ServiceComponent serviceComponent2 = Mockito.mock(ServiceComponent.class);
+ final Map<String, ServiceComponent> serviceComponents = new HashMap<String, ServiceComponent>();
+ serviceComponents.put("component1", serviceComponent1);
+ serviceComponents.put("component2", serviceComponent2);
+ Mockito.when(service.getServiceComponents()).thenReturn(serviceComponents);
+ final ServiceComponentHost serviceComponentHost1 = Mockito.mock(ServiceComponentHost.class);
+ final ServiceComponentHost serviceComponentHost2 = Mockito.mock(ServiceComponentHost.class);
+ Mockito.when(serviceComponent1.getServiceComponentHosts()).thenReturn(Collections.singletonMap("serviceComponentHost1", serviceComponentHost1));
+ Mockito.when(serviceComponent2.getServiceComponentHosts()).thenReturn(Collections.singletonMap("serviceComponentHost2", serviceComponentHost2));
+ Mockito.when(serviceComponent1.getServiceComponentHost(Mockito.anyString())).thenReturn(serviceComponentHost1);
+ Mockito.when(serviceComponent2.getServiceComponentHost(Mockito.anyString())).thenReturn(serviceComponentHost2);
+ Mockito.when(serviceComponentHost1.getComponentAdminState()).thenReturn(HostComponentAdminState.DECOMMISSIONED);
+ Mockito.when(serviceComponentHost2.getComponentAdminState()).thenReturn(HostComponentAdminState.INSERVICE);
+
+ PrerequisiteCheck check = new PrerequisiteCheck(null, null, null, null);
+ servicesDecommissionCheck.perform(check, new PrereqCheckRequest("cluster"));
+ Assert.assertEquals(PrereqCheckStatus.FAIL, check.getStatus());
+
+ Mockito.when(serviceComponentHost1.getComponentAdminState()).thenReturn(HostComponentAdminState.INSERVICE);
+ check = new PrerequisiteCheck(null, null, null, null);
+ servicesDecommissionCheck.perform(check, new PrereqCheckRequest("cluster"));
+ Assert.assertEquals(PrereqCheckStatus.PASS, check.getStatus());
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/53241b91/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesMaintenanceModeCheckTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesMaintenanceModeCheckTest.java b/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesMaintenanceModeCheckTest.java
new file mode 100644
index 0000000..c8c8bd8
--- /dev/null
+++ b/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesMaintenanceModeCheckTest.java
@@ -0,0 +1,74 @@
+/*
+ * 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.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.State;
+import org.apache.ambari.server.state.stack.PrereqCheckStatus;
+import org.apache.ambari.server.state.stack.PrerequisiteCheck;
+import org.junit.Assert;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import com.google.inject.Provider;
+
+/**
+ * Unit tests for ServicesMaintenanceModeCheck
+ *
+ */
+public class ServicesMaintenanceModeCheckTest {
+ private final Clusters clusters = Mockito.mock(Clusters.class);
+
+ @Test
+ public void testIsApplicable() throws Exception {
+ Assert.assertTrue(new ServicesMaintenanceModeCheck().isApplicable(null));
+ }
+
+ @Test
+ public void testPerform() throws Exception {
+ final ServicesMaintenanceModeCheck servicesMaintenanceModeCheck = new ServicesMaintenanceModeCheck();
+ servicesMaintenanceModeCheck.clustersProvider = new Provider<Clusters>() {
+
+ @Override
+ public Clusters get() {
+ return clusters;
+ }
+ };
+ 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.getServices()).thenReturn(Collections.singletonMap("service", service));
+ Mockito.when(service.isClientOnlyService()).thenReturn(false);
+ Mockito.when(service.getDesiredState()).thenReturn(State.UNKNOWN);
+
+ PrerequisiteCheck check = new PrerequisiteCheck(null, null, null, null);
+ servicesMaintenanceModeCheck.perform(check, new PrereqCheckRequest("cluster"));
+ Assert.assertEquals(PrereqCheckStatus.FAIL, check.getStatus());
+
+ Mockito.when(service.getDesiredState()).thenReturn(State.STARTED);
+ check = new PrerequisiteCheck(null, null, null, null);
+ servicesMaintenanceModeCheck.perform(check, new PrereqCheckRequest("cluster"));
+ Assert.assertEquals(PrereqCheckStatus.PASS, check.getStatus());
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/53241b91/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
new file mode 100644
index 0000000..ef8740b
--- /dev/null
+++ b/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesMapReduceDistributedCacheCheckTest.java
@@ -0,0 +1,98 @@
+/*
+ * 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 java.util.HashMap;
+import java.util.Map;
+
+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.Config;
+import org.apache.ambari.server.state.DesiredConfig;
+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 com.google.inject.Provider;
+
+/**
+ * Unit tests for ServicesMapReduceDistributedCacheCheck
+ *
+ */
+public class ServicesMapReduceDistributedCacheCheckTest {
+ private final Clusters clusters = Mockito.mock(Clusters.class);
+
+ private final ServicesMapReduceDistributedCacheCheck servicesMapReduceDistributedCacheCheck = new ServicesMapReduceDistributedCacheCheck();
+
+ @Before
+ public void setup() {
+ servicesMapReduceDistributedCacheCheck.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("YARN")).thenReturn(service);
+ Assert.assertTrue(servicesMapReduceDistributedCacheCheck.isApplicable(new PrereqCheckRequest("cluster")));
+
+ Mockito.when(cluster.getService("YARN")).thenThrow(new ServiceNotFoundException("no", "service"));
+ Assert.assertFalse(servicesMapReduceDistributedCacheCheck.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.getCluster("cluster")).thenReturn(cluster);
+
+ final DesiredConfig desiredConfig = Mockito.mock(DesiredConfig.class);
+ Mockito.when(desiredConfig.getTag()).thenReturn("tag");
+ Mockito.when(cluster.getDesiredConfigs()).thenReturn(Collections.singletonMap("mapred-site", desiredConfig));
+ 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>();
+ Mockito.when(config.getProperties()).thenReturn(properties);
+
+ PrerequisiteCheck check = new PrerequisiteCheck(null, null, null, null);
+ servicesMapReduceDistributedCacheCheck.perform(check, new PrereqCheckRequest("cluster"));
+ Assert.assertEquals(PrereqCheckStatus.FAIL, check.getStatus());
+
+ 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());
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/53241b91/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesNamenodeHighAvailabilityCheckTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesNamenodeHighAvailabilityCheckTest.java b/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesNamenodeHighAvailabilityCheckTest.java
new file mode 100644
index 0000000..c1b2022
--- /dev/null
+++ b/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesNamenodeHighAvailabilityCheckTest.java
@@ -0,0 +1,97 @@
+/*
+ * 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 java.util.HashMap;
+import java.util.Map;
+
+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.Config;
+import org.apache.ambari.server.state.DesiredConfig;
+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 com.google.inject.Provider;
+
+/**
+ * Unit tests for ServicesNamenodeHighAvailabilityCheck
+ *
+ */
+public class ServicesNamenodeHighAvailabilityCheckTest {
+ private final Clusters clusters = Mockito.mock(Clusters.class);
+
+ private final ServicesNamenodeHighAvailabilityCheck servicesNamenodeHighAvailabilityCheck = new ServicesNamenodeHighAvailabilityCheck();
+
+ @Before
+ public void setup() {
+ servicesNamenodeHighAvailabilityCheck.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("HDFS")).thenReturn(service);
+ Assert.assertTrue(servicesNamenodeHighAvailabilityCheck.isApplicable(new PrereqCheckRequest("cluster")));
+
+ Mockito.when(cluster.getService("HDFS")).thenThrow(new ServiceNotFoundException("no", "service"));
+ Assert.assertFalse(servicesNamenodeHighAvailabilityCheck.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.getCluster("cluster")).thenReturn(cluster);
+
+ final DesiredConfig desiredConfig = Mockito.mock(DesiredConfig.class);
+ Mockito.when(desiredConfig.getTag()).thenReturn("tag");
+ Mockito.when(cluster.getDesiredConfigs()).thenReturn(Collections.singletonMap("hdfs-site", desiredConfig));
+ 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>();
+ Mockito.when(config.getProperties()).thenReturn(properties);
+
+ PrerequisiteCheck check = new PrerequisiteCheck(null, null, null, null);
+ servicesNamenodeHighAvailabilityCheck.perform(check, new PrereqCheckRequest("cluster"));
+ Assert.assertEquals(PrereqCheckStatus.FAIL, check.getStatus());
+
+ properties.put("dfs.nameservices", "anything");
+ check = new PrerequisiteCheck(null, null, null, null);
+ servicesNamenodeHighAvailabilityCheck.perform(check, new PrereqCheckRequest("cluster"));
+ Assert.assertEquals(PrereqCheckStatus.PASS, check.getStatus());
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/53241b91/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
new file mode 100644
index 0000000..5b0687a
--- /dev/null
+++ b/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesOozieDistributedCacheCheckTest.java
@@ -0,0 +1,114 @@
+/*
+ * 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/53241b91/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
new file mode 100644
index 0000000..222ad00
--- /dev/null
+++ b/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesTezDistributedCacheCheckTest.java
@@ -0,0 +1,98 @@
+/*
+ * 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 java.util.HashMap;
+import java.util.Map;
+
+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.Config;
+import org.apache.ambari.server.state.DesiredConfig;
+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 com.google.inject.Provider;
+
+/**
+ * Unit tests for ServicesTezDistributedCacheCheck
+ *
+ */
+public class ServicesTezDistributedCacheCheckTest {
+ private final Clusters clusters = Mockito.mock(Clusters.class);
+
+ private final ServicesTezDistributedCacheCheck servicesTezDistributedCacheCheck = new ServicesTezDistributedCacheCheck();
+
+ @Before
+ public void setup() {
+ servicesTezDistributedCacheCheck.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("TEZ")).thenReturn(service);
+ Assert.assertTrue(servicesTezDistributedCacheCheck.isApplicable(new PrereqCheckRequest("cluster")));
+
+ Mockito.when(cluster.getService("TEZ")).thenThrow(new ServiceNotFoundException("no", "service"));
+ Assert.assertFalse(servicesTezDistributedCacheCheck.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.getCluster("cluster")).thenReturn(cluster);
+
+ final DesiredConfig desiredConfig = Mockito.mock(DesiredConfig.class);
+ Mockito.when(desiredConfig.getTag()).thenReturn("tag");
+ Mockito.when(cluster.getDesiredConfigs()).thenReturn(Collections.singletonMap("tez-site", desiredConfig));
+ 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>();
+ Mockito.when(config.getProperties()).thenReturn(properties);
+
+ PrerequisiteCheck check = new PrerequisiteCheck(null, null, null, null);
+ servicesTezDistributedCacheCheck.perform(check, new PrereqCheckRequest("cluster"));
+ Assert.assertEquals(PrereqCheckStatus.FAIL, check.getStatus());
+
+ 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());
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/53241b91/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesUpCheckTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesUpCheckTest.java b/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesUpCheckTest.java
new file mode 100644
index 0000000..ad60f1c
--- /dev/null
+++ b/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesUpCheckTest.java
@@ -0,0 +1,74 @@
+/*
+ * 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.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.State;
+import org.apache.ambari.server.state.stack.PrereqCheckStatus;
+import org.apache.ambari.server.state.stack.PrerequisiteCheck;
+import org.junit.Assert;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import com.google.inject.Provider;
+
+/**
+ * Unit tests for ServicesUpCheck
+ *
+ */
+public class ServicesUpCheckTest {
+ private final Clusters clusters = Mockito.mock(Clusters.class);
+
+ @Test
+ public void testIsApplicable() throws Exception {
+ Assert.assertTrue(new ServicesUpCheck().isApplicable(null));
+ }
+
+ @Test
+ public void testPerform() throws Exception {
+ final ServicesUpCheck servicesUpCheck = new ServicesUpCheck();
+ servicesUpCheck.clustersProvider = new Provider<Clusters>() {
+
+ @Override
+ public Clusters get() {
+ return clusters;
+ }
+ };
+ 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.getServices()).thenReturn(Collections.singletonMap("service", service));
+ Mockito.when(service.isClientOnlyService()).thenReturn(false);
+ Mockito.when(service.getDesiredState()).thenReturn(State.UNKNOWN);
+
+ PrerequisiteCheck check = new PrerequisiteCheck(null, null, null, null);
+ servicesUpCheck.perform(check, new PrereqCheckRequest("cluster"));
+ Assert.assertEquals(PrereqCheckStatus.FAIL, check.getStatus());
+
+ Mockito.when(service.getDesiredState()).thenReturn(State.STARTED);
+ check = new PrerequisiteCheck(null, null, null, null);
+ servicesUpCheck.perform(check, new PrereqCheckRequest("cluster"));
+ Assert.assertEquals(PrereqCheckStatus.PASS, check.getStatus());
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/53241b91/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesYarnWorkPreservingCheckTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesYarnWorkPreservingCheckTest.java b/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesYarnWorkPreservingCheckTest.java
new file mode 100644
index 0000000..2135c19
--- /dev/null
+++ b/ambari-server/src/test/java/org/apache/ambari/server/checks/ServicesYarnWorkPreservingCheckTest.java
@@ -0,0 +1,97 @@
+/*
+ * 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 java.util.HashMap;
+import java.util.Map;
+
+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.Config;
+import org.apache.ambari.server.state.DesiredConfig;
+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 com.google.inject.Provider;
+
+/**
+ * Unit tests for ServicesYarnWorkPreservingCheck
+ *
+ */
+public class ServicesYarnWorkPreservingCheckTest {
+ private final Clusters clusters = Mockito.mock(Clusters.class);
+
+ private final ServicesYarnWorkPreservingCheck servicesYarnWorkPreservingCheck = new ServicesYarnWorkPreservingCheck();
+
+ @Before
+ public void setup() {
+ servicesYarnWorkPreservingCheck.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("YARN")).thenReturn(service);
+ Assert.assertTrue(servicesYarnWorkPreservingCheck.isApplicable(new PrereqCheckRequest("cluster")));
+
+ Mockito.when(cluster.getService("YARN")).thenThrow(new ServiceNotFoundException("no", "service"));
+ Assert.assertFalse(servicesYarnWorkPreservingCheck.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.getCluster("cluster")).thenReturn(cluster);
+
+ final DesiredConfig desiredConfig = Mockito.mock(DesiredConfig.class);
+ Mockito.when(desiredConfig.getTag()).thenReturn("tag");
+ Mockito.when(cluster.getDesiredConfigs()).thenReturn(Collections.singletonMap("yarn-site", desiredConfig));
+ 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>();
+ Mockito.when(config.getProperties()).thenReturn(properties);
+
+ PrerequisiteCheck check = new PrerequisiteCheck(null, null, null, null);
+ servicesYarnWorkPreservingCheck.perform(check, new PrereqCheckRequest("cluster"));
+ Assert.assertEquals(PrereqCheckStatus.FAIL, check.getStatus());
+
+ properties.put("yarn.resourcemanager.work-preserving-recovery.enabled", "true");
+ check = new PrerequisiteCheck(null, null, null, null);
+ servicesYarnWorkPreservingCheck.perform(check, new PrereqCheckRequest("cluster"));
+ Assert.assertEquals(PrereqCheckStatus.PASS, check.getStatus());
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/53241b91/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog200Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog200Test.java b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog200Test.java
index 2351ecb..1d4713a 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog200Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog200Test.java
@@ -328,6 +328,7 @@ public class UpgradeCatalog200Test {
Method addNewConfigurationsFromXml = AbstractUpgradeCatalog.class.getDeclaredMethod
("addNewConfigurationsFromXml");
Method setSecurityType = UpgradeCatalog200.class.getDeclaredMethod("setSecurityType");
+ Method updateTezConfiguration = UpgradeCatalog200.class.getDeclaredMethod("updateTezConfiguration");
Method updateConfigurationProperties = AbstractUpgradeCatalog.class.getDeclaredMethod
("updateConfigurationProperties", String.class, Map.class, boolean.class, boolean.class);
@@ -336,6 +337,7 @@ public class UpgradeCatalog200Test {
.addMockedMethod(updateHiveDatabaseType)
.addMockedMethod(addNewConfigurationsFromXml)
.addMockedMethod(setSecurityType)
+ .addMockedMethod(updateTezConfiguration)
.addMockedMethod(updateConfigurationProperties)
.createMock();
@@ -349,6 +351,9 @@ public class UpgradeCatalog200Test {
upgradeCatalog.setSecurityType();
expectLastCall().once();
+ upgradeCatalog.updateTezConfiguration();
+ expectLastCall().once();
+
upgradeCatalog.updateConfigurationProperties("hive-site",
Collections.singletonMap("hive.server2.transport.mode", "binary"), false, false);
expectLastCall();