Search in sources :

Example 6 with SetupException

use of org.apache.atlas.setup.SetupException in project incubator-atlas by apache.

the class SetupStepsTest method shouldThrowSetupExceptionAndNotDoSetupIfSetupInProgressNodeExists.

@Test
public void shouldThrowSetupExceptionAndNotDoSetupIfSetupInProgressNodeExists() throws Exception {
    Set<SetupStep> steps = new LinkedHashSet<>();
    SetupStep setupStep1 = mock(SetupStep.class);
    steps.add(setupStep1);
    when(configuration.getString(HAConfiguration.ATLAS_SERVER_HA_ZK_ROOT_KEY, HAConfiguration.ATLAS_SERVER_ZK_ROOT_DEFAULT)).thenReturn(HAConfiguration.ATLAS_SERVER_ZK_ROOT_DEFAULT);
    setupServerIdSelectionMocks();
    setupSetupInProgressPathMocks(ZooDefs.Ids.OPEN_ACL_UNSAFE, mock(Stat.class));
    InterProcessMutex lock = mock(InterProcessMutex.class);
    when(curatorFactory.lockInstance(HAConfiguration.ATLAS_SERVER_ZK_ROOT_DEFAULT)).thenReturn(lock);
    SetupSteps setupSteps = new SetupSteps(steps, curatorFactory, configuration);
    try {
        setupSteps.runSetup();
    } catch (Exception e) {
        assertTrue(e instanceof SetupException);
    }
    verifyZeroInteractions(setupStep1);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Stat(org.apache.zookeeper.data.Stat) SetupException(org.apache.atlas.setup.SetupException) SetupStep(org.apache.atlas.setup.SetupStep) InterProcessMutex(org.apache.curator.framework.recipes.locks.InterProcessMutex) SetupException(org.apache.atlas.setup.SetupException) Test(org.testng.annotations.Test)

Aggregations

SetupException (org.apache.atlas.setup.SetupException)6 SetupStep (org.apache.atlas.setup.SetupStep)3 InterProcessMutex (org.apache.curator.framework.recipes.locks.InterProcessMutex)3 LinkedHashSet (java.util.LinkedHashSet)2 AtlasException (org.apache.atlas.AtlasException)2 CuratorFramework (org.apache.curator.framework.CuratorFramework)2 Test (org.testng.annotations.Test)2 PostConstruct (javax.annotation.PostConstruct)1 HAConfiguration (org.apache.atlas.ha.HAConfiguration)1 ACL (org.apache.zookeeper.data.ACL)1 Stat (org.apache.zookeeper.data.Stat)1 InOrder (org.mockito.InOrder)1