You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ga...@apache.org on 2016/06/15 15:46:59 UTC

[1/2] ambari git commit: AMBARI-17218. Show message of Audit to DB Removal during upgrade for Ranger(Mugdha Varadkar via gautam)

Repository: ambari
Updated Branches:
  refs/heads/branch-2.4 e67780109 -> 471f1d921
  refs/heads/trunk 757addd2b -> b03e8d8e7


AMBARI-17218. Show message of Audit to DB Removal during upgrade for Ranger(Mugdha Varadkar via gautam)


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

Branch: refs/heads/trunk
Commit: b03e8d8e7e178f1e03ccb21ba794fdb3f05db2d1
Parents: 757addd
Author: Gautam Borad <ga...@apache.org>
Authored: Wed Jun 15 19:40:35 2016 +0530
Committer: Gautam Borad <ga...@apache.org>
Committed: Wed Jun 15 21:16:41 2016 +0530

----------------------------------------------------------------------
 .../ambari/server/checks/CheckDescription.java  |   9 ++
 .../server/checks/RangerAuditDbCheck.java       |  61 ++++++++++
 .../ambari/server/checks/UpgradeCheckGroup.java |   7 +-
 .../HDP/2.3/upgrades/nonrolling-upgrade-2.5.xml |   1 +
 .../stacks/HDP/2.3/upgrades/upgrade-2.5.xml     |   1 +
 .../HDP/2.4/upgrades/nonrolling-upgrade-2.5.xml |   1 +
 .../stacks/HDP/2.4/upgrades/upgrade-2.5.xml     |   1 +
 .../server/checks/RangerAuditDbCheckTest.java   | 115 +++++++++++++++++++
 8 files changed, 195 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/b03e8d8e/ambari-server/src/main/java/org/apache/ambari/server/checks/CheckDescription.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/checks/CheckDescription.java b/ambari-server/src/main/java/org/apache/ambari/server/checks/CheckDescription.java
index 850b58a..e3d70c9 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/checks/CheckDescription.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/checks/CheckDescription.java
@@ -275,6 +275,15 @@ public enum CheckDescription {
         "After upgrading, Atlas can be reinstalled");
     }}),
 
