ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aonis...@apache.org
Subject git commit: AMBARI-5458. Repo validation for ubuntu fails (aonishuk)
Date Tue, 15 Apr 2014 12:48:14 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 21b1b61fe -> 215a351d3


AMBARI-5458. Repo validation for ubuntu fails (aonishuk)


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

Branch: refs/heads/trunk
Commit: 215a351d35be356f648112f74fd89a6aea71de2f
Parents: 21b1b61
Author: Andrew Onishuk <aonishuk@hortonworks.com>
Authored: Tue Apr 15 15:48:04 2014 +0300
Committer: Andrew Onishuk <aonishuk@hortonworks.com>
Committed: Tue Apr 15 15:48:04 2014 +0300

----------------------------------------------------------------------
 .../server/configuration/Configuration.java     | 33 +++++++++-----------
 .../AmbariManagementControllerImpl.java         |  2 +-
 .../AmbariManagementControllerTest.java         | 18 +++++------
 3 files changed, 24 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/215a351d/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
b/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
index 2b7fa14..19b3c9a 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
@@ -198,7 +198,8 @@ public class Configuration {
   /**
    * Key for repo validation suffixes.
    */
-  public static final String REPO_SUFFIX_KEY = "repo.validation.suffixes";
+  public static final String REPO_SUFFIX_KEY_UBUNTU = "repo.validation.suffixes.ubuntu";
+  public static final String REPO_SUFFIX_KEY_DEFAULT = "repo.validation.suffixes.default";
   public static final String EXECUTION_SCHEDULER_CLUSTERED =
       "server.execution.scheduler.isClustered";
   public static final String EXECUTION_SCHEDULER_THREADS =
@@ -271,6 +272,7 @@ public class Configuration {
    */
   private static final String REPO_SUFFIX_DEFAULT = "/repodata/repomd.xml";
   private static final String REPO_SUFFIX_UBUNTU = "/dists/HDP/Release.gpg,/dists/HDP/Release";
+  
   private static final String PARALLEL_STAGE_EXECUTION_DEFAULT = "true";
   private static final Logger LOG = LoggerFactory.getLogger(
       Configuration.class);
@@ -893,25 +895,18 @@ public class Configuration {
   /**
    * @return a string array of suffixes used to validate repo URLs.
    */
-  public String[] getRepoValidationSuffixes() {
-	String osType = getServerOsType();
-	
-	if (osType == null || osType.isEmpty()) {
-	  throw new RuntimeException(Configuration.OS_VERSION_KEY + " is not "
-	      + " set in the ambari.properties file");
-	}
-	
-	String value = null;
-	
-	if(osType.equals(UBUNTU_OS)) {
-	    value = properties.getProperty(REPO_SUFFIX_KEY,
-	        REPO_SUFFIX_UBUNTU);
-	} else {
-	    value = properties.getProperty(REPO_SUFFIX_KEY,
-		        REPO_SUFFIX_DEFAULT);		
-	}
+  public String[] getRepoValidationSuffixes(String osFamily) {
+    String repoSuffixes;
+    
+    if(osFamily.equals(UBUNTU_OS)) {
+      repoSuffixes = properties.getProperty(REPO_SUFFIX_KEY_UBUNTU, 
+          REPO_SUFFIX_UBUNTU);
+    } else {
+      repoSuffixes = properties.getProperty(REPO_SUFFIX_KEY_DEFAULT, 
+          REPO_SUFFIX_DEFAULT);
+    }
     
-    return value.split(",");
+    return repoSuffixes.split(",");
   }
 
   public String isExecutionSchedulerClusterd() {

http://git-wip-us.apache.org/repos/asf/ambari/blob/215a351d/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
index 2e2822c..60d372c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
@@ -2544,7 +2544,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
 
           boolean bFound = false;
           
-          String[] suffixes = configs.getRepoValidationSuffixes();
+          String[] suffixes = configs.getRepoValidationSuffixes(rr.getOsType());
           for (int i = 0; i < suffixes.length && !bFound; i++) {
             String suffix = suffixes[i];
             String spec = rr.getBaseUrl();

http://git-wip-us.apache.org/repos/asf/ambari/blob/215a351d/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
index ca4ac80..73530a8 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
@@ -8043,36 +8043,36 @@ public class AmbariManagementControllerTest {
       baseUrl += "/";
 
     // variation #1: url with trailing slash, suffix preceding slash
-    backingProperties.setProperty(Configuration.REPO_SUFFIX_KEY, "/repodata/repomd.xml");
-    Assert.assertTrue(baseUrl.endsWith("/") && configuration.getRepoValidationSuffixes()[0].startsWith("/"));
+    backingProperties.setProperty(Configuration.REPO_SUFFIX_KEY_UBUNTU, "/repodata/repomd.xml");
+    Assert.assertTrue(baseUrl.endsWith("/") && configuration.getRepoValidationSuffixes("debian12")[0].startsWith("/"));
     request.setBaseUrl(baseUrl);
     controller.updateRespositories(requests);
     Assert.assertEquals(baseUrl, repo.getBaseUrl());
 
     // variation #2: url with trailing slash, suffix no preceding slash
-    backingProperties.setProperty(Configuration.REPO_SUFFIX_KEY, "repodata/repomd.xml");
-    Assert.assertTrue(baseUrl.endsWith("/") && !configuration.getRepoValidationSuffixes()[0].startsWith("/"));
+    backingProperties.setProperty(Configuration.REPO_SUFFIX_KEY_DEFAULT, "repodata/repomd.xml");
+    Assert.assertTrue(baseUrl.endsWith("/") && !configuration.getRepoValidationSuffixes("redhat6")[0].startsWith("/"));
     request.setBaseUrl(baseUrl);
     controller.updateRespositories(requests);
     Assert.assertEquals(baseUrl, repo.getBaseUrl());
 
     baseUrl = baseUrl.substring(0, baseUrl.length()-1);
     // variation #3: url with no trailing slash, suffix no prededing slash
-    Assert.assertTrue(!baseUrl.endsWith("/") && !configuration.getRepoValidationSuffixes()[0].startsWith("/"));
+    Assert.assertTrue(!baseUrl.endsWith("/") && !configuration.getRepoValidationSuffixes("redhat6")[0].startsWith("/"));
     request.setBaseUrl(baseUrl);
     controller.updateRespositories(requests);
     Assert.assertEquals(baseUrl, repo.getBaseUrl());
 
     // variation #4: url with no trailing slash, suffix preceding slash
-    backingProperties.setProperty(Configuration.REPO_SUFFIX_KEY, "/repodata/repomd.xml");
-    Assert.assertTrue(!baseUrl.endsWith("/") && configuration.getRepoValidationSuffixes()[0].startsWith("/"));
+    backingProperties.setProperty(Configuration.REPO_SUFFIX_KEY_DEFAULT, "/repodata/repomd.xml");
+    Assert.assertTrue(!baseUrl.endsWith("/") && configuration.getRepoValidationSuffixes("suse11")[0].startsWith("/"));
     request.setBaseUrl(baseUrl);
     controller.updateRespositories(requests);
     Assert.assertEquals(baseUrl, repo.getBaseUrl());
 
     // variation #5: multiple suffix tests
-    backingProperties.setProperty(Configuration.REPO_SUFFIX_KEY, "/foo/bar.xml,/repodata/repomd.xml");
-    Assert.assertTrue(configuration.getRepoValidationSuffixes().length > 1);
+    backingProperties.setProperty(Configuration.REPO_SUFFIX_KEY_UBUNTU, "/foo/bar.xml,/repodata/repomd.xml");
+    Assert.assertTrue(configuration.getRepoValidationSuffixes("debian12").length > 1);
     request.setBaseUrl(baseUrl);
     controller.updateRespositories(requests);
     Assert.assertEquals(baseUrl, repo.getBaseUrl());


Mime
View raw message