ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vbrodets...@apache.org
Subject ambari git commit: AMBARI-15568. ambari-server check-database has errors after upgrade from 170 to ambari 2.2.2.0 [service SLIDER].(vbrodetskyi)
Date Fri, 25 Mar 2016 10:34:45 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.2 1e8da1a5a -> d650e5fa7


AMBARI-15568. ambari-server check-database has errors after upgrade from 170 to ambari 2.2.2.0
[service SLIDER].(vbrodetskyi)


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

Branch: refs/heads/branch-2.2
Commit: d650e5fa787e233ab3cf5c35a175ea7ebcaee4fd
Parents: 1e8da1a
Author: Vitaly Brodetskyi <vbrodetskyi@hortonworks.com>
Authored: Fri Mar 25 12:32:02 2016 +0200
Committer: Vitaly Brodetskyi <vbrodetskyi@hortonworks.com>
Committed: Fri Mar 25 12:32:02 2016 +0200

----------------------------------------------------------------------
 .../server/upgrade/UpgradeCatalog222.java       | 22 +++++
 .../main/python/ambari_server/checkDatabase.py  |  1 +
 .../server/upgrade/UpgradeCatalog222Test.java   | 98 ++++++++++++++------
 3 files changed, 91 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/d650e5fa/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog222.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog222.java
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog222.java
index 7601e4c..7021a46 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog222.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog222.java
@@ -39,6 +39,7 @@ import org.apache.ambari.server.orm.entities.WidgetEntity;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.Config;
+import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.ServiceComponentHost;
 import org.apache.ambari.server.state.ServiceInfo;
 import org.apache.ambari.server.state.StackId;
