use of com.sequenceiq.cloudbreak.client.HttpClientConfig in project cloudbreak by hortonworks.
the class AmbariClientFactoryTest method testGetDefaultAmbariClientWhenExceptionOccuredWhichIsCloudbreakSecuritySetupException.
@Test
public void testGetDefaultAmbariClientWhenExceptionOccuredWhichIsCloudbreakSecuritySetupException() throws CloudbreakSecuritySetupException {
Stack stack = TestUtil.stack();
HttpClientConfig httpClientConfig = new HttpClientConfig(stack.getAmbariIp());
AmbariClient ambariClient = Mockito.mock(AmbariClient.class);
when(tlsSecurityService.buildTLSClientConfigForPrimaryGateway(stack.getId(), stack.getAmbariIp())).thenThrow(new IllegalArgumentException("failed"));
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("failed");
AmbariClient defaultAmbariClient = underTest.getDefaultAmbariClient(stack);
Assert.assertEquals(ambariClient, defaultAmbariClient);
verify(tlsSecurityService, times(1)).buildTLSClientConfigForPrimaryGateway(stack.getId(), stack.getAmbariIp());
verify(ambariClientProvider, times(0)).getDefaultAmbariClient(httpClientConfig, stack.getGatewayPort());
}
use of com.sequenceiq.cloudbreak.client.HttpClientConfig in project cloudbreak by hortonworks.
the class AmbariClientFactoryTest method testGetAmbariClientWhenExceptionOccuredWhichIsCloudbreakSecuritySetupException.
@Test
public void testGetAmbariClientWhenExceptionOccuredWhichIsCloudbreakSecuritySetupException() throws CloudbreakSecuritySetupException {
Stack stack = TestUtil.stack();
Cluster cluster = TestUtil.cluster();
stack.setCluster(cluster);
HttpClientConfig httpClientConfig = new HttpClientConfig(stack.getAmbariIp());
AmbariClient ambariClient = Mockito.mock(AmbariClient.class);
when(tlsSecurityService.buildTLSClientConfigForPrimaryGateway(stack.getId(), stack.getAmbariIp())).thenThrow(new IllegalArgumentException("failed"));
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("failed");
AmbariClient defaultAmbariClient = underTest.getAmbariClient(stack, cluster);
Assert.assertEquals(ambariClient, defaultAmbariClient);
verify(tlsSecurityService, times(1)).buildTLSClientConfigForPrimaryGateway(stack.getId(), stack.getAmbariIp());
verify(ambariClientProvider, times(0)).getAmbariClient(httpClientConfig, stack.getGatewayPort(), cluster);
}
use of com.sequenceiq.cloudbreak.client.HttpClientConfig in project cloudbreak by hortonworks.
the class AmbariClientFactoryTest method testGetDefaultAmbariClientWhenEverythingWorksFine.
@Test
public void testGetDefaultAmbariClientWhenEverythingWorksFine() throws CloudbreakSecuritySetupException {
Stack stack = TestUtil.stack();
HttpClientConfig httpClientConfig = new HttpClientConfig(stack.getAmbariIp());
AmbariClient ambariClient = Mockito.mock(AmbariClient.class);
when(tlsSecurityService.buildTLSClientConfigForPrimaryGateway(stack.getId(), stack.getAmbariIp())).thenReturn(httpClientConfig);
when(ambariClientProvider.getDefaultAmbariClient(httpClientConfig, stack.getGatewayPort())).thenReturn(ambariClient);
AmbariClient defaultAmbariClient = underTest.getDefaultAmbariClient(stack);
Assert.assertEquals(ambariClient, defaultAmbariClient);
verify(tlsSecurityService, times(1)).buildTLSClientConfigForPrimaryGateway(stack.getId(), stack.getAmbariIp());
verify(ambariClientProvider, times(1)).getDefaultAmbariClient(httpClientConfig, stack.getGatewayPort());
}
use of com.sequenceiq.cloudbreak.client.HttpClientConfig in project cloudbreak by hortonworks.
the class AmbariClientFactoryTest method testGetAmbariClientWhenEverythingWorksFine.
@Test
public void testGetAmbariClientWhenEverythingWorksFine() throws CloudbreakSecuritySetupException {
Stack stack = TestUtil.stack();
Cluster cluster = TestUtil.cluster();
stack.setCluster(cluster);
HttpClientConfig httpClientConfig = new HttpClientConfig(stack.getAmbariIp());
AmbariClient ambariClient = Mockito.mock(AmbariClient.class);
when(tlsSecurityService.buildTLSClientConfigForPrimaryGateway(stack.getId(), stack.getAmbariIp())).thenReturn(httpClientConfig);
when(ambariClientProvider.getAmbariClient(httpClientConfig, stack.getGatewayPort(), cluster)).thenReturn(ambariClient);
AmbariClient defaultAmbariClient = underTest.getAmbariClient(stack, cluster);
Assert.assertEquals(ambariClient, defaultAmbariClient);
verify(tlsSecurityService, times(1)).buildTLSClientConfigForPrimaryGateway(stack.getId(), stack.getAmbariIp());
verify(ambariClientProvider, times(1)).getAmbariClient(httpClientConfig, stack.getGatewayPort(), cluster);
}
use of com.sequenceiq.cloudbreak.client.HttpClientConfig in project cloudbreak by hortonworks.
the class AmbariDecommissionerTest method testVerifyNodeCountWithValidationException.
@Test
public void testVerifyNodeCountWithValidationException() throws CloudbreakSecuritySetupException {
thrown.expect(NotEnoughNodeException.class);
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("DATANODE"));
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);
when(configurationService.getConfiguration(ambariClient, hostGroupName)).thenReturn(Collections.singletonMap(ConfigParam.DFS_REPLICATION.key(), "3"));
thrown.expect(NotEnoughNodeException.class);
thrown.expectMessage("There is not enough node to downscale. Check the replication factor and the ApplicationMaster occupation.");
underTest.verifyNodeCount(stack, cluster, hostname);
}
Aggregations