Search in sources :

Example 1 with HostGroupRequest

use of com.sequenceiq.cloudbreak.api.model.HostGroupRequest in project cloudbreak by hortonworks.

the class MockClusterCreationWithSaltFailTest method convertHostGroups.

private Set<HostGroupRequest> convertHostGroups(Iterable<HostGroup> hostGroups, String runRecipesOnHosts) {
    Set<Long> recipeIds = Collections.emptySet();
    List<String> hostGroupsWithRecipe = Collections.emptyList();
    if (!runRecipesOnHosts.isEmpty()) {
        recipeIds = getItContext().getContextParam(CloudbreakITContextConstants.RECIPE_ID, Set.class);
        Assert.assertFalse(recipeIds == null || recipeIds.isEmpty());
        hostGroupsWithRecipe = Arrays.asList(runRecipesOnHosts.split(","));
    }
    Set<HostGroupRequest> hgMaps = new HashSet<>();
    for (HostGroup hostgroup : hostGroups) {
        HostGroupRequest hostGroupBase = new HostGroupRequest();
        hostGroupBase.setName(hostgroup.getName());
        ConstraintJson constraintJson = new ConstraintJson();
        constraintJson.setInstanceGroupName(hostgroup.getInstanceGroupName());
        constraintJson.setHostCount(hostgroup.getHostCount());
        hostGroupBase.setConstraint(constraintJson);
        if (hostGroupsWithRecipe.contains(hostgroup.getName())) {
            hostGroupBase.setRecipeIds(recipeIds);
        }
        hgMaps.add(hostGroupBase);
    }
    return hgMaps;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HostGroupRequest(com.sequenceiq.cloudbreak.api.model.HostGroupRequest) HostGroup(com.sequenceiq.it.cloudbreak.HostGroup) ConstraintJson(com.sequenceiq.cloudbreak.api.model.ConstraintJson) HashSet(java.util.HashSet)

Example 2 with HostGroupRequest

use of com.sequenceiq.cloudbreak.api.model.HostGroupRequest in project cloudbreak by hortonworks.

the class MockClusterCreationWithSaltFailTest method testClusterCreation.

@Test
@Parameters({ "clusterName", "ambariPort", "ambariUser", "ambariPassword", "emailNeeded", "enableSecurity", "kerberosMasterKey", "kerberosAdmin", "kerberosPassword", "runRecipesOnHosts", "checkAmbari", "mockPort" })
public void testClusterCreation(@Optional("it-cluster") String clusterName, @Optional("8080") String ambariPort, @Optional("admin") String ambariUser, @Optional("admin123!@#") String ambariPassword, @Optional("false") boolean emailNeeded, @Optional("false") boolean enableSecurity, @Optional String kerberosMasterKey, @Optional String kerberosAdmin, @Optional String kerberosPassword, @Optional("") String runRecipesOnHosts, @Optional("true") boolean checkAmbari, @Optional("9443") int mockPort) throws Exception {
    // GIVEN
    IntegrationTestContext itContext = getItContext();
    String stackIdStr = itContext.getContextParam(CloudbreakITContextConstants.STACK_ID);
    Integer stackId = Integer.valueOf(stackIdStr);
    Integer blueprintId = Integer.valueOf(itContext.getContextParam(CloudbreakITContextConstants.BLUEPRINT_ID));
    List<HostGroup> hostgroups = itContext.getContextParam(CloudbreakITContextConstants.HOSTGROUP_ID, List.class);
    Set<HostGroupRequest> hostGroupJsons1 = convertHostGroups(hostgroups, runRecipesOnHosts);
    itContext.putContextParam(CloudbreakITContextConstants.AMBARI_USER_ID, ambariUser);
    itContext.putContextParam(CloudbreakITContextConstants.AMBARI_PASSWORD_ID, ambariPassword);
    // WHEN
    ClusterRequest clusterRequest = new ClusterRequest();
    clusterRequest.setName(clusterName);
    clusterRequest.setDescription("Cluster for integration test");
    clusterRequest.setEnableSecurity(enableSecurity);
    clusterRequest.setPassword(ambariPassword);
    clusterRequest.setUserName(ambariUser);
    clusterRequest.setBlueprintId(Long.valueOf(blueprintId));
    clusterRequest.setHostGroups(hostGroupJsons1);
    KerberosRequest kerberosRequest = new KerberosRequest();
    kerberosRequest.setAdmin(kerberosAdmin);
    kerberosRequest.setPassword(kerberosPassword);
    kerberosRequest.setMasterKey(kerberosMasterKey);
    clusterRequest.setKerberos(kerberosRequest);
    initSpark();
    Map<String, CloudVmMetaDataStatus> instanceMap = itContext.getContextParam(CloudbreakITContextConstants.MOCK_INSTANCE_MAP, Map.class);
    addSaltMappings(instanceMap);
    addAmbariMappings(instanceMap);
    ClusterV1Endpoint clusterV1Endpoint = getCloudbreakClient().clusterEndpoint();
    Long clusterId = clusterV1Endpoint.post(Long.valueOf(stackId), clusterRequest).getId();
    // THEN
    Assert.assertNotNull(clusterId);
    CloudbreakUtil.waitAndCheckStackStatus(getCloudbreakClient(), stackIdStr, "AVAILABLE");
    String failMessage = "Source file salt://ambari/scripts/ambari-server-initttt.sh not found | " + "Service ambari-server is already enabled, and is dead | " + "Package haveged is already installed.";
    CloudbreakUtil.checkClusterFailed(getCloudbreakClient().stackV1Endpoint(), stackIdStr, failMessage);
}
Also used : IntegrationTestContext(com.sequenceiq.it.IntegrationTestContext) ClusterRequest(com.sequenceiq.cloudbreak.api.model.ClusterRequest) HostGroupRequest(com.sequenceiq.cloudbreak.api.model.HostGroupRequest) HostGroup(com.sequenceiq.it.cloudbreak.HostGroup) ClusterV1Endpoint(com.sequenceiq.cloudbreak.api.endpoint.v1.ClusterV1Endpoint) CloudVmMetaDataStatus(com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus) KerberosRequest(com.sequenceiq.cloudbreak.api.model.KerberosRequest) Parameters(org.testng.annotations.Parameters) AbstractMockIntegrationTest(com.sequenceiq.it.cloudbreak.AbstractMockIntegrationTest) Test(org.testng.annotations.Test)

Example 3 with HostGroupRequest

use of com.sequenceiq.cloudbreak.api.model.HostGroupRequest in project cloudbreak by hortonworks.

the class MockClusterCreationWithSaltSuccessTest method testClusterCreation.

@Test
@Parameters({ "clusterName", "ambariPort", "ambariUser", "ambariPassword", "emailNeeded", "enableSecurity", "kerberosMasterKey", "kerberosAdmin", "kerberosPassword", "runRecipesOnHosts", "checkAmbari", "mockPort" })
public void testClusterCreation(@Optional("it-cluster") String clusterName, @Optional("8080") String ambariPort, @Optional("admin") String ambariUser, @Optional("admin123!@#") String ambariPassword, @Optional("false") boolean emailNeeded, @Optional("false") boolean enableSecurity, @Optional String kerberosMasterKey, @Optional String kerberosAdmin, @Optional String kerberosPassword, @Optional("") String runRecipesOnHosts, @Optional("true") boolean checkAmbari, @Optional("9443") int mockPort) throws Exception {
    // GIVEN
    IntegrationTestContext itContext = getItContext();
    String stackIdStr = itContext.getContextParam(CloudbreakITContextConstants.STACK_ID);
    Integer stackId = Integer.valueOf(stackIdStr);
    Integer blueprintId = Integer.valueOf(itContext.getContextParam(CloudbreakITContextConstants.BLUEPRINT_ID));
    List<HostGroup> hostgroups = itContext.getContextParam(CloudbreakITContextConstants.HOSTGROUP_ID, List.class);
    Set<HostGroupRequest> hostGroupJsons1 = convertHostGroups(hostgroups, runRecipesOnHosts);
    itContext.putContextParam(CloudbreakITContextConstants.AMBARI_USER_ID, ambariUser);
    itContext.putContextParam(CloudbreakITContextConstants.AMBARI_PASSWORD_ID, ambariPassword);
    // WHEN
    ClusterRequest clusterRequest = new ClusterRequest();
    clusterRequest.setName(clusterName);
    clusterRequest.setDescription("Cluster for integration test");
    clusterRequest.setEmailNeeded(emailNeeded);
    clusterRequest.setEnableSecurity(enableSecurity);
    clusterRequest.setPassword(ambariPassword);
    clusterRequest.setUserName(ambariUser);
    clusterRequest.setBlueprintId(Long.valueOf(blueprintId));
    clusterRequest.setHostGroups(hostGroupJsons1);
    if (enableSecurity) {
        KerberosRequest kerberosRequest = new KerberosRequest();
        kerberosRequest.setAdmin(kerberosAdmin);
        kerberosRequest.setPassword(kerberosPassword);
        kerberosRequest.setMasterKey(kerberosMasterKey);
        clusterRequest.setKerberos(kerberosRequest);
    }
    GatewayJson gatewayJson = new GatewayJson();
    gatewayJson.setEnableGateway(Boolean.TRUE);
    gatewayJson.setExposedServices(ImmutableList.of("ALL"));
    clusterRequest.setGateway(gatewayJson);
    ClusterV1Endpoint clusterV1Endpoint = getCloudbreakClient().clusterEndpoint();
    Long clusterId = clusterV1Endpoint.post(Long.valueOf(stackId), clusterRequest).getId();
    // THEN
    Assert.assertNotNull(clusterId);
    CloudbreakUtil.waitAndCheckStackStatus(getCloudbreakClient(), stackIdStr, "AVAILABLE");
    CloudbreakUtil.checkClusterAvailability(getCloudbreakClient().stackV1Endpoint(), ambariPort, stackIdStr, ambariUser, ambariPassword, checkAmbari);
    StackCreationMock stackCreationMock = getItContext().getContextParam(CloudbreakV2Constants.MOCK_SERVER, StackCreationMock.class);
    stackCreationMock.verifyCalls(clusterName);
}
Also used : IntegrationTestContext(com.sequenceiq.it.IntegrationTestContext) ClusterRequest(com.sequenceiq.cloudbreak.api.model.ClusterRequest) HostGroupRequest(com.sequenceiq.cloudbreak.api.model.HostGroupRequest) HostGroup(com.sequenceiq.it.cloudbreak.HostGroup) ClusterV1Endpoint(com.sequenceiq.cloudbreak.api.endpoint.v1.ClusterV1Endpoint) KerberosRequest(com.sequenceiq.cloudbreak.api.model.KerberosRequest) StackCreationMock(com.sequenceiq.it.cloudbreak.v2.mock.StackCreationMock) GatewayJson(com.sequenceiq.cloudbreak.api.model.GatewayJson) Parameters(org.testng.annotations.Parameters) AbstractCloudbreakIntegrationTest(com.sequenceiq.it.cloudbreak.AbstractCloudbreakIntegrationTest) Test(org.testng.annotations.Test)

Example 4 with HostGroupRequest

use of com.sequenceiq.cloudbreak.api.model.HostGroupRequest in project cloudbreak by hortonworks.

the class ClusterCreationTest method convertHostGroups.

private Set<HostGroupRequest> convertHostGroups(Collection<HostGroup> hostGroups, String runRecipesOnHosts, Boolean autoRecoveryMode) {
    Set<Long> recipeIds = Collections.emptySet();
    List<String> hostGroupsWithRecipe = Collections.emptyList();
    if (!runRecipesOnHosts.isEmpty()) {
        recipeIds = getItContext().getContextParam(CloudbreakITContextConstants.RECIPE_ID, Set.class);
        Assert.assertFalse(recipeIds == null || recipeIds.isEmpty());
        hostGroupsWithRecipe = Arrays.asList(runRecipesOnHosts.split(","));
    }
    Set<HostGroupRequest> hgMaps = new HashSet<>(hostGroups.size());
    for (HostGroup hostgroup : hostGroups) {
        HostGroupRequest hostGroupBase = new HostGroupRequest();
        hostGroupBase.setName(hostgroup.getName());
        if (Boolean.TRUE.equals(autoRecoveryMode)) {
            hostGroupBase.setRecoveryMode(RecoveryMode.AUTO);
        }
        ConstraintJson constraintJson = new ConstraintJson();
        constraintJson.setInstanceGroupName(hostgroup.getInstanceGroupName());
        constraintJson.setHostCount(hostgroup.getHostCount());
        hostGroupBase.setConstraint(constraintJson);
        if (hostGroupsWithRecipe.contains(hostgroup.getName())) {
            hostGroupBase.setRecipeIds(recipeIds);
        }
        hgMaps.add(hostGroupBase);
    }
    return hgMaps;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HostGroupRequest(com.sequenceiq.cloudbreak.api.model.HostGroupRequest) ConstraintJson(com.sequenceiq.cloudbreak.api.model.ConstraintJson) HashSet(java.util.HashSet)

Example 5 with HostGroupRequest

use of com.sequenceiq.cloudbreak.api.model.HostGroupRequest in project cloudbreak by hortonworks.

the class ClusterCreationTest method testClusterCreation.

@Test
@Parameters({ "clusterName", "emailNeeded", "enableSecurity", "kerberosMasterKey", "kerberosAdmin", "kerberosPassword", "runRecipesOnHosts", "checkAmbari", "withRDSConfig", "autoRecoveryMode", "withFs" })
public void testClusterCreation(@Optional("it-cluster") String clusterName, @Optional("false") boolean emailNeeded, @Optional("false") boolean enableSecurity, @Optional String kerberosMasterKey, @Optional String kerberosAdmin, @Optional String kerberosPassword, @Optional("") String runRecipesOnHosts, @Optional("true") boolean checkAmbari, @Optional("false") boolean withRDSConfig, @Optional("false") boolean autoRecoveryMode, @Optional("false") boolean withFs) throws Exception {
    // GIVEN
    IntegrationTestContext itContext = getItContext();
    String stackIdStr = itContext.getContextParam(CloudbreakITContextConstants.STACK_ID);
    Integer stackId = Integer.valueOf(stackIdStr);
    Integer blueprintId = Integer.valueOf(itContext.getContextParam(CloudbreakITContextConstants.BLUEPRINT_ID));
    List<HostGroup> hostgroups = itContext.getContextParam(CloudbreakITContextConstants.HOSTGROUP_ID, List.class);
    Set<HostGroupRequest> hostGroupJsons1 = convertHostGroups(hostgroups, runRecipesOnHosts, autoRecoveryMode);
    String ambariUser = itContext.getContextParam(CloudbreakITContextConstants.AMBARI_USER_ID);
    String ambariPassword = itContext.getContextParam(CloudbreakITContextConstants.AMBARI_PASSWORD_ID);
    String ambariPort = itContext.getContextParam(CloudbreakITContextConstants.AMBARI_PORT_ID);
    // WHEN
    ClusterRequest clusterRequest = new ClusterRequest();
    clusterRequest.setName(clusterName);
    clusterRequest.setDescription("Cluster for integration test");
    clusterRequest.setEnableSecurity(enableSecurity);
    clusterRequest.setPassword(ambariPassword);
    clusterRequest.setUserName(ambariUser);
    clusterRequest.setBlueprintId(Long.valueOf(blueprintId));
    clusterRequest.setHostGroups(hostGroupJsons1);
    if (withRDSConfig) {
        clusterRequest = setRDSConfiguration(itContext, clusterRequest);
    }
    if (withFs) {
        clusterRequest = setFileSystem(itContext, clusterRequest);
    }
    if (enableSecurity) {
        KerberosRequest kerberosRequest = new KerberosRequest();
        kerberosRequest.setAdmin(kerberosAdmin);
        kerberosRequest.setPassword(kerberosPassword);
        kerberosRequest.setMasterKey(kerberosMasterKey);
        clusterRequest.setKerberos(kerberosRequest);
    }
    ClusterV1Endpoint clusterV1Endpoint = getCloudbreakClient().clusterEndpoint();
    Long clusterId = clusterV1Endpoint.post(Long.valueOf(stackId), clusterRequest).getId();
    // THEN
    Assert.assertNotNull(clusterId);
    CloudbreakUtil.waitAndCheckStackStatus(getCloudbreakClient(), stackIdStr, "AVAILABLE");
    CloudbreakUtil.checkClusterAvailability(getCloudbreakClient().stackV1Endpoint(), ambariPort, stackIdStr, ambariUser, ambariPassword, checkAmbari);
    if (Boolean.TRUE.equals(withRDSConfig)) {
        checkRDSConfigWithCluster(itContext, clusterName);
    }
}
Also used : IntegrationTestContext(com.sequenceiq.it.IntegrationTestContext) ClusterV1Endpoint(com.sequenceiq.cloudbreak.api.endpoint.v1.ClusterV1Endpoint) ClusterRequest(com.sequenceiq.cloudbreak.api.model.ClusterRequest) HostGroupRequest(com.sequenceiq.cloudbreak.api.model.HostGroupRequest) KerberosRequest(com.sequenceiq.cloudbreak.api.model.KerberosRequest) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Aggregations

HostGroupRequest (com.sequenceiq.cloudbreak.api.model.HostGroupRequest)13 HashSet (java.util.HashSet)7 ConstraintJson (com.sequenceiq.cloudbreak.api.model.ConstraintJson)5 ClusterRequest (com.sequenceiq.cloudbreak.api.model.ClusterRequest)4 HostGroup (com.sequenceiq.it.cloudbreak.HostGroup)4 ClusterV1Endpoint (com.sequenceiq.cloudbreak.api.endpoint.v1.ClusterV1Endpoint)3 KerberosRequest (com.sequenceiq.cloudbreak.api.model.KerberosRequest)3 HostGroup (com.sequenceiq.cloudbreak.domain.HostGroup)3 IntegrationTestContext (com.sequenceiq.it.IntegrationTestContext)3 Set (java.util.Set)3 Parameters (org.testng.annotations.Parameters)3 Test (org.testng.annotations.Test)3 InstanceGroupV2Request (com.sequenceiq.cloudbreak.api.model.v2.InstanceGroupV2Request)2 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)2 AmbariStackDetailsJson (com.sequenceiq.cloudbreak.api.model.AmbariStackDetailsJson)1 GatewayJson (com.sequenceiq.cloudbreak.api.model.GatewayJson)1 UpdateClusterJson (com.sequenceiq.cloudbreak.api.model.UpdateClusterJson)1 CloudVmMetaDataStatus (com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus)1 StackRepoDetails (com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails)1 IdentityUser (com.sequenceiq.cloudbreak.common.model.user.IdentityUser)1