ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject git commit: AMBARI-5424 Fix BootStrap of Ambari Agents to work on Ubuntu. (dsen)
Date Mon, 14 Apr 2014 10:57:11 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk f6d0436c6 -> c9e181d25


AMBARI-5424 Fix BootStrap of Ambari Agents to work on Ubuntu. (dsen)


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

Branch: refs/heads/trunk
Commit: c9e181d25f57f5ea56770a080e6d3b09dbda82b1
Parents: f6d0436
Author: Dmitry Sen <dsen@hortonworks.com>
Authored: Mon Apr 14 13:37:32 2014 +0300
Committer: Dmitry Sen <dsen@hortonworks.com>
Committed: Mon Apr 14 13:37:32 2014 +0300

----------------------------------------------------------------------
 .../server/api/services/AmbariMetaInfo.java     |  38 ++---
 ambari-server/src/main/python/bootstrap.py      |  50 +++++--
 ambari-server/src/main/python/setupAgent.py     | 108 +++++++-------
 .../server/api/services/AmbariMetaInfoTest.java |  77 +++++-----
 ambari-server/src/test/python/TestBootstrap.py  |  24 +++-
 ambari-server/src/test/python/TestSetupAgent.py | 143 ++++++++++++-------
 6 files changed, 275 insertions(+), 165 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/c9e181d2/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
b/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
index f62bfd0..52c7309 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
@@ -111,8 +111,8 @@ public class AmbariMetaInfo {
   // all the supported OS'es
   private static final List<String> ALL_SUPPORTED_OS = Arrays.asList(
       "centos5", "redhat5", "centos6", "redhat6", "oraclelinux5",
-      "oraclelinux6", "suse11", "sles11", "ubuntu12");
-  
+      "oraclelinux6", "suse11", "sles11", "ubuntu12", "debian12");
+
   private final ActionDefinitionManager adManager = new ActionDefinitionManager();
   private String serverVersion = "undefined";
   private List<StackInfo> stacksResult = new ArrayList<StackInfo>();
@@ -688,9 +688,9 @@ public class AmbariMetaInfo {
         return new Thread(r, "Stack Version Loading Thread");
       }
     });
-    
+
     List<LatestRepoCallable> lookupList = new ArrayList<LatestRepoCallable>();
