ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hapyles...@apache.org
Subject [1/2] ambari git commit: AMBARI-22318 repositoryFile entity populating for wrong repository for RU (dgrinenko)
Date Mon, 13 Nov 2017 16:31:38 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.6 36f2ad4e1 -> 6a09885d5


http://git-wip-us.apache.org/repos/asf/ambari/blob/6a09885d/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProviderTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProviderTest.java
index 11142e4..de16bf6 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProviderTest.java
@@ -1914,11 +1914,56 @@ public class ClusterStackVersionResourceProviderTest {
      stackEntity.setStackName("HDP");
      stackEntity.setStackVersion("2.1.1");
 
-     File f = new File("src/test/resources/hbase_version_test.xml");
+     String hbaseVersionTestXML = "\n" +
+       "<repository-version xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
+
+       "  xsi:noNamespaceSchemaLocation=\"version_definition.xsd\">\n" +
+       "  \n" +
+       "  <release>\n" +
+       "    <type>PATCH</type>\n" +
+       "    <stack-id>HDP-2.3</stack-id>\n" +
+       "    <version>2.3.4.0</version>\n" +
+       "    <build>3396</build>\n" +
+       "    <compatible-with>2.3.2.[0-9]</compatible-with>\n" +
+       "    <release-notes>http://docs.hortonworks.com/HDPDocuments/HDP2/HDP-2.3.4/</release-notes>\n"
+
+       "  </release>\n" +
+       "  \n" +
+       "  <manifest>\n" +
+       "    <service id=\"HBASE-112\" name=\"HBASE\" version=\"1.1.2\" version-id=\"2_3_4_0-3396\"
/>\n" +
+       "  </manifest>\n" +
+       "  \n" +
+       "  <available-services>\n" +
+       "    <service idref=\"HBASE-112\" />\n" +
+       "  </available-services>\n" +
+       "  \n" +
+       "  <repository-info>\n" +
+       "    <os family=\"redhat6\">\n" +
+       "      <package-version>2_3_4_0_3396</package-version>\n" +
+       "      <repo>\n" +
+       "        <baseurl>http://public-repo-1.hortonworks.com/HDP/centos6/2.x/updates/2.3.4.0</baseurl>\n"
+
+       "        <repoid>HDP-2.3</repoid>\n" +
+       "        <reponame>HDP</reponame>\n" +
+       "        <unique>true</unique>\n" +
+       "      </repo>\n" +
+       "      <repo>\n" +
+       "        <baseurl>http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.20/repos/centos6</baseurl>\n"
+
+       "        <repoid>HDP-UTILS-1.1.0.20</repoid>\n" +
+       "        <reponame>HDP-UTILS</reponame>\n" +
+       "        <unique>false</unique>\n" +
+       "      </repo>\n" +
+       "    </os>\n" +
+       "  </repository-info>\n" +
+       "  \n" +
+       "  <upgrade>\n" +
+       "    <configuration type=\"hdfs-site\">\n" +
+       "      <set key=\"foo\" value=\"bar\" />\n" +
+       "    </configuration>\n" +
+       "  </upgrade>\n" +
+       "</repository-version>";
+
      RepositoryVersionEntity repoVersion = new RepositoryVersionEntity();
      repoVersion.setId(1l);
      repoVersion.setOperatingSystems(os_json);
-     repoVersion.setVersionXml(IOUtils.toString(new FileInputStream(f)));
+     repoVersion.setVersionXml(hbaseVersionTestXML);
      repoVersion.setVersionXsd("version_definition.xsd");
      repoVersion.setType(RepositoryType.PATCH);
      repoVersion.setStack(stackEntity);
@@ -2009,7 +2054,7 @@ public class ClusterStackVersionResourceProviderTest {
      expect(managementController.findConfigurationTagsWithOverrides(anyObject(Cluster.class),
EasyMock.anyString()))
      .andReturn(new HashMap<String, Map<String, String>>()).anyTimes();
 
-     expect(clusters.getCluster(anyObject(String.class))).andReturn(cluster);
+     expect(clusters.getCluster(anyObject(String.class))).andReturn(cluster).anyTimes();
      expect(clusters.getHostsForCluster(anyObject(String.class))).andReturn(
          hostsForCluster).anyTimes();
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/6a09885d/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java
index 477b776..a8c0954 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java
@@ -214,23 +214,25 @@ public class UpgradeResourceProviderTest extends EasyMockSupport {
     StackEntity stackEntity220 = stackDAO.find("HDP", "2.2.0");
     StackId stack211 = new StackId(stackEntity211);
 
+    String operatingSystems = "[{\"OperatingSystems/ambari_managed_repositories\":\"true\",\"repositories\":[{\"Repositories/repo_id\":\"HDP\",\"Repositories/base_url\":\"\",\"Repositories/repo_name\":\"HDP\"},{\"Repositories/repo_id\":\"HDP-UTILS\",\"Repositories/base_url\":\"\",\"Repositories/repo_name\":\"HDP-UTILS\"}],\"OperatingSystems/os_type\":\"redhat6\"}]";
+
     repoVersionEntity2110 = new RepositoryVersionEntity();
     repoVersionEntity2110.setDisplayName("My New Version 1");
-    repoVersionEntity2110.setOperatingSystems("");
+    repoVersionEntity2110.setOperatingSystems(operatingSystems);
     repoVersionEntity2110.setStack(stackEntity211);
     repoVersionEntity2110.setVersion("2.1.1.0");
     repoVersionDao.create(repoVersionEntity2110);
 
     repoVersionEntity2111 = new RepositoryVersionEntity();
     repoVersionEntity2111.setDisplayName("My New Version 2 for minor upgrade");
-    repoVersionEntity2111.setOperatingSystems("");
+    repoVersionEntity2111.setOperatingSystems(operatingSystems);
     repoVersionEntity2111.setStack(stackEntity211);
     repoVersionEntity2111.setVersion("2.1.1.1");
     repoVersionDao.create(repoVersionEntity2111);
 
     repoVersionEntity2112 = new RepositoryVersionEntity();
     repoVersionEntity2112.setDisplayName("My New Version 3 for patch upgrade");
-    repoVersionEntity2112.setOperatingSystems("");
+    repoVersionEntity2112.setOperatingSystems(operatingSystems);
     repoVersionEntity2112.setStack(stackEntity211);
     repoVersionEntity2112.setVersion("2.1.1.2");
     repoVersionEntity2112.setType(RepositoryType.PATCH);
@@ -239,7 +241,7 @@ public class UpgradeResourceProviderTest extends EasyMockSupport {
 
     repoVersionEntity2200 = new RepositoryVersionEntity();
     repoVersionEntity2200.setDisplayName("My New Version 4 for major upgrade");
-    repoVersionEntity2200.setOperatingSystems("");
+    repoVersionEntity2200.setOperatingSystems(operatingSystems);
     repoVersionEntity2200.setStack(stackEntity220);
     repoVersionEntity2200.setVersion("2.2.0.0");
     repoVersionDao.create(repoVersionEntity2200);
@@ -1931,7 +1933,7 @@ public class UpgradeResourceProviderTest extends EasyMockSupport {
     StackEntity stackEntity = stackDAO.find("HDP", "2.1.1");
     RepositoryVersionEntity repoVersionEntity = new RepositoryVersionEntity();
     repoVersionEntity.setDisplayName("My New Version 3");
-    repoVersionEntity.setOperatingSystems("");
+    repoVersionEntity.setOperatingSystems("[{\"OperatingSystems/ambari_managed_repositories\":\"true\",\"repositories\":[{\"Repositories/repo_id\":\"HDP\",\"Repositories/base_url\":\"\",\"Repositories/repo_name\":\"HDP\"},{\"Repositories/repo_id\":\"HDP-UTILS\",\"Repositories/base_url\":\"\",\"Repositories/repo_name\":\"HDP-UTILS\"}],\"OperatingSystems/os_type\":\"redhat6\"}]");
     repoVersionEntity.setStack(stackEntity);
     repoVersionEntity.setVersion("2.2.2.3");
     repoVersionDao.create(repoVersionEntity);

http://git-wip-us.apache.org/repos/asf/ambari/blob/6a09885d/ambari-server/src/test/java/org/apache/ambari/server/orm/OrmTestHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/orm/OrmTestHelper.java b/ambari-server/src/test/java/org/apache/ambari/server/orm/OrmTestHelper.java
index c905a42..a2406ea 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/orm/OrmTestHelper.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/orm/OrmTestHelper.java
@@ -670,8 +670,10 @@ public class OrmTestHelper {
 
     if (repositoryVersion == null) {
       try {
+        String operatingSystems = "[{\"OperatingSystems/ambari_managed_repositories\":\"true\",\"repositories\":[{\"Repositories/repo_id\":\"HDP\",\"Repositories/base_url\":\"\",\"Repositories/repo_name\":\"HDP\"},{\"Repositories/repo_id\":\"HDP-UTILS\",\"Repositories/base_url\":\"\",\"Repositories/repo_name\":\"HDP-UTILS\"}],\"OperatingSystems/os_type\":\"redhat6\"}]";
+
         repositoryVersion = repositoryVersionDAO.create(stackEntity, version,
-            String.valueOf(System.currentTimeMillis()) + uniqueCounter.incrementAndGet(),
"");
+            String.valueOf(System.currentTimeMillis()) + uniqueCounter.incrementAndGet(),
operatingSystems);
       } catch (Exception ex) {
         LOG.error("Caught exception", ex);
 


Mime
View raw message