Return-Path: X-Original-To: apmail-incubator-ambari-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-ambari-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 72C94980C for ; Tue, 12 Mar 2013 17:40:00 +0000 (UTC) Received: (qmail 52080 invoked by uid 500); 12 Mar 2013 17:39:59 -0000 Delivered-To: apmail-incubator-ambari-commits-archive@incubator.apache.org Received: (qmail 52056 invoked by uid 500); 12 Mar 2013 17:39:59 -0000 Mailing-List: contact ambari-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ambari-dev@incubator.apache.org Delivered-To: mailing list ambari-commits@incubator.apache.org Received: (qmail 52028 invoked by uid 99); 12 Mar 2013 17:39:59 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Mar 2013 17:39:59 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Mar 2013 17:39:56 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id A782C23888EA; Tue, 12 Mar 2013 17:39:35 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1455643 - in /incubator/ambari/trunk: ./ ambari-agent/src/main/python/ambari_agent/ ambari-agent/src/test/python/ ambari-server/src/main/java/org/apache/ambari/server/agent/ Date: Tue, 12 Mar 2013 17:39:35 -0000 To: ambari-commits@incubator.apache.org From: mahadev@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130312173935.A782C23888EA@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: mahadev Date: Tue Mar 12 17:39:35 2013 New Revision: 1455643 URL: http://svn.apache.org/r1455643 Log: AMBARI-1617. Host check is broken because of changing the serialization from jackson to gson. (mahadev) Modified: incubator/ambari/trunk/CHANGES.txt incubator/ambari/trunk/ambari-agent/src/main/python/ambari_agent/ActionQueue.py incubator/ambari/trunk/ambari-agent/src/test/python/TestActionQueue.py incubator/ambari/trunk/ambari-agent/src/test/python/TestHeartbeat.py incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/agent/AgentEnv.java Modified: incubator/ambari/trunk/CHANGES.txt URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1455643&r1=1455642&r2=1455643&view=diff ============================================================================== --- incubator/ambari/trunk/CHANGES.txt (original) +++ incubator/ambari/trunk/CHANGES.txt Tue Mar 12 17:39:35 2013 @@ -822,6 +822,9 @@ Trunk (unreleased changes): AMBARI-1547. Fix ambari agent test cases that are failing due to missing directory. (mahadev) + AMBARI-1617. Host check is broken because of changing the serialization from + jackson to gson. (mahadev) + AMBARI-1.2.0 branch: INCOMPATIBLE CHANGES Modified: incubator/ambari/trunk/ambari-agent/src/main/python/ambari_agent/ActionQueue.py URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-agent/src/main/python/ambari_agent/ActionQueue.py?rev=1455643&r1=1455642&r2=1455643&view=diff ============================================================================== --- incubator/ambari/trunk/ambari-agent/src/main/python/ambari_agent/ActionQueue.py (original) +++ incubator/ambari/trunk/ambari-agent/src/main/python/ambari_agent/ActionQueue.py Tue Mar 12 17:39:35 2013 @@ -105,11 +105,15 @@ class ActionQueue(threading.Thread): self.resultQueue.put((command['commandType'], entry)) elif command['commandType'] == self.STATUS_COMMAND: - cluster = command['clusterName'] - service = command['serviceName'] - component = command['componentName'] - globalConfig = command['configurations']['global'] try: + cluster = command['clusterName'] + service = command['serviceName'] + component = command['componentName'] + configurations = command['configurations'] + if configurations.has_key('global'): + globalConfig = configurations['global'] + else: + globalConfig = {} livestatus = LiveStatus(cluster, service, component, globalConfig, self.config) result = livestatus.build() Modified: incubator/ambari/trunk/ambari-agent/src/test/python/TestActionQueue.py URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-agent/src/test/python/TestActionQueue.py?rev=1455643&r1=1455642&r2=1455643&view=diff ============================================================================== --- incubator/ambari/trunk/ambari-agent/src/test/python/TestActionQueue.py (original) +++ incubator/ambari/trunk/ambari-agent/src/test/python/TestActionQueue.py Tue Mar 12 17:39:35 2013 @@ -23,7 +23,10 @@ from ambari_agent.ActionQueue import Act from ambari_agent.AmbariConfig import AmbariConfig from ambari_agent.FileUtil import getFilePath from ambari_agent.UpgradeExecutor import UpgradeExecutor +from ambari_agent.StackVersionsFileHandler import StackVersionsFileHandler import os, errno, time, pprint, tempfile, threading +import TestStackVersionsFileHandler + from mock.mock import patch, MagicMock, call class TestActionQueue(TestCase): @@ -179,6 +182,36 @@ class TestActionQueue(TestCase): self.assertEquals(result, expected_result) + @patch.object(StackVersionsFileHandler, "read_stack_version") + @patch.object(ActionQueue, "stopped") + def test_status_command_without_globals_section(self, stopped_method, + read_stack_version_method): + config = AmbariConfig().getConfig() + config.set('agent', 'prefix', TestStackVersionsFileHandler.dummyVersionsFile) + queue = ActionQueue(config) + statusCommand = { + "serviceName" : 'HDFS', + "commandType" : "STATUS_COMMAND", + "clusterName" : "", + "componentName" : "DATANODE", + 'configurations':{} + } + queue.stopped = stopped_method + stopped_method.side_effect = [False, False, True, True, True] + read_stack_version_method.return_value="1.3.0" + queue.IDLE_SLEEP_TIME = 0.001 + queue.put(statusCommand) + queue.run() + returned_result = queue.resultQueue.get() + self.assertEquals(returned_result, ('STATUS_COMMAND', + {'clusterName': '', + 'componentName': 'DATANODE', + 'msg': '', + 'serviceName': 'HDFS', + 'stackVersion': '1.3.0', + 'status': 'INSTALLED'})) + + class FakeExecutor(): def __init__(self, executor_started_event, end_executor_event): Modified: incubator/ambari/trunk/ambari-agent/src/test/python/TestHeartbeat.py URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-agent/src/test/python/TestHeartbeat.py?rev=1455643&r1=1455642&r2=1455643&view=diff ============================================================================== --- incubator/ambari/trunk/ambari-agent/src/test/python/TestHeartbeat.py (original) +++ incubator/ambari/trunk/ambari-agent/src/test/python/TestHeartbeat.py Tue Mar 12 17:39:35 2013 @@ -26,6 +26,8 @@ from ambari_agent import AmbariConfig import socket import os import time +from mock.mock import patch, MagicMock, call +from ambari_agent.StackVersionsFileHandler import StackVersionsFileHandler class TestHeartbeat(TestCase): @@ -47,8 +49,10 @@ class TestHeartbeat(TestCase): self.assertEquals(not heartbeat.reports, True, "Heartbeat should not contain task in progress") - def test_heartbeat_with_status(self): + @patch.object(StackVersionsFileHandler, "read_stack_version") + def test_heartbeat_with_status(self, read_stack_version_method): actionQueue = ActionQueue(AmbariConfig.AmbariConfig().getConfig()) + read_stack_version_method.return_value="1.3.0" heartbeat = Heartbeat(actionQueue) statusCommand = { "serviceName" : 'HDFS', @@ -65,9 +69,11 @@ class TestHeartbeat(TestCase): result = heartbeat.build(101) self.assertEquals(len(result['componentStatus']) > 0, True, 'Heartbeat should contain status of HDFS components') - def test_heartbeat_with_status_multiple(self): + @patch.object(StackVersionsFileHandler, "read_stack_version") + def test_heartbeat_with_status_multiple(self, read_stack_version_method): actionQueue = ActionQueue(AmbariConfig.AmbariConfig().getConfig()) actionQueue.IDLE_SLEEP_TIME = 0.01 + read_stack_version_method.return_value="1.3.0" heartbeat = Heartbeat(actionQueue) actionQueue.start() max_number_of_status_entries = 0 Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/agent/AgentEnv.java URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/agent/AgentEnv.java?rev=1455643&r1=1455642&r2=1455643&view=diff ============================================================================== --- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/agent/AgentEnv.java (original) +++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/agent/AgentEnv.java Tue Mar 12 17:39:35 2013 @@ -17,6 +17,7 @@ */ package org.apache.ambari.server.agent; +import com.google.gson.annotations.SerializedName; import org.codehaus.jackson.map.annotate.JsonSerialize; import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; @@ -122,8 +123,11 @@ public class AgentEnv { * Represents information about rpm-installed packages */ public static class Rpm { + @SerializedName("name") private String rpmName; + @SerializedName("installed") private boolean rpmInstalled = false; + @SerializedName("version") private String rpmVersion; public void setName(String name) { @@ -156,7 +160,9 @@ public class AgentEnv { * Represents information about a directory of interest. */ public static class Directory { + @SerializedName("name") private String dirName; + @SerializedName("type") private String dirType; public void setName(String name) { @@ -180,9 +186,13 @@ public class AgentEnv { * Represents information about running java processes. */ public static class JavaProc { + @SerializedName("user") private String user; + @SerializedName("pid") private int pid = 0; + @SerializedName("hadoop") private boolean is_hadoop = false; + @SerializedName("command") private String command; public void setUser(String user) { @@ -219,7 +229,9 @@ public class AgentEnv { } public static class Alternative { + @SerializedName("name") private String altName; + @SerializedName("target") private String altTarget; public void setName(String name) {