use of com.sequenceiq.cloudbreak.client.HttpClientConfig 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);
}
use of com.sequenceiq.cloudbreak.client.HttpClientConfig in project cloudbreak by hortonworks.
the class AmbariDecommissionerTest method testVerifyNodeCountWithReplicationFactory.
@Test
public void testVerifyNodeCountWithReplicationFactory() 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("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(Sets.newHashSet(getHostMetadata(0L), getHostMetadata(1L), getHostMetadata(2L), getHostMetadata(3L)));
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"));
underTest.verifyNodeCount(stack, cluster, hostname);
verify(configurationService, times(1)).getConfiguration(ambariClient, hostGroupName);
}
use of com.sequenceiq.cloudbreak.client.HttpClientConfig in project cloudbreak by hortonworks.
the class AmbariClusterHostServiceTypeTest method setUp.
@Before
public void setUp() {
stack = TestUtil.stack();
cluster = TestUtil.cluster(TestUtil.blueprint(), stack, 1L);
stack.setCluster(cluster);
when(stackService.get(anyLong())).thenReturn(stack);
when(stackService.getByIdWithLists(anyLong())).thenReturn(stack);
when(stackService.getById(anyLong())).thenReturn(stack);
when(clusterRepository.save(any(Cluster.class))).thenReturn(cluster);
given(tlsSecurityService.buildTLSClientConfigForPrimaryGateway(anyLong(), anyString())).willReturn(new HttpClientConfig("", "", "/tmp", "/tmp"));
}
use of com.sequenceiq.cloudbreak.client.HttpClientConfig in project cloudbreak by hortonworks.
the class AmbariClientFactoryTest method testGetAmbariClientWithUsernameAndPasswordWhenEverythingWorksFine.
@Test
public void testGetAmbariClientWithUsernameAndPasswordWhenEverythingWorksFine() throws CloudbreakSecuritySetupException {
Stack stack = TestUtil.stack();
Cluster cluster = TestUtil.cluster();
stack.setCluster(cluster);
String userName = "userName";
String password = "password";
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(), userName, password)).thenReturn(ambariClient);
AmbariClient defaultAmbariClient = underTest.getAmbariClient(stack, userName, password);
Assert.assertEquals(ambariClient, defaultAmbariClient);
verify(tlsSecurityService, times(1)).buildTLSClientConfigForPrimaryGateway(stack.getId(), stack.getAmbariIp());
verify(ambariClientProvider, times(1)).getAmbariClient(httpClientConfig, stack.getGatewayPort(), userName, password);
}
use of com.sequenceiq.cloudbreak.client.HttpClientConfig in project cloudbreak by hortonworks.
the class AmbariClientFactoryTest method testGetAmbariClientWithUsernameAndPasswordWhenExceptionOccuredWhichIsCloudbreakSecuritySetupException.
@Test
public void testGetAmbariClientWithUsernameAndPasswordWhenExceptionOccuredWhichIsCloudbreakSecuritySetupException() throws CloudbreakSecuritySetupException {
Stack stack = TestUtil.stack();
Cluster cluster = TestUtil.cluster();
String userName = "userName";
String password = "password";
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, userName, password);
Assert.assertEquals(ambariClient, defaultAmbariClient);
verify(tlsSecurityService, times(1)).buildTLSClientConfigForPrimaryGateway(stack.getId(), stack.getAmbariIp());
verify(ambariClientProvider, times(0)).getAmbariClient(httpClientConfig, stack.getGatewayPort(), userName, password);
}
Aggregations