Search in sources :

Example 1 with RDSConfigRequest

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);
}
Also used : RDSConfigJson(com.sequenceiq.cloudbreak.api.model.rds.RDSConfigJson) Matchers.anySet(org.mockito.Matchers.anySet) Set(java.util.Set) HashSet(java.util.HashSet) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) RDSConfig(com.sequenceiq.cloudbreak.domain.RDSConfig) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) RDSConfigRequest(com.sequenceiq.cloudbreak.api.model.rds.RDSConfigRequest) ProxyConfigResponse(com.sequenceiq.cloudbreak.api.model.proxy.ProxyConfigResponse) ProxyConfig(com.sequenceiq.cloudbreak.domain.ProxyConfig) AmbariClient(com.sequenceiq.ambari.client.AmbariClient)

Example 2 with RDSConfigRequest

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);
}
Also used : IntegrationTestContext(com.sequenceiq.it.IntegrationTestContext) RDSConfigRequest(com.sequenceiq.cloudbreak.api.model.rds.RDSConfigRequest) RDSTestRequest(com.sequenceiq.cloudbreak.api.model.rds.RDSTestRequest) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Example 3 with RDSConfigRequest

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;
}
Also used : RDSConfigRequest(com.sequenceiq.cloudbreak.api.model.rds.RDSConfigRequest)

Example 4 with 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));
}
Also used : RDSConfig(com.sequenceiq.cloudbreak.domain.RDSConfig) APIResourceType(com.sequenceiq.cloudbreak.common.type.APIResourceType) RDSConfigRequest(com.sequenceiq.cloudbreak.api.model.rds.RDSConfigRequest) Test(org.junit.Test)

Example 5 with RDSConfigRequest

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;
}
Also used : RDSConfig(com.sequenceiq.cloudbreak.domain.RDSConfig) RDSConfigRequest(com.sequenceiq.cloudbreak.api.model.rds.RDSConfigRequest) RdsTestResult(com.sequenceiq.cloudbreak.api.model.rds.RdsTestResult)

Aggregations

RDSConfigRequest (com.sequenceiq.cloudbreak.api.model.rds.RDSConfigRequest)9 RDSConfig (com.sequenceiq.cloudbreak.domain.RDSConfig)6 APIResourceType (com.sequenceiq.cloudbreak.common.type.APIResourceType)4 Test (org.junit.Test)4 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)2 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)2 HashSet (java.util.HashSet)2 Set (java.util.Set)2 Strings (com.google.common.base.Strings)1 AmbariClient (com.sequenceiq.ambari.client.AmbariClient)1 BlueprintInputJson (com.sequenceiq.cloudbreak.api.model.BlueprintInputJson)1 BlueprintParameterJson (com.sequenceiq.cloudbreak.api.model.BlueprintParameterJson)1 ClusterRequest (com.sequenceiq.cloudbreak.api.model.ClusterRequest)1 ConfigsResponse (com.sequenceiq.cloudbreak.api.model.ConfigsResponse)1 ConnectedClusterRequest (com.sequenceiq.cloudbreak.api.model.ConnectedClusterRequest)1 HostGroupRequest (com.sequenceiq.cloudbreak.api.model.HostGroupRequest)1 LdapConfigRequest (com.sequenceiq.cloudbreak.api.model.ldap.LdapConfigRequest)1 ProxyConfigResponse (com.sequenceiq.cloudbreak.api.model.proxy.ProxyConfigResponse)1 RDSConfigJson (com.sequenceiq.cloudbreak.api.model.rds.RDSConfigJson)1 RDSTestRequest (com.sequenceiq.cloudbreak.api.model.rds.RDSTestRequest)1