Search in sources :

Example 26 with IntegrationTestContext

use of com.sequenceiq.it.IntegrationTestContext in project cloudbreak by hortonworks.

the class ClusterStopTest method testClusterStop.

@Test
public void testClusterStop() {
    // GIVEN
    IntegrationTestContext itContext = getItContext();
    String stackId = itContext.getContextParam(CloudbreakITContextConstants.STACK_ID);
    Integer stackIntId = Integer.valueOf(stackId);
    // WHEN
    UpdateClusterJson updateClusterJson = new UpdateClusterJson();
    updateClusterJson.setStatus(StatusRequest.valueOf(STOPPED));
    CloudbreakUtil.checkResponse("StopCluster", getCloudbreakClient().clusterEndpoint().put(Long.valueOf(stackIntId), updateClusterJson));
    CloudbreakUtil.waitAndCheckClusterStatus(getCloudbreakClient(), stackId, STOPPED);
// THEN
}
Also used : IntegrationTestContext(com.sequenceiq.it.IntegrationTestContext) UpdateClusterJson(com.sequenceiq.cloudbreak.api.model.UpdateClusterJson) AbstractCloudbreakIntegrationTest(com.sequenceiq.it.cloudbreak.AbstractCloudbreakIntegrationTest) Test(org.testng.annotations.Test)

Example 27 with IntegrationTestContext

use of com.sequenceiq.it.IntegrationTestContext in project cloudbreak by hortonworks.

the class ClusterCreationTest method setContextParameters.

@BeforeMethod
public void setContextParameters() {
    IntegrationTestContext itContext = getItContext();
    Assert.assertNotNull(itContext.getContextParam(CloudbreakITContextConstants.BLUEPRINT_ID), "Blueprint id is mandatory.");
    Assert.assertNotNull(itContext.getContextParam(CloudbreakITContextConstants.STACK_ID), "Stack id is mandatory.");
    Assert.assertNotNull(itContext.getContextParam(CloudbreakITContextConstants.AMBARI_USER_ID), "Ambari user id is mandatory.");
    Assert.assertNotNull(itContext.getContextParam(CloudbreakITContextConstants.AMBARI_PASSWORD_ID), "Ambari password id is mandatory.");
    Assert.assertNotNull(itContext.getContextParam(CloudbreakITContextConstants.AMBARI_PORT_ID), "Ambari port id is mandatory.");
}
Also used : IntegrationTestContext(com.sequenceiq.it.IntegrationTestContext) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 28 with IntegrationTestContext

use of com.sequenceiq.it.IntegrationTestContext 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)

Example 29 with IntegrationTestContext

use of com.sequenceiq.it.IntegrationTestContext in project cloudbreak by hortonworks.

the class GatewayTests method setup.

@BeforeTest
public void setup() throws Exception {
    given(CloudbreakClient.isCreated());
    given(cloudProvider.aValidCredential());
    IntegrationTestContext it = getItContext();
    credentialId = Credential.getTestContextCredential().apply(it).getResponse().getId();
}
Also used : IntegrationTestContext(com.sequenceiq.it.IntegrationTestContext) BeforeTest(org.testng.annotations.BeforeTest)

Example 30 with IntegrationTestContext

use of com.sequenceiq.it.IntegrationTestContext in project cloudbreak by hortonworks.

the class StackCreationTest method testStackCreation.

