atlas-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shweth...@apache.org
Subject incubator-atlas git commit: ATLAS-998 determine HA mode from property atlas.server.ids, instead of atlas.server.ha.enabled (madhan.neethiraj via shwethags)
Date Fri, 15 Jul 2016 11:57:19 GMT
Repository: incubator-atlas
Updated Branches:
  refs/heads/master de0bf1db9 -> ab624ddab


ATLAS-998 determine HA mode from property atlas.server.ids, instead of atlas.server.ha.enabled
(madhan.neethiraj via shwethags)


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

Branch: refs/heads/master
Commit: ab624ddabba53772ca72a5cb717baa22712ab27d
Parents: de0bf1d
Author: Shwetha GS <sshivalingamurthy@hortonworks.com>
Authored: Fri Jul 15 17:26:57 2016 +0530
Committer: Shwetha GS <sshivalingamurthy@hortonworks.com>
Committed: Fri Jul 15 17:26:57 2016 +0530

----------------------------------------------------------------------
 .../org/apache/atlas/ha/HAConfiguration.java    | 12 ++++++-
 .../apache/atlas/ha/HAConfigurationTest.java    | 32 ++++++++++++++++++-
 release-log.txt                                 |  1 +
 .../audit/HBaseBasedAuditRepositoryHATest.java  |  6 ++--
 .../graph/GraphBackedSearchIndexerMockTest.java |  9 +++---
 .../DefaultMetadataServiceMockTest.java         | 15 +++++----
 .../NotificationHookConsumerTest.java           |  7 +++--
 .../ActiveInstanceElectorServiceTest.java       | 33 ++++++++++++--------
 .../atlas/web/service/ServiceStateTest.java     |  3 +-
 .../apache/atlas/web/setup/SetupStepsTest.java  |  2 +-
 10 files changed, 88 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/ab624dda/common/src/main/java/org/apache/atlas/ha/HAConfiguration.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/atlas/ha/HAConfiguration.java b/common/src/main/java/org/apache/atlas/ha/HAConfiguration.java
