use of com.sequenceiq.cloudbreak.api.model.rds.RDSConfigRequest in project cloudbreak by hortonworks.
the class ClusterToClusterResponseConverterTest method mockAll.
private void mockAll() throws IOException {
when(ambariViewProvider.provideViewInformation(any(AmbariClient.class), any(Cluster.class))).thenAnswer(invocation -> {
Object[] args = invocation.getArguments();
return args[1];
});
given(blueprintValidator.getHostGroupNode(any(Blueprint.class))).willReturn(jsonNode);
given(jsonNode.iterator()).willReturn(mockIterator);
given(mockIterator.hasNext()).willReturn(true).willReturn(false);
given(mockIterator.next()).willReturn(jsonNode);
given(conversionService.convert(any(RDSConfig.class), eq(RDSConfigJson.class))).willReturn(new RDSConfigRequest());
given(blueprintValidator.getHostGroupName(jsonNode)).willReturn("slave_1");
given(blueprintValidator.createHostGroupMap(any(Set.class))).willReturn(hostGroupMap);
given(hostGroupMap.get("slave_1")).willReturn(hostGroup);
given(instanceGroup.getInstanceMetaData()).willReturn(Sets.newHashSet(instanceMetaData));
given(blueprintValidator.getComponentsNode(jsonNode)).willReturn(nameJsonNode);
given(nameJsonNode.iterator()).willReturn(mockComponentIterator);
given(mockComponentIterator.hasNext()).willReturn(true).willReturn(false);
given(mockComponentIterator.next()).willReturn(nameJsonNode);
given(nameJsonNode.get(anyString())).willReturn(nameJsonNode);
given(nameJsonNode.asText()).willReturn("dummyName");
given(componentConfigProvider.getAmbariRepo(any(Set.class))).willReturn(null);
given(stackServiceComponentDescs.get(anyString())).willReturn(stackServiceComponentDescriptor);
ProxyConfigResponse proxyConfigResponse = new ProxyConfigResponse();
proxyConfigResponse.setId(1L);
given(proxyConfigMapper.mapEntityToResponse(any(ProxyConfig.class))).willReturn(proxyConfigResponse);
}
use of com.sequenceiq.cloudbreak.api.model.rds.RDSConfigRequest in project cloudbreak by hortonworks.
the class RDSConfigTest method testRDSConfig.
@Test
@Parameters({ "rdsName", "rdsUser", "rdsPassword", "rdsConnectionUrl", "rdsDbType", "hdpVersion" })
public void testRDSConfig(String rdsName, @Optional("") String rdsUser, @Optional("") String rdsPassword, @Optional("") String rdsConnectionUrl, @Optional("POSTGRES") String rdsDbType, @Optional("2.5") String hdpVersion) {
// GIVEN
IntegrationTestContext itContext = getItContext();
rdsUser = StringUtils.hasLength(rdsUser) ? rdsUser : defaultRdsUser;
rdsPassword = StringUtils.hasLength(rdsPassword) ? rdsPassword : defaultRdsPassword;
rdsConnectionUrl = StringUtils.hasLength(rdsConnectionUrl) ? rdsConnectionUrl : defaultRdsConnectionUrl;
RDSConfigRequest rdsCreateRequest = new RDSConfigRequest();
rdsCreateRequest.setName(rdsName);
rdsCreateRequest.setConnectionUserName(rdsUser);
rdsCreateRequest.setConnectionPassword(rdsPassword);
rdsCreateRequest.setConnectionURL(rdsConnectionUrl);
RDSTestRequest testRequest = new RDSTestRequest();
testRequest.setRdsConfig(rdsCreateRequest);
// WHEN
String rdsConnectionResult = getCloudbreakClient().rdsConfigEndpoint().testRdsConnection(testRequest).getConnectionResult();
Assert.assertEquals(rdsConnectionResult, "connected", "RDS connection test failed. Set the RDS configuration parameters properly.");
String rdsConfigId = getCloudbreakClient().rdsConfigEndpoint().postPrivate(rdsCreateRequest).getId().toString();
itContext.putContextParam(CloudbreakITContextConstants.RDS_CONFIG_ID, rdsConfigId);
itContext.putCleanUpParam(CloudbreakITContextConstants.RDS_CONFIG_ID, rdsConfigId);
// THEN
String listedRDSByName = getCloudbreakClient().rdsConfigEndpoint().getPrivate(rdsName).getName();
Assert.assertEquals(listedRDSByName, rdsName);
}
use of com.sequenceiq.cloudbreak.api.model.rds.RDSConfigRequest in project cloudbreak by hortonworks.
the class RDSConfigRequestToRDSConfigConverterTest method rdsConfigRequest.
private RDSConfigRequest rdsConfigRequest() {
RDSConfigRequest rdsConfigRequest = new RDSConfigRequest();
rdsConfigRequest.setConnectionPassword("password");
rdsConfigRequest.setConnectionUserName("username");
rdsConfigRequest.setConnectionURL("jdbc:postgresql://test.eu-west-1.rds.amazonaws.com:5432/test");
rdsConfigRequest.setName("testname");
rdsConfigRequest.setType("HIVE");
return rdsConfigRequest;
}
use of com.sequenceiq.cloudbreak.api.model.rds.RDSConfigRequest in project cloudbreak by hortonworks.
the class RDSConfigRequestToRDSConfigConverterTest method mysqlJdbcConverterTestWhenDatabaseCanBeDetectedThenShouldReturnMysqlVendorProperties.
@Test
public void mysqlJdbcConverterTestWhenDatabaseCanBeDetectedThenShouldReturnMysqlVendorProperties() {
RDSConfigRequest rdsConfigRequest = rdsConfigRequest();
rdsConfigRequest.setConnectionURL("jdbc:mysql://test.eu-west-1.rds.amazonaws.com:5432/test");
RDSConfig rdsConfig = underTest.convert(rdsConfigRequest);
Assert.assertEquals(rdsConfigRequest.getConnectionPassword(), rdsConfig.getConnectionPassword());
Assert.assertEquals(rdsConfigRequest.getConnectionUserName(), rdsConfig.getConnectionUserName());
Assert.assertEquals(rdsConfigRequest.getConnectionURL(), rdsConfig.getConnectionURL());
Assert.assertEquals(rdsConfigRequest.getType(), rdsConfig.getType());
Assert.assertEquals(rdsConfigRequest.getName(), rdsConfig.getName());
Assert.assertEquals(DatabaseVendor.MYSQL.connectionDriver(), rdsConfig.getConnectionDriver());
Assert.assertEquals(DatabaseVendor.MYSQL.name(), rdsConfig.getDatabaseEngine());
verify(missingResourceNameGenerator, times(0)).generateName(any(APIResourceType.class));
}
use of com.sequenceiq.cloudbreak.api.model.rds.RDSConfigRequest in project cloudbreak by hortonworks.
the class RdsConfigController method testRdsConnection.
@Override
public RdsTestResult testRdsConnection(RDSTestRequest rdsTestRequest) {
String existingRDSConfigName = rdsTestRequest.getName();
RDSConfigRequest configRequest = rdsTestRequest.getRdsConfig();
if (existingRDSConfigName == null && configRequest == null) {
throw new BadRequestException("Either an RDSConfig id, name or an RDSConfig request needs to be specified in the request. ");
}
RdsTestResult rdsTestResult = new RdsTestResult();
if (existingRDSConfigName != null) {
try {
RDSConfig config = rdsConfigService.getByName(existingRDSConfigName, authenticatedUserService.getCbUser());
rdsTestResult = testRDSConnectivity(config.getConnectionURL(), config.getConnectionUserName(), config.getConnectionPassword());
} catch (NotFoundException e) {
rdsTestResult.setConnectionResult("not found");
}
} else {
rdsTestResult = testRDSConnectivity(configRequest.getConnectionURL(), configRequest.getConnectionUserName(), configRequest.getConnectionPassword());
}
return rdsTestResult;
}
Aggregations