ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fba...@apache.org
Subject [3/3] ambari git commit: AMBARI-12211 Windows unit tests: Server unit tests: adapt the existing unit tests to Windows
Date Fri, 24 Jul 2015 18:05:14 GMT
AMBARI-12211 Windows unit tests: Server unit tests: adapt the existing unit tests to Windows

Fixed the platform-specific Python and Java tests. Fixed file handle leaks in serverConfiguration.py.
Added profile to help suppress Python tests execution.


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

Branch: refs/heads/trunk
Commit: 03a927ddb2fca9c2984e554361ff98cd0fc1f8b0
Parents: 17ac0d6
Author: Florian Barca <fbarca@hortonworks.com>
Authored: Thu Jul 23 11:25:00 2015 -0700
Committer: Florian Barca <fbarca@hortonworks.com>
Committed: Fri Jul 24 11:03:38 2015 -0700

----------------------------------------------------------------------
 .../main/python/ambari_commons/os_windows.py    |    4 +-
 .../src/test/python/only_for_platform.py        |    7 +-
 ambari-server/pom.xml                           |   16 +-
 ambari-server/src/main/python/ambari-server.py  |   29 +-
 .../python/ambari_server/dbConfiguration.py     |    3 +
 .../python/ambari_server/serverConfiguration.py |   49 +-
 .../main/python/ambari_server/setupSecurity.py  |    2 +-
 ambari-server/src/main/python/setupAgent.py     |    2 +-
 .../ambari/server/bootstrap/BootStrapTest.java  |   22 +-
 .../ClientConfigResourceProviderTest.java       |   26 +-
 .../CreateKeytabFilesServerActionTest.java      |    5 +
 .../src/test/python/TestAmbariServer.py         | 1797 +++++++++++++++---
 ambari-server/src/test/python/TestOSCheck.py    |   17 +-
 .../src/test/python/TestResourceFilesKeeper.py  |   66 +-
 ambari-server/src/test/python/TestSetupAgent.py |   91 +-
 ambari-server/src/test/python/TestUtils.py      |    5 +-
 .../src/test/python/TestValidateConfigs.py      |    1 +
 .../test/python/custom_actions/TestCheckHost.py |   66 +-
 .../custom_actions/TestInstallPackages.py       |    1 +
 .../custom_actions/test_ru_execute_tasks.py     |   41 +-
 ambari-server/src/test/python/unitTests.py      |    6 +-
 21 files changed, 1857 insertions(+), 399 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/03a927dd/ambari-common/src/main/python/ambari_commons/os_windows.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/ambari_commons/os_windows.py b/ambari-common/src/main/python/ambari_commons/os_windows.py
index a826eef..058dbfd 100644
--- a/ambari-common/src/main/python/ambari_commons/os_windows.py
+++ b/ambari-common/src/main/python/ambari_commons/os_windows.py
@@ -532,8 +532,8 @@ class WinServiceController:
         win32serviceutil.StopServiceWithDeps(serviceName, waitSecs=waitSecs)
       else:
         win32serviceutil.StopService(serviceName)
-        if waitSecs:
-          win32serviceutil.WaitForServiceStatus(serviceName, win32service.SERVICE_STOPPED,
waitSecs)
+      if waitSecs:
+        win32serviceutil.WaitForServiceStatus(serviceName, win32service.SERVICE_STOPPED,
waitSecs)
     except win32service.error, exc:
       if exc.winerror != 1062:
         msg = "Error stopping service: %s (%d)" % (exc.strerror, exc.winerror)

http://git-wip-us.apache.org/repos/asf/ambari/blob/03a927dd/ambari-common/src/test/python/only_for_platform.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/test/python/only_for_platform.py b/ambari-common/src/test/python/only_for_platform.py
index fba2771..cc2d13e 100644
--- a/ambari-common/src/test/python/only_for_platform.py
+++ b/ambari-common/src/test/python/only_for_platform.py
@@ -46,7 +46,10 @@ def for_specific_platforms(systems):
       return obj
   return decorator
 