index f3c9bc5..aefaef5 100644
--- a/common/src/main/java/org/apache/atlas/ha/HAConfiguration.java
+++ b/common/src/main/java/org/apache/atlas/ha/HAConfiguration.java
@@ -59,7 +59,17 @@ public final class HAConfiguration {
      * @return
      */
     public static boolean isHAEnabled(Configuration configuration) {
-        return configuration.getBoolean(ATLAS_SERVER_HA_ENABLED_KEY, false);
+        boolean ret = false;
+
+        if (configuration.containsKey(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)) {
+            ret = configuration.getBoolean(ATLAS_SERVER_HA_ENABLED_KEY);
+        } else {
+            String[] ids = configuration.getStringArray(HAConfiguration.ATLAS_SERVER_IDS);
+
+            ret = ids != null && ids.length > 1;
+        }
+
+        return ret;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/ab624dda/common/src/test/java/org/apache/atlas/ha/HAConfigurationTest.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/atlas/ha/HAConfigurationTest.java b/common/src/test/java/org/apache/atlas/ha/HAConfigurationTest.java
index a3129c9..b1188f9 100644
--- a/common/src/test/java/org/apache/atlas/ha/HAConfigurationTest.java
+++ b/common/src/test/java/org/apache/atlas/ha/HAConfigurationTest.java
@@ -30,10 +30,13 @@ import java.util.List;
 
 import static org.mockito.Mockito.when;
 import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
 import static org.testng.Assert.assertTrue;
 
 public class HAConfigurationTest {
 
+    private static final String[] TEST_ATLAS_SERVER_IDS_HA = new String[] { "id1", "id2"
};
+
     @Mock
     private Configuration configuration;
 
@@ -44,6 +47,33 @@ public class HAConfigurationTest {
     }
 
     @Test
+    public void testIsHAEnabledByLegacyConfiguration() {
+        when(configuration.containsKey(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(true);
+        when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(Boolean.TRUE);
+
+        boolean isHAEnabled = HAConfiguration.isHAEnabled(configuration);
+        assertTrue(isHAEnabled);
+
+        // restore
+        when(configuration.containsKey(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(false);
+        isHAEnabled = HAConfiguration.isHAEnabled(configuration);
+        assertFalse(isHAEnabled);
+    }
+
+    @Test
+    public void testIsHAEnabledByIds() {
+        when(configuration.containsKey(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(false);
+        when(configuration.getStringArray(HAConfiguration.ATLAS_SERVER_IDS)).thenReturn(TEST_ATLAS_SERVER_IDS_HA);
+        boolean isHAEnabled = HAConfiguration.isHAEnabled(configuration);
+        assertTrue(isHAEnabled);
+
+        // restore
+        when(configuration.getStringArray(HAConfiguration.ATLAS_SERVER_IDS)).thenReturn(new
String[] { "id1"});
+        isHAEnabled = HAConfiguration.isHAEnabled(configuration);
+        assertFalse(isHAEnabled);
+    }
+
+    @Test
     public void testShouldReturnHTTPSBoundAddress() {
         when(configuration.getString(HAConfiguration.ATLAS_SERVER_ADDRESS_PREFIX +"id1")).thenReturn("127.0.0.1:21443");
         when(configuration.getBoolean(SecurityProperties.TLS_ENABLED)).thenReturn(true);
@@ -55,7 +85,7 @@ public class HAConfigurationTest {
 
     @Test
     public void testShouldReturnListOfAddressesInConfig() {
-        when(configuration.getStringArray(HAConfiguration.ATLAS_SERVER_IDS)).thenReturn(new
String[] {"id1", "id2"});
+        when(configuration.getStringArray(HAConfiguration.ATLAS_SERVER_IDS)).thenReturn(TEST_ATLAS_SERVER_IDS_HA);
         when(configuration.getString(HAConfiguration.ATLAS_SERVER_ADDRESS_PREFIX +"id1")).thenReturn("127.0.0.1:21000");
         when(configuration.getString(HAConfiguration.ATLAS_SERVER_ADDRESS_PREFIX +"id2")).thenReturn("127.0.0.1:31000");
 

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/ab624dda/release-log.txt
----------------------------------------------------------------------
diff --git a/release-log.txt b/release-log.txt
index 8c195e7..df88f17 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -6,6 +6,7 @@ INCOMPATIBLE CHANGES:
 
 
 ALL CHANGES:
+ATLAS-998 determine HA mode from property atlas.server.ids, instead of atlas.server.ha.enabled
(madhan.neethiraj via shwethags)
 ATLAS-986 Ability to differentiate business catalog terms from traits (sumasai,svimal2106
via shwethags)
 ATLAS-1025 Set HIVE_HOME if hive is available in relative path to import hive script (svimal2106
via shwethags)
 ATLAS-1009 Source HIVE_HOME and HIVE_CONF_DIR from hive_env.sh (svimal2106 via shwethags)

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/ab624dda/repository/src/test/java/org/apache/atlas/repository/audit/HBaseBasedAuditRepositoryHATest.java
----------------------------------------------------------------------
diff --git a/repository/src/test/java/org/apache/atlas/repository/audit/HBaseBasedAuditRepositoryHATest.java
b/repository/src/test/java/org/apache/atlas/repository/audit/HBaseBasedAuditRepositoryHATest.java
index 2f7edb4..f66ac74 100644
--- a/repository/src/test/java/org/apache/atlas/repository/audit/HBaseBasedAuditRepositoryHATest.java
+++ b/repository/src/test/java/org/apache/atlas/repository/audit/HBaseBasedAuditRepositoryHATest.java
@@ -54,7 +54,8 @@ public class HBaseBasedAuditRepositoryHATest {
 
     @Test
     public void testTableShouldNotBeCreatedOnStartIfHAIsEnabled() throws IOException, AtlasException
{
-        when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY, false)).thenReturn(true);
+        when(configuration.containsKey(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(true);
+        when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(true);
         when(configuration.getString(HBaseBasedAuditRepository.CONFIG_TABLE_NAME,
                 HBaseBasedAuditRepository.DEFAULT_TABLE_NAME)).
                 thenReturn(HBaseBasedAuditRepository.DEFAULT_TABLE_NAME);
@@ -71,7 +72,8 @@ public class HBaseBasedAuditRepositoryHATest {
 
     @Test
     public void testShouldCreateTableWhenReactingToActive() throws AtlasException, IOException
{
-        when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY, false)).thenReturn(true);
+        when(configuration.containsKey(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(true);
+        when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(true);
         when(configuration.getString(HBaseBasedAuditRepository.CONFIG_TABLE_NAME,
                 HBaseBasedAuditRepository.DEFAULT_TABLE_NAME)).
                 thenReturn(HBaseBasedAuditRepository.DEFAULT_TABLE_NAME);

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/ab624dda/repository/src/test/java/org/apache/atlas/repository/graph/GraphBackedSearchIndexerMockTest.java
----------------------------------------------------------------------
diff --git a/repository/src/test/java/org/apache/atlas/repository/graph/GraphBackedSearchIndexerMockTest.java
b/repository/src/test/java/org/apache/atlas/repository/graph/GraphBackedSearchIndexerMockTest.java
index 94dd298..f3680de 100644
--- a/repository/src/test/java/org/apache/atlas/repository/graph/GraphBackedSearchIndexerMockTest.java
+++ b/repository/src/test/java/org/apache/atlas/repository/graph/GraphBackedSearchIndexerMockTest.java
@@ -68,20 +68,21 @@ public class GraphBackedSearchIndexerMockTest {
 
     @Test
     public void testSearchIndicesAreNotInitializedOnConstructionWhenHAIsEnabled() throws
IndexException, RepositoryException {
-        when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY, false)).thenReturn(true);
+        when(configuration.containsKey(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(true);
+        when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(true);
         when(graphProvider.get()).thenReturn(titanGraph);
         when(titanGraph.getManagementSystem()).thenReturn(titanManagement);
         when(titanManagement.containsPropertyKey(Constants.VERTEX_TYPE_PROPERTY_KEY)).thenReturn(true);
 
-        GraphBackedSearchIndexer graphBackedSearchIndexer = new GraphBackedSearchIndexer(graphProvider,
configuration);
-
+        new GraphBackedSearchIndexer(graphProvider, configuration);
         verifyZeroInteractions(titanManagement);
 
     }
 
     @Test
     public void testIndicesAreReinitializedWhenServerBecomesActive() throws AtlasException
{
-        when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY, false)).thenReturn(true);
+        when(configuration.containsKey(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(true);
+        when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(true);
         when(graphProvider.get()).thenReturn(titanGraph);
         when(titanGraph.getManagementSystem()).thenReturn(titanManagement);
         when(titanManagement.containsPropertyKey(Constants.VERTEX_TYPE_PROPERTY_KEY)).thenReturn(true);

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/ab624dda/repository/src/test/java/org/apache/atlas/services/DefaultMetadataServiceMockTest.java
----------------------------------------------------------------------
diff --git a/repository/src/test/java/org/apache/atlas/services/DefaultMetadataServiceMockTest.java
b/repository/src/test/java/org/apache/atlas/services/DefaultMetadataServiceMockTest.java
index 393b539..9722a72 100644
--- a/repository/src/test/java/org/apache/atlas/services/DefaultMetadataServiceMockTest.java
+++ b/repository/src/test/java/org/apache/atlas/services/DefaultMetadataServiceMockTest.java
@@ -72,7 +72,8 @@ public class DefaultMetadataServiceMockTest {
     @Test
     public void testShouldInvokeTypesRegistrarOnCreation() throws AtlasException {
         when(typeSystem.isRegistered(any(String.class))).thenReturn(true);
-        when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY, false)).thenReturn(false);
+        when(configuration.containsKey(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(true);
+        when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(false);
         DefaultMetadataService defaultMetadataService = new DefaultMetadataService(mock(MetadataRepository.class),
                 mock(ITypeStore.class),
                 typesRegistrar, new ArrayList<Provider<TypesChangeListener>>(),
@@ -84,10 +85,10 @@ public class DefaultMetadataServiceMockTest {
 
     @Test
     public void testShouldNotRestoreTypesIfHAIsEnabled() throws AtlasException {
-        when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY, false)).thenReturn(true);
+        when(configuration.containsKey(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(true);
+        when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(true);
 
-        DefaultMetadataService defaultMetadataService = new DefaultMetadataService(metadataRepository,
-                typeStore,
+        new DefaultMetadataService(metadataRepository, typeStore,
                 typesRegistrar, new ArrayList<Provider<TypesChangeListener>>(),
                 new ArrayList<Provider<EntityChangeListener>>(), typeSystem,
configuration, null);
 
@@ -98,7 +99,8 @@ public class DefaultMetadataServiceMockTest {
 
     @Test
     public void testShouldRestoreTypeSystemOnServerActive() throws AtlasException {
-        when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY, false)).thenReturn(true);
+        when(configuration.containsKey(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(true);
+        when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(true);
 
         TypesDef typesDef = mock(TypesDef.class);
         when(typeStore.restore()).thenReturn(typesDef);
@@ -118,7 +120,8 @@ public class DefaultMetadataServiceMockTest {
 
     @Test
     public void testShouldOnlyRestoreCacheOnServerActiveIfAlreadyDoneOnce() throws AtlasException
{
-        when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY, false)).thenReturn(true);
+        when(configuration.containsKey(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(true);
+        when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(true);
 
         TypesDef typesDef = mock(TypesDef.class);
         when(typeStore.restore()).thenReturn(typesDef);

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/ab624dda/webapp/src/test/java/org/apache/atlas/notification/NotificationHookConsumerTest.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/atlas/notification/NotificationHookConsumerTest.java
b/webapp/src/test/java/org/apache/atlas/notification/NotificationHookConsumerTest.java
index 7860eb6..d22c5f1 100644
--- a/webapp/src/test/java/org/apache/atlas/notification/NotificationHookConsumerTest.java
+++ b/webapp/src/test/java/org/apache/atlas/notification/NotificationHookConsumerTest.java
@@ -35,7 +35,6 @@ import java.util.concurrent.ExecutorService;
 import static org.mockito.Mockito.any;
 import static org.mockito.Mockito.doThrow;
 import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verifyZeroInteractions;
@@ -162,7 +161,8 @@ public class NotificationHookConsumerTest {
 
     @Test
     public void testConsumersAreNotStartedIfHAIsEnabled() {
-        when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY, false)).thenReturn(true);
+        when(configuration.containsKey(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(true);
+        when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(true);
         when(configuration.getInt(NotificationHookConsumer.CONSUMER_THREADS_PROPERTY, 1)).thenReturn(1);
         List<NotificationConsumer<Object>> consumers = new ArrayList();
         consumers.add(mock(NotificationConsumer.class));
@@ -175,7 +175,8 @@ public class NotificationHookConsumerTest {
 
     @Test
     public void testConsumersAreStartedWhenInstanceBecomesActive() {
-        when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY, false)).thenReturn(true);
+        when(configuration.containsKey(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(true);
+        when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(true);
         when(configuration.getInt(NotificationHookConsumer.CONSUMER_THREADS_PROPERTY, 1)).thenReturn(1);
         List<NotificationConsumer<Object>> consumers = new ArrayList();
         consumers.add(mock(NotificationConsumer.class));

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/ab624dda/webapp/src/test/java/org/apache/atlas/web/service/ActiveInstanceElectorServiceTest.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/atlas/web/service/ActiveInstanceElectorServiceTest.java
b/webapp/src/test/java/org/apache/atlas/web/service/ActiveInstanceElectorServiceTest.java
index 2b7691f..c0ffc6e 100644
--- a/webapp/src/test/java/org/apache/atlas/web/service/ActiveInstanceElectorServiceTest.java
+++ b/webapp/src/test/java/org/apache/atlas/web/service/ActiveInstanceElectorServiceTest.java
@@ -64,7 +64,8 @@ public class ActiveInstanceElectorServiceTest {
 
     @Test
     public void testLeaderElectionIsJoinedOnStart() throws Exception {
-        when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY, false)).thenReturn(true);
+        when(configuration.containsKey(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(true);
+        when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(true);
         when(configuration.getStringArray(HAConfiguration.ATLAS_SERVER_IDS)).thenReturn(new
String[] {"id1"});
         when(configuration.getString(HAConfiguration.ATLAS_SERVER_ADDRESS_PREFIX +"id1")).thenReturn("127.0.0.1:21000");
         when(configuration.getString(
@@ -83,7 +84,8 @@ public class ActiveInstanceElectorServiceTest {
 
     @Test
     public void testListenerIsAddedForActiveInstanceCallbacks() throws Exception {
-        when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY, false)).thenReturn(true);
+        when(configuration.containsKey(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(true);
+        when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(true);
         when(configuration.getStringArray(HAConfiguration.ATLAS_SERVER_IDS)).thenReturn(new
String[] {"id1"});
         when(configuration.getString(HAConfiguration.ATLAS_SERVER_ADDRESS_PREFIX +"id1")).thenReturn("127.0.0.1:21000");
         when(configuration.getString(
@@ -115,7 +117,8 @@ public class ActiveInstanceElectorServiceTest {
 
     @Test
     public void testLeaderElectionIsLeftOnStop() throws IOException, AtlasException {
-        when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY, false)).thenReturn(true);
+        when(configuration.containsKey(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(true);
+        when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(true);
         when(configuration.getStringArray(HAConfiguration.ATLAS_SERVER_IDS)).thenReturn(new
String[] {"id1"});
         when(configuration.getString(HAConfiguration.ATLAS_SERVER_ADDRESS_PREFIX +"id1")).thenReturn("127.0.0.1:21000");
         when(configuration.getString(
@@ -136,8 +139,8 @@ public class ActiveInstanceElectorServiceTest {
 
     @Test
     public void testCuratorFactoryIsClosedOnStop() throws AtlasException {
-
-        when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY, false)).thenReturn(true);
+        when(configuration.containsKey(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(true);
+        when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(true);
         when(configuration.getStringArray(HAConfiguration.ATLAS_SERVER_IDS)).thenReturn(new
String[] {"id1"});
         when(configuration.getString(HAConfiguration.ATLAS_SERVER_ADDRESS_PREFIX +"id1")).thenReturn("127.0.0.1:21000");
         when(configuration.getString(
@@ -171,7 +174,8 @@ public class ActiveInstanceElectorServiceTest {
 
     @Test
     public void testRegisteredHandlersAreNotifiedWhenInstanceIsActive() throws AtlasException
{
-        when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY, false)).thenReturn(true);
+        when(configuration.containsKey(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(true);
+        when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(true);
         when(configuration.getStringArray(HAConfiguration.ATLAS_SERVER_IDS)).thenReturn(new
String[] {"id1"});
         when(configuration.getString(HAConfiguration.ATLAS_SERVER_ADDRESS_PREFIX +"id1")).thenReturn("127.0.0.1:21000");
         when(configuration.getString(
@@ -211,7 +215,8 @@ public class ActiveInstanceElectorServiceTest {
 
     @Test
     public void testSharedStateIsUpdatedWhenInstanceIsActive() throws Exception {
-        when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY, false)).thenReturn(true);
+        when(configuration.containsKey(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(true);
+        when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(true);
         when(configuration.getStringArray(HAConfiguration.ATLAS_SERVER_IDS)).thenReturn(new
String[] {"id1"});
         when(configuration.getString(HAConfiguration.ATLAS_SERVER_ADDRESS_PREFIX +"id1")).thenReturn("127.0.0.1:21000");
         when(configuration.getString(
@@ -233,7 +238,8 @@ public class ActiveInstanceElectorServiceTest {
 
     @Test
     public void testRegisteredHandlersAreNotifiedOfPassiveWhenStateUpdateFails() throws Exception
{
-        when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY, false)).thenReturn(true);
+        when(configuration.containsKey(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(true);
+        when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(true);
         when(configuration.getStringArray(HAConfiguration.ATLAS_SERVER_IDS)).thenReturn(new
String[] {"id1"});
         when(configuration.getString(HAConfiguration.ATLAS_SERVER_ADDRESS_PREFIX +"id1")).thenReturn("127.0.0.1:21000");
         when(configuration.getString(
@@ -276,8 +282,8 @@ public class ActiveInstanceElectorServiceTest {
 
     @Test
     public void testElectionIsRejoinedWhenStateUpdateFails() throws Exception {
-
-        when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY, false)).thenReturn(true);
+        when(configuration.containsKey(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(true);
+        when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(true);
         when(configuration.getStringArray(HAConfiguration.ATLAS_SERVER_IDS)).thenReturn(new
String[] {"id1"});
         when(configuration.getString(HAConfiguration.ATLAS_SERVER_ADDRESS_PREFIX +"id1")).thenReturn("127.0.0.1:21000");
         when(configuration.getString(
@@ -306,8 +312,8 @@ public class ActiveInstanceElectorServiceTest {
 
     @Test
     public void testRegisteredHandlersAreNotifiedOfPassiveWhenInstanceIsPassive() throws
AtlasException {
-
-        when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY, false)).thenReturn(true);
+        when(configuration.containsKey(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(true);
+        when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(true);
         when(configuration.getStringArray(HAConfiguration.ATLAS_SERVER_IDS)).thenReturn(new
String[] {"id1"});
         when(configuration.getString(HAConfiguration.ATLAS_SERVER_ADDRESS_PREFIX +"id1")).thenReturn("127.0.0.1:21000");
         when(configuration.getString(
@@ -374,7 +380,8 @@ public class ActiveInstanceElectorServiceTest {
 
     @Test
     public void testPassiveStateSetIfActivationFails() throws Exception {
-        when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY, false)).thenReturn(true);
+        when(configuration.containsKey(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(true);
+        when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(true);
         when(configuration.getStringArray(HAConfiguration.ATLAS_SERVER_IDS)).thenReturn(new
String[] {"id1"});
         when(configuration.getString(HAConfiguration.ATLAS_SERVER_ADDRESS_PREFIX +"id1")).thenReturn("127.0.0.1:21000");
         when(configuration.getString(

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/ab624dda/webapp/src/test/java/org/apache/atlas/web/service/ServiceStateTest.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/atlas/web/service/ServiceStateTest.java b/webapp/src/test/java/org/apache/atlas/web/service/ServiceStateTest.java
index 77aba88..c171dfd 100644
--- a/webapp/src/test/java/org/apache/atlas/web/service/ServiceStateTest.java
+++ b/webapp/src/test/java/org/apache/atlas/web/service/ServiceStateTest.java
@@ -58,7 +58,8 @@ public class ServiceStateTest {
 
     @Test
     public void testShouldChangeStateIfHAIsEnabled() {
-        when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY, false)).thenReturn(true);
+        when(configuration.containsKey(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(true);
+        when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(true);
 
         ServiceState serviceState = new ServiceState(configuration);
         serviceState.becomingPassive();

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/ab624dda/webapp/src/test/java/org/apache/atlas/web/setup/SetupStepsTest.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/atlas/web/setup/SetupStepsTest.java b/webapp/src/test/java/org/apache/atlas/web/setup/SetupStepsTest.java
index 93eb3f7..82abc1b 100644
--- a/webapp/src/test/java/org/apache/atlas/web/setup/SetupStepsTest.java
+++ b/webapp/src/test/java/org/apache/atlas/web/setup/SetupStepsTest.java
@@ -20,7 +20,6 @@ package org.apache.atlas.web.setup;
 
 import com.google.common.base.Charsets;
 import org.apache.atlas.AtlasConstants;
-import org.apache.atlas.AtlasException;
 import org.apache.atlas.ha.HAConfiguration;
 import org.apache.atlas.setup.SetupException;
 import org.apache.atlas.setup.SetupStep;
@@ -123,6 +122,7 @@ public class SetupStepsTest {
 
 
     private void setupServerIdSelectionMocks() {
+        when(configuration.containsKey(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(false);
         when(configuration.getStringArray(HAConfiguration.ATLAS_SERVER_IDS)).thenReturn(new
String[] {"id1", "id2"});
         when(configuration.getString(HAConfiguration.ATLAS_SERVER_ADDRESS_PREFIX +"id1")).thenReturn("127.0.0.1:31000");
         when(configuration.getString(HAConfiguration.ATLAS_SERVER_ADDRESS_PREFIX +"id2")).thenReturn("127.0.0.1:21000");


Mime
View raw message