ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mpapirkovs...@apache.org
Subject [1/2] ambari git commit: AMBARI-22565. Repository validation fails for HDP-GPL. (mpapirkovskyy)
Date Thu, 30 Nov 2017 20:36:43 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.6 cc38ee8b7 -> 47ae2f8e0
  refs/heads/trunk 195195fac -> 58868f7f3


AMBARI-22565. Repository validation fails for HDP-GPL. (mpapirkovskyy)


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

Branch: refs/heads/branch-2.6
Commit: 47ae2f8e08c059b26129841931bf5fad90546b1f
Parents: cc38ee8
Author: Myroslav Papirkovskyi <mpapyrkovskyy@hortonworks.com>
Authored: Thu Nov 30 17:51:00 2017 +0200
Committer: Myroslav Papirkovskyi <mpapyrkovskyy@hortonworks.com>
Committed: Thu Nov 30 22:32:42 2017 +0200

----------------------------------------------------------------------
 .../AmbariManagementControllerImpl.java         |  6 ++++--
 .../server/controller/RepositoryRequest.java    | 22 ++++++++++++++++++--
 .../internal/RepositoryResourceProvider.java    |  3 ++-
 .../AmbariManagementControllerImplTest.java     |  7 +------
 .../AmbariManagementControllerTest.java         |  7 ++++---
 5 files changed, 31 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/47ae2f8e/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 48ab1b9..85e0c1c 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
@@ -4582,8 +4582,10 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
     URLStreamProvider usp = new URLStreamProvider(REPO_URL_CONNECT_TIMEOUT, REPO_URL_READ_TIMEOUT,
null, null, null);
     usp.setSetupTruststoreForHttps(false);
 
-    RepositoryInfo repositoryInfo = ambariMetaInfo.getRepository(request.getStackName(),
request.getStackVersion(), request.getOsType(), request.getRepoId());
-    String repoName = repositoryInfo.getRepoName();
+    String repoName = request.getRepoName();
+    if (StringUtils.isEmpty(repoName)) {
+      throw new IllegalArgumentException("repo_name is required to verify repository");
+    }
 
     String errorMessage = null;
     Exception e = null;

