Search in sources :

Example 6 with AmbariClient

use of com.sequenceiq.ambari.client.AmbariClient in project cloudbreak by hortonworks.

the class AmbariSmartSenseCapturerTest method testCaptureWhenNoTriggerNeedsToBeDone.

@Test
public void testCaptureWhenNoTriggerNeedsToBeDone() {
    Optional<SmartSenseSubscription> smartSenseSubscription = Optional.empty();
    AmbariClient ambariClient = Mockito.mock(AmbariClient.class);
    when(smartSenseSubscriptionService.getDefault()).thenReturn(smartSenseSubscription);
    when(smartsenseConfigurationLocator.smartsenseConfigurable(smartSenseSubscription)).thenReturn(false);
    underTest.capture(1, ambariClient);
    verify(ambariClient, times(0)).smartSenseCapture(anyInt());
}
Also used : SmartSenseSubscription(com.sequenceiq.cloudbreak.domain.SmartSenseSubscription) AmbariClient(com.sequenceiq.ambari.client.AmbariClient) Test(org.junit.Test)

Example 7 with AmbariClient

use of com.sequenceiq.ambari.client.AmbariClient in project cloudbreak by hortonworks.

the class AmbariUserHandlerTest method testCreateAmbariUserWhenNoExceptionOccuredThenEverythingShouldWorksFine.

@Test
public void testCreateAmbariUserWhenNoExceptionOccuredThenEverythingShouldWorksFine() throws CloudbreakException {
    String newUserName = "newUserName";
    String newPassword = "newPassword";
    Stack stack = TestUtil.stack();
    AmbariClient ambariClient = mock(AmbariClient.class);
    when(ambariClient.createUser(newUserName, newPassword, true)).thenReturn(ambariClient);
    AmbariClient ambariClientResult = underTest.createAmbariUser(newUserName, newPassword, stack, ambariClient);
    Assert.assertEquals(ambariClient, ambariClientResult);
    verify(ambariClient, times(1)).createUser(newUserName, newPassword, true);
    verify(ambariClientFactory, times(0)).getAmbariClient(stack, newUserName, newPassword);
    verify(ambariClient, times(0)).ambariServerVersion();
}
Also used : Stack(com.sequenceiq.cloudbreak.domain.Stack) AmbariClient(com.sequenceiq.ambari.client.AmbariClient) Test(org.junit.Test)

Example 8 with AmbariClient

use of com.sequenceiq.ambari.client.AmbariClient in project cloudbreak by hortonworks.

the class AmbariViewProviderTest method testProvideViewInformationWhenExceptionOccuredThenNoSaveHappensOnRepository.

@Test
public void testProvideViewInformationWhenExceptionOccuredThenNoSaveHappensOnRepository() {
    Cluster cluster = TestUtil.cluster();
    AmbariClient ambariClient = mock(AmbariClient.class);
    when(ambariClient.getViewDefinitions()).thenThrow(new AmbariHostsUnavailableException("failed"));
    Cluster result = underTest.provideViewInformation(ambariClient, cluster);
    Assert.assertEquals(cluster, result);
    verify(clusterRepository, times(0)).save(any(Cluster.class));
    verify(ambariClient, times(1)).getViewDefinitions();
}
Also used : Cluster(com.sequenceiq.cloudbreak.domain.Cluster) AmbariClient(com.sequenceiq.ambari.client.AmbariClient) Test(org.junit.Test)

Example 9 with AmbariClient

use of com.sequenceiq.ambari.client.AmbariClient in project cloudbreak by hortonworks.

the class AmbariViewProviderTest method testProvideViewInformationWhenEverythingWorksFine.

