You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by od...@apache.org on 2013/08/27 17:06:40 UTC

git commit: AMBARI-3036. Ambari version check failing for local development/VM. (Dmytro Shkvyra via odiachenko)

Updated Branches:
  refs/heads/trunk 6f5b24fbd -> 88d69cb56


AMBARI-3036. Ambari version check failing for local development/VM. (Dmytro Shkvyra via odiachenko)


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

Branch: refs/heads/trunk
Commit: 88d69cb56c4299049fae975fd071281fee225afd
Parents: 6f5b24f
Author: Oleksandr Diachenko <od...@hortonworks.com>
Authored: Tue Aug 27 18:06:21 2013 +0300
Committer: Oleksandr Diachenko <od...@hortonworks.com>
Committed: Tue Aug 27 18:06:21 2013 +0300

----------------------------------------------------------------------
 .../apache/ambari/server/bootstrap/BootStrapImpl.java   |  2 ++
 .../org/apache/ambari/server/utils/VersionUtils.java    |  6 ++++++
 ambari-server/src/main/python/setupAgent.py             | 12 ++++++------
 .../apache/ambari/server/utils/TestVersionUtils.java    |  4 ++++
 ambari-server/src/test/python/TestSetupAgent.py         |  8 ++++++++
 5 files changed, 26 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/88d69cb5/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/BootStrapImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/BootStrapImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/BootStrapImpl.java
index 025ff83..1f68f1f 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/BootStrapImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/BootStrapImpl.java
@@ -36,6 +36,7 @@ import org.apache.ambari.server.controller.AmbariServer;
 
 @Singleton
 public class BootStrapImpl {
+  public static final String DEV_VERSION = "${ambariVersion}";
   private File bootStrapDir;
   private String bootScript;
   private String bootSetupAgentScript;
@@ -64,6 +65,7 @@ public class BootStrapImpl {
         InetAddress.getLocalHost().getCanonicalHostName());
     this.clusterOsType = conf.getServerOsType();
     this.projectVersion = ambariMetaInfo.getServerVersion();
+    this.projectVersion = (this.projectVersion.equals(DEV_VERSION)) ? DEV_VERSION.replace("$", "") : this.projectVersion;
     this.serverPort = (conf.getApiSSLAuthentication())? conf.getClientSSLApiPort() : conf.getClientApiPort();
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/88d69cb5/ambari-server/src/main/java/org/apache/ambari/server/utils/VersionUtils.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/utils/VersionUtils.java b/ambari-server/src/main/java/org/apache/ambari/server/utils/VersionUtils.java
index 8877b9b..d3df4e5 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/utils/VersionUtils.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/utils/VersionUtils.java
@@ -17,6 +17,8 @@
  */
 package org.apache.ambari.server.utils;
 
+import org.apache.ambari.server.bootstrap.BootStrapImpl;
+
 /**
  * Provides various utility functions to be used for version handling.
  * The compatibility matrix between server, agent, store can also be maintained
@@ -44,6 +46,9 @@ public class VersionUtils {
       throw new IllegalArgumentException("maxLengthToCompare cannot be less than 0");
     }
 
+    
+    if(BootStrapImpl.DEV_VERSION.equals(version1.trim())) return 0;
+    
     String[] version1Parts = version1.split("\\.");
     String[] version2Parts = version2.split("\\.");
 
@@ -75,6 +80,7 @@ public class VersionUtils {
    */
   public static int compareVersions(String version1, String version2, boolean allowEmptyVersions) {
     if (allowEmptyVersions) {
+      if (version1 != null && version1.equals(BootStrapImpl.DEV_VERSION)) return 0;
       if (version1 == null && version2 == null) {
         return 0;
       } else {

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/88d69cb5/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 717c92a..e0b72a2 100755
--- a/ambari-server/src/main/python/setupAgent.py
+++ b/ambari-server/src/main/python/setupAgent.py
@@ -158,16 +158,16 @@ def main(argv=None):
   try:
     server_port = int(server_port)
   except (Exception), e:
-    server_port = 8080	 
-      
-  if projectVersion is None or projectVersion == "null":
-    projectVersion = ""
+    server_port = 8080
 
   checkServerReachability(hostname, server_port)
 
-  projectVersion = getOptimalVersion(projectVersion)
-  if projectVersion != "":
+  if projectVersion is None or projectVersion == "null":
+    projectVersion = getOptimalVersion("")
+  elif (projectVersion != "" and projectVersion != "{ambariVersion}"):
     projectVersion = "-" + projectVersion
+  elif projectVersion == "{ambariVersion}":
+    projectVersion = ""
 
   if is_suse():
     ret = installAgentSuse(projectVersion)

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/88d69cb5/ambari-server/src/test/java/org/apache/ambari/server/utils/TestVersionUtils.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/utils/TestVersionUtils.java b/ambari-server/src/test/java/org/apache/ambari/server/utils/TestVersionUtils.java
index be9b211..19d2af4 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/utils/TestVersionUtils.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/utils/TestVersionUtils.java
@@ -18,6 +18,7 @@
 package org.apache.ambari.server.utils;
 
 import junit.framework.Assert;
+import org.apache.ambari.server.bootstrap.BootStrapImpl;
 import org.junit.Rule;
 import org.junit.Test;
 
@@ -34,6 +35,9 @@ public class TestVersionUtils {
     Assert.assertTrue(VersionUtils.areVersionsEqual("1.2.3", "1.2.3", true));
     Assert.assertTrue(VersionUtils.areVersionsEqual("", "", true));
     Assert.assertTrue(VersionUtils.areVersionsEqual(null, null, true));
+    Assert.assertTrue(VersionUtils.areVersionsEqual(BootStrapImpl.DEV_VERSION, "1.2.3", false));
+    Assert.assertTrue(VersionUtils.areVersionsEqual(BootStrapImpl.DEV_VERSION, "", true));
+    Assert.assertTrue(VersionUtils.areVersionsEqual(BootStrapImpl.DEV_VERSION, null, true));
 
     Assert.assertFalse(VersionUtils.areVersionsEqual("1.2.3.1", "1.2.3", false));
     Assert.assertFalse(VersionUtils.areVersionsEqual("2.1.3", "1.2.3", false));

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/88d69cb5/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 3cdb514..ae6106b 100644
--- a/ambari-server/src/test/python/TestSetupAgent.py
+++ b/ambari-server/src/test/python/TestSetupAgent.py
@@ -297,9 +297,17 @@ class TestSetupAgent(TestCase):
     runAgent_mock.return_value = 0
     setup_agent.main(("setupAgent.py","agents_host","password", "server_hostname","1.1.1","8080"))
     self.assertTrue(exit_mock.called)
+    self.assertFalse(getOptimalVersion_mock.called)
     exit_mock.reset()
+    getOptimalVersion_mock.reset()
+    setup_agent.main(("setupAgent.py","agents_host","password", "server_hostname","{ambariVersion}","8080"))
+    self.assertFalse(getOptimalVersion_mock.called)
+    self.assertTrue(exit_mock.called)
+    exit_mock.reset()
+    getOptimalVersion_mock.reset()
     setup_agent.main(("setupAgent.py","agents_host","password", "server_hostname","null","8080"))
     self.assertTrue(exit_mock.called)
+    self.assertTrue(getOptimalVersion_mock.called)
     exit_mock.reset()
     is_suse_mock.return_value = False
     setup_agent.main(("setupAgent.py","agents_host","password", "server_hostname","null","null"))