+os_distro_value_linux = ('Suse','11','Final')
+os_distro_value_windows = ('win2012serverr2','6.3','WindowsServer')
+
 if get_platform() != PLATFORM_WINDOWS:
-  os_distro_value = ('Suse','11','Final')
+  os_distro_value = os_distro_value_linux
 else:
-  os_distro_value = ('win2012serverr2','6.3','WindowsServer')
+  os_distro_value = os_distro_value_windows

http://git-wip-us.apache.org/repos/asf/ambari/blob/03a927dd/ambari-server/pom.xml
----------------------------------------------------------------------
diff --git a/ambari-server/pom.xml b/ambari-server/pom.xml
index 7d5575a..717d331 100644
--- a/ambari-server/pom.xml
+++ b/ambari-server/pom.xml
@@ -41,6 +41,7 @@
     <ambari-admin-dir>${basedir}/../ambari-admin</ambari-admin-dir>
     <contrib-views-dir>${basedir}/../contrib/views</contrib-views-dir>
     <powermock.version>1.5</powermock.version>
+    <skipPythonTests>false</skipPythonTests>
   </properties>
   <build>
     <plugins>
@@ -1217,7 +1218,7 @@
               <environmentVariables>
                   <PYTHONPATH>${path.python.1}${pathsep}$PYTHONPATH</PYTHONPATH>
               </environmentVariables>
-              <skip>${skipTests}</skip>
+              <skip>${skipPythonTests}</skip>
             </configuration>
             <id>python-test</id>
             <phase>test</phase>
@@ -1365,6 +1366,17 @@
       </build>
     </profile>
     <profile>
+      <id>skipTestRun</id>
+      <activation>
+        <property>
+          <name>skipTests</name>
+        </property>
+      </activation>
+      <properties>
+        <skipPythonTests>true</skipPythonTests>
+      </properties>
+    </profile>
+    <profile>
       <id>windows</id>
       <activation>
         <os>
@@ -1379,7 +1391,7 @@
         <executable.shell>cmd</executable.shell>
         <fileextension.shell>cmd</fileextension.shell>
         <fileextension.dot.shell-default>.cmd</fileextension.dot.shell-default>
-        <path.python.1>${project.basedir}\..\ambari-common\src\main\python;${project.basedir}\..\ambari-agent\src\main\python;${project.basedir}\..\ambari-common\src\main\python\ambari_jinja2;${project.basedir}\..\ambari-common\src\main\python\ambari_commons;${project.basedir}\..\ambari-common\src\test\python;${project.basedir}\src\main\python;${project.basedir}\src\main\python\ambari-server-state;${project.basedir}\src\main\resources\custom_actions;${project.basedir}\src\main\resources\scripts;${project.basedir}\src\test\python</path.python.1>
+        <path.python.1>${project.basedir}\..\ambari-common\src\main\python;${project.basedir}\..\ambari-agent\src\main\python;${project.basedir}\..\ambari-common\src\main\python\ambari_jinja2;${project.basedir}\..\ambari-common\src\main\python\ambari_commons;${project.basedir}\..\ambari-common\src\test\python;${project.basedir}\src\main\python;${project.basedir}\src\main\python\ambari-server-state;${project.basedir}\src\main\resources\custom_actions\scripts;${project.basedir}\src\main\resources\scripts;${project.basedir}\src\test\python</path.python.1>
         <assemblydescriptor>src/main/assemblies/server-windows.xml</assemblydescriptor>
         <assemblybootstrap>src/main/assemblies/bootstrap-windows.xml</assemblybootstrap>
         <assemblychocodescriptor>src/main/assemblies/server-windows-choco.xml</assemblychocodescriptor>

http://git-wip-us.apache.org/repos/asf/ambari/blob/03a927dd/ambari-server/src/main/python/ambari-server.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/ambari-server.py b/ambari-server/src/main/python/ambari-server.py
index 1b02162..b9ca331 100755
--- a/ambari-server/src/main/python/ambari-server.py
+++ b/ambari-server/src/main/python/ambari-server.py
@@ -433,6 +433,7 @@ def init_debug(options):
 
 @OsFamilyFuncImpl(OSConst.WINSRV_FAMILY)
 def fix_database_options(options, parser):