http://git-wip-us.apache.org/repos/asf/ambari/blob/47ae2f8e/ambari-server/src/main/java/org/apache/ambari/server/controller/RepositoryRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/RepositoryRequest.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/RepositoryRequest.java
index 84929bf..d9f3753 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/RepositoryRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/RepositoryRequest.java
@@ -24,10 +24,12 @@ public class RepositoryRequest extends OperatingSystemRequest {
   private String baseUrl;
   private boolean verify = true;
   private Long clusterVersionId = null;
+  private String repoName = null;
 
-  public RepositoryRequest(String stackName, String stackVersion, String osType, String repoId)
{
+  public RepositoryRequest(String stackName, String stackVersion, String osType, String repoId,
String repoName) {
     super(stackName, stackVersion, osType);
     setRepoId(repoId);
+    setRepoName(repoName);
   }
 
   public String getRepoId() {
@@ -84,13 +86,29 @@ public class RepositoryRequest extends OperatingSystemRequest {
     return clusterVersionId;
   }
 
+  /**
+   * @return name of the repository (without version identifier)
+   */
+  public String getRepoName() {
+    return repoName;
+  }
+
+  /**
+   * @param repoName name of the repository (without version identifier)
+   */
+  public void setRepoName(String repoName) {
+    this.repoName = repoName;
+  }
+
   @Override
   public String toString() {
     return "RepositoryRequest [repoId=" + repoId + ", baseUrl=" + baseUrl
         + ", verify=" + verify + ", getOsType()=" + getOsType()
         + ", getRepositoryVersionId()=" + getRepositoryVersionId()
         + ", getStackVersion()=" + getStackVersion() + ", getStackName()="
-        + getStackName() + "]";
+        + getStackName() + ", getRepoName()=" + getRepoName() + "]";
   }
 
+
+
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/47ae2f8e/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RepositoryResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RepositoryResourceProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RepositoryResourceProvider.java
index cec43dd..242485a 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RepositoryResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RepositoryResourceProvider.java
@@ -244,7 +244,8 @@ public class RepositoryResourceProvider extends AbstractControllerResourceProvid
         (String) properties.get(REPOSITORY_STACK_NAME_PROPERTY_ID),
         (String) properties.get(REPOSITORY_STACK_VERSION_PROPERTY_ID),
         (String) properties.get(REPOSITORY_OS_TYPE_PROPERTY_ID),
-        (String) properties.get(REPOSITORY_REPO_ID_PROPERTY_ID));
+        (String) properties.get(REPOSITORY_REPO_ID_PROPERTY_ID),
+        (String) properties.get(REPOSITORY_REPO_NAME_PROPERTY_ID));
 
     if (properties.containsKey(REPOSITORY_REPOSITORY_VERSION_ID_PROPERTY_ID)) {
       request.setRepositoryVersionId(Long.parseLong(properties.get(REPOSITORY_REPOSITORY_VERSION_ID_PROPERTY_ID).toString()));

http://git-wip-us.apache.org/repos/asf/ambari/blob/47ae2f8e/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java
index 00b87a6..a4a8aa9 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java
@@ -2242,11 +2242,6 @@ public class AmbariManagementControllerImplTest {
     expect(injector.getInstance(MaintenanceStateHelper.class)).andReturn(null);
     expect(injector.getInstance(KerberosHelper.class)).andReturn(createNiceMock(KerberosHelper.class));
 
-    RepositoryInfo dummyRepoInfo = new RepositoryInfo();
-    dummyRepoInfo.setRepoName("repo_name");
-
-    expect(ambariMetaInfo.getRepository("stackName", "stackVersion", "redhat6", "repoId")).andReturn(dummyRepoInfo);
-
     Configuration configuration = createNiceMock(Configuration.class);
     String[] suffices = {"/repodata/repomd.xml"};
     expect(configuration.getRepoValidationSuffixes("redhat6")).andReturn(suffices);
@@ -2265,7 +2260,7 @@ public class AmbariManagementControllerImplTest {
     f.set(controller, configuration);
 
     Set<RepositoryRequest> requests = new HashSet<>();
-    RepositoryRequest request = new RepositoryRequest("stackName", "stackVersion", "redhat6",
"repoId");
+    RepositoryRequest request = new RepositoryRequest("stackName", "stackVersion", "redhat6",
"repoId", "repo_name");
     request.setBaseUrl("file:///some/repo");
     requests.add(request);
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/47ae2f8e/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 6e9e5ef..ab7d1ec 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
@@ -188,6 +188,7 @@ public class AmbariManagementControllerTest {
   private static final String NEW_STACK_VERSION = "2.0.6";
   private static final String OS_TYPE = "centos5";
   private static final String REPO_ID = "HDP-1.1.1.16";
+  private static final String REPO_NAME = "HDP";
   private static final String PROPERTY_NAME = "hbase.regionserver.msginterval";
   private static final String SERVICE_NAME = "HDFS";
   private static final String FAKE_SERVICE_NAME = "FAKENAGIOS";
@@ -7002,11 +7003,11 @@ public class AmbariManagementControllerTest {
   @Test
   public void testGetRepositories() throws Exception {
 
-    RepositoryRequest request = new RepositoryRequest(STACK_NAME, STACK_VERSION, OS_TYPE,
null);
+    RepositoryRequest request = new RepositoryRequest(STACK_NAME, STACK_VERSION, OS_TYPE,
null, REPO_NAME);
     Set<RepositoryResponse> responses = controller.getRepositories(Collections.singleton(request));
     Assert.assertEquals(REPOS_CNT, responses.size());
 
-    RepositoryRequest requestWithParams = new RepositoryRequest(STACK_NAME, STACK_VERSION,
OS_TYPE, REPO_ID);
+    RepositoryRequest requestWithParams = new RepositoryRequest(STACK_NAME, STACK_VERSION,
OS_TYPE, REPO_ID, REPO_NAME);
     requestWithParams.setClusterVersionId(525L);
     Set<RepositoryResponse> responsesWithParams = controller.getRepositories(Collections.singleton(requestWithParams));
     Assert.assertEquals(1, responsesWithParams.size());
@@ -7015,7 +7016,7 @@ public class AmbariManagementControllerTest {
       Assert.assertEquals(525L, responseWithParams.getClusterVersionId().longValue());
     }
 
-    RepositoryRequest invalidRequest = new RepositoryRequest(STACK_NAME, STACK_VERSION, OS_TYPE,
NON_EXT_VALUE);
+    RepositoryRequest invalidRequest = new RepositoryRequest(STACK_NAME, STACK_VERSION, OS_TYPE,
NON_EXT_VALUE, REPO_NAME);
     try {
       controller.getRepositories(Collections.singleton(invalidRequest));
     } catch (StackAccessException e) {


Mime
View raw message