-    
+
     for (StackInfo stack : stacks) {
       LOG.debug("Adding new stack to known stacks"
         + ", stackName = " + stack.getName()
@@ -733,9 +733,9 @@ public class AmbariMetaInfo {
               resolveHooksFolder(stack);
       stack.setStackHooksFolder(stackHooksToUse);
     }
-    
+
     es.invokeAll(lookupList);
-    
+
     es.shutdown();
   }
 
@@ -747,7 +747,7 @@ public class AmbariMetaInfo {
   private List<RepositoryInfo> getRepository(File repositoryFile, StackInfo stack,
       List<LatestRepoCallable> lookupList)
       throws JAXBException {
-    
+
     RepositoryXml rxml = StackExtensionHelper.unmarshal(RepositoryXml.class, repositoryFile);
 
     List<RepositoryInfo> list = new ArrayList<RepositoryInfo>();
@@ -763,7 +763,7 @@ public class AmbariMetaInfo {
           ri.setRepoId(r.getRepoId());
           ri.setRepoName(r.getRepoName());
           ri.setLatestBaseUrl(r.getBaseUrl());
-          
+
           if (null != metainfoDAO) {
             LOG.debug("Checking for override for base_url");
             String key = generateRepoMetaKey(r.getRepoName(), stack.getVersion(),
@@ -783,7 +783,7 @@ public class AmbariMetaInfo {
         }
       }
     }
-    
+
     if (null != rxml.getLatestURI() && list.size() > 0) {
       lookupList.add(new LatestRepoCallable(rxml.getLatestURI(),
           repositoryFile.getParentFile(), stack));
@@ -849,7 +849,7 @@ public class AmbariMetaInfo {
   public File getStackRoot() {
     return stackRoot;
   }
-  
+
   /**
    * Gets the metrics for a Role (component).
    * @return the list of defined metrics.
@@ -857,42 +857,42 @@ public class AmbariMetaInfo {
   public List<MetricDefinition> getMetrics(String stackName, String stackVersion,
       String serviceName, String componentName, String metricType)
   throws AmbariException {
-    
+
     ServiceInfo svc = getService(stackName, stackVersion, serviceName);
-    
+
     if (null == svc.getMetricsFile() || !svc.getMetricsFile().exists()) {
       LOG.debug("Metrics file for " + stackName + "/" + stackVersion + "/" + serviceName
+ " not found.");
       return null;
     }
-    
+
     Map<String, Map<String, List<MetricDefinition>>> map = svc.getMetrics();
-    
+
     // check for cached
     if (null == map) {
       // data layout:
       // "DATANODE" -> "Component" -> [ MetricDefinition, MetricDefinition, ... ]
       //           \-> "HostComponent" -> [ MetricDefinition, ... ]
       Type type = new TypeToken<Map<String, Map<String, List<MetricDefinition>>>>(){}.getType();
-      
+
       Gson gson = new Gson();
 
       try {
         map = gson.fromJson(new FileReader(svc.getMetricsFile()), type);
-    
+
         svc.setMetrics(map);
-        
+
       } catch (Exception e) {
         LOG.error ("Could not read the metrics file", e);
         throw new AmbariException("Could not read metrics file", e);
       }
     }
-    
+
     if (map.containsKey(componentName)) {
       if (map.get(componentName).containsKey(metricType)) {
         return map.get(componentName).get(metricType);
       }
     }
-	  
+
 	  return null;
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/c9e181d2/ambari-server/src/main/python/bootstrap.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/bootstrap.py b/ambari-server/src/main/python/bootstrap.py
index 908451e..f2548a8 100755
--- a/ambari-server/src/main/python/bootstrap.py
+++ b/ambari-server/src/main/python/bootstrap.py
@@ -28,6 +28,7 @@ import os
 import subprocess
 import threading
 import traceback
+import re
 from pprint import pformat
 
 AMBARI_PASSPHRASE_VAR_NAME = "AMBARI_PASSPHRASE"
@@ -36,7 +37,7 @@ HOST_BOOTSTRAP_TIMEOUT = 300
 MAX_PARALLEL_BOOTSTRAPS = 20
 # How many seconds to wait between polling parallel bootstraps
 POLL_INTERVAL_SEC = 1
-DEBUG=False
+DEBUG = False
 PYTHON_ENV="env PYTHONPATH=$PYTHONPATH:/tmp "
 
 
@@ -138,7 +139,7 @@ class Bootstrap(threading.Thread):
   """ Bootstrap the agent on a separate host"""
   TEMP_FOLDER = "/tmp"
   OS_CHECK_SCRIPT_FILENAME = "os_check_type.py"
-  AMBARI_REPO_FILENAME = "ambari.repo"
+  AMBARI_REPO_FILENAME = "ambari"
   SETUP_SCRIPT_FILENAME = "setupAgent.py"
   PASSWORD_FILENAME = "host_pass"
   COMMON_FUNCTIONS="/usr/lib/python2.6/site-packages/common_functions"
@@ -155,6 +156,11 @@ class Bootstrap(threading.Thread):
     self.host_log = HostLog(log_file)
     self.daemon = True
 
+    if self.is_debian():
+      self.AMBARI_REPO_FILENAME = self.AMBARI_REPO_FILENAME + ".list"
+    else:
+      self.AMBARI_REPO_FILENAME = self.AMBARI_REPO_FILENAME + ".repo"
+
 
   def getRemoteName(self, filename):
     full_name = os.path.join(self.TEMP_FOLDER, filename)
@@ -179,17 +185,23 @@ class Bootstrap(threading.Thread):
       self(obj, *args, **kwargs)
     return _call
 
-
   def is_suse(self):
     if os.path.isfile("/etc/issue"):
       if "suse" in open("/etc/issue").read().lower():
         return True
     return False
 
+  def is_debian(self):
+    if self.getServerFamily()[0] == "debian":
+      return True
+    return False
+
   def getRepoDir(self):
     """ Ambari repo file for Ambari."""
     if self.is_suse():
       return "/etc/zypp/repos.d"
+    elif self.is_debian():
+      return "/etc/apt/sources.list.d"
     else:
       return "/etc/yum.repos.d"
 
@@ -203,7 +215,7 @@ class Bootstrap(threading.Thread):
 
   def getOsCheckScriptRemoteLocation(self):
     return self.getRemoteName(self.OS_CHECK_SCRIPT_FILENAME)
-  
+
   def getCommonFunctionsRemoteLocation(self):
     return self.TEMP_FOLDER;
 
@@ -230,7 +242,7 @@ class Bootstrap(threading.Thread):
     result = scp.run()
     self.host_log.write("\n")
     return result
-  
+
   def copyCommonFunctions(self):
     # Copying the os check script file
     fileToCopy = self.COMMON_FUNCTIONS
@@ -261,6 +273,9 @@ class Bootstrap(threading.Thread):
     else:
       return self.getMoveRepoFileWithoutPasswordCommand(targetDir)
 
+  def getAptUpdateCommand(self):
+    return "apt-get update -o Dir::Etc::sourcelist=\"%s/%s\" -o API::Get::List-Cleanup=\"0\"
--no-list-cleanup" %\
+          ("sources.list.d", self.AMBARI_REPO_FILENAME)
 
   def copyNeededFiles(self):
     # Copying the files
@@ -285,6 +300,18 @@ class Bootstrap(threading.Thread):
     retcode2 = ssh.run()
     self.host_log.write("\n")
 
+    # Update repo cache for debian OS
+    if self.is_debian():
+      self.host_log.write("==========================\n")
+      self.host_log.write("Update apt cache of repository...")
+      command = self.getAptUpdateCommand()
+      ssh = SSH(params.user, params.sshkey_file, self.host, command,
+                params.bootdir, self.host_log)
+      retcode2 = ssh.run()
+      self.host_log.write("\n")
+
+
+
     self.host_log.write("==========================\n")
     self.host_log.write("Copying setup script file...")
     fileToCopy = params.setup_agent_file
@@ -345,7 +372,7 @@ class Bootstrap(threading.Thread):
     params = self.shared_state
     self.host_log.write("==========================\n")
     self.host_log.write("Running OS type check...")
-    
+
     command = "chmod a+x %s && %s %s" % \
               (self.getOsCheckScriptRemoteLocation(),
                PYTHON_ENV + self.getOsCheckScriptRemoteLocation(), params.cluster_os_type)
@@ -379,13 +406,20 @@ class Bootstrap(threading.Thread):
       doneFile.write(str(retcode))
       doneFile.close()
 
+  def getServerFamily(self):
+    '''Return server OS family and version'''
+    cot = re.search("([^\d]+)([\d]*)", self.shared_state.cluster_os_type)
+    return cot.group(1).lower(),cot.group(2).lower()
 
   def checkSudoPackage(self):
     """ Checking 'sudo' package on remote host """
     self.host_log.write("==========================\n")
     self.host_log.write("Checking 'sudo' package on remote host...")
     params = self.shared_state
-    command = "rpm -qa | grep sudo"
+    if self.getServerFamily()[0] == "debian":
+      command = "dpkg --get-selections|grep -e ^sudo"
+    else:
+      command = "rpm -qa | grep -e ^sudo"
     ssh = SSH(params.user, params.sshkey_file, self.host, command,
               params.bootdir, self.host_log,
               errorMessage="Error: Sudo command is not available. " \
@@ -606,7 +640,7 @@ def main(argv=None):
 
   if passwordFile is not None and passwordFile != 'null':
     subprocess.Popen(["chmod", "600", passwordFile], stdout=subprocess.PIPE)
-  
+
   logging.info("BootStrapping hosts " + pprint.pformat(hostList) +
                " using " + scriptDir + " cluster primary OS: " + cluster_os_type +
                " with user '" + user + "' sshKey File " + sshkey_file + " password File "
+ passwordFile +\

http://git-wip-us.apache.org/repos/asf/ambari/blob/c9e181d2/ambari-server/src/main/python/setupAgent.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/setupAgent.py b/ambari-server/src/main/python/setupAgent.py
index 69f357a..0c2851a 100755
--- a/ambari-server/src/main/python/setupAgent.py
+++ b/ambari-server/src/main/python/setupAgent.py
@@ -29,7 +29,6 @@ import threading
 import traceback
 import stat
 from pprint import pformat
-import re
 
 AMBARI_PASSPHRASE_VAR = "AMBARI_PASSPHRASE"
 
@@ -40,22 +39,33 @@ def execOsCommand(osCommand):
   ret = {"exitstatus": osStat.returncode, "log": log}
   return ret
 
+
 def is_suse():
   if os.path.isfile("/etc/issue"):
     if "suse" in open("/etc/issue").read().lower():
       return True
   return False
 
-def installAgentSuse(projectVersion):
-  """ Run zypper install and make sure the agent install alright """
-  zypperCommand = ["zypper", "install", "-y", "ambari-agent" + projectVersion]
-  return execOsCommand(zypperCommand)
+
+def is_ubuntu():
+  if os.path.isfile("/etc/issue"):
+    if "ubuntu" in open("/etc/issue").read().lower():
+      return True
+  return False
+
 
 def installAgent(projectVersion):
-  """ Run yum install and make sure the agent install alright """
+  """ Run install and make sure the agent install alright """
   # The command doesn't work with file mask ambari-agent*.rpm, so rename it on agent host
-  rpmCommand = ["yum", "-y", "install", "--nogpgcheck", "ambari-agent" + projectVersion]
-  return execOsCommand(rpmCommand)
+  if is_suse():
+    Command = ["zypper", "install", "-y", "ambari-agent-" + projectVersion]
+  elif is_ubuntu():
+    # add * to end of version in case of some test releases
+    Command = ["apt-get", "install", "-y", "--force-yes", "ambari-agent=" + projectVersion
+ "*"]
+  else:
+    Command = ["yum", "-y", "install", "--nogpgcheck", "ambari-agent-" + projectVersion]
+  return execOsCommand(Command)
+
 
 def configureAgent(server_hostname):
   """ Configure the agent so that it has all the configs knobs properly installed """
@@ -64,6 +74,7 @@ def configureAgent(server_hostname):
   execOsCommand(osCommand)
   return
 
+
 def runAgent(passPhrase, expected_hostname):
   os.environ[AMBARI_PASSPHRASE_VAR] = passPhrase
   agent_retcode = subprocess.call("/usr/sbin/ambari-agent restart --expected-hostname=" +\
@@ -82,68 +93,73 @@ def runAgent(passPhrase, expected_hostname):
       return ret['exitstatus']
 
     return agent_retcode
-  except (Exception), e:
+  except (Exception):
     return 1
 
 
 def getOptimalVersion(initialProjectVersion):
   optimalVersion = initialProjectVersion
-  if is_suse():
-    ret = findNearestAgentPackageVersionSuse(optimalVersion)
-  else:
-    ret = findNearestAgentPackageVersion(optimalVersion)
+  ret = findNearestAgentPackageVersion(optimalVersion)
 
   if ret["exitstatus"] == 0 and ret["log"][0].strip() != "" and ret["log"][0].strip() ==
initialProjectVersion:
     optimalVersion = ret["log"][0].strip()
     retcode = 0
   else:
-    if is_suse():
-        ret = getAvaliableAgentPackageVersionsSuse()
-    else:
-        ret = getAvaliableAgentPackageVersions()
+    ret = getAvaliableAgentPackageVersions()
     retcode = 1
     optimalVersion = ret["log"]
 
   return {"exitstatus": retcode, "log": optimalVersion}
 
 
-def findNearestAgentPackageVersionSuse(projectVersion):
-  if projectVersion == "":
-    projectVersion = "  "
-  zypperCommand = ["bash", "-c", "zypper search -s --match-exact ambari-agent | grep '" +
projectVersion +\
-                                 "' | cut -d '|' -f 4 | head -n1 | sed -e 's/-\w[^:]*//1'
"]
-  return execOsCommand(zypperCommand)
-
 def findNearestAgentPackageVersion(projectVersion):
   if projectVersion == "":
     projectVersion = "  "
-  yumCommand = ["bash", "-c", "yum list all ambari-agent | grep '" + projectVersion +\
+  if is_suse():
+    Command = ["bash", "-c", "zypper search -s --match-exact ambari-agent | grep '" + projectVersion
+\
+                                 "' | cut -d '|' -f 4 | head -n1 | sed -e 's/-\w[^:]*//1'
"]
+  elif is_ubuntu():
+    if projectVersion == "  ":
+      Command = ["bash", "-c", "apt-cache show ambari-agent |grep Version|cut -d ' ' -f 2|tr
-d '\\n'|sed -s 's/[-|~][A-Za-z\d]*//g'"]
+    else:
+      Command = ["bash", "-c", "apt-cache show ambari-agent |grep Version|cut -d ' ' -f 2|grep
'" +
+               projectVersion + "'|tr -d '\\n'|sed -s 's/[-|~][A-Za-z\d]*//g'"]
+  else:
+    Command = ["bash", "-c", "yum list all ambari-agent | grep '" + projectVersion +\
                               "' | sed -re 's/\s+/ /g' | cut -d ' ' -f 2 | head -n1 | sed
-e 's/-\w[^:]*//1' "]
-  return execOsCommand(yumCommand)
+  return execOsCommand(Command)
+
 
 def isAgentPackageAlreadyInstalled(projectVersion):
-    yumCommand = ["bash", "-c", "rpm -qa | grep ambari-agent"+projectVersion]
-    ret = execOsCommand(yumCommand)
+    if is_ubuntu():
+      Command = ["bash", "-c", "dpkg -s ambari-agent  2>&1|grep Version|grep " + projectVersion]
+    else:
+      Command = ["bash", "-c", "rpm -qa | grep ambari-agent-"+projectVersion]
+    ret = execOsCommand(Command)
     res = False
     if ret["exitstatus"] == 0 and ret["log"][0].strip() != "":
         res = True
     return res
 
+
 def getAvaliableAgentPackageVersions():
-    yumCommand = ["bash", "-c",
+  if is_suse():
+    Command = ["bash", "-c",
+        """zypper search -s --match-exact ambari-agent | grep ambari-agent | sed -re 's/\s+/
/g' | cut -d '|' -f 4 | tr '\\n' ', ' | sed -e 's/-\w[^:]*//1' """]
+  elif is_ubuntu():
+    Command = ["bash", "-c",
+        """apt-cache show ambari-agent|grep Version|cut -d ' ' -f 2| tr '\\n' ', '|sed -s
's/[-|~][A-Za-z\d]*//g'"""]
+  else:
+    Command = ["bash", "-c",
         """yum list all ambari-agent | grep -E '^ambari-agent' | sed -re 's/\s+/ /g' | cut
-d ' ' -f 2 | tr '\\n' ', ' | sed -e 's/-\w[^:]*//1' """]
-    return execOsCommand(yumCommand)
+  return execOsCommand(Command)
 
-def getAvaliableAgentPackageVersionsSuse():
-    yumCommand = ["bash", "-c",
-        """zypper search -s --match-exact ambari-agent | grep ambari-agent | sed -re 's/\s+/
/g' | cut -d '|' -f 4 | tr '\\n' ', ' | sed -e 's/-\w[^:]*//1' """]
-    return execOsCommand(yumCommand)
 
 def checkServerReachability(host, port):
   ret = {}
-  s = socket.socket() 
-  try: 
-   s.connect((host, port)) 
+  s = socket.socket()
+  try:
+   s.connect((host, port))
    return
   except Exception:
    ret["exitstatus"] = 1
@@ -153,8 +169,8 @@ def checkServerReachability(host, port):
    sys.exit(ret)
   pass
 
+
 def main(argv=None):
-  scriptDir = os.path.realpath(os.path.dirname(argv[0]))
   # Parse the input
   onlyargs = argv[1:]
   expected_hostname = onlyargs[0]
@@ -168,26 +184,23 @@ def main(argv=None):
     server_port = onlyargs[4]
   try:
     server_port = int(server_port)
-  except (Exception), e:
+  except (Exception):
     server_port = 8080
 
   checkServerReachability(hostname, server_port)
 
   if projectVersion is None or projectVersion == "null" or projectVersion == "{ambariVersion}"
or projectVersion == "":
+    projectVersion = ""  # fix error in error output, if projectVersion leaves None
     retcode = getOptimalVersion("")
   else:
     retcode = getOptimalVersion(projectVersion)
 
-
   if retcode["exitstatus"] == 0 and retcode["log"] != None and retcode["log"] != "" and retcode["log"][0].strip()
!= "":
-      availiableProjectVersion = "-" + retcode["log"].strip()
+      availiableProjectVersion = retcode["log"].strip()
       if not isAgentPackageAlreadyInstalled(availiableProjectVersion):
-          if is_suse():
-            ret = installAgentSuse(availiableProjectVersion)
-          else:
-            ret = installAgent(availiableProjectVersion)
-          if (not ret["exitstatus"]== 0):
-            sys.exit(ret)
+        ret = installAgent(availiableProjectVersion)
+        if (not ret["exitstatus"] == 0):
+          sys.exit(ret)
   elif retcode["exitstatus"] == 1 and retcode["log"][0].strip() != "":
       sys.exit({"exitstatus": 1, "log": "Desired version ("+projectVersion+") of ambari-agent
package"
                                         " is not available."
@@ -202,4 +215,3 @@ def main(argv=None):
 if __name__ == '__main__':
   logging.basicConfig(level=logging.DEBUG)
   main(sys.argv)
-

http://git-wip-us.apache.org/repos/asf/ambari/blob/c9e181d2/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java
index c76ab46..8c0bd65 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java
@@ -74,9 +74,9 @@ public class AmbariMetaInfoTest {
   private static final String OS_TYPE = "centos5";
   private static final String REPO_ID = "HDP-UTILS-1.1.0.15";
   private static final String PROPERTY_NAME = "hbase.regionserver.msginterval";
-  
+
   private static final String NON_EXT_VALUE = "XXX";
-  
+
   private static final int REPOS_CNT = 3;
   private static final int STACKS_NAMES_CNT = 1;
   private static final int PROPERTIES_CNT = 63;
@@ -86,7 +86,7 @@ public class AmbariMetaInfoTest {
   private final static Logger LOG =
       LoggerFactory.getLogger(AmbariMetaInfoTest.class);
   private static final String FILE_NAME = "hbase-site.xml";
-  
+
 
   @Rule
   public TemporaryFolder tmpFolder = new TemporaryFolder();
@@ -136,7 +136,7 @@ public class AmbariMetaInfoTest {
     boolean supportedStack = metaInfo.isSupportedStack(STACK_NAME_HDP,
         STACK_VERSION_HDP);
     assertTrue(supportedStack);
-    
+
     boolean notSupportedStack = metaInfo.isSupportedStack(NON_EXT_VALUE,
         NON_EXT_VALUE);
     assertFalse(notSupportedStack);
@@ -180,7 +180,7 @@ public class AmbariMetaInfoTest {
   /**
    * Method: Map<String, ServiceInfo> getServices(String stackName, String
    * version, String serviceName)
-   * @throws AmbariException 
+   * @throws AmbariException
    */
   @Test
   public void getServices() throws AmbariException {
@@ -266,11 +266,11 @@ public class AmbariMetaInfoTest {
     assertEquals(3, redhat5cnt.size());
     assertEquals(3, centos6Cnt.size());
   }
-  
-  
+
+
   @Test
   /**
-   * Make sure global mapping is avaliable when global.xml is 
+   * Make sure global mapping is avaliable when global.xml is
    * in the path.
    * @throws Exception
    */
@@ -280,7 +280,7 @@ public class AmbariMetaInfoTest {
     List<PropertyInfo> pinfo = sinfo.getProperties();
     /** check all the config knobs and make sure the global one is there **/
     boolean checkforglobal = false;
-    
+
     for (PropertyInfo pinfol: pinfo) {
       if ("global.xml".equals(pinfol.getFilename())) {
         checkforglobal = true;
@@ -299,7 +299,7 @@ public class AmbariMetaInfoTest {
     }
     Assert.assertTrue(checkforhadoopheapsize);
   }
-  
+
   @Test
   public void testMetaInfoFileFilter() throws Exception {
     String buildDir = tmpFolder.getRoot().getAbsolutePath();
@@ -322,7 +322,7 @@ public class AmbariMetaInfoTest {
     getSupportedConfigs();
     // Check .svn is not part of the stack but abcd.svn is
     Assert.assertNotNull(ambariMetaInfo.getStackInfo("abcd.svn", "001.svn"));
-    
+
     Assert.assertFalse(ambariMetaInfo.isSupportedStack(".svn", ""));
     Assert.assertFalse(ambariMetaInfo.isSupportedStack(".svn", ""));
   }
@@ -339,9 +339,9 @@ public class AmbariMetaInfoTest {
     } catch (StackAccessException e) {
       Assert.assertTrue(e instanceof StackAccessException);
     }
-    
+
   }
-  
+
   @Test
   public void testGetRepositories() throws Exception {
     List<RepositoryInfo> repositories = metaInfo.getRepositories(STACK_NAME_HDP, STACK_VERSION_HDP,
OS_TYPE);
@@ -359,7 +359,7 @@ public class AmbariMetaInfoTest {
       Assert.assertTrue(e instanceof StackAccessException);
     }
   }
-  
+
   @Test
   public void testGetService() throws Exception {
     ServiceInfo service = metaInfo.getService(STACK_NAME_HDP, STACK_VERSION_HDP, SERVICE_NAME_HDFS);
@@ -369,16 +369,16 @@ public class AmbariMetaInfoTest {
     } catch (StackAccessException e) {
       Assert.assertTrue(e instanceof StackAccessException);
     }
-    
+
   }
-  
+
   @Test
   public void testGetStacksNames() throws Exception {
     Set<Stack> stackNames = metaInfo.getStackNames();
     assertEquals(stackNames.size(), STACKS_NAMES_CNT);
     assertTrue(stackNames.contains(new Stack(STACK_NAME_HDP)));
   }
-  
+
   @Test
   public void testGetStack() throws Exception {
     Stack stack = metaInfo.getStack(STACK_NAME_HDP);
@@ -408,7 +408,7 @@ public class AmbariMetaInfoTest {
     Set<PropertyInfo> properties = metaInfo.getProperties(STACK_NAME_HDP, STACK_VERSION_HDP,
SERVICE_NAME_HDFS);
     Assert.assertEquals(properties.size(), PROPERTIES_CNT);
   }
-  
+
   @Test
   public void testGetProperty() throws Exception {
     PropertyInfo property = metaInfo.getProperty(STACK_NAME_HDP, STACK_VERSION_HDP, SERVICE_NAME_HDFS,
PROPERTY_NAME);
@@ -420,21 +420,21 @@ public class AmbariMetaInfoTest {
     } catch (StackAccessException e) {
       Assert.assertTrue(e instanceof StackAccessException);
     }
-    
+
   }
-  
+
   @Test
   public void testGetOperatingSystems() throws Exception {
     Set<OperatingSystemInfo> operatingSystems = metaInfo.getOperatingSystems(STACK_NAME_HDP,
STACK_VERSION_HDP);
     Assert.assertEquals(OS_CNT, operatingSystems.size());
   }
-  
+
   @Test
   public void testGetOperatingSystem() throws Exception {
     OperatingSystemInfo operatingSystem = metaInfo.getOperatingSystem(STACK_NAME_HDP, STACK_VERSION_HDP,
OS_TYPE);
     Assert.assertEquals(operatingSystem.getOsType(), OS_TYPE);
-    
-    
+
+
     try {
       metaInfo.getOperatingSystem(STACK_NAME_HDP, STACK_VERSION_HDP, NON_EXT_VALUE);
     } catch (StackAccessException e) {
@@ -453,6 +453,7 @@ public class AmbariMetaInfoTest {
     Assert.assertTrue(metaInfo.isOsSupported("suse11"));
     Assert.assertTrue(metaInfo.isOsSupported("sles11"));
     Assert.assertTrue(metaInfo.isOsSupported("ubuntu12"));
+    Assert.assertTrue(metaInfo.isOsSupported("debian12"));
     Assert.assertFalse(metaInfo.isOsSupported("windows"));
   }
 
@@ -622,7 +623,7 @@ public class AmbariMetaInfoTest {
     Set<PropertyInfo> properties = metaInfo.getProperties(STACK_NAME_HDP, STACK_VERSION_HDP_02,
SERVICE_NAME_HDFS);
     Assert.assertEquals(81, properties.size());
   }
-  
+
   @Test
   public void testBadStack() throws Exception {
     File stackRoot = new File("src/test/resources/bad-stacks");
@@ -634,27 +635,27 @@ public class AmbariMetaInfoTest {
       assertTrue(JAXBException.class.isInstance(e));
     }
   }
-  
+
   @Test
   public void testMetricsJson() throws Exception {
     ServiceInfo svc = metaInfo.getService(STACK_NAME_HDP, "2.0.5", "HDFS");
     Assert.assertNotNull(svc);
     Assert.assertNotNull(svc.getMetricsFile());
-    
+
     svc = metaInfo.getService(STACK_NAME_HDP, "2.0.6", "HDFS");
     Assert.assertNotNull(svc);
     Assert.assertNotNull(svc.getMetricsFile());
-    
+
     List<MetricDefinition> list = metaInfo.getMetrics(STACK_NAME_HDP, "2.0.5", "HDFS",
"NAMENODE", "Component");
     Assert.assertNotNull(list);
-    
+
     list = metaInfo.getMetrics(STACK_NAME_HDP, "2.0.5", "HDFS", "DATANODE", "Component");
     Assert.assertNull(list);
-    
+
     List<MetricDefinition> list0 = metaInfo.getMetrics(STACK_NAME_HDP, "2.0.5", "HDFS",
"DATANODE", "Component");
     Assert.assertNull(list0);
     Assert.assertTrue("Expecting subsequent calls to use a cached value for the definition",
list == list0);
-    
+
 
     // not explicitly defined, uses 2.0.5
     list = metaInfo.getMetrics(STACK_NAME_HDP, "2.0.6", "HDFS", "DATANODE", "Component");
@@ -1254,16 +1255,16 @@ public class AmbariMetaInfoTest {
     }
     return null;
   }
-  
+
   @Test
   public void testCustomConfigDir() throws Exception {
-    
+
     ServiceInfo service = metaInfo.getService(STACK_NAME_HDP, "2.0.7", "MAPREDUCE2");
 
     // assert that the property was found in a differently-named directory
     // cannot check the dirname itself since extended stacks won't carry over
     // the name
-    
+
     boolean found = false;
     for (PropertyInfo pi : service.getProperties()) {
       if (pi.getName().equals("mr2-prop")) {
@@ -1271,13 +1272,13 @@ public class AmbariMetaInfoTest {
         found = true;
       }
     }
-    
+
     Assert.assertTrue(found);
   }
 
   @Test
   public void testLatestRepo() throws Exception {
-    
+
     for (RepositoryInfo ri : metaInfo.getRepositories("HDP", "2.1.1", "centos6")) {
       Assert.assertEquals(
           "Expected the base url to be set properly",
@@ -1288,7 +1289,7 @@ public class AmbariMetaInfoTest {
           "http://public-repo-1.hortonworks.com/HDP/centos6/2.x/updates/2.0.6.0",
           ri.getDefaultBaseUrl());
     }
-    
+
     for (RepositoryInfo ri : metaInfo.getRepositories("HDP", "2.1.1", "suse11")) {
       Assert.assertEquals(
           "Expected hdp.json to be stripped from the url",
@@ -1300,8 +1301,8 @@ public class AmbariMetaInfoTest {
       Assert.assertEquals("http://s3.amazonaws.com/dev.hortonworks.com/HDP/suse11/2.x/BUILDS/2.1.1.0-118",
           ri.getLatestBaseUrl());
     }
-    
-    
+
+
   }
 
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/c9e181d2/ambari-server/src/test/python/TestBootstrap.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/TestBootstrap.py b/ambari-server/src/test/python/TestBootstrap.py
index 88ff3c2..bae5c1e 100644
--- a/ambari-server/src/test/python/TestBootstrap.py
+++ b/ambari-server/src/test/python/TestBootstrap.py
@@ -520,10 +520,11 @@ class TestBootstrap(TestCase):
       self.assertEqual(res, str(expected))
     os.unlink(done_file)
 
+  @patch.object(Bootstrap, "getServerFamily")
   @patch.object(SSH, "__init__")
   @patch.object(SSH, "run")
   @patch.object(HostLog, "write")
-  def test_checkSudoPackage(self, write_mock, run_mock, init_mock):
+  def test_checkSudoPackage(self, write_mock, run_mock, init_mock, server_family_mock):
     shared_state = SharedState("root", "sshkey_file", "scriptDir", "bootdir",
                                "setupAgentFile", "ambariServer", "centos6",
                                None, "8440")
@@ -531,10 +532,29 @@ class TestBootstrap(TestCase):
     expected = 42
     init_mock.return_value = None
     run_mock.return_value = expected
+    server_family_mock.return_value = ["centos", "6"]
     res = bootstrap_obj.checkSudoPackage()
     self.assertEquals(res, expected)
     command = str(init_mock.call_args[0][3])
-    self.assertEqual(command, "rpm -qa | grep sudo")
+    self.assertEqual(command, "rpm -qa | grep -e ^sudo")
+
+  @patch.object(Bootstrap, "getServerFamily")
+  @patch.object(SSH, "__init__")
+  @patch.object(SSH, "run")
+  @patch.object(HostLog, "write")
+  def test_checkSudoPackageDebian(self, write_mock, run_mock, init_mock, server_family_mock):
+    shared_state = SharedState("root", "sshkey_file", "scriptDir", "bootdir",
+                               "setupAgentFile", "ambariServer", "debian12",
+                               None, "8440")
+    bootstrap_obj = Bootstrap("hostname", shared_state)
+    expected = 42
+    init_mock.return_value = None
+    run_mock.return_value = expected
+    server_family_mock.return_value = ["debian", "12"]
+    res = bootstrap_obj.checkSudoPackage()
+    self.assertEquals(res, expected)
+    command = str(init_mock.call_args[0][3])
+    self.assertEqual(command, "dpkg --get-selections|grep -e ^sudo")
 
 
   @patch.object(SSH, "__init__")

http://git-wip-us.apache.org/repos/asf/ambari/blob/c9e181d2/ambari-server/src/test/python/TestSetupAgent.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/TestSetupAgent.py b/ambari-server/src/test/python/TestSetupAgent.py
index b9c6056..35edadf 100644
--- a/ambari-server/src/test/python/TestSetupAgent.py
+++ b/ambari-server/src/test/python/TestSetupAgent.py
@@ -81,59 +81,93 @@ class TestSetupAgent(TestCase):
     self.assertEqual(ret, 2)
 
 
-  @patch.object(setup_agent, 'getAvaliableAgentPackageVersionsSuse')
+  @patch.object(setup_agent, 'getAvaliableAgentPackageVersions')
   @patch.object(setup_agent, 'is_suse')
-  @patch.object(setup_agent, 'findNearestAgentPackageVersionSuse')
+  @patch.object(setup_agent, 'is_ubuntu')
   @patch.object(setup_agent, 'findNearestAgentPackageVersion')
-  def test_returned_optimal_version_is_initial_on_suse(self, findNearestAgentPackageVersion_method,
-                                                       findNearestAgentPackageVersionSuse_method,
-                                                       is_suse_method, getAvaliableAgentPackageVersionsSuse_method):
-    getAvaliableAgentPackageVersionsSuse_method.return_value = {"exitstatus": 0, "log": "1.1.1"}
+  def test_returned_optimal_version_is_initial_on_suse(self, findNearestAgentPackageVersion_method,
is_ubuntu_mock,
+                                                       is_suse_method, getAvaliableAgentPackageVersions_method):
+    getAvaliableAgentPackageVersions_method.return_value = {"exitstatus": 0, "log": "1.1.1"}
     is_suse_method.return_value = True
+    is_ubuntu_mock.return_value = False
 
     projectVersion = "1.1.1"
     result_version = setup_agent.getOptimalVersion(projectVersion)
-    self.assertTrue(findNearestAgentPackageVersionSuse_method.called)
-    self.assertFalse(findNearestAgentPackageVersion_method.called)
+    self.assertTrue(findNearestAgentPackageVersion_method.called)
     self.assertTrue(result_version["exitstatus"] == 1)
     pass
 
+  @patch.object(setup_agent, 'getAvaliableAgentPackageVersions')
   @patch.object(setup_agent, 'is_suse')
-  @patch.object(setup_agent, 'findNearestAgentPackageVersionSuse')
+  @patch.object(setup_agent, 'is_ubuntu')
+  @patch.object(setup_agent, 'findNearestAgentPackageVersion')
+  def test_returned_optimal_version_is_initial_on_ubuntu(self, findNearestAgentPackageVersion_method,
is_ubuntu_mock,
+                                                       is_suse_method, getAvaliableAgentPackageVersions_method):
+    getAvaliableAgentPackageVersions_method.return_value = {"exitstatus": 0, "log": "1.1.1"}
+    is_suse_method.return_value = False
+    is_ubuntu_mock.return_value = True
+
+    projectVersion = "1.1.1"
+    result_version = setup_agent.getOptimalVersion(projectVersion)
+    self.assertTrue(findNearestAgentPackageVersion_method.called)
+    self.assertTrue(result_version["exitstatus"] == 1)
+    pass
+
+  @patch.object(setup_agent, 'is_suse')
+  @patch.object(setup_agent, 'is_ubuntu')
   @patch.object(setup_agent, 'findNearestAgentPackageVersion')
   def test_returned_optimal_version_is_nearest_on_suse(self, findNearestAgentPackageVersion_method,
-                                                       findNearestAgentPackageVersionSuse_method,
+                                                       is_ubuntu_method,
                                                        is_suse_method):
     is_suse_method.return_value = True
+    is_ubuntu_method.return_value = False
 
     projectVersion = ""
     nearest_version = projectVersion + "1.1.1"
-    findNearestAgentPackageVersionSuse_method.return_value = {
+    findNearestAgentPackageVersion_method.return_value = {
       "exitstatus" : 0,
       "log": [nearest_version, ""]
     }
 
     result_version = setup_agent.getOptimalVersion(projectVersion)
-
-    self.assertTrue(findNearestAgentPackageVersionSuse_method.called)
-    self.assertFalse(findNearestAgentPackageVersion_method.called)
+    self.assertTrue(findNearestAgentPackageVersion_method.called)
     self.assertTrue(result_version["exitstatus"] == 1)
     pass
 
+  @patch.object(setup_agent, 'is_suse')
+  @patch.object(setup_agent, 'is_ubuntu')
+  @patch.object(setup_agent, 'findNearestAgentPackageVersion')
+  def test_returned_optimal_version_is_nearest_on_ubuntu(self, findNearestAgentPackageVersion_method,
+                                                       is_ubuntu_method,
+                                                       is_suse_method):
+    is_suse_method.return_value = False
+    is_ubuntu_method.return_value = True
+
+    projectVersion = ""
+    nearest_version = projectVersion + "1.1.1"
+    findNearestAgentPackageVersion_method.return_value = {
+      "exitstatus" : 0,
+      "log": [nearest_version, ""]
+    }
+
+    result_version = setup_agent.getOptimalVersion(projectVersion)
+    self.assertTrue(findNearestAgentPackageVersion_method.called)
+    self.assertTrue(result_version["exitstatus"] == 1)
+    pass
 
   @patch.object(setup_agent, 'getAvaliableAgentPackageVersions')
   @patch.object(setup_agent, 'is_suse')
-  @patch.object(setup_agent, 'findNearestAgentPackageVersionSuse')
+  @patch.object(setup_agent, 'is_ubuntu')
   @patch.object(setup_agent, 'findNearestAgentPackageVersion')
   def test_returned_optimal_version_is_initial(self, findNearestAgentPackageVersion_method,
-                                               findNearestAgentPackageVersionSuse_method,
+                                               is_ubuntu_method,
                                                is_suse_method, getAvaliableAgentPackageVersions_method):
     getAvaliableAgentPackageVersions_method.return_value = {"exitstatus": 0, "log": "1.1.1"}
     is_suse_method.return_value = False
+    is_ubuntu_method.return_value = False
 
     projectVersion = "1.1.1"
     result_version = setup_agent.getOptimalVersion(projectVersion)
-    self.assertFalse(findNearestAgentPackageVersionSuse_method.called)
     self.assertTrue(findNearestAgentPackageVersion_method.called)
     self.assertTrue(result_version["log"] == projectVersion)
     pass
@@ -141,13 +175,14 @@ class TestSetupAgent(TestCase):
 
   @patch.object(setup_agent, 'getAvaliableAgentPackageVersions')
   @patch.object(setup_agent, 'is_suse')
-  @patch.object(setup_agent, 'findNearestAgentPackageVersionSuse')
+  @patch.object(setup_agent, 'is_ubuntu')
   @patch.object(setup_agent, 'findNearestAgentPackageVersion')
   def test_returned_optimal_version_is_default(self, findNearestAgentPackageVersion_method,
-                                               findNearestAgentPackageVersionSuse_method,
+                                               is_ubuntu_method,
                                                is_suse_method, getAvaliableAgentPackageVersions_method):
     getAvaliableAgentPackageVersions_method.return_value = {"exitstatus": 0, "log": "1.1.1"}
     is_suse_method.return_value = False
+    is_ubuntu_method.return_value = False
     findNearestAgentPackageVersion_method.return_value = {
       "exitstatus" : 0,
       "log": ["1.1.1.1", ""]
@@ -156,7 +191,6 @@ class TestSetupAgent(TestCase):
     projectVersion = "1.1.1"
     result_version = setup_agent.getOptimalVersion(projectVersion)
 
-    self.assertFalse(findNearestAgentPackageVersionSuse_method.called)
     self.assertTrue(findNearestAgentPackageVersion_method.called)
     self.assertTrue(result_version["exitstatus"] == 1)
 
@@ -173,27 +207,30 @@ class TestSetupAgent(TestCase):
     f.read.return_value = " suse "
     self.assertTrue(setup_agent.is_suse())
 
-  @patch.object(subprocess, 'Popen')
-  def test_installAgentSuse(self, Popen_mock):
-    self.assertFalse(setup_agent.installAgentSuse("1") == None)
+  @patch("os.path.isfile")
+  @patch("__builtin__.open")
+  def test_is_ubuntu(self, open_mock, isfile_mock):
+    isfile_mock.return_value = True
+    f = open_mock.return_value
+    f.read.return_value = " ubuntu "
+    self.assertTrue(setup_agent.is_ubuntu())
 
   @patch.object(setup_agent, 'isAgentPackageAlreadyInstalled')
   @patch.object(setup_agent, 'runAgent')
   @patch.object(setup_agent, 'configureAgent')
   @patch.object(setup_agent, 'installAgent')
-  @patch.object(setup_agent, 'installAgentSuse')
   @patch.object(setup_agent, 'is_suse')
+  @patch.object(setup_agent, 'is_ubuntu')
   @patch.object(setup_agent, 'getOptimalVersion')
   @patch.object(setup_agent, 'checkServerReachability')
   @patch("sys.exit")
   @patch("os.path.dirname")
   @patch("os.path.realpath")
   def test_setup_agent_main(self, dirname_mock, realpath_mock, exit_mock, checkServerReachability_mock,
-                            getOptimalVersion_mock, is_suse_mock, installAgentSuse_mock,
+                            getOptimalVersion_mock, is_ubuntu_mock, is_suse_mock,
                             installAgent_mock, configureAgent_mock, runAgent_mock,
                             isAgentPackageAlreadyInstalled_mock):
     installAgent_mock.return_value = {'log': 'log', 'exitstatus': 0}
-    installAgentSuse_mock.return_value = {'log': 'log', 'exitstatus': 0}
     runAgent_mock.return_value = 0
     getOptimalVersion_mock.return_value = {'log': '1.1.2, 1.1.3, ', 'exitstatus': 1}
     setup_agent.main(("setupAgent.py","agents_host","password", "server_hostname","1.1.1","8080"))
@@ -201,21 +238,23 @@ class TestSetupAgent(TestCase):
     self.assertTrue(getOptimalVersion_mock.called)
     exit_mock.reset_mock()
     getOptimalVersion_mock.reset_mock()
+
     getOptimalVersion_mock.return_value = {'log': '1.1.1', 'exitstatus': 0}
     isAgentPackageAlreadyInstalled_mock.return_value = False
     is_suse_mock.return_value = True
+    is_ubuntu_mock.return_value = False
     setup_agent.main(("setupAgent.py","agents_host","password", "server_hostname","1.1.1","8080"))
     self.assertTrue(exit_mock.called)
     self.assertTrue(getOptimalVersion_mock.called)
     self.assertTrue(isAgentPackageAlreadyInstalled_mock.called)
-    self.assertTrue(is_suse_mock.called)
-    self.assertTrue(installAgentSuse_mock.called)
-    self.assertFalse(installAgent_mock.called)
+    self.assertTrue(installAgent_mock.called)
+    self.assertFalse(is_suse_mock.called)
+    self.assertFalse(is_ubuntu_mock.called)
     exit_mock.reset_mock()
     getOptimalVersion_mock.reset_mock()
     isAgentPackageAlreadyInstalled_mock.reset_mock()
     is_suse_mock.reset_mock()
-    installAgentSuse_mock.reset_mock()
+    is_ubuntu_mock.reset_mock()
     installAgent_mock.reset_mock()
 
     getOptimalVersion_mock.return_value = {'log': '', 'exitstatus': 0}
@@ -224,23 +263,25 @@ class TestSetupAgent(TestCase):
     self.assertTrue(getOptimalVersion_mock.called)
     self.assertFalse(isAgentPackageAlreadyInstalled_mock.called)
     self.assertFalse(is_suse_mock.called)
-    self.assertFalse(installAgentSuse_mock.called)
+    self.assertFalse(is_ubuntu_mock.called)
+
     exit_mock.reset_mock()
     getOptimalVersion_mock.reset_mock()
     isAgentPackageAlreadyInstalled_mock.reset_mock()
     is_suse_mock.reset_mock()
-    installAgentSuse_mock.reset_mock()
+    is_ubuntu_mock.reset_mock()
     installAgent_mock.reset_mock()
 
-
     is_suse_mock.return_value = False
+    is_ubuntu_mock.return_value = False
     getOptimalVersion_mock.return_value = {'log': '1.1.1', 'exitstatus': 0}
     setup_agent.main(("setupAgent.py","agents_host","password", "server_hostname","1.1.1","8080"))
     self.assertTrue(exit_mock.called)
     self.assertTrue(getOptimalVersion_mock.called)
     self.assertTrue(isAgentPackageAlreadyInstalled_mock.called)
-    self.assertTrue(is_suse_mock.called)
     self.assertTrue(installAgent_mock.called)
+    self.assertFalse(is_suse_mock.called)
+    self.assertFalse(is_ubuntu_mock.called)
     exit_mock.reset_mock()
     getOptimalVersion_mock.reset_mock()
     isAgentPackageAlreadyInstalled_mock.reset_mock()
@@ -248,7 +289,7 @@ class TestSetupAgent(TestCase):
     getOptimalVersion_mock.reset_mock()
     isAgentPackageAlreadyInstalled_mock.reset_mock()
     is_suse_mock.reset_mock()
-    installAgentSuse_mock.reset_mock()
+    is_ubuntu_mock.reset_mock()
     installAgent_mock.reset_mock()
 
     setup_agent.main(("setupAgent.py","agents_host","password", "server_hostname","{ambariVersion}","8080"))
@@ -261,6 +302,7 @@ class TestSetupAgent(TestCase):
     self.assertTrue(getOptimalVersion_mock.called)
     exit_mock.reset_mock()
     is_suse_mock.return_value = False
+    is_ubuntu_mock.return_value = False
     setup_agent.main(("setupAgent.py","agents_host","password", "server_hostname","null","null"))
     self.assertTrue(exit_mock.called)
     exit_mock.reset_mock()
@@ -276,11 +318,13 @@ class TestSetupAgent(TestCase):
         # Expected
         pass
     self.assertTrue(exit_mock.called)
+    installAgent_mock.reset_mock()
     exit_mock.reset_mock()
     #if suse
     is_suse_mock.return_value = True
+    is_ubuntu_mock.return_value = False
     #if "zypper install -y ambari-agent" return not 0 result
-    installAgentSuse_mock.return_value = {'log': 'log', 'exitstatus': 1}
+    installAgent_mock.return_value = {'log': 'log', 'exitstatus': 1}
     try:
         setup_agent.main(("setupAgent.py","agents_host","password", "server_hostname","1.1.1","8080"))
         self.fail("Should throw exception")
@@ -288,15 +332,19 @@ class TestSetupAgent(TestCase):
         # Expected
         pass
     self.assertTrue(exit_mock.called)
+    exit_mock.reset_mock()
+    #if ubuntu
+    is_suse_mock.return_value = False
+    is_ubuntu_mock.return_value = True
 
-
-  @patch.object(setup_agent, 'execOsCommand')
-  def test_findNearestAgentPackageVersionSuse(self, execOsCommand_mock):
-      setup_agent.findNearestAgentPackageVersionSuse("1.1.1")
-      self.assertTrue(execOsCommand_mock.called)
-      execOsCommand_mock.reset_mock()
-      setup_agent.findNearestAgentPackageVersionSuse("")
-      self.assertTrue(execOsCommand_mock.called)
+    installAgent_mock.return_value = {'log': 'log', 'exitstatus': 1}
+    try:
+        setup_agent.main(("setupAgent.py","agents_host","password", "server_hostname","1.1.1","8080"))
+        self.fail("Should throw exception")
+    except Exception:
+        # Expected
+        pass
+    self.assertTrue(exit_mock.called)
 
   @patch.object(setup_agent, 'execOsCommand')
   def test_findNearestAgentPackageVersion(self, execOsCommand_mock):
@@ -322,11 +370,6 @@ class TestSetupAgent(TestCase):
       self.assertTrue(execOsCommand_mock.called)
 
   @patch.object(setup_agent, 'execOsCommand')
-  def test_getAvaliableAgentPackageVersionsSuse(self, execOsCommand_mock):
-      setup_agent.getAvaliableAgentPackageVersionsSuse()
-      self.assertTrue(execOsCommand_mock.called)
-
-  @patch.object(setup_agent, 'execOsCommand')
   def test_installAgent(self, execOsCommand_mock):
     setup_agent.installAgent("1.1.1")
-    self.assertTrue(execOsCommand_mock.called)
\ No newline at end of file
+    self.assertTrue(execOsCommand_mock.called)


Mime
View raw message