+  _validate_database_port(options, parser)
   pass
 
 @OsFamilyFuncImpl(OsFamilyImpl.DEFAULT)
@@ -450,18 +451,7 @@ def fix_database_options(options, parser):
   elif options.dbms is not None:
     options.dbms = options.dbms.lower()
 
-  # correct port
-  if options.database_port is not None:
-    correct = False
-    try:
-      port = int(options.database_port)
-      if 65536 > port > 0:
-        correct = True
-    except ValueError:
-      pass
-    if not correct:
-      parser.print_help()
-      parser.error("Incorrect database port " + options.database_port)
+  _validate_database_port(options, parser)
 
   # jdbc driver and db options validation
   if options.jdbc_driver is None and options.jdbc_db is not None:
@@ -477,6 +467,21 @@ def fix_database_options(options, parser):
     options.sid_or_sname = options.sid_or_sname.lower()
 
 
+def _validate_database_port(options, parser):
+  # correct port
+  if options.database_port is not None:
+    correct = False
+    try:
+      port = int(options.database_port)
+      if 65536 > port > 0:
+        correct = True
+    except ValueError:
+      pass
+    if not correct:
+      parser.print_help()
+      parser.error("Incorrect database port " + options.database_port)
+
+
 @OsFamilyFuncImpl(OSConst.WINSRV_FAMILY)
 def create_user_action_map(args, options):
   action_map = {

http://git-wip-us.apache.org/repos/asf/ambari/blob/03a927dd/ambari-server/src/main/python/ambari_server/dbConfiguration.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/ambari_server/dbConfiguration.py b/ambari-server/src/main/python/ambari_server/dbConfiguration.py
index fa8d6e3..3d93002 100644
--- a/ambari-server/src/main/python/ambari_server/dbConfiguration.py
+++ b/ambari-server/src/main/python/ambari_server/dbConfiguration.py
@@ -276,6 +276,9 @@ class DBMSConfigFactory(object):
   def get_supported_dbms(self):
     return []
 
+  def get_supported_jdbc_drivers(self):
+    return []
+
 #
 # Database configuration factory for Windows
 #

http://git-wip-us.apache.org/repos/asf/ambari/blob/03a927dd/ambari-server/src/main/python/ambari_server/serverConfiguration.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/ambari_server/serverConfiguration.py b/ambari-server/src/main/python/ambari_server/serverConfiguration.py
index 88683e4..d9fc0ba 100644
--- a/ambari-server/src/main/python/ambari_server/serverConfiguration.py
+++ b/ambari-server/src/main/python/ambari_server/serverConfiguration.py
@@ -411,7 +411,8 @@ def get_ambari_properties():
   properties = None
   try:
     properties = Properties()
-    properties.load(open(conf_file))
+    with open(conf_file) as hfR:
+      properties.load(hfR)
   except (Exception), e:
     print 'Could not read "%s": %s' % (conf_file, e)
     return -1
@@ -571,7 +572,8 @@ def update_database_name_property(upgrade=False):
     properties.process_pair(JDBC_DATABASE_NAME_PROPERTY, configDefaults.DEFAULT_DB_NAME)
     conf_file = find_properties_file()
     try:
-      properties.store(open(conf_file, "w"))
+      with open(conf_file, "w") as hfW:
+        properties.store(hfW)
     except Exception, e:
       err = 'Could not write ambari config file "%s": %s' % (conf_file, e)
       raise FatalException(-1, err)
@@ -631,9 +633,8 @@ def read_passwd_for_alias(alias, masterKey=""):
     tempDir = tempfile.gettempdir()
     #create temporary file for writing
     tempFilePath = tempDir + os.sep + tempFileName
-    file = open(tempFilePath, 'w+')
-    os.chmod(tempFilePath, stat.S_IREAD | stat.S_IWRITE)
-    file.close()
+    with open(tempFilePath, 'w+'):
+      os.chmod(tempFilePath, stat.S_IREAD | stat.S_IWRITE)
 
     if masterKey is None or masterKey == "":
       masterKey = "None"
@@ -646,7 +647,8 @@ def read_passwd_for_alias(alias, masterKey=""):
     if retcode != 0:
       print 'ERROR: Unable to read password from store. alias = ' + alias
     else:
-      passwd = open(tempFilePath, 'r').read()
+      with open(tempFilePath, 'r') as hfRTemp:
+        passwd = hfRTemp.read()
       # Remove temporary file
     os.remove(tempFilePath)
     return passwd
@@ -783,7 +785,8 @@ def parse_properties_file(args):
   args.database_password_file = properties[JDBC_PASSWORD_PROPERTY]
   if args.database_password_file:
     if not is_alias_string(args.database_password_file):
-      args.database_password = open(properties[JDBC_PASSWORD_PROPERTY]).read()
+      with open(properties[JDBC_PASSWORD_PROPERTY]) as hfDbPwd:
+        args.database_password = hfDbPwd.read()
     else:
       args.database_password = args.database_password_file
   return 0
@@ -837,16 +840,18 @@ def update_ambari_properties():
     print_error_msg("Can't find %s file" % AMBARI_PROPERTIES_FILE)
     return -1
 
-  try:
-    old_properties = Properties()
-    old_properties.load(open(prev_conf_file))
-  except Exception, e:
-    print 'Could not read "%s": %s' % (prev_conf_file, e)
-    return -1
+  with open(prev_conf_file) as hfOld:
+    try:
+      old_properties = Properties()
+      old_properties.load(hfOld)
+    except Exception, e:
+      print 'Could not read "%s": %s' % (prev_conf_file, e)
+      return -1
 
   try:
     new_properties = Properties()
-    new_properties.load(open(conf_file))
+    with open(conf_file) as hfNew:
+      new_properties.load(hfNew)
 
     for prop_key, prop_value in old_properties.getPropertyDict().items():
       if "agent.fqdn.service.url" == prop_key:
@@ -866,7 +871,8 @@ def update_ambari_properties():
     if OS_FAMILY_PROPERTY not in new_properties.keys():
       new_properties.process_pair(OS_FAMILY_PROPERTY, OS_FAMILY + OS_VERSION)
 
-    new_properties.store(open(conf_file, 'w'))
+    with open(conf_file, 'w') as hfW:
+      new_properties.store(hfW)
 
   except Exception, e:
     print 'Could not write "%s": %s' % (conf_file, e)
@@ -874,7 +880,12 @@ def update_ambari_properties():
 
   timestamp = datetime.datetime.now()
   fmt = '%Y%m%d%H%M%S'
-  os.rename(prev_conf_file, prev_conf_file + '.' + timestamp.strftime(fmt))
+  new_conf_file = prev_conf_file + '.' + timestamp.strftime(fmt)
+  try:
+    os.rename(prev_conf_file, new_conf_file)
+  except Exception, e:
+    print 'Could not rename "%s" to "%s": %s' % (prev_conf_file, new_conf_file, e)
+    #Not critical, move on
 
   return 0
 
@@ -924,13 +935,15 @@ def write_property(key, value):
   conf_file = find_properties_file()
   properties = Properties()
   try:
-    properties.load(open(conf_file))
+    with open(conf_file, "r") as hfR:
+      properties.load(hfR)
   except Exception, e:
     print_error_msg('Could not read ambari config file "%s": %s' % (conf_file, e))
     return -1
   properties.process_pair(key, value)
   try:
-    properties.store(open(conf_file, "w"))
+    with open(conf_file, 'w') as hfW:
+      properties.store(hfW)
   except Exception, e:
     print_error_msg('Could not write ambari config file "%s": %s' % (conf_file, e))
     return -1

http://git-wip-us.apache.org/repos/asf/ambari/blob/03a927dd/ambari-server/src/main/python/ambari_server/setupSecurity.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/ambari_server/setupSecurity.py b/ambari-server/src/main/python/ambari_server/setupSecurity.py
index 6bb8e4b..f1987aa 100644
--- a/ambari-server/src/main/python/ambari_server/setupSecurity.py
+++ b/ambari-server/src/main/python/ambari_server/setupSecurity.py
@@ -555,7 +555,7 @@ def init_ldap_properties_list_reqd(properties):
     LdapPropTemplate(properties, "authentication.ldap.usernameAttribute", "User name attribute*
{0}: ", REGEX_ANYTHING, False, "uid"),
     LdapPropTemplate(properties, "authentication.ldap.baseDn", "Base DN* {0}: ", REGEX_ANYTHING,
False),
     LdapPropTemplate(properties, "authentication.ldap.referral", "Referral method [follow/ignore]
{0}: ", REGEX_REFERRAL, True),
-    LdapPropTemplate(properties, "authentication.ldap.bindAnonymously" "Bind anonymously*
[true/false] {0}: ", REGEX_TRUE_FALSE, False, "false")
+    LdapPropTemplate(properties, "authentication.ldap.bindAnonymously", "Bind anonymously*
[true/false] {0}: ", REGEX_TRUE_FALSE, False, "false")
   ]
   return ldap_properties
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/03a927dd/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 459276d..033a370 100755
--- a/ambari-server/src/main/python/setupAgent.py
+++ b/ambari-server/src/main/python/setupAgent.py
@@ -206,7 +206,7 @@ def checkVerbose():
 def getOptimalVersion(initialProjectVersion):
   optimalVersion = initialProjectVersion
   ret = findNearestAgentPackageVersion(optimalVersion)
-  if ret["exitstatus"] == 0 and ret["log"][0].strip() != "" \
+  if ret["exitstatus"] == 0 and ret["log"][0].strip() != "" and initialProjectVersion \
      and ret["log"][0].strip().startswith(initialProjectVersion):
     optimalVersion = ret["log"][0].strip()
     retcode = 0

http://git-wip-us.apache.org/repos/asf/ambari/blob/03a927dd/ambari-server/src/test/java/org/apache/ambari/server/bootstrap/BootStrapTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/bootstrap/BootStrapTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/bootstrap/BootStrapTest.java
index 6d9a31e..90cb913 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/bootstrap/BootStrapTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/bootstrap/BootStrapTest.java
@@ -72,7 +72,7 @@ public class BootStrapTest extends TestCase {
     }
 
     properties.setProperty(Configuration.BOOTSTRAP_DIR, bootdir);
-    properties.setProperty(Configuration.BOOTSTRAP_SCRIPT, "echo");
+    properties.setProperty(Configuration.BOOTSTRAP_SCRIPT, prepareEchoCommand(bootdir));
     properties.setProperty(Configuration.SRVR_KSTR_DIR_KEY, "target" + File.separator + "classes");
     properties.setProperty(Configuration.METADETA_DIR_PATH, metadetadir);
     properties.setProperty(Configuration.SERVER_VERSION_FILE, serverVersionFilePath);
@@ -111,6 +111,24 @@ public class BootStrapTest extends TestCase {
     Assert.assertFalse(new File(bootdir + File.separator + "1" + File.separator + "host_pass").exists());
   }
 
+  private static String prepareEchoCommand(String bootdir) throws IOException {
+    if (System.getProperty("os.name").contains("Windows")) {
+      //The command line becomes "python echo", so create a Python script in the current
dir
+      String pythonEcho = "import sys;\nif __name__ == '__main__':\n" +
+          "  args = sys.argv\n" +
+          "  if len(args) > 1:\n" +
+          "    print args[1]";
+      File echo = new File(bootdir, "echo.py");
+      //Ensure the file wasn't there
+      echo.delete();
+      FileUtils.writeStringToFile(echo, pythonEcho);
+
+      return echo.getPath();
+    } else {
+      return "echo";
+    }
+  }
+
   @Test
   public void testHostFailure() throws Exception {
     Properties properties = new Properties();
@@ -129,7 +147,7 @@ public class BootStrapTest extends TestCase {
     }
 
     properties.setProperty(Configuration.BOOTSTRAP_DIR, bootdir);
-    properties.setProperty(Configuration.BOOTSTRAP_SCRIPT, "echo");
+    properties.setProperty(Configuration.BOOTSTRAP_SCRIPT, prepareEchoCommand(bootdir));
     properties.setProperty(Configuration.SRVR_KSTR_DIR_KEY, serverKSTRDir);
     properties.setProperty(Configuration.METADETA_DIR_PATH, metadetadir);
     properties.setProperty(Configuration.SERVER_VERSION_FILE, serverVersionFilePath);

http://git-wip-us.apache.org/repos/asf/ambari/blob/03a927dd/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProviderTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProviderTest.java
index d5808d3..7643abb 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProviderTest.java
@@ -181,8 +181,8 @@ public class ClientConfigResourceProviderTest {
 
     // create the request
     Request request = PropertyHelper.getReadRequest(ClientConfigResourceProvider.COMPONENT_CLUSTER_NAME_PROPERTY_ID,
"c1",
-            ClientConfigResourceProvider.COMPONENT_COMPONENT_NAME_PROPERTY_ID,
-            ClientConfigResourceProvider.COMPONENT_SERVICE_NAME_PROPERTY_ID);
+        ClientConfigResourceProvider.COMPONENT_COMPONENT_NAME_PROPERTY_ID,
+        ClientConfigResourceProvider.COMPONENT_SERVICE_NAME_PROPERTY_ID);
 
     Predicate predicate = new PredicateBuilder().property(ClientConfigResourceProvider.COMPONENT_CLUSTER_NAME_PROPERTY_ID).equals("c1").
         toPredicate();
@@ -200,11 +200,10 @@ public class ClientConfigResourceProviderTest {
     String packageFolder="PIG/package";
 
     if (System.getProperty("os.name").contains("Windows")) {
-      stackRoot = "\\tmp\\stacks\\S1\\V1";
+      stackRoot = "C:\\tmp\\stacks\\S1\\V1";
       packageFolder = "PIG\\package";
     }
 
-    File stackRootFile = new File(stackRoot);
     HashMap<String, Host> hosts = new HashMap<String, Host>();
     hosts.put(hostName, host);
     HashMap<String, Service> services = new HashMap<String, Service>();
@@ -220,7 +219,7 @@ public class ClientConfigResourceProviderTest {
 
     Set<ServiceComponentHostResponse> responses = new LinkedHashSet<ServiceComponentHostResponse>();
     responses.add(shr1);
-    
+
     Map<String, String> returnConfigMap = new HashMap<String, String>();
     returnConfigMap.put(Configuration.SERVER_TMP_DIR_KEY, Configuration.SERVER_TMP_DIR_DEFAULT);
     returnConfigMap.put(Configuration.AMBARI_PYTHON_WRAP_KEY, Configuration.AMBARI_PYTHON_WRAP_DEFAULT);
@@ -236,7 +235,7 @@ public class ClientConfigResourceProviderTest {
     expect(configMap.get(Configuration.SERVER_TMP_DIR_KEY)).andReturn(Configuration.SERVER_TMP_DIR_DEFAULT);
     expect(configMap.get(Configuration.AMBARI_PYTHON_WRAP_KEY)).andReturn(Configuration.AMBARI_PYTHON_WRAP_DEFAULT);
     expect(configuration.getConfigsMap()).andReturn(returnConfigMap);
-    expect(configuration.getResourceDirPath()).andReturn("/tmp/stacks/S1/V1");
+    expect(configuration.getResourceDirPath()).andReturn(stackRoot);
     expect(configuration.getJavaVersion()).andReturn(8);
     expect(configuration.areHostsSysPrepped()).andReturn("false");
     expect(configuration.getExternalScriptTimeout()).andReturn(Integer.parseInt(Configuration.EXTERNAL_SCRIPT_TIMEOUT_DEFAULT));
@@ -300,10 +299,9 @@ public class ClientConfigResourceProviderTest {
             "INFO /var/lib/ambari-server/tmp";
 
     if (System.getProperty("os.name").contains("Windows")) {
-      String absoluteStackRoot = stackRootFile.getAbsolutePath();
-      commandLine = "ambari-python-wrap " + absoluteStackRoot +
+      commandLine = "ambari-python-wrap " + stackRoot +
               "\\PIG\\package\\null generate_configs null " +
-              absoluteStackRoot + "\\PIG\\package /var/lib/ambari-server/tmp\\structured-out.json
" +
+              stackRoot + "\\PIG\\package /var/lib/ambari-server/tmp\\structured-out.json
" +
               "INFO /var/lib/ambari-server/tmp";
     }
 
@@ -381,8 +379,8 @@ public class ClientConfigResourceProviderTest {
 
     // create the request
     Request request = PropertyHelper.getReadRequest(ClientConfigResourceProvider.COMPONENT_CLUSTER_NAME_PROPERTY_ID,
"c1",
-            ClientConfigResourceProvider.COMPONENT_COMPONENT_NAME_PROPERTY_ID,
-            ClientConfigResourceProvider.COMPONENT_SERVICE_NAME_PROPERTY_ID);
+        ClientConfigResourceProvider.COMPONENT_COMPONENT_NAME_PROPERTY_ID,
+        ClientConfigResourceProvider.COMPONENT_SERVICE_NAME_PROPERTY_ID);
 
     Predicate predicate = new PredicateBuilder().property(ClientConfigResourceProvider.COMPONENT_CLUSTER_NAME_PROPERTY_ID).equals("c1").
         toPredicate();
@@ -398,14 +396,13 @@ public class ClientConfigResourceProviderTest {
 
     String stackRoot="/tmp/stacks/S1/V1";
     String packageFolder= StackManager.COMMON_SERVICES + "/PIG/package";
-    String commonServicesPath = "/var/lib/ambari-server/src/main/resources/common-services";
+    String commonServicesPath = "/var/lib/ambari-server/src/main/resources" + File.separator
+ "common-services";
 
     if (System.getProperty("os.name").contains("Windows")) {
-      stackRoot = "\\tmp\\stacks\\S1\\V1";
+      stackRoot = "C:\\tmp\\stacks\\S1\\V1";
       packageFolder = StackManager.COMMON_SERVICES + "\\PIG\\package";
     }
 
-    File stackRootFile = new File(stackRoot);
     HashMap<String, Host> hosts = new HashMap<String, Host>();
     hosts.put(hostName, host);
     HashMap<String, Service> services = new HashMap<String, Service>();
@@ -502,7 +499,6 @@ public class ClientConfigResourceProviderTest {
             "INFO /var/lib/ambari-server/tmp";
 
     if (System.getProperty("os.name").contains("Windows")) {
-      String absoluteStackRoot = stackRootFile.getAbsolutePath();
       commandLine = "ambari-python-wrap " + commonServicesPath +
               "\\PIG\\package\\null generate_configs null " +
               commonServicesPath + "\\PIG\\package /var/lib/ambari-server/tmp\\structured-out.json
" +

http://git-wip-us.apache.org/repos/asf/ambari/blob/03a927dd/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/CreateKeytabFilesServerActionTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/CreateKeytabFilesServerActionTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/CreateKeytabFilesServerActionTest.java
index d2252a9..5c4475e 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/CreateKeytabFilesServerActionTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/CreateKeytabFilesServerActionTest.java
@@ -19,6 +19,7 @@
 package org.apache.ambari.server.serveraction.kerberos;
 
 import junit.framework.Assert;
+import org.junit.Assume;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
@@ -30,6 +31,8 @@ import java.nio.file.Paths;
 import java.nio.file.attribute.PosixFilePermission;
 import java.util.Set;
 
+import org.apache.ambari.server.utils.ShellCommandUtil;
+
 public class CreateKeytabFilesServerActionTest {
 
   @Rule
@@ -37,6 +40,8 @@ public class CreateKeytabFilesServerActionTest {
 
   @Test
   public void testEnsureAmbariOnlyAccess() throws Exception {
+    Assume.assumeTrue(ShellCommandUtil.UNIX_LIKE);
+
     Path path;
     Set<PosixFilePermission> permissions;
 


Mime
View raw message