Search in sources :

Example 41 with IntegrationTestContext

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

the class FilesystemTest method testFileSystem.

@Test
@Parameters({ "filesystemType", "filesystemName", "folderPrefix", "wasbContainerName", "sshCommand", "sshUser", "sshChecker" })
public void testFileSystem(String filesystemType, String filesystemName, String folderPrefix, @Optional("it-container") String wasbContainerName, String sshCommand, @Optional("cloudbreak") String sshUser, String sshChecker) throws IOException {
    // GIVEN
    Assert.assertEquals(new File(defaultPrivateKeyFile).exists(), true, "Private cert file not found: " + defaultPrivateKeyFile);
    fsParams.put("filesystemType", filesystemType);
    fsParams.put("filesystemName", filesystemName);
    fsParams.put("folderPrefix", folderPrefix);
    fsParams.put("wasbContainerName", wasbContainerName);
    IntegrationTestContext itContext = getItContext();
    String stackId = itContext.getContextParam(CloudbreakITContextConstants.STACK_ID);
    StackV1Endpoint stackV1Endpoint = itContext.getContextParam(CloudbreakITContextConstants.CLOUDBREAK_CLIENT, CloudbreakClient.class).stackV1Endpoint();
    String masterIp = CloudbreakUtil.getAmbariIp(stackV1Endpoint, stackId, itContext);
    Map<String, String> cloudProviderParams = itContext.getContextParam(CloudbreakITContextConstants.CLOUDPROVIDER_PARAMETERS, Map.class);
    sshCommand = ResourceUtil.readStringFromResource(applicationContext, sshCommand.replaceAll("\n", ""));
    if ("WASB".equals(filesystemType)) {
        FilesystemUtil.createWasbContainer(cloudProviderParams, filesystemName, wasbContainerName);
    }
    // WHEN
    boolean sshResult = SshUtil.executeCommand(masterIp, defaultPrivateKeyFile, sshCommand, sshUser, SshUtil.getSshCheckMap(sshChecker));
    // THEN
    Assert.assertTrue(sshResult, "Ssh command executing was not successful");
}
Also used : StackV1Endpoint(com.sequenceiq.cloudbreak.api.endpoint.v1.StackV1Endpoint) IntegrationTestContext(com.sequenceiq.it.IntegrationTestContext) CloudbreakClient(com.sequenceiq.cloudbreak.client.CloudbreakClient) File(java.io.File) Parameters(org.testng.annotations.Parameters) AbstractCloudbreakIntegrationTest(com.sequenceiq.it.cloudbreak.AbstractCloudbreakIntegrationTest) Test(org.testng.annotations.Test) AfterTest(org.testng.annotations.AfterTest)

Example 42 with IntegrationTestContext

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

the class FilesystemTest method cleanUpFilesystem.

@AfterTest
public void cleanUpFilesystem() throws Exception {
    IntegrationTestContext itContext = getItContext();
    Map<String, String> cloudProviderParams = itContext.getContextParam(CloudbreakITContextConstants.CLOUDPROVIDER_PARAMETERS, Map.class);
    FilesystemUtil.cleanUpFiles(applicationContext, cloudProviderParams, fsParams.get("filesystemType"), fsParams.get("filesystemName"), fsParams.get("folderPrefix"), fsParams.get("wasbContainerName"));
}
Also used : IntegrationTestContext(com.sequenceiq.it.IntegrationTestContext) AfterTest(org.testng.annotations.AfterTest)

Example 43 with IntegrationTestContext

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

the class AwsCheckSpotInstance method setContextParams.

@BeforeMethod
public void setContextParams() {
    IntegrationTestContext itContext = getItContext();
    Assert.assertNotNull("Stack id is mandatory.", itContext.getContextParam(CloudbreakITContextConstants.STACK_ID));
}
Also used : IntegrationTestContext(com.sequenceiq.it.IntegrationTestContext) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 44 with IntegrationTestContext

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

