You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by jo...@apache.org on 2014/11/17 14:37:46 UTC
ambari git commit: AMBARI-8344 - Alerts: Remove Flume Alerts From
Host Components (jonathanhurley)
Repository: ambari
Updated Branches:
refs/heads/trunk 025892604 -> aa43727ea
AMBARI-8344 - Alerts: Remove Flume Alerts From Host Components (jonathanhurley)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/aa43727e
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/aa43727e
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/aa43727e
Branch: refs/heads/trunk
Commit: aa43727ea3ee301eb79245739dafde336623d86d
Parents: 0258926
Author: Jonathan Hurley <jh...@hortonworks.com>
Authored: Sun Nov 16 08:47:45 2014 -0500
Committer: Jonathan Hurley <jh...@hortonworks.com>
Committed: Mon Nov 17 08:37:24 2014 -0500
----------------------------------------------------------------------
.../apache/ambari/server/agent/AgentAlert.java | 82 ------------
.../ambari/server/agent/ComponentStatus.java | 24 +---
.../ambari/server/agent/HeartBeatHandler.java | 40 ++----
.../apache/ambari/server/agent/HostStatus.java | 37 ++----
.../org/apache/ambari/server/state/Cluster.java | 16 +--
.../server/state/cluster/ClusterImpl.java | 42 ------
.../FLUME/package/scripts/flume_handler.py | 54 +-------
.../FLUME/package/scripts/flume_handler.py | 43 -------
.../server/agent/TestHeartbeatHandler.java | 98 ++++++--------
.../server/agent/TestHeartbeatMonitor.java | 18 +--
.../server/state/cluster/ClusterTest.java | 40 +-----
.../python/stacks/2.0.6/FLUME/test_flume.py | 127 +------------------
12 files changed, 80 insertions(+), 541 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/aa43727e/ambari-server/src/main/java/org/apache/ambari/server/agent/AgentAlert.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/agent/AgentAlert.java b/ambari-server/src/main/java/org/apache/ambari/server/agent/AgentAlert.java
deleted file mode 100644
index 8c8bc78..0000000
--- a/ambari-server/src/main/java/org/apache/ambari/server/agent/AgentAlert.java
+++ /dev/null
@@ -1,82 +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.agent;
-
-import org.apache.ambari.server.state.AlertState;
-
-/**
- * Represents an alert that originates from an Agent.
- */
-public class AgentAlert {
-
- private String name = null;
- private AlertState state = null;
- private String instance = null;
- private String label = null;
- private String text = null;
-
- /**
- * Public constructor for use by JSON parsers.
- */
- public AgentAlert() {
- }
-
- /**
- * Constructor used for testing
- */
- AgentAlert(String alertName, AlertState alertState) {
- name = alertName;
- state = alertState;
- }
-
- /**
- * @return the label
- */
- public String getLabel() {
- return label;
- }
-
- /**
- * @return the text
- */
- public String getText() {
- return text;
- }
-
- /**
- * @return the state
- */
- public AlertState getState() {
- return state;
- }
-
- /**
- * @return the name
- */
- public String getName() {
- return name;
- }
-
- /**
- * @return instance specific information
- */
- public String getInstance() {
- return instance;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/aa43727e/ambari-server/src/main/java/org/apache/ambari/server/agent/ComponentStatus.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/agent/ComponentStatus.java b/ambari-server/src/main/java/org/apache/ambari/server/agent/ComponentStatus.java
index 7a0c1c7..8403ba6 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/agent/ComponentStatus.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/agent/ComponentStatus.java
@@ -17,7 +17,6 @@
*/
package org.apache.ambari.server.agent;
-import java.util.List;
import java.util.Map;
@@ -33,10 +32,9 @@ public class ComponentStatus {
private String stackVersion;
private Map<String, Map<String, String>> configurationTags;
private Map<String, Object> extra;
- private List<AgentAlert> alerts;
public String getComponentName() {
- return this.componentName;
+ return componentName;
}
public void setComponentName(String componentName) {
@@ -44,7 +42,7 @@ public class ComponentStatus {
}
public String getMessage() {
- return this.msg;
+ return msg;
}
public void setMessage(String msg) {
@@ -52,7 +50,7 @@ public class ComponentStatus {
}
public String getStatus() {
- return this.status;
+ return status;
}
public void setStatus(String status) {
@@ -60,7 +58,7 @@ public class ComponentStatus {
}
public String getStackVersion() {
- return this.stackVersion;
+ return stackVersion;
}
public void setStackVersion(String stackVersion) {
@@ -120,20 +118,6 @@ public class ComponentStatus {
return extra;
}
- /**
- * Sets alert information from the agent
- */
- public void setAlerts(List<AgentAlert> alertInfo) {
- alerts = alertInfo;
- }
-
- /**
- * Gets alert information from the agent
- */
- public List<AgentAlert> getAlerts() {
- return alerts;
- }
-
@Override
public String toString() {
return "ComponentStatus{" +
http://git-wip-us.apache.org/repos/asf/ambari/blob/aa43727e/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java b/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java
index 82b642b..844b8cb 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java
@@ -225,7 +225,7 @@ public class HeartBeatHandler {
// NOTE: This step must be after processing command/status reports
processHostStatus(heartbeat, hostname);
- calculateHostAlerts(heartbeat, hostname);
+ processAlerts(heartbeat, hostname);
// Send commands if node is active
if (hostObject.getState().equals(HostState.HEALTHY)) {
@@ -236,8 +236,19 @@ public class HeartBeatHandler {
return response;
}
- protected void calculateHostAlerts(HeartBeat heartbeat, String hostname)
- throws AmbariException {
+ /**
+ * Extracts all of the {@link Alert}s from the heartbeat and fires
+ * {@link AlertEvent}s for each one.
+ *
+ * @param heartbeat
+ * the heartbeat to process.
+ * @param hostname
+ * the host that the heartbeat is for.
+ * @throws AmbariException
+ */
+ protected void processAlerts(HeartBeat heartbeat, String hostname)
+ throws AmbariException {
+
if (null == hostname || null == heartbeat) {
return;
}
@@ -253,10 +264,6 @@ public class HeartBeatHandler {
alertEventPublisher.publish(event);
}
}
-
- for (Cluster cluster : clusterFsm.getClustersForHost(hostname)) {
- cluster.addAlerts(heartbeat.getNodeStatus().getAlerts());
- }
}
protected void processHostStatus(HeartBeat heartbeat, String hostname) throws AmbariException {
@@ -533,25 +540,6 @@ public class HeartBeatHandler {
" (" + e.getMessage() + ")");
}
}
-
- if (null != status.getAlerts()) {
- List<Alert> clusterAlerts = new ArrayList<Alert>();
- for (AgentAlert aa : status.getAlerts()) {
- Alert alert = new Alert(aa.getName(), aa.getInstance(),
- scHost.getServiceName(), scHost.getServiceComponentName(),
- scHost.getHostName(), aa.getState());
- alert.setLabel(aa.getLabel());
- alert.setText(aa.getText());
-
- clusterAlerts.add(alert);
- }
-
- if (0 != clusterAlerts.size()) {
- cl.addAlerts(clusterAlerts);
- }
- }
-
-
} else {
// TODO: What should be done otherwise?
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/aa43727e/ambari-server/src/main/java/org/apache/ambari/server/agent/HostStatus.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/agent/HostStatus.java b/ambari-server/src/main/java/org/apache/ambari/server/agent/HostStatus.java
index c63e018..2d021e9 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/agent/HostStatus.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/agent/HostStatus.java
@@ -17,9 +17,6 @@
*/
package org.apache.ambari.server.agent;
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.ambari.server.state.Alert;
import org.codehaus.jackson.annotate.JsonProperty;
/**
@@ -27,58 +24,48 @@ import org.codehaus.jackson.annotate.JsonProperty;
*
*/
public class HostStatus {
+ Status status;
+ String cause;
+
public HostStatus(Status status, String cause) {
super();
this.status = status;
this.cause = cause;
}
+
public HostStatus() {
super();
}
-
+
public enum Status {
HEALTHY,
UNHEALTHY
}
- Status status;
- String cause;
- List<Alert> alerts = new ArrayList<Alert>();
-
+
@JsonProperty("status")
public Status getStatus() {
return status;
}
-
+
@JsonProperty("status")
public void setStatus(Status status) {
this.status = status;
}
-
- @JsonProperty("cause")
+
+ @JsonProperty("cause")
public String getCause() {
return cause;
}
-
+
@JsonProperty("cause")
public void setCause(String cause) {
this.cause = cause;
}
-
- @JsonProperty("alerts")
- public List<Alert> getAlerts() {
- return alerts;
- }
-
- @JsonProperty("alerts")
- public void setAlerts(List<Alert> alerts) {
- this.alerts = alerts;
- }
-
+
@Override
public String toString() {
return "HostStatus{" +
"status=" + status +
- ", cause='" + cause + '\'' +
- ", alerts=" + alerts.size() + '}';
+ ", cause='" + cause + '}';
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/aa43727e/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java b/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java
index 77ab0eb..204e1d9 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java
@@ -24,13 +24,14 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.locks.ReadWriteLock;
-import com.google.common.collect.ListMultimap;
import org.apache.ambari.server.AmbariException;
import org.apache.ambari.server.controller.ClusterResponse;
+import org.apache.ambari.server.controller.ServiceConfigVersionResponse;
import org.apache.ambari.server.orm.entities.PrivilegeEntity;
import org.apache.ambari.server.state.configgroup.ConfigGroup;
import org.apache.ambari.server.state.scheduler.RequestExecution;
-import org.apache.ambari.server.controller.ServiceConfigVersionResponse;
+
+import com.google.common.collect.ListMultimap;
public interface Cluster {
@@ -352,17 +353,6 @@ public interface Cluster {
*/
List<ServiceComponentHostEvent> processServiceComponentHostEvents(ListMultimap<String, ServiceComponentHostEvent> eventMap);
-
- /**
- * Adds alerts for the current cluster.
- */
- public void addAlerts(Collection<Alert> alerts);
-
- /**
- * @return a collection of current known alerts.
- */
- public Collection<Alert> getAlerts();
-
/**
* Determine whether or not access to this cluster resource should be allowed based
* on the given privilege.
http://git-wip-us.apache.org/repos/asf/ambari/blob/aa43727e/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
index 30dceb0..dd3f7e5 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
@@ -94,8 +94,6 @@ import org.apache.ambari.server.state.configgroup.ConfigGroupFactory;
import org.apache.ambari.server.state.fsm.InvalidStateTransitionException;
import org.apache.ambari.server.state.scheduler.RequestExecution;
import org.apache.ambari.server.state.scheduler.RequestExecutionFactory;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.collections.Predicate;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -2078,46 +2076,6 @@ public class ClusterImpl implements Cluster {
}
@Override
- public void addAlerts(Collection<Alert> alerts) {
- try {
- writeLock.lock();
-
- for (final Alert alert : alerts) {
- if (clusterAlerts.size() > 0) {
- CollectionUtils.filter(clusterAlerts, new Predicate() {
- @Override
- public boolean evaluate(Object obj) {
- Alert collectedAlert = (Alert) obj;
- return !collectedAlert.almostEquals(alert);
- }
- });
- }
-
- if (LOG.isDebugEnabled()) {
- LOG.debug("Adding alert for name={} service={}, on host={}",
- alert.getName(), alert.getService(), alert.getHost());
- }
- }
-
- clusterAlerts.addAll(alerts);
-
- } finally {
- writeLock.unlock();
- }
- }
-
- @Override
- public Collection<Alert> getAlerts() {
- try {
- readLock.lock();
-
- return Collections.unmodifiableSet(clusterAlerts);
- } finally {
- readLock.unlock();
- }
- }
-
- @Override
public boolean checkPermission(PrivilegeEntity privilegeEntity, boolean readOnly) {
ResourceEntity resourceEntity = clusterEntity.getResource();
if (resourceEntity != null) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/aa43727e/ambari-server/src/main/resources/stacks/BIGTOP/0.8/services/FLUME/package/scripts/flume_handler.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/BIGTOP/0.8/services/FLUME/package/scripts/flume_handler.py b/ambari-server/src/main/resources/stacks/BIGTOP/0.8/services/FLUME/package/scripts/flume_handler.py
index 42ac560..66e40d5 100644
--- a/ambari-server/src/main/resources/stacks/BIGTOP/0.8/services/FLUME/package/scripts/flume_handler.py
+++ b/ambari-server/src/main/resources/stacks/BIGTOP/0.8/services/FLUME/package/scripts/flume_handler.py
@@ -17,12 +17,13 @@ limitations under the License.
"""
-from resource_management import *
from flume import flume
-from flume import flume_status
-from flume import find_expected_agent_names
from flume import get_desired_state
+from resource_management import *
+from resource_management.libraries.functions.flume_agent_helper import find_expected_agent_names
+from resource_management.libraries.functions.flume_agent_helper import get_flume_status
+
class FlumeHandler(Script):
def install(self, env):
import params
@@ -57,54 +58,11 @@ class FlumeHandler(Script):
env.set_params(params)
- processes = flume_status()
- expected_agents = find_expected_agent_names()
+ processes = get_flume_status(params.flume_conf_dir, params.flume_run_dir)
+ expected_agents = find_expected_agent_names(params.flume_conf_dir)
json = {}
json['processes'] = processes
- json['alerts'] = []
-
- alert = {}
- alert['name'] = 'flume_agent'
- alert['label'] = 'Flume Agent process'
-
- if len(processes) == 0 and len(expected_agents) == 0:
- alert['state'] = 'OK'
-
- if not params.hostname is None:
- alert['text'] = 'No agents defined on ' + params.hostname
- else:
- alert['text'] = 'No agents defined'
-
- else:
- crit = []
- ok = []
-
- for proc in processes:
- if not proc.has_key('status') or proc['status'] == 'NOT_RUNNING':
- crit.append(proc['name'])
- else:
- ok.append(proc['name'])
-
- text_arr = []
-
- if len(crit) > 0:
- text_arr.append("{0} {1} NOT running".format(", ".join(crit),
- "is" if len(crit) == 1 else "are"))
-
- if len(ok) > 0:
- text_arr.append("{0} {1} running".format(", ".join(ok),
- "is" if len(ok) == 1 else "are"))
-
- plural = len(crit) > 1 or len(ok) > 1
- alert['text'] = "Agent{0} {1} {2}".format(
- "s" if plural else "",
- " and ".join(text_arr),
- "" if params.hostname is None else "on " + str(params.hostname))
-
- alert['state'] = 'CRITICAL' if len(crit) > 0 else 'OK'
-
- json['alerts'].append(alert)
self.put_structured_out(json)
# only throw an exception if there are agents defined and there is a
http://git-wip-us.apache.org/repos/asf/ambari/blob/aa43727e/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/FLUME/package/scripts/flume_handler.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/FLUME/package/scripts/flume_handler.py b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/FLUME/package/scripts/flume_handler.py
index 7c7d635..66e40d5 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/FLUME/package/scripts/flume_handler.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/FLUME/package/scripts/flume_handler.py
@@ -63,49 +63,6 @@ class FlumeHandler(Script):
json = {}
json['processes'] = processes
- json['alerts'] = []
-
- alert = {}
- alert['name'] = 'flume_agent'
- alert['label'] = 'Flume Agent process'
-
- if len(processes) == 0 and len(expected_agents) == 0:
- alert['state'] = 'OK'
-
- if not params.hostname is None:
- alert['text'] = 'No agents defined on ' + params.hostname
- else:
- alert['text'] = 'No agents defined'
-
- else:
- crit = []
- ok = []
-
- for proc in processes:
- if not proc.has_key('status') or proc['status'] == 'NOT_RUNNING':
- crit.append(proc['name'])
- else:
- ok.append(proc['name'])
-
- text_arr = []
-
- if len(crit) > 0:
- text_arr.append("{0} {1} NOT running".format(", ".join(crit),
- "is" if len(crit) == 1 else "are"))
-
- if len(ok) > 0:
- text_arr.append("{0} {1} running".format(", ".join(ok),
- "is" if len(ok) == 1 else "are"))
-
- plural = len(crit) > 1 or len(ok) > 1
- alert['text'] = "Agent{0} {1} {2}".format(
- "s" if plural else "",
- " and ".join(text_arr),
- "" if params.hostname is None else "on " + str(params.hostname))
-
- alert['state'] = 'CRITICAL' if len(crit) > 0 else 'OK'
-
- json['alerts'].append(alert)
self.put_structured_out(json)
# only throw an exception if there are agents defined and there is a
http://git-wip-us.apache.org/repos/asf/ambari/blob/aa43727e/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java b/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java
index 6e78b1d..6c64b31 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java
@@ -79,7 +79,6 @@ import org.apache.ambari.server.orm.GuiceJpaInitializer;
import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
import org.apache.ambari.server.serveraction.ServerActionManager;
import org.apache.ambari.server.state.Alert;
-import org.apache.ambari.server.state.AlertState;
import org.apache.ambari.server.state.Cluster;
import org.apache.ambari.server.state.Clusters;
import org.apache.ambari.server.state.Host;
@@ -179,31 +178,19 @@ public class TestHeartbeatHandler {
HostStatus hs = new HostStatus(Status.HEALTHY, DummyHostStatus);
List<Alert> al = new ArrayList<Alert>();
al.add(new Alert());
- hs.setAlerts(al);
hb.setNodeStatus(hs);
hb.setHostname(DummyHostname1);
-
- for (Map.Entry<String, Cluster> entry : clusters.getClusters().entrySet()) {
- Cluster cl = entry.getValue();
- assertEquals(0, cl.getAlerts().size());
- }
handler.handleHeartBeat(hb);
-
- for (Map.Entry<String, Cluster> entry : clusters.getClusters().entrySet()) {
- Cluster cl = entry.getValue();
- assertEquals(1, cl.getAlerts().size());
- }
-
assertEquals(HostState.HEALTHY, hostObject.getState());
assertEquals(0, aq.dequeueAll(DummyHostname1).size());
}
-
+
@Test
@SuppressWarnings("unchecked")
public void testHeartbeatWithConfigs() throws Exception {
Cluster cluster = getDummyCluster();
-
+
@SuppressWarnings("serial")
Set<String> hostNames = new HashSet<String>(){{
add(DummyHostname1);
@@ -217,7 +204,7 @@ public class TestHeartbeatHandler {
hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1).persist();
hdfs.addServiceComponent(SECONDARY_NAMENODE).persist();
hdfs.getServiceComponent(SECONDARY_NAMENODE).addServiceComponentHost(DummyHostname1).persist();
-
+
ActionQueue aq = new ActionQueue();
ServiceComponentHost serviceComponentHost1 = clusters.getCluster(DummyCluster).getService(HDFS).
@@ -231,7 +218,7 @@ public class TestHeartbeatHandler {
hb.setResponseId(0);
hb.setNodeStatus(new HostStatus(Status.HEALTHY, DummyHostStatus));
hb.setHostname(DummyHostname1);
-
+
List<CommandReport> reports = new ArrayList<CommandReport>();
CommandReport cr = new CommandReport();
cr.setActionId(StageUtils.getActionId(requestId, stageId));
@@ -244,11 +231,11 @@ public class TestHeartbeatHandler {
cr.setExitCode(215);
cr.setRoleCommand("START");
cr.setClusterName(DummyCluster);
-
+
cr.setConfigurationTags(new HashMap<String, Map<String,String>>() {{
put("global", new HashMap<String,String>() {{ put("tag", "version1"); }});
}});
-
+
reports.add(cr);
hb.setReports(reports);
@@ -727,7 +714,7 @@ public class TestHeartbeatHandler {
assertEquals(State.STARTED, componentState1);
assertEquals(State.INSTALLED, componentState2);
}
-
+
@Test
public void testCommandReport() throws AmbariException {
injector.injectMembers(this);
@@ -751,12 +738,12 @@ public class TestHeartbeatHandler {
cr.setStdErr("");
cr.setStdOut("");
cr.setExitCode(215);
-
+
cr.setConfigurationTags(new HashMap<String, Map<String,String>>() {{
put("global", new HashMap<String,String>() {{ put("tag", "version1"); }});
}});
-
-
+
+
reports.add(cr);
am.processTaskResponse(DummyHostname1, reports, stage.getOrderedHostRoleCommands());
assertEquals(215,
@@ -834,7 +821,7 @@ public class TestHeartbeatHandler {
HostInfo hi = new HostInfo();
hi.setHostName(DummyHostname1);
hi.setOS(DummyOsType);
-
+
reg.setHostname(DummyHostname1);
reg.setHardwareProfile(hi);
reg.setAgentVersion(""); // Invalid agent version
@@ -885,11 +872,11 @@ public class TestHeartbeatHandler {
assertTrue(hostObject.getLastRegistrationTime() != 0);
assertEquals(hostObject.getLastHeartbeatTime(),
hostObject.getLastRegistrationTime());
-
+
Host verifyHost = clusters.getHost(DummyHostname1);
assertEquals(verifyHost.getPublicHostName(), reg.getPublicHostname());
}
-
+
@Test
public void testInvalidOSRegistration() throws AmbariException,
@@ -1816,7 +1803,7 @@ public class TestHeartbeatHandler {
assertEquals("Stack version of SCH should not change after fail report",
State.INSTALL_FAILED, serviceComponentHost2.getState());
}
-
+
@Test
@SuppressWarnings("unchecked")
public void testProcessStatusReports() throws Exception {
@@ -1860,7 +1847,7 @@ public class TestHeartbeatHandler {
hostObject.setState(HostState.UNHEALTHY);
aq.enqueue(DummyHostname1, new StatusCommand());
-
+
//All components are up
HeartBeat hb1 = new HeartBeat();
hb1.setResponseId(0);
@@ -1882,7 +1869,7 @@ public class TestHeartbeatHandler {
hb1.setComponentStatus(componentStatus);
handler.handleHeartBeat(hb1);
assertEquals(HostHealthStatus.HealthStatus.HEALTHY.name(), hostObject.getStatus());
-
+
//Some slaves are down, masters are up
HeartBeat hb2 = new HeartBeat();
hb2.setResponseId(1);
@@ -1904,7 +1891,7 @@ public class TestHeartbeatHandler {
hb2.setComponentStatus(componentStatus);
handler.handleHeartBeat(hb2);
assertEquals(HostHealthStatus.HealthStatus.ALERT.name(), hostObject.getStatus());
-
+
// mark the installed DN as maintenance
hdfs.getServiceComponent(DATANODE).getServiceComponentHost(
DummyHostname1).setMaintenanceState(MaintenanceState.ON);
@@ -1928,10 +1915,10 @@ public class TestHeartbeatHandler {
hb2a.setComponentStatus(componentStatus);
handler.handleHeartBeat(hb2a);
assertEquals(HostHealthStatus.HealthStatus.HEALTHY.name(), hostObject.getStatus());
-
+
hdfs.getServiceComponent(DATANODE).getServiceComponentHost(
DummyHostname1).setMaintenanceState(MaintenanceState.OFF);
-
+
//Some masters are down
HeartBeat hb3 = new HeartBeat();
hb3.setResponseId(3);
@@ -2103,7 +2090,7 @@ public class TestHeartbeatHandler {
expected.setStackVersion(dummyStackId.getStackVersion());
expected.setComponents(dummyComponents);
- this.getDummyCluster();
+ getDummyCluster();
HeartBeatHandler handler = getHeartBeatHandler(getMockActionManager(),
new ActionQueue());
@@ -2167,13 +2154,13 @@ public class TestHeartbeatHandler {
throws AmbariException {
clusters.addHost(DummyHostname1);
clusters.getHost(DummyHostname1).setOsType(DummyOsType);
-
+
Map<String, String> hostAttributes = new HashMap<String, String>();
hostAttributes.put("os_family", "redhat");
hostAttributes.put("os_release_version", "6.3");
clusters.getHost(DummyHostname1).setHostAttributes(hostAttributes);
-
+
clusters.getHost(DummyHostname1).persist();
clusters.addCluster(DummyCluster);
@@ -2183,7 +2170,7 @@ public class TestHeartbeatHandler {
cluster.setCurrentStackVersion(stackId);
return cluster;
}
-
+
@Test
@SuppressWarnings("unchecked")
public void testCommandStatusProcesses() throws Exception {
@@ -2195,7 +2182,7 @@ public class TestHeartbeatHandler {
hdfs.addServiceComponent(DATANODE).persist();
hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
hdfs.getServiceComponent(DATANODE).getServiceComponentHost(DummyHostname1).setState(State.STARTED);
-
+
ActionQueue aq = new ActionQueue();
HeartBeat hb = new HeartBeat();
@@ -2210,15 +2197,15 @@ public class TestHeartbeatHandler {
proc1info.put("name", "a");
proc1info.put("status", "RUNNING");
procs.add(proc1info);
-
+
Map<String, String> proc2info = new HashMap<String, String>();
proc2info.put("name", "b");
proc2info.put("status", "NOT_RUNNING");
procs.add(proc2info);
-
+
Map<String, Object> extra = new HashMap<String, Object>();
extra.put("processes", procs);
-
+
ArrayList<ComponentStatus> componentStatuses = new ArrayList<ComponentStatus>();
ComponentStatus componentStatus1 = new ComponentStatus();
componentStatus1.setClusterName(DummyCluster);
@@ -2226,7 +2213,7 @@ public class TestHeartbeatHandler {
componentStatus1.setMessage(DummyHostStatus);
componentStatus1.setStatus(State.STARTED.name());
componentStatus1.setComponentName(DATANODE);
-
+
componentStatus1.setExtra(extra);
componentStatuses.add(componentStatus1);
hb.setComponentStatus(componentStatuses);
@@ -2243,39 +2230,28 @@ public class TestHeartbeatHandler {
HeartBeatHandler handler = getHeartBeatHandler(am, aq);
handler.handleHeartBeat(hb);
- ServiceComponentHost sch = hdfs.getServiceComponent(DATANODE).getServiceComponentHost(DummyHostname1);
+ ServiceComponentHost sch = hdfs.getServiceComponent(DATANODE).getServiceComponentHost(DummyHostname1);
Assert.assertEquals(Integer.valueOf(2), Integer.valueOf(sch.getProcesses().size()));
-
+
hb = new HeartBeat();
hb.setTimestamp(System.currentTimeMillis());
hb.setResponseId(1);
hb.setHostname(DummyHostname1);
hb.setNodeStatus(new HostStatus(Status.HEALTHY, DummyHostStatus));
hb.setReports(new ArrayList<CommandReport>());
-
+
componentStatus1 = new ComponentStatus();
componentStatus1.setClusterName(DummyCluster);
componentStatus1.setServiceName(HDFS);
componentStatus1.setMessage(DummyHostStatus);
componentStatus1.setStatus(State.STARTED.name());
componentStatus1.setComponentName(DATANODE);
- componentStatus1.setAlerts(Collections.singletonList(
- new AgentAlert("xyz", AlertState.CRITICAL)));
hb.setComponentStatus(Collections.singletonList(componentStatus1));
-
+
handler.handleHeartBeat(hb);
-
- Assert.assertNotNull(hdfs.getCluster().getAlerts());
- Assert.assertEquals(1, hdfs.getCluster().getAlerts().size());
- Alert clusterAlert = hdfs.getCluster().getAlerts().iterator().next();
- Assert.assertNotNull(clusterAlert);
- Assert.assertEquals(HDFS, clusterAlert.getService());
- Assert.assertEquals(DATANODE, clusterAlert.getComponent());
- Assert.assertEquals(DummyHostname1, clusterAlert.getHost());
- Assert.assertEquals(AlertState.CRITICAL, clusterAlert.getState());
}
-
+
@Test
@SuppressWarnings("unchecked")
public void testCommandStatusProcesses_empty() throws Exception {
@@ -2287,7 +2263,7 @@ public class TestHeartbeatHandler {
hdfs.addServiceComponent(DATANODE).persist();
hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
hdfs.getServiceComponent(DATANODE).getServiceComponentHost(DummyHostname1).setState(State.STARTED);
-
+
ActionQueue aq = new ActionQueue();
HeartBeat hb = new HeartBeat();
hb.setTimestamp(System.currentTimeMillis());
@@ -2295,7 +2271,7 @@ public class TestHeartbeatHandler {
hb.setHostname(DummyHostname1);
hb.setNodeStatus(new HostStatus(Status.HEALTHY, DummyHostStatus));
hb.setReports(new ArrayList<CommandReport>());
-
+
ArrayList<ComponentStatus> componentStatuses = new ArrayList<ComponentStatus>();
ComponentStatus componentStatus1 = new ComponentStatus();
componentStatus1.setClusterName(DummyCluster);
@@ -2303,7 +2279,7 @@ public class TestHeartbeatHandler {
componentStatus1.setMessage(DummyHostStatus);
componentStatus1.setStatus(State.STARTED.name());
componentStatus1.setComponentName(DATANODE);
-
+
componentStatuses.add(componentStatus1);
hb.setComponentStatus(componentStatuses);
@@ -2321,5 +2297,5 @@ public class TestHeartbeatHandler {
ServiceComponentHost sch = hdfs.getServiceComponent(DATANODE).getServiceComponentHost(DummyHostname1);
Assert.assertEquals(Integer.valueOf(0), Integer.valueOf(sch.getProcesses().size()));
- }
+ }
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/aa43727e/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatMonitor.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatMonitor.java b/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatMonitor.java
index 2a0f3db..08c18ca 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatMonitor.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatMonitor.java
@@ -25,7 +25,6 @@ import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -39,8 +38,6 @@ import org.apache.ambari.server.actionmanager.ActionManager;
import org.apache.ambari.server.api.services.AmbariMetaInfo;
import org.apache.ambari.server.orm.GuiceJpaInitializer;
import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
-import org.apache.ambari.server.state.Alert;
-import org.apache.ambari.server.state.AlertState;
import org.apache.ambari.server.state.Cluster;
import org.apache.ambari.server.state.Clusters;
import org.apache.ambari.server.state.Config;
@@ -166,26 +163,20 @@ public class TestHeartbeatMonitor {
hb.setResponseId(12);
handler.handleHeartBeat(hb);
- List<Alert> al = new ArrayList<Alert>();
- Alert alert = new Alert("host_alert", null, "AMBARI", null, hostname1, AlertState.OK);
- al.add(alert);
- for (Map.Entry<String, Cluster> entry : clusters.getClusters().entrySet()) {
- Cluster cl = entry.getValue();
- cl.addAlerts(al);
- }
-
List<StatusCommand> cmds = hm.generateStatusCommands(hostname1);
assertTrue("HeartbeatMonitor should generate StatusCommands for host1", cmds.size() == 3);
assertEquals("HDFS", cmds.get(0).getServiceName());
boolean containsDATANODEStatus = false;
boolean containsNAMENODEStatus = false;
boolean containsSECONDARY_NAMENODEStatus = false;
+
for (StatusCommand cmd : cmds) {
containsDATANODEStatus |= cmd.getComponentName().equals("DATANODE");
containsNAMENODEStatus |= cmd.getComponentName().equals("NAMENODE");
containsSECONDARY_NAMENODEStatus |= cmd.getComponentName().equals("SECONDARY_NAMENODE");
assertTrue(cmd.getConfigurations().size() > 0);
}
+
assertEquals(true, containsDATANODEStatus);
assertEquals(true, containsNAMENODEStatus);
assertEquals(true, containsSECONDARY_NAMENODEStatus);
@@ -554,11 +545,6 @@ public class TestHeartbeatMonitor {
hdfs.getServiceComponent(Role.NAMENODE.name()).getServiceComponentHost(hostname1).setState(State.INSTALLED);
hdfs.getServiceComponent(Role.SECONDARY_NAMENODE.name()).getServiceComponentHost(hostname1).setState(State.INSTALLED);
- Alert alert = new Alert("datanode_madeup", null, "HDFS", "DATANODE",
- hostname1, AlertState.CRITICAL);
-
- cluster.addAlerts(Collections.singleton(alert));
-
ActionQueue aq = new ActionQueue();
ActionManager am = mock(ActionManager.class);
HeartbeatMonitor hm = new HeartbeatMonitor(clusters, aq, am,
http://git-wip-us.apache.org/repos/asf/ambari/blob/aa43727e/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java
index 7a09514..e8bdc14 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java
@@ -28,7 +28,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
-import java.util.Comparator;
import java.util.ConcurrentModificationException;
import java.util.HashMap;
import java.util.HashSet;
@@ -39,7 +38,6 @@ import java.util.Set;
import javax.persistence.EntityManager;
-import com.google.common.collect.Multimap;
import junit.framework.Assert;
import org.apache.ambari.server.AmbariException;
@@ -54,13 +52,11 @@ import org.apache.ambari.server.orm.GuiceJpaInitializer;
import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
import org.apache.ambari.server.orm.entities.ClusterEntity;
import org.apache.ambari.server.orm.entities.ClusterServiceEntity;
+import org.apache.ambari.server.orm.entities.ClusterStateEntity;
import org.apache.ambari.server.orm.entities.HostEntity;
import org.apache.ambari.server.orm.entities.HostStateEntity;
import org.apache.ambari.server.orm.entities.ServiceDesiredStateEntity;
-import org.apache.ambari.server.orm.entities.ClusterStateEntity;
import org.apache.ambari.server.state.AgentVersion;
-import org.apache.ambari.server.state.Alert;
-import org.apache.ambari.server.state.AlertState;
import org.apache.ambari.server.state.Cluster;
import org.apache.ambari.server.state.Clusters;
import org.apache.ambari.server.state.Config;
@@ -85,7 +81,6 @@ import org.apache.ambari.server.state.host.HostHealthyHeartbeatEvent;
import org.apache.ambari.server.state.host.HostRegistrationRequestEvent;
import org.junit.After;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -612,39 +607,6 @@ public class ClusterTest {
Assert.assertEquals(State.INSTALLED,
c1.getProvisioningState());
}
-
- @Test
- public void testAlertUpdates() {
-
- Set<Alert> alerts = new HashSet<Alert>();
- alerts.add(new Alert("alert_1", "instance1", "service", "component", "host1", AlertState.OK));
- alerts.add(new Alert("alert_1", "instance2", "service", "component", "host1", AlertState.OK));
-
- c1.addAlerts(alerts);
-
- Collection<Alert> result = c1.getAlerts();
- assertEquals(2, result.size());
- for (Alert a : result) {
- assertEquals("alert_1", a.getName());
- }
-
- // add an alert that removes the previous 2 with the same name
- alerts = new HashSet<Alert>();
- alerts.add(new Alert("alert_1", null, "service", "component", "host1", AlertState.WARNING));
- c1.addAlerts(alerts);
-
- result = c1.getAlerts();
- assertEquals(1, result.size());
-
- // add alerts that remove the old type, regardless of instance name
- alerts = new HashSet<Alert>();
- alerts.add(new Alert("alert_1", "instance1", "service", "component", "host1", AlertState.OK));
- alerts.add(new Alert("alert_1", "instance2", "service", "component", "host1", AlertState.OK));
- c1.addAlerts(alerts);
-
- result = c1.getAlerts();
- assertEquals(2, result.size());
- }
@Test
public void testServiceConfigVersions() throws AmbariException {
http://git-wip-us.apache.org/repos/asf/ambari/blob/aa43727e/ambari-server/src/test/python/stacks/2.0.6/FLUME/test_flume.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.0.6/FLUME/test_flume.py b/ambari-server/src/test/python/stacks/2.0.6/FLUME/test_flume.py
index 28a0ec9..d7b3537 100644
--- a/ambari-server/src/test/python/stacks/2.0.6/FLUME/test_flume.py
+++ b/ambari-server/src/test/python/stacks/2.0.6/FLUME/test_flume.py
@@ -103,8 +103,7 @@ class TestFlumeHandler(RMFTestCase):
# test that the method was called with empty processes
self.assertTrue(structured_out_mock.called)
- structured_out_mock.assert_called_with({'processes': [],
- 'alerts': [{'text': 'No agents defined on c6401.ambari.apache.org', 'state': 'OK', 'name': 'flume_agent', 'label': 'Flume Agent process'}]})
+ structured_out_mock.assert_called_with({'processes': []})
self.assertNoMoreResources()
@patch("resource_management.libraries.script.Script.put_structured_out")
@@ -127,7 +126,6 @@ class TestFlumeHandler(RMFTestCase):
# call_args[0] is a tuple, whose first element is the actual call argument
struct_out = structured_out_mock.call_args[0][0]
self.assertTrue(struct_out.has_key('processes'))
- self.assertTrue(struct_out.has_key('alerts'))
self.assertNoMoreResources()
@@ -151,7 +149,6 @@ class TestFlumeHandler(RMFTestCase):
# call_args[0] is a tuple, whose first element is the actual call argument
struct_out = structured_out_mock.call_args[0][0]
self.assertTrue(struct_out.has_key('processes'))
- self.assertTrue(struct_out.has_key('alerts'))
self.assertNoMoreResources()
def assert_configure_default(self):
@@ -318,128 +315,6 @@ class TestFlumeHandler(RMFTestCase):
self.assert_configure_default()
self.assertNoMoreResources()
- @patch("resource_management.libraries.script.Script.put_structured_out")
- @patch("resource_management.libraries.functions.flume_agent_helper.find_expected_agent_names")
- @patch("resource_management.libraries.functions.flume_agent_helper.get_flume_status")
- def test_status_many_mixed(self, status_mock, expected_names_mock, structured_out_mock):
- expected_names_mock.return_value = ["a1", "a2"]
- status_mock.return_value = [{'name': 'a1', 'status': 'RUNNING'}, {'name': 'a2', 'status': 'NOT_RUNNING'}]
-
- try:
- self.executeScript("2.0.6/services/FLUME/package/scripts/flume_handler.py",
- classname = "FlumeHandler",
- command = "status",
- config_file="default.json")
- except:
- # expected since ComponentIsNotRunning gets raised
- pass
-
- self.assertTrue(structured_out_mock.called)
-
- # call_args[0] is a tuple, whose first element is the actual call argument
- struct_out = structured_out_mock.call_args[0][0]
- self.assertTrue(struct_out.has_key('processes'))
- self.assertTrue(struct_out.has_key('alerts'))
- self.assertTrue('Agent a2 is NOT running and a1 is running on c6401.ambari.apache.org' == struct_out['alerts'][0]['text'])
- self.assertTrue('CRITICAL' == struct_out['alerts'][0]['state'])
- self.assertNoMoreResources()
-
- @patch("resource_management.libraries.script.Script.put_structured_out")
- @patch("resource_management.libraries.functions.flume_agent_helper.find_expected_agent_names")
- @patch("resource_management.libraries.functions.flume_agent_helper.get_flume_status")
- def test_status_many_ok(self, status_mock, expected_names_mock, structured_out_mock):
- expected_names_mock.return_value = ["a1", "a2"]
- status_mock.return_value = [{'name': 'a1', 'status': 'RUNNING'}, {'name': 'a2', 'status': 'RUNNING'}]
-
- self.executeScript("2.0.6/services/FLUME/package/scripts/flume_handler.py",
- classname = "FlumeHandler",
- command = "status",
- config_file="default.json")
-
- self.assertTrue(structured_out_mock.called)
-
- # call_args[0] is a tuple, whose first element is the actual call argument
- struct_out = structured_out_mock.call_args[0][0]
- self.assertTrue(struct_out.has_key('processes'))
- self.assertTrue(struct_out.has_key('alerts'))
- self.assertTrue('Agents a1, a2 are running on c6401.ambari.apache.org' == struct_out['alerts'][0]['text'])
- self.assertTrue('OK' == struct_out['alerts'][0]['state'])
- self.assertNoMoreResources()
-
- @patch("resource_management.libraries.script.Script.put_structured_out")
- @patch("resource_management.libraries.functions.flume_agent_helper.find_expected_agent_names")
- @patch("resource_management.libraries.functions.flume_agent_helper.get_flume_status")
- def test_status_many_critical(self, status_mock, expected_names_mock, structured_out_mock):
- expected_names_mock.return_value = ["a1", "a2"]
- status_mock.return_value = [{'name': 'a1', 'status': 'NOT_RUNNING'}, {'name': 'a2', 'status': 'NOT_RUNNING'}]
-
- try:
- self.executeScript("2.0.6/services/FLUME/package/scripts/flume_handler.py",
- classname = "FlumeHandler",
- command = "status",
- config_file="default.json")
- except:
- # expected since ComponentIsNotRunning gets raised
- pass
-
- self.assertTrue(structured_out_mock.called)
-
- # call_args[0] is a tuple, whose first element is the actual call argument
- struct_out = structured_out_mock.call_args[0][0]
- self.assertTrue(struct_out.has_key('processes'))
- self.assertTrue(struct_out.has_key('alerts'))
- self.assertTrue('Agents a1, a2 are NOT running on c6401.ambari.apache.org' == struct_out['alerts'][0]['text'])
- self.assertTrue('CRITICAL' == struct_out['alerts'][0]['state'])
- self.assertNoMoreResources()
-
-
- @patch("resource_management.libraries.script.Script.put_structured_out")
- @patch("resource_management.libraries.functions.flume_agent_helper.find_expected_agent_names")
- @patch("resource_management.libraries.functions.flume_agent_helper.get_flume_status")
- def test_status_single_ok(self, status_mock, expected_names_mock, structured_out_mock):
- expected_names_mock.return_value = ["a1"]
- status_mock.return_value = [{'name': 'a1', 'status': 'RUNNING'}]
-
- self.executeScript("2.0.6/services/FLUME/package/scripts/flume_handler.py",
- classname = "FlumeHandler",
- command = "status",
- config_file="default.json")
-
- self.assertTrue(structured_out_mock.called)
-
- # call_args[0] is a tuple, whose first element is the actual call argument
- struct_out = structured_out_mock.call_args[0][0]
- self.assertTrue(struct_out.has_key('processes'))
- self.assertTrue(struct_out.has_key('alerts'))
- self.assertTrue('Agent a1 is running on c6401.ambari.apache.org' == struct_out['alerts'][0]['text'])
- self.assertTrue('OK' == struct_out['alerts'][0]['state'])
- self.assertNoMoreResources()
-
- @patch("resource_management.libraries.script.Script.put_structured_out")
- @patch("resource_management.libraries.functions.flume_agent_helper.find_expected_agent_names")
- @patch("resource_management.libraries.functions.flume_agent_helper.get_flume_status")
- def test_status_single_critical(self, status_mock, expected_names_mock, structured_out_mock):
- expected_names_mock.return_value = ['a1']
- status_mock.return_value = [{'name': 'a1', 'status': 'NOT_RUNNING'}]
-
- try:
- self.executeScript("2.0.6/services/FLUME/package/scripts/flume_handler.py",
- classname = "FlumeHandler",
- command = "status",
- config_file="default.json")
- except:
- # expected since ComponentIsNotRunning gets raised
- pass
-
- self.assertTrue(structured_out_mock.called)
-
- # call_args[0] is a tuple, whose first element is the actual call argument
- struct_out = structured_out_mock.call_args[0][0]
- self.assertTrue(struct_out.has_key('processes'))
- self.assertTrue(struct_out.has_key('alerts'))
- self.assertTrue('Agent a1 is NOT running on c6401.ambari.apache.org' == struct_out['alerts'][0]['text'])
- self.assertTrue('CRITICAL' == struct_out['alerts'][0]['state'])
- self.assertNoMoreResources()
def test_flume_env_not_22(self):
self.executeScript("2.0.6/services/FLUME/package/scripts/flume_handler.py",