@Test
@Parameters({ "stackName", "region", "onFailureAction", "threshold", "adjustmentType", "variant", "availabilityZone", "persistentStorage", "orchestrator", "userDefinedTags", "publicKeyFile" })
public void testStackCreation(@Optional("testing1") String stackName, @Optional("europe-west1") String region, @Optional("DO_NOTHING") String onFailureAction, @Optional("4") Long threshold, @Optional("EXACT") String adjustmentType, @Optional("") String variant, @Optional String availabilityZone, @Optional String persistentStorage, @Optional("SALT") String orchestrator, @Optional("") String userDefinedTags, @Optional("") String publicKeyFile) throws Exception {
    // GIVEN
    IntegrationTestContext itContext = getItContext();
    List<InstanceGroup> instanceGroups = itContext.getContextParam(CloudbreakITContextConstants.TEMPLATE_ID, List.class);
    List<InstanceGroupRequest> igMap = new ArrayList<>();
    for (InstanceGroup ig : instanceGroups) {
        InstanceGroupRequest instanceGroupRequest = new InstanceGroupRequest();
        instanceGroupRequest.setGroup(ig.getName());
        instanceGroupRequest.setNodeCount(ig.getNodeCount());
        instanceGroupRequest.setTemplateId(Long.valueOf(ig.getTemplateId()));
        instanceGroupRequest.setType(InstanceGroupType.valueOf(ig.getType()));
        instanceGroupRequest.setSecurityGroupId(Long.valueOf(itContext.getContextParam(CloudbreakITContextConstants.SECURITY_GROUP_ID)));
        igMap.add(instanceGroupRequest);
    }
    String credentialId = itContext.getContextParam(CloudbreakITContextConstants.CREDENTIAL_ID);
    String networkId = itContext.getContextParam(CloudbreakITContextConstants.NETWORK_ID);
    publicKeyFile = StringUtils.hasLength(publicKeyFile) ? publicKeyFile : defaultPublicKeyFile;
    String publicKey = ResourceUtil.readStringFromResource(applicationContext, publicKeyFile).replaceAll("\n", "");
    StackRequest stackRequest = new StackRequest();
    StackAuthenticationRequest stackAuthenticationRequest = new StackAuthenticationRequest();
    stackAuthenticationRequest.setPublicKey(publicKey);
    stackRequest.setStackAuthentication(stackAuthenticationRequest);
    stackRequest.setName(stackName);
    stackRequest.setCredentialId(Long.valueOf(credentialId));
    stackRequest.setRegion(region);
    stackRequest.setOnFailureAction(OnFailureAction.valueOf(onFailureAction));
    FailurePolicyRequest failurePolicyRequest = new FailurePolicyRequest();
    failurePolicyRequest.setAdjustmentType(AdjustmentType.valueOf(adjustmentType));
    failurePolicyRequest.setThreshold(threshold);
    stackRequest.setFailurePolicy(failurePolicyRequest);
    stackRequest.setNetworkId(Long.valueOf(networkId));
    stackRequest.setPlatformVariant(variant);
    stackRequest.setAvailabilityZone(availabilityZone);
    stackRequest.setInstanceGroups(igMap);
    if (!userDefinedTags.isEmpty()) {
        stackRequest.setUserDefinedTags(TagsUtil.getTagsToCheck(userDefinedTags));
    }
    OrchestratorRequest orchestratorRequest = new OrchestratorRequest();
    orchestratorRequest.setType(orchestrator);
    stackRequest.setOrchestrator(orchestratorRequest);
    Map<String, String> map = new HashMap<>();
    if (persistentStorage != null && !persistentStorage.isEmpty()) {
        map.put("persistentStorage", persistentStorage);
    }
    stackRequest.setParameters(map);
    // WHEN
    String stackId = getCloudbreakClient().stackV1Endpoint().postPrivate(stackRequest).getId().toString();
    // THEN
    Assert.assertNotNull(stackId);
    itContext.putCleanUpParam(CloudbreakITContextConstants.STACK_ID, stackId);
    CloudbreakUtil.waitAndCheckStackStatus(getCloudbreakClient(), stackId, "AVAILABLE");
    itContext.putContextParam(CloudbreakITContextConstants.STACK_ID, stackId);
    ScalingUtil.putInstanceCountToContext(itContext, stackId);
}
Also used : IntegrationTestContext(com.sequenceiq.it.IntegrationTestContext) StackAuthenticationRequest(com.sequenceiq.cloudbreak.api.model.StackAuthenticationRequest) InstanceGroupRequest(com.sequenceiq.cloudbreak.api.model.InstanceGroupRequest) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) StackRequest(com.sequenceiq.cloudbreak.api.model.StackRequest) OrchestratorRequest(com.sequenceiq.cloudbreak.api.model.OrchestratorRequest) FailurePolicyRequest(com.sequenceiq.cloudbreak.api.model.FailurePolicyRequest) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Aggregations

IntegrationTestContext (com.sequenceiq.it.IntegrationTestContext)71 Parameters (org.testng.annotations.Parameters)39 Test (org.testng.annotations.Test)32 AbstractCloudbreakIntegrationTest (com.sequenceiq.it.cloudbreak.AbstractCloudbreakIntegrationTest)26 BeforeMethod (org.testng.annotations.BeforeMethod)26 StackV1Endpoint (com.sequenceiq.cloudbreak.api.endpoint.v1.StackV1Endpoint)10 InstanceGroupV2Request (com.sequenceiq.cloudbreak.api.model.v2.InstanceGroupV2Request)9 BeforeClass (org.testng.annotations.BeforeClass)9 HashMap (java.util.HashMap)8 UpdateClusterJson (com.sequenceiq.cloudbreak.api.model.UpdateClusterJson)7 UpdateStackJson (com.sequenceiq.cloudbreak.api.model.UpdateStackJson)7 CloudbreakClient (com.sequenceiq.cloudbreak.client.CloudbreakClient)7 StackResponse (com.sequenceiq.cloudbreak.api.model.StackResponse)6 ArrayList (java.util.ArrayList)6 StackV2Request (com.sequenceiq.cloudbreak.api.model.v2.StackV2Request)5 KerberosRequest (com.sequenceiq.cloudbreak.api.model.KerberosRequest)4 ClusterV1Endpoint (com.sequenceiq.cloudbreak.api.endpoint.v1.ClusterV1Endpoint)3 ClusterRequest (com.sequenceiq.cloudbreak.api.model.ClusterRequest)3 HostGroupAdjustmentJson (com.sequenceiq.cloudbreak.api.model.HostGroupAdjustmentJson)3 HostGroupRequest (com.sequenceiq.cloudbreak.api.model.HostGroupRequest)3