the class AwsCheckSpotInstance method checkSpotInstance.

@Parameters({ "region", "hostGroupToCheck", "scalingAdjustment" })
@Test
public void checkSpotInstance(Regions region, String hostGroupToCheck, @Optional Integer scalingAdjustment) {
    // GIVEN
    Integer spotInstanceCount = 0;
    IntegrationTestContext itContext = getItContext();
    String stackId = itContext.getContextParam(CloudbreakITContextConstants.STACK_ID);
    StackV1Endpoint stackV1Endpoint = getCloudbreakClient().stackV1Endpoint();
    StackResponse stackResponse = stackV1Endpoint.get(Long.valueOf(stackId), new HashSet<>());
    List<InstanceGroupResponse> instanceGroups = stackResponse.getInstanceGroups();
    Collection<String> instanceIdList = new ArrayList<>();
    List<String> hostGroupList = Arrays.asList(hostGroupToCheck.split(","));
    for (InstanceGroupResponse instanceGroup : instanceGroups) {
        if (hostGroupList.contains(instanceGroup.getGroup())) {
            Set<InstanceMetaDataJson> instanceMetaData = instanceGroup.getMetadata();
            for (InstanceMetaDataJson metaData : instanceMetaData) {
                instanceIdList.add(metaData.getInstanceId());
            }
        }
    }
    // WHEN
    AmazonEC2 ec2 = AmazonEC2ClientBuilder.standard().withRegion(region).build();
    DescribeSpotInstanceRequestsResult describeSpotInstanceRequestsResult = ec2.describeSpotInstanceRequests();
    List<SpotInstanceRequest> spotInstanceRequests = describeSpotInstanceRequestsResult.getSpotInstanceRequests();
    // THEN
    Assert.assertFalse(spotInstanceRequests.isEmpty());
    Collection<String> spotInstanceIdList = new ArrayList<>();
    for (SpotInstanceRequest request : spotInstanceRequests) {
        spotInstanceIdList.add(request.getInstanceId());
    }
    for (String id : instanceIdList) {
        Assert.assertTrue(spotInstanceIdList.contains(id));
        if (spotInstanceIdList.contains(id)) {
            spotInstanceCount += 1;
        }
    }
    if (scalingAdjustment != null) {
        Assert.assertNotNull(itContext.getContextParam(CloudbreakITContextConstants.INSTANCE_COUNT, List.class));
        Integer instanceCountPrev = 0;
        for (String hostGroup : hostGroupList) {
            List<Map<String, Integer>> instanceList = itContext.getContextParam(CloudbreakITContextConstants.INSTANCE_COUNT, List.class);
            Assert.assertTrue(instanceList.size() >= 2);
            instanceCountPrev += instanceList.get(instanceList.size() - 2).get(hostGroup);
        }
        Assert.assertEquals(Integer.valueOf(instanceCountPrev + scalingAdjustment), spotInstanceCount);
    }
}
Also used : StackV1Endpoint(com.sequenceiq.cloudbreak.api.endpoint.v1.StackV1Endpoint) IntegrationTestContext(com.sequenceiq.it.IntegrationTestContext) ArrayList(java.util.ArrayList) InstanceGroupResponse(com.sequenceiq.cloudbreak.api.model.InstanceGroupResponse) AmazonEC2(com.amazonaws.services.ec2.AmazonEC2) SpotInstanceRequest(com.amazonaws.services.ec2.model.SpotInstanceRequest) DescribeSpotInstanceRequestsResult(com.amazonaws.services.ec2.model.DescribeSpotInstanceRequestsResult) ArrayList(java.util.ArrayList) List(java.util.List) InstanceMetaDataJson(com.sequenceiq.cloudbreak.api.model.InstanceMetaDataJson) StackResponse(com.sequenceiq.cloudbreak.api.model.StackResponse) Map(java.util.Map) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Example 45 with IntegrationTestContext

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

the class SshKeysTests 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)

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