ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aonis...@apache.org
Subject [59/64] [abbrv] ambari git commit: AMBARI-20461 override_uid should set to false when upgrading Ambari 2.1 to 2.2 or newer with custom stacks (dili)
Date Wed, 29 Mar 2017 11:58:03 GMT
AMBARI-20461 override_uid should set to false when upgrading Ambari 2.1 to 2.2 or newer with
custom stacks (dili)


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

Branch: refs/heads/branch-3.0-perf
Commit: 64b132bd4e9f51a97dffa7c5df842a7a81f99402
Parents: f6078ea3
Author: Di Li <dili@apache.org>
Authored: Tue Mar 28 14:54:00 2017 -0400
Committer: Andrew Onishuk <aonishuk@hortonworks.com>
Committed: Wed Mar 29 14:55:56 2017 +0300

----------------------------------------------------------------------
 .../server/upgrade/UpgradeCatalog212.java       |  16 +-
 .../server/upgrade/UpgradeCatalog212Test.java   | 148 +++++++++++++++++++
 2 files changed, 163 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/64b132bd/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog212.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog212.java
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog212.java
index 499c726..810451d 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog212.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog212.java
@@ -264,7 +264,11 @@ public class UpgradeCatalog212 extends AbstractUpgradeCatalog {
               removes.add("override_hbase_uid");
               updateConfigurationPropertiesForCluster(cluster, HBASE_ENV, new HashMap<String,
String>(), removes, false, true);
               updateConfigurationPropertiesForCluster(cluster, CLUSTER_ENV, updates, true,
false);
+            } else {
+              updateOverrideUIDClusterConfig("false", cluster);
             }
+          } else {
+            updateOverrideUIDClusterConfig("false", cluster);
           }
 
           if (hbaseSiteProps != null) {
@@ -277,13 +281,23 @@ public class UpgradeCatalog212 extends AbstractUpgradeCatalog {
                 updateConfigurationPropertiesForCluster(cluster, HBASE_SITE, updates, true,
false);
               }
             }
-
           }
         }
       }
     }
   }
 