@@ -180,6 +181,27 @@ public class UpgradeCatalog222 extends AbstractUpgradeCatalog {
     updateHDFSWidgetDefinition();
     updateCorruptedReplicaWidget();
     updateZookeeperConfigs();
+    createNewSliderConfigVersion();
+  }
+
+  protected void createNewSliderConfigVersion() {
+    // Here we are creating new service config version for SLIDER, to link slider-client
+    // config to SLIDER service, in serviceconfigmapping table. It could be not mapped because
+    // of bug which we had a long time ago.
+    AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class);
+    Map<String, Cluster> clusterMap = getCheckedClusterMap(ambariManagementController.getClusters());
+
+    for (final Cluster cluster : clusterMap.values()) {
+      Service sliderService = null;
+      try {
+        sliderService = cluster.getService("SLIDER");
+      } catch(AmbariException ambariException) {
+        LOG.info("SLIDER service not found in cluster while creating new serviceconfig version
for SLIDER service.");
+      }
+      if (sliderService != null) {
+        cluster.createServiceConfigVersion("SLIDER", AUTHENTICATED_USER_NAME, "Creating new
service config version for SLIDER service.", null);
+      }
+    }
   }
 
   protected void updateZookeeperConfigs() throws  AmbariException {

http://git-wip-us.apache.org/repos/asf/ambari/blob/d650e5fa/ambari-server/src/main/python/ambari_server/checkDatabase.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/ambari_server/checkDatabase.py b/ambari-server/src/main/python/ambari_server/checkDatabase.py
index 2deca0a..2b5c735 100644
--- a/ambari-server/src/main/python/ambari_server/checkDatabase.py
+++ b/ambari-server/src/main/python/ambari_server/checkDatabase.py
@@ -58,6 +58,7 @@ def check_database(options):
   if not database_type:
     print_error_msg("Please run \"ambari-server setup\" command"
                     " to initialize ambari db properties.")
+    sys.exit(1)
 
   options.database_index = LINUX_DBMS_KEYS_LIST.index(properties[JDBC_DATABASE_PROPERTY])
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/d650e5fa/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog222Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog222Test.java
b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog222Test.java
index 17d7e4e..7321f69 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog222Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog222Test.java
@@ -19,16 +19,29 @@
 package org.apache.ambari.server.upgrade;
 
 
-import com.google.common.collect.Maps;
-import com.google.gson.Gson;
-import com.google.inject.AbstractModule;
-import com.google.inject.Binder;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import com.google.inject.Module;
-import com.google.inject.Provider;
-import com.google.inject.persist.PersistService;
+import javax.persistence.EntityManager;
+import static org.easymock.EasyMock.capture;
+import static org.easymock.EasyMock.createMockBuilder;
+import static org.easymock.EasyMock.createNiceMock;
+import static org.easymock.EasyMock.createStrictMock;
+import static org.easymock.EasyMock.eq;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.reset;
+import static org.easymock.EasyMock.verify;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.lang.reflect.Method;
 import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.actionmanager.ActionManager;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
@@ -51,6 +64,7 @@ import org.apache.ambari.server.stack.StackManagerFactory;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.Config;
+import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.ServiceComponentHost;
 import org.apache.ambari.server.state.ServiceInfo;
 import org.apache.ambari.server.state.StackId;
@@ -67,27 +81,15 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
 
-import javax.persistence.EntityManager;
-import java.io.File;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-
-import static org.easymock.EasyMock.capture;
-import static org.easymock.EasyMock.createMockBuilder;
-import static org.easymock.EasyMock.createNiceMock;
-import static org.easymock.EasyMock.createStrictMock;
-import static org.easymock.EasyMock.eq;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.expectLastCall;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.reset;
-import static org.easymock.EasyMock.verify;
-import static org.junit.Assert.assertTrue;
+import com.google.common.collect.Maps;
+import com.google.gson.Gson;
+import com.google.inject.AbstractModule;
+import com.google.inject.Binder;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.Module;
+import com.google.inject.Provider;
+import com.google.inject.persist.PersistService;
 
 public class UpgradeCatalog222Test {
   private Injector injector;
@@ -130,6 +132,7 @@ public class UpgradeCatalog222Test {
     Method updateHostRoleCommands = UpgradeCatalog222.class.getDeclaredMethod("updateHostRoleCommands");
     Method updateHDFSWidget = UpgradeCatalog222.class.getDeclaredMethod("updateHDFSWidgetDefinition");
     Method updateCorruptedReplicaWidget = UpgradeCatalog222.class.getDeclaredMethod("updateCorruptedReplicaWidget");
+    Method createNewSliderConfigVersion = UpgradeCatalog222.class.getDeclaredMethod("createNewSliderConfigVersion");
     Method updateZookeeperConfigs = UpgradeCatalog222.class.getDeclaredMethod("updateZookeeperConfigs");
 
     UpgradeCatalog222 upgradeCatalog222 = createMockBuilder(UpgradeCatalog222.class)
@@ -141,6 +144,7 @@ public class UpgradeCatalog222Test {
       .addMockedMethod(updateHostRoleCommands)
       .addMockedMethod(updateHDFSWidget)
       .addMockedMethod(updateCorruptedReplicaWidget)
+      .addMockedMethod(createNewSliderConfigVersion)
       .addMockedMethod(updateZookeeperConfigs)
       .createMock();
 
@@ -162,6 +166,8 @@ public class UpgradeCatalog222Test {
     expectLastCall().once();
     upgradeCatalog222.updateZookeeperConfigs();
     expectLastCall().once();
+    upgradeCatalog222.createNewSliderConfigVersion();
+    expectLastCall().once();
 
     replay(upgradeCatalog222);
 
@@ -680,4 +686,36 @@ public class UpgradeCatalog222Test {
 
   }
 
+  @Test
+  public void testCreateNewSliderConfigVersion() throws AmbariException {
+    EasyMockSupport easyMockSupport = new EasyMockSupport();
+    final AmbariManagementController mockAmbariManagementController = easyMockSupport.createNiceMock(AmbariManagementController.class);
+    final Clusters mockClusters = easyMockSupport.createStrictMock(Clusters.class);
+    final Cluster mockClusterExpected = easyMockSupport.createNiceMock(Cluster.class);
+    final Service mockSliderService = easyMockSupport.createNiceMock(Service.class);
+
+    final Injector mockInjector = Guice.createInjector(new AbstractModule() {
+      @Override
+      protected void configure() {
+        bind(AmbariManagementController.class).toInstance(mockAmbariManagementController);
+        bind(Clusters.class).toInstance(mockClusters);
+        bind(EntityManager.class).toInstance(entityManager);
+        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);
+    }}).atLeastOnce();
+    expect(mockClusterExpected.getService("SLIDER")).andReturn(mockSliderService);
+    expect(mockClusterExpected.createServiceConfigVersion("SLIDER", "ambari-upgrade", "Creating
new service config version for SLIDER service.", null)).andReturn(null).once();
+
+    easyMockSupport.replayAll();
+    mockInjector.getInstance(UpgradeCatalog222.class).createNewSliderConfigVersion();
+    easyMockSupport.verifyAll();
+  }
+
+
 }


Mime
View raw message