+  RANGER_SERVICE_AUDIT_DB_CHECK(PrereqCheckType.SERVICE,
+    "Remove the Ranger Audit to Database Capability",
+    new HashMap<String, String>() {{
+      put(AbstractCheckDescriptor.DEFAULT,
+        "After upgrading, Ranger will no longer support the Audit to Database feature. Instead, Ranger will audit to Solr. " +
+        "To migrate the existing audit logs to Solr, follow the steps in this link."
+        );
+    }}),
+
   KAFKA_KERBEROS_CHECK(PrereqCheckType.SERVICE,
     "Kafka upgrade on Kerberized cluster",
     new HashMap<String, String>() {{

http://git-wip-us.apache.org/repos/asf/ambari/blob/b03e8d8e/ambari-server/src/main/java/org/apache/ambari/server/checks/RangerAuditDbCheck.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/checks/RangerAuditDbCheck.java b/ambari-server/src/main/java/org/apache/ambari/server/checks/RangerAuditDbCheck.java
new file mode 100644
index 0000000..ec4ed09
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/checks/RangerAuditDbCheck.java
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ambari.server.checks;
+
+import java.util.Arrays;
+
+import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.controller.PrereqCheckRequest;
+import org.apache.ambari.server.state.stack.PrereqCheckStatus;
+import org.apache.ambari.server.state.stack.PrerequisiteCheck;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.inject.Singleton;
+
+/**
+ * Ranger Service will not support Audit to DB after upgrade to 2.5 stack.
+ */
+@Singleton
+@UpgradeCheck(group = UpgradeCheckGroup.INFORMATIONAL_WARNING)
+public class RangerAuditDbCheck extends AbstractCheckDescriptor{
+
+  private static final Logger LOG = LoggerFactory.getLogger(RangerAuditDbCheck.class);
+  private static final String serviceName = "RANGER";
+
+  public RangerAuditDbCheck(){
+    super(CheckDescription.RANGER_SERVICE_AUDIT_DB_CHECK);
+  }
+
+  @Override
+  public boolean isApplicable(PrereqCheckRequest request) throws AmbariException {
+    return super.isApplicable(request, Arrays.asList(serviceName), true);
+  }
+
+  @Override
+  public void perform(PrerequisiteCheck prerequisiteCheck, PrereqCheckRequest request) throws AmbariException {
+
+    String propertyValue = getProperty(request, "ranger-admin-site", "ranger.audit.source.type");
+
+    if (null != propertyValue && propertyValue.equalsIgnoreCase("db")) {
+      prerequisiteCheck.getFailedOn().add(serviceName);
+      prerequisiteCheck.setStatus(PrereqCheckStatus.WARNING);
+      prerequisiteCheck.setFailReason(getFailReason(prerequisiteCheck, request));
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/b03e8d8e/ambari-server/src/main/java/org/apache/ambari/server/checks/UpgradeCheckGroup.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/checks/UpgradeCheckGroup.java b/ambari-server/src/main/java/org/apache/ambari/server/checks/UpgradeCheckGroup.java
index 34d016e..67cf4f1 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/checks/UpgradeCheckGroup.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/checks/UpgradeCheckGroup.java
@@ -75,11 +75,16 @@ public enum UpgradeCheckGroup {
   COMPONENT_VERSION(9.0f),
 
   /**
-   * A general group for related to Kerberos checks
+   * A general group for related to Kerberos checks.
    */
   KERBEROS(10.0f),
 
   /**
+   * A general group for informational warning checks.
+   */
+  INFORMATIONAL_WARNING(100.0f),
+
+  /**
    * All other checks.
    */
   DEFAULT(Float.MAX_VALUE);

http://git-wip-us.apache.org/repos/asf/ambari/blob/b03e8d8e/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.5.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.5.xml b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.5.xml
index 464c444..42c4979 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.5.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.5.xml
@@ -22,6 +22,7 @@
   <target-stack>HDP-2.5</target-stack>
   <type>NON_ROLLING</type>
   <prerequisite-checks>
+    <check>org.apache.ambari.server.checks.RangerAuditDbCheck</check>
     <configuration>
       <!-- Configuration properties for all pre-reqs including required pre-reqs -->
       <check-properties name="org.apache.ambari.server.checks.HiveDynamicServiceDiscoveryCheck">

http://git-wip-us.apache.org/repos/asf/ambari/blob/b03e8d8e/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.5.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.5.xml b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.5.xml
index dd04b64..3461ad4 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.5.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.5.xml
@@ -36,6 +36,7 @@
     <check>org.apache.ambari.server.checks.YarnRMHighAvailabilityCheck</check>
     <check>org.apache.ambari.server.checks.YarnTimelineServerStatePreservingCheck</check>
     <check>org.apache.ambari.server.checks.AtlasPresenceCheck</check>
+    <check>org.apache.ambari.server.checks.RangerAuditDbCheck</check>
 
     <configuration>
       <!-- Configuration properties for all pre-reqs including required pre-reqs -->

http://git-wip-us.apache.org/repos/asf/ambari/blob/b03e8d8e/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/nonrolling-upgrade-2.5.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/nonrolling-upgrade-2.5.xml b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/nonrolling-upgrade-2.5.xml
index 27461e8..b1c2468d 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/nonrolling-upgrade-2.5.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/nonrolling-upgrade-2.5.xml
@@ -22,6 +22,7 @@
   <target-stack>HDP-2.5</target-stack>
   <type>NON_ROLLING</type>
   <prerequisite-checks>
+    <check>org.apache.ambari.server.checks.RangerAuditDbCheck</check>
     <configuration>
       <!-- Configuration properties for all pre-reqs including required pre-reqs -->
       <check-properties name="org.apache.ambari.server.checks.HiveDynamicServiceDiscoveryCheck">

http://git-wip-us.apache.org/repos/asf/ambari/blob/b03e8d8e/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.5.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.5.xml b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.5.xml
index ad1bc34..426b452 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.5.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.5.xml
@@ -36,6 +36,7 @@
     <check>org.apache.ambari.server.checks.YarnRMHighAvailabilityCheck</check>
     <check>org.apache.ambari.server.checks.YarnTimelineServerStatePreservingCheck</check>
     <check>org.apache.ambari.server.checks.AtlasPresenceCheck</check>
+    <check>org.apache.ambari.server.checks.RangerAuditDbCheck</check>
 
     <configuration>
       <!-- Configuration properties for all pre-reqs including required pre-reqs -->

http://git-wip-us.apache.org/repos/asf/ambari/blob/b03e8d8e/ambari-server/src/test/java/org/apache/ambari/server/checks/RangerAuditDbCheckTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/checks/RangerAuditDbCheckTest.java b/ambari-server/src/test/java/org/apache/ambari/server/checks/RangerAuditDbCheckTest.java
new file mode 100644
index 0000000..94284ac
--- /dev/null
+++ b/ambari-server/src/test/java/org/apache/ambari/server/checks/RangerAuditDbCheckTest.java
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ambari.server.checks;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.ambari.server.configuration.Configuration;
+import org.apache.ambari.server.controller.PrereqCheckRequest;
+import org.apache.ambari.server.orm.entities.ClusterVersionEntity;
+import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
+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.DesiredConfig;
+import org.apache.ambari.server.state.Service;
+import org.apache.ambari.server.state.StackId;
+import org.apache.ambari.server.state.stack.PrereqCheckStatus;
+import org.apache.ambari.server.state.stack.PrerequisiteCheck;
+import org.apache.ambari.server.state.stack.UpgradePack.PrerequisiteCheckConfig;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import com.google.inject.Provider;
+
+/* Tests for RangerAuditDbCheck */
+
+public class RangerAuditDbCheckTest {
+  private final Clusters clusters = Mockito.mock(Clusters.class);
+  private final RangerAuditDbCheck rangerAuditDbCheck = new RangerAuditDbCheck();
+
+  @Before
+  public void setup() {
+    rangerAuditDbCheck.clustersProvider = new Provider<Clusters>() {
+
+      @Override
+      public Clusters get() {
+        return clusters;
+      }
+    };
+    Configuration config = Mockito.mock(Configuration.class);
+    rangerAuditDbCheck.config = config;
+  }
+
+  @Test
+  public void testIsApplicable() throws Exception {
+    final Cluster cluster = Mockito.mock(Cluster.class);
+    final Map<String, Service> services = new HashMap<>();
+    final Service service = Mockito.mock(Service.class);
+
+    services.put("RANGER", service);
+
+    Mockito.when(cluster.getServices()).thenReturn(services);
+    Mockito.when(cluster.getClusterId()).thenReturn(1L);
+    Mockito.when(clusters.getCluster("cluster")).thenReturn(cluster);
+
+    Assert.assertTrue(rangerAuditDbCheck.isApplicable(new PrereqCheckRequest("cluster")));
+
+    services.remove("RANGER");
+    Assert.assertFalse(rangerAuditDbCheck.isApplicable(new PrereqCheckRequest("cluster")));
+  }
+
+  @Test
+  public void testPerform() throws Exception {
+    final Cluster cluster = Mockito.mock(Cluster.class);
+    final Map<String, Service> services = new HashMap<>();
+    final Service service = Mockito.mock(Service.class);
+
+    services.put("RANGER", service);
+
+    Mockito.when(cluster.getServices()).thenReturn(services);
+    Mockito.when(cluster.getClusterId()).thenReturn(1L);
+    Mockito.when(clusters.getCluster("cluster")).thenReturn(cluster);
+
+    final DesiredConfig desiredConfig = Mockito.mock(DesiredConfig.class);
+    Mockito.when(desiredConfig.getTag()).thenReturn("tag");
+    Map<String, DesiredConfig> configMap = new HashMap<String, DesiredConfig>();
+    configMap.put("ranger-admin-site", desiredConfig);
+
+    Mockito.when(cluster.getDesiredConfigs()).thenReturn(configMap);
+    final Config config = Mockito.mock(Config.class);
+    Mockito.when(cluster.getConfig(Mockito.anyString(), Mockito.anyString())).thenReturn(config);
+    final Map<String, String> properties = new HashMap<String, String>();
+    Mockito.when(config.getProperties()).thenReturn(properties);
+
+    properties.put("ranger.audit.source.type", "db");
+    PrerequisiteCheck check = new PrerequisiteCheck(null, null);
+    rangerAuditDbCheck.perform(check, new PrereqCheckRequest("cluster"));
+    Assert.assertEquals(PrereqCheckStatus.WARNING, check.getStatus());
+
+    properties.put("ranger.audit.source.type", "solr");
+    check = new PrerequisiteCheck(null, null);
+    rangerAuditDbCheck.perform(check, new PrereqCheckRequest("cluster"));
+    Assert.assertEquals(PrereqCheckStatus.PASS, check.getStatus());
+
+  }
+  
+}
\ No newline at end of file


[2/2] ambari git commit: AMBARI-17218. Show message of Audit to DB Removal during upgrade for Ranger(Mugdha Varadkar via gautam)

Posted by ga...@apache.org.
AMBARI-17218. Show message of Audit to DB Removal during upgrade for Ranger(Mugdha Varadkar via gautam)


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

Branch: refs/heads/branch-2.4
Commit: 471f1d921a88365c12284c9695da81901879f6be
Parents: e677801
Author: Gautam Borad <ga...@apache.org>
Authored: Wed Jun 15 19:40:35 2016 +0530
Committer: Gautam Borad <ga...@apache.org>
Committed: Wed Jun 15 21:16:49 2016 +0530

----------------------------------------------------------------------
 .../ambari/server/checks/CheckDescription.java  |   9 ++
 .../server/checks/RangerAuditDbCheck.java       |  61 ++++++++++
 .../ambari/server/checks/UpgradeCheckGroup.java |   7 +-
 .../HDP/2.3/upgrades/nonrolling-upgrade-2.5.xml |   1 +
 .../stacks/HDP/2.3/upgrades/upgrade-2.5.xml     |   1 +
 .../HDP/2.4/upgrades/nonrolling-upgrade-2.5.xml |   1 +
 .../stacks/HDP/2.4/upgrades/upgrade-2.5.xml     |   1 +
 .../server/checks/RangerAuditDbCheckTest.java   | 115 +++++++++++++++++++
 8 files changed, 195 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/471f1d92/ambari-server/src/main/java/org/apache/ambari/server/checks/CheckDescription.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/checks/CheckDescription.java b/ambari-server/src/main/java/org/apache/ambari/server/checks/CheckDescription.java
index 850b58a..e3d70c9 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/checks/CheckDescription.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/checks/CheckDescription.java
@@ -275,6 +275,15 @@ public enum CheckDescription {
         "After upgrading, Atlas can be reinstalled");
     }}),
 
+  RANGER_SERVICE_AUDIT_DB_CHECK(PrereqCheckType.SERVICE,
+    "Remove the Ranger Audit to Database Capability",
+    new HashMap<String, String>() {{
+      put(AbstractCheckDescriptor.DEFAULT,
+        "After upgrading, Ranger will no longer support the Audit to Database feature. Instead, Ranger will audit to Solr. " +
+        "To migrate the existing audit logs to Solr, follow the steps in this link."
+        );
+    }}),
+
   KAFKA_KERBEROS_CHECK(PrereqCheckType.SERVICE,
     "Kafka upgrade on Kerberized cluster",
     new HashMap<String, String>() {{

http://git-wip-us.apache.org/repos/asf/ambari/blob/471f1d92/ambari-server/src/main/java/org/apache/ambari/server/checks/RangerAuditDbCheck.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/checks/RangerAuditDbCheck.java b/ambari-server/src/main/java/org/apache/ambari/server/checks/RangerAuditDbCheck.java
new file mode 100644
index 0000000..ec4ed09
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/checks/RangerAuditDbCheck.java
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ambari.server.checks;
+
+import java.util.Arrays;
+
+import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.controller.PrereqCheckRequest;
+import org.apache.ambari.server.state.stack.PrereqCheckStatus;
+import org.apache.ambari.server.state.stack.PrerequisiteCheck;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.inject.Singleton;
+
+/**
+ * Ranger Service will not support Audit to DB after upgrade to 2.5 stack.
+ */
+@Singleton
+@UpgradeCheck(group = UpgradeCheckGroup.INFORMATIONAL_WARNING)
+public class RangerAuditDbCheck extends AbstractCheckDescriptor{
+
+  private static final Logger LOG = LoggerFactory.getLogger(RangerAuditDbCheck.class);
+  private static final String serviceName = "RANGER";
+
+  public RangerAuditDbCheck(){
+    super(CheckDescription.RANGER_SERVICE_AUDIT_DB_CHECK);
+  }
+
+  @Override
+  public boolean isApplicable(PrereqCheckRequest request) throws AmbariException {
+    return super.isApplicable(request, Arrays.asList(serviceName), true);
+  }
+
+  @Override
+  public void perform(PrerequisiteCheck prerequisiteCheck, PrereqCheckRequest request) throws AmbariException {
+
+    String propertyValue = getProperty(request, "ranger-admin-site", "ranger.audit.source.type");
+
+    if (null != propertyValue && propertyValue.equalsIgnoreCase("db")) {
+      prerequisiteCheck.getFailedOn().add(serviceName);
+      prerequisiteCheck.setStatus(PrereqCheckStatus.WARNING);
+      prerequisiteCheck.setFailReason(getFailReason(prerequisiteCheck, request));
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/471f1d92/ambari-server/src/main/java/org/apache/ambari/server/checks/UpgradeCheckGroup.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/checks/UpgradeCheckGroup.java b/ambari-server/src/main/java/org/apache/ambari/server/checks/UpgradeCheckGroup.java
index 34d016e..67cf4f1 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/checks/UpgradeCheckGroup.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/checks/UpgradeCheckGroup.java
@@ -75,11 +75,16 @@ public enum UpgradeCheckGroup {
   COMPONENT_VERSION(9.0f),
 
   /**
-   * A general group for related to Kerberos checks
+   * A general group for related to Kerberos checks.
    */
   KERBEROS(10.0f),
 
   /**
+   * A general group for informational warning checks.
+   */
+  INFORMATIONAL_WARNING(100.0f),
+
+  /**
    * All other checks.
    */
   DEFAULT(Float.MAX_VALUE);

http://git-wip-us.apache.org/repos/asf/ambari/blob/471f1d92/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.5.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.5.xml b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.5.xml
index 464c444..42c4979 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.5.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.5.xml
@@ -22,6 +22,7 @@
   <target-stack>HDP-2.5</target-stack>
   <type>NON_ROLLING</type>
   <prerequisite-checks>
+    <check>org.apache.ambari.server.checks.RangerAuditDbCheck</check>
     <configuration>
       <!-- Configuration properties for all pre-reqs including required pre-reqs -->
       <check-properties name="org.apache.ambari.server.checks.HiveDynamicServiceDiscoveryCheck">

http://git-wip-us.apache.org/repos/asf/ambari/blob/471f1d92/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.5.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.5.xml b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.5.xml
index dd04b64..3461ad4 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.5.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.5.xml
@@ -36,6 +36,7 @@
     <check>org.apache.ambari.server.checks.YarnRMHighAvailabilityCheck</check>
     <check>org.apache.ambari.server.checks.YarnTimelineServerStatePreservingCheck</check>
     <check>org.apache.ambari.server.checks.AtlasPresenceCheck</check>
+    <check>org.apache.ambari.server.checks.RangerAuditDbCheck</check>
 
     <configuration>
       <!-- Configuration properties for all pre-reqs including required pre-reqs -->

http://git-wip-us.apache.org/repos/asf/ambari/blob/471f1d92/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/nonrolling-upgrade-2.5.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/nonrolling-upgrade-2.5.xml b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/nonrolling-upgrade-2.5.xml
index 27461e8..b1c2468d 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/nonrolling-upgrade-2.5.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/nonrolling-upgrade-2.5.xml
@@ -22,6 +22,7 @@
   <target-stack>HDP-2.5</target-stack>
   <type>NON_ROLLING</type>
   <prerequisite-checks>
+    <check>org.apache.ambari.server.checks.RangerAuditDbCheck</check>
     <configuration>
       <!-- Configuration properties for all pre-reqs including required pre-reqs -->
       <check-properties name="org.apache.ambari.server.checks.HiveDynamicServiceDiscoveryCheck">

http://git-wip-us.apache.org/repos/asf/ambari/blob/471f1d92/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.5.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.5.xml b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.5.xml
index ad1bc34..426b452 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.5.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.5.xml
@@ -36,6 +36,7 @@
     <check>org.apache.ambari.server.checks.YarnRMHighAvailabilityCheck</check>
     <check>org.apache.ambari.server.checks.YarnTimelineServerStatePreservingCheck</check>
     <check>org.apache.ambari.server.checks.AtlasPresenceCheck</check>
+    <check>org.apache.ambari.server.checks.RangerAuditDbCheck</check>
 
     <configuration>
       <!-- Configuration properties for all pre-reqs including required pre-reqs -->

http://git-wip-us.apache.org/repos/asf/ambari/blob/471f1d92/ambari-server/src/test/java/org/apache/ambari/server/checks/RangerAuditDbCheckTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/checks/RangerAuditDbCheckTest.java b/ambari-server/src/test/java/org/apache/ambari/server/checks/RangerAuditDbCheckTest.java
new file mode 100644
index 0000000..94284ac
--- /dev/null
+++ b/ambari-server/src/test/java/org/apache/ambari/server/checks/RangerAuditDbCheckTest.java
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ambari.server.checks;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.ambari.server.configuration.Configuration;
+import org.apache.ambari.server.controller.PrereqCheckRequest;
+import org.apache.ambari.server.orm.entities.ClusterVersionEntity;
+import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
+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.DesiredConfig;
+import org.apache.ambari.server.state.Service;
+import org.apache.ambari.server.state.StackId;
+import org.apache.ambari.server.state.stack.PrereqCheckStatus;
+import org.apache.ambari.server.state.stack.PrerequisiteCheck;
+import org.apache.ambari.server.state.stack.UpgradePack.PrerequisiteCheckConfig;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import com.google.inject.Provider;
+
+/* Tests for RangerAuditDbCheck */
+
+public class RangerAuditDbCheckTest {
+  private final Clusters clusters = Mockito.mock(Clusters.class);
+  private final RangerAuditDbCheck rangerAuditDbCheck = new RangerAuditDbCheck();
+
+  @Before
+  public void setup() {
+    rangerAuditDbCheck.clustersProvider = new Provider<Clusters>() {
+
+      @Override
+      public Clusters get() {
+        return clusters;
+      }
+    };
+    Configuration config = Mockito.mock(Configuration.class);
+    rangerAuditDbCheck.config = config;
+  }
+
+  @Test
+  public void testIsApplicable() throws Exception {
+    final Cluster cluster = Mockito.mock(Cluster.class);
+    final Map<String, Service> services = new HashMap<>();
+    final Service service = Mockito.mock(Service.class);
+
+    services.put("RANGER", service);
+
+    Mockito.when(cluster.getServices()).thenReturn(services);
+    Mockito.when(cluster.getClusterId()).thenReturn(1L);
+    Mockito.when(clusters.getCluster("cluster")).thenReturn(cluster);
+
+    Assert.assertTrue(rangerAuditDbCheck.isApplicable(new PrereqCheckRequest("cluster")));
+
+    services.remove("RANGER");
+    Assert.assertFalse(rangerAuditDbCheck.isApplicable(new PrereqCheckRequest("cluster")));
+  }
+
+  @Test
+  public void testPerform() throws Exception {
+    final Cluster cluster = Mockito.mock(Cluster.class);
+    final Map<String, Service> services = new HashMap<>();
+    final Service service = Mockito.mock(Service.class);
+
+    services.put("RANGER", service);
+
+    Mockito.when(cluster.getServices()).thenReturn(services);
+    Mockito.when(cluster.getClusterId()).thenReturn(1L);
+    Mockito.when(clusters.getCluster("cluster")).thenReturn(cluster);
+
+    final DesiredConfig desiredConfig = Mockito.mock(DesiredConfig.class);
+    Mockito.when(desiredConfig.getTag()).thenReturn("tag");
+    Map<String, DesiredConfig> configMap = new HashMap<String, DesiredConfig>();
+    configMap.put("ranger-admin-site", desiredConfig);
+
+    Mockito.when(cluster.getDesiredConfigs()).thenReturn(configMap);
+    final Config config = Mockito.mock(Config.class);
+    Mockito.when(cluster.getConfig(Mockito.anyString(), Mockito.anyString())).thenReturn(config);
+    final Map<String, String> properties = new HashMap<String, String>();
+    Mockito.when(config.getProperties()).thenReturn(properties);
+
+    properties.put("ranger.audit.source.type", "db");
+    PrerequisiteCheck check = new PrerequisiteCheck(null, null);
+    rangerAuditDbCheck.perform(check, new PrereqCheckRequest("cluster"));
+    Assert.assertEquals(PrereqCheckStatus.WARNING, check.getStatus());
+
+    properties.put("ranger.audit.source.type", "solr");
+    check = new PrerequisiteCheck(null, null);
+    rangerAuditDbCheck.perform(check, new PrereqCheckRequest("cluster"));
+    Assert.assertEquals(PrereqCheckStatus.PASS, check.getStatus());
+
+  }
+  
+}
\ No newline at end of file