+  /**
+   * Set override_uid to false during the upgrade to retain UIDs already set on the cluster
+   * This is necessary for upgrading a third party Ambari/stack distribution from
+   * Ambari version 2.1.0 where HBase does not have override_hbase_uid.
+   * */
+  private void updateOverrideUIDClusterConfig(String toOverride, Cluster cluster) throws
AmbariException{
+    Map<String, String> updates = new HashMap<String, String>();
+    updates.put("override_uid", toOverride);
+    updateConfigurationPropertiesForCluster(cluster, CLUSTER_ENV, updates, true, false);
+  }
+
   protected void updateHiveConfigs() throws AmbariException {
     AmbariManagementController ambariManagementController = injector.getInstance(
             AmbariManagementController.class);

http://git-wip-us.apache.org/repos/asf/ambari/blob/64b132bd/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog212Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog212Test.java
b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog212Test.java
index 3f7bcc8..a60238a 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog212Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog212Test.java
@@ -298,7 +298,155 @@ public class UpgradeCatalog212Test {
     easyMockSupport.replayAll();
     mockInjector.getInstance(UpgradeCatalog212.class).updateHbaseAndClusterConfigurations();
     easyMockSupport.verifyAll();
+  }
+
+  @Test
+  public void testUpdateHBaseAdnClusterConfigsTrue() throws Exception {
+    setupIoCContext();
+    EasyMockSupport easyMockSupport = new EasyMockSupport();
+    final AmbariManagementController mockAmbariManagementController = easyMockSupport.createNiceMock(AmbariManagementController.class);
+    final ConfigHelper mockConfigHelper = easyMockSupport.createMock(ConfigHelper.class);
+
+    final Clusters mockClusters = easyMockSupport.createStrictMock(Clusters.class);
+    final Cluster mockClusterExpected = easyMockSupport.createNiceMock(Cluster.class);
+
+    final Map<String, String> propertiesHbaseEnv = new HashMap<String, String>()
{
+      {
+        put("override_hbase_uid", "true");
+      }
+    };
+
+    final Config mockHbaseEnv = easyMockSupport.createNiceMock(Config.class);
+    expect(mockHbaseEnv.getProperties()).andReturn(propertiesHbaseEnv).once();
+    final Config mockClusterEnv = easyMockSupport.createNiceMock(Config.class);
+
+    final Map<String, String> propertiesExpectedHbaseEnv = new HashMap<String, String>();
+    final Map<String, String> propertiesExpectedClusterEnv = new HashMap<String,
String>() {{
+      put("override_uid", "true");
+    }};
+
+    final Injector mockInjector = Guice.createInjector(new AbstractModule() {
+      @Override
+      protected void configure() {
+        bind(AmbariManagementController.class).toInstance(mockAmbariManagementController);
+        bind(ConfigHelper.class).toInstance(mockConfigHelper);
+        bind(Clusters.class).toInstance(mockClusters);
+
+        bind(DBAccessor.class).toInstance(createNiceMock(DBAccessor.class));
+        bind(OsFamily.class).toInstance(createNiceMock(OsFamily.class));
+      }
+    });
+
+    expect(mockAmbariManagementController.getClusters()).andReturn(mockClusters).once();
+    expect(mockClusters.getClusters()).andReturn(new HashMap<String, Cluster>() {{
+      put("normal", mockClusterExpected);
+    }}).once();
+
+    expect(mockClusterExpected.getDesiredConfigByType("cluster-env")).andReturn(mockClusterEnv).atLeastOnce();
+    expect(mockClusterExpected.getDesiredConfigByType("hbase-env")).andReturn(mockHbaseEnv).atLeastOnce();
+
+    expect(mockClusterEnv.getProperties()).andReturn(propertiesExpectedClusterEnv).atLeastOnce();
+    expect(mockHbaseEnv.getProperties()).andReturn(propertiesExpectedHbaseEnv).atLeastOnce();
+
+    easyMockSupport.replayAll();
+    mockInjector.getInstance(UpgradeCatalog212.class).updateHbaseAndClusterConfigurations();
+    easyMockSupport.verifyAll();
+  }
+
+  @Test
+  public void testUpdateHBaseAdnClusterConfigsNoHBaseEnv() throws Exception {
+    setupIoCContext();
+    EasyMockSupport easyMockSupport = new EasyMockSupport();
+    final AmbariManagementController mockAmbariManagementController = easyMockSupport.createNiceMock(AmbariManagementController.class);
+    final ConfigHelper mockConfigHelper = easyMockSupport.createMock(ConfigHelper.class);
+
+    final Clusters mockClusters = easyMockSupport.createStrictMock(Clusters.class);
+    final Cluster mockClusterExpected = easyMockSupport.createNiceMock(Cluster.class);
+
+    final Config mockClusterEnv = easyMockSupport.createNiceMock(Config.class);
+
+    final Map<String, String> propertiesExpectedClusterEnv = new HashMap<String,
String>() {{
+      put("override_uid", "false");
+    }};
+
+    final Injector mockInjector = Guice.createInjector(new AbstractModule() {
+      @Override
+      protected void configure() {
+        bind(AmbariManagementController.class).toInstance(mockAmbariManagementController);
+        bind(ConfigHelper.class).toInstance(mockConfigHelper);
+        bind(Clusters.class).toInstance(mockClusters);
+
+        bind(DBAccessor.class).toInstance(createNiceMock(DBAccessor.class));
+        bind(OsFamily.class).toInstance(createNiceMock(OsFamily.class));
+      }
+    });
+
+    expect(mockAmbariManagementController.getClusters()).andReturn(mockClusters).once();
+    expect(mockClusters.getClusters()).andReturn(new HashMap<String, Cluster>() {{
+      put("normal", mockClusterExpected);
+    }}).once();
+
+    expect(mockClusterExpected.getDesiredConfigByType("cluster-env")).andReturn(mockClusterEnv).atLeastOnce();
+
+    expect(mockClusterEnv.getProperties()).andReturn(propertiesExpectedClusterEnv).atLeastOnce();
+
+    easyMockSupport.replayAll();
+    mockInjector.getInstance(UpgradeCatalog212.class).updateHbaseAndClusterConfigurations();
+    easyMockSupport.verifyAll();
+  }
+
+  @Test
+  public void testUpdateHBaseAdnClusterConfigsNoOverrideHBaseUID() throws Exception {
+    setupIoCContext();
+    EasyMockSupport easyMockSupport = new EasyMockSupport();
+    final AmbariManagementController mockAmbariManagementController = easyMockSupport.createNiceMock(AmbariManagementController.class);
+    final ConfigHelper mockConfigHelper = easyMockSupport.createMock(ConfigHelper.class);
+
+    final Clusters mockClusters = easyMockSupport.createStrictMock(Clusters.class);
+    final Cluster mockClusterExpected = easyMockSupport.createNiceMock(Cluster.class);
+
+    final Map<String, String> propertiesHbaseEnv = new HashMap<String, String>()
{
+      {
+        put("hbase_user", "hbase");
+      }
+    };
+
+    final Config mockHbaseEnv = easyMockSupport.createNiceMock(Config.class);
+    expect(mockHbaseEnv.getProperties()).andReturn(propertiesHbaseEnv).once();
+    final Config mockClusterEnv = easyMockSupport.createNiceMock(Config.class);
+
+    final Map<String, String> propertiesExpectedHbaseEnv = new HashMap<String, String>()
{{
+      put("hbase_user", "hbase");
+    }};
+    final Map<String, String> propertiesExpectedClusterEnv = new HashMap<String,
String>() {{
+      put("override_uid", "false");
+    }};
 
+    final Injector mockInjector = Guice.createInjector(new AbstractModule() {
+      @Override
+      protected void configure() {
+        bind(AmbariManagementController.class).toInstance(mockAmbariManagementController);
+        bind(ConfigHelper.class).toInstance(mockConfigHelper);
+        bind(Clusters.class).toInstance(mockClusters);
+
+        bind(DBAccessor.class).toInstance(createNiceMock(DBAccessor.class));
+        bind(OsFamily.class).toInstance(createNiceMock(OsFamily.class));
+      }
+    });
+
+    expect(mockAmbariManagementController.getClusters()).andReturn(mockClusters).once();
+    expect(mockClusters.getClusters()).andReturn(new HashMap<String, Cluster>() {{
+      put("normal", mockClusterExpected);
+    }}).once();
+
+    expect(mockClusterExpected.getDesiredConfigByType("cluster-env")).andReturn(mockClusterEnv).atLeastOnce();
+    expect(mockClusterExpected.getDesiredConfigByType("hbase-env")).andReturn(mockHbaseEnv).atLeastOnce();
+
+    expect(mockClusterEnv.getProperties()).andReturn(propertiesExpectedClusterEnv).atLeastOnce();
+
+    easyMockSupport.replayAll();
+    mockInjector.getInstance(UpgradeCatalog212.class).updateHbaseAndClusterConfigurations();
+    easyMockSupport.verifyAll();
   }
 
   @Test


Mime
View raw message