@Test
public void testProvideViewInformationWhenEverythingWorksFine() {
    Cluster cluster = TestUtil.cluster();
    AmbariClient ambariClient = mock(AmbariClient.class);
    when(clusterRepository.save(cluster)).thenReturn(cluster);
    when(ambariClient.getViewDefinitions()).thenReturn(Lists.newArrayList("test1", "test2"));
    Cluster result = underTest.provideViewInformation(ambariClient, cluster);
    Assert.assertEquals(cluster, result);
    verify(clusterRepository, times(1)).save(any(Cluster.class));
    verify(ambariClient, times(1)).getViewDefinitions();
}
Also used : Cluster(com.sequenceiq.cloudbreak.domain.Cluster) AmbariClient(com.sequenceiq.ambari.client.AmbariClient) Test(org.junit.Test)

Example 10 with AmbariClient

use of com.sequenceiq.ambari.client.AmbariClient in project cloudbreak by hortonworks.

the class AmbariDecommissionerTest method testVerifyNodeCountWithoutReplicationFactory.

@Test
public void testVerifyNodeCountWithoutReplicationFactory() throws CloudbreakSecuritySetupException {
    String hostGroupName = "hostGroupName";
    String hostname = "hostname";
    String ipAddress = "192.18.256.1";
    int gatewayPort = 1234;
    String ambariName = "ambari-name";
    Map<String, List<String>> blueprintMap = new HashMap<>();
    blueprintMap.put(hostGroupName, Collections.singletonList("NODEMANAGER"));
    Blueprint blueprint = new Blueprint();
    blueprint.setName(ambariName);
    blueprint.setAmbariName(ambariName);
    Cluster cluster = new Cluster();
    cluster.setAmbariIp(ipAddress);
    cluster.setBlueprint(blueprint);
    Stack stack = new Stack();
    stack.setGatewayPort(gatewayPort);
    stack.setId(100L);
    HostGroup hostGroup = new HostGroup();
    hostGroup.setName(hostGroupName);
    hostGroup.setHostMetadata(Collections.singleton(getHostMetadata(0L)));
    AmbariClient ambariClient = mock(AmbariClient.class);
    HttpClientConfig config = new HttpClientConfig(ipAddress);
    when(tlsSecurityService.buildTLSClientConfigForPrimaryGateway(stack.getId(), cluster.getAmbariIp())).thenReturn(config);
    when(ambariClientProvider.getAmbariClient(config, stack.getGatewayPort(), cluster)).thenReturn(ambariClient);
    when(hostGroupService.getByClusterAndHostName(cluster, hostname)).thenReturn(hostGroup);
    when(ambariClient.getBlueprintMap(ambariName)).thenReturn(blueprintMap);
    underTest.verifyNodeCount(stack, cluster, hostname);
    verify(configurationService, times(0)).getConfiguration(ambariClient, hostGroupName);
}
Also used : HttpClientConfig(com.sequenceiq.cloudbreak.client.HttpClientConfig) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) List(java.util.List) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) Stack(com.sequenceiq.cloudbreak.domain.Stack) AmbariClient(com.sequenceiq.ambari.client.AmbariClient) Test(org.junit.Test)

Aggregations

AmbariClient (com.sequenceiq.ambari.client.AmbariClient)78 Test (org.junit.Test)39 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)37 Stack (com.sequenceiq.cloudbreak.domain.Stack)32 HttpClientConfig (com.sequenceiq.cloudbreak.client.HttpClientConfig)23 HostMetadata (com.sequenceiq.cloudbreak.domain.HostMetadata)16 CloudbreakException (com.sequenceiq.cloudbreak.service.CloudbreakException)16 HashMap (java.util.HashMap)16 PollingResult (com.sequenceiq.cloudbreak.service.PollingResult)15 CancellationException (com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException)14 HostGroup (com.sequenceiq.cloudbreak.domain.HostGroup)14 Matchers.anyString (org.mockito.Matchers.anyString)14 Map (java.util.Map)13 AmbariConnectionException (com.sequenceiq.ambari.client.AmbariConnectionException)10 Collections.singletonMap (java.util.Collections.singletonMap)9 HashSet (java.util.HashSet)9 HostGroupAdjustmentJson (com.sequenceiq.cloudbreak.api.model.HostGroupAdjustmentJson)6 Status (com.sequenceiq.cloudbreak.api.model.Status)6 List (java.util.List)6 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)6