Search in sources :

Example 56 with IntegrationTestContext

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

the class AbstractStackCreationV2Test method createStackRequest.

@BeforeMethod(groups = "V2StackCreationInit")
@Parameters({ "stackName", "credentialName", "region", "availabilityZone", "imageCatalog", "imageId" })
public void createStackRequest(String stackName, @Optional("") String credentialName, @Optional("") String region, @Optional("") String availabilityZone, @Optional("") String imageCatalog, @Optional("") String imageId) {
    IntegrationTestContext itContext = getItContext();
    credentialName = StringUtils.hasText(credentialName) ? credentialName : itContext.getContextParam(CloudbreakV2Constants.CREDENTIAL_NAME);
    region = StringUtils.hasText(region) ? region : itContext.getContextParam(CloudbreakV2Constants.REGION);
    availabilityZone = StringUtils.hasText(availabilityZone) ? availabilityZone : itContext.getContextParam(CloudbreakV2Constants.AVAILABILTYZONE);
    imageCatalog = StringUtils.hasText(imageCatalog) ? imageCatalog : itContext.getContextParam(CloudbreakV2Constants.IMAGECATALOG);
    imageId = StringUtils.hasText(imageId) ? imageId : itContext.getContextParam(CloudbreakV2Constants.IMAGEID);
    Map<String, InstanceGroupV2Request> instanceGroupV2RequestMap = itContext.getContextParam(CloudbreakV2Constants.INSTANCEGROUP_MAP, Map.class);
    Assert.assertTrue(StringUtils.hasText(credentialName), "Credential name is mandatory.");
    Assert.assertTrue(StringUtils.hasText(region), "Region is mandatory.");
    Assert.assertTrue(StringUtils.hasText(availabilityZone), "AvailabilityZone is mandatory.");
    Assert.assertNotNull(instanceGroupV2RequestMap, "InstanceGroup map is mandatory");
    StackV2Request stackV2Request = new StackV2Request();
    GeneralSettings gs = new GeneralSettings();
    stackV2Request.setGeneral(gs);
    gs.setName(stackName);
    gs.setCredentialName(credentialName);
    PlacementSettings ps = new PlacementSettings();
    stackV2Request.setPlacement(ps);
    ps.setRegion(region);
    ps.setAvailabilityZone(availabilityZone);
    if (StringUtils.hasText(imageCatalog) || StringUtils.hasText(imageId)) {
        ImageSettings is = new ImageSettings();
        is.setImageCatalog(imageCatalog);
        is.setImageId(imageId);
        stackV2Request.setImageSettings(is);
    }
    stackV2Request.setInstanceGroups(Lists.newArrayList(instanceGroupV2RequestMap.values()));
    itContext.putContextParam(CloudbreakV2Constants.STACK_CREATION_REQUEST, stackV2Request);
}
Also used : IntegrationTestContext(com.sequenceiq.it.IntegrationTestContext) StackV2Request(com.sequenceiq.cloudbreak.api.model.v2.StackV2Request) InstanceGroupV2Request(com.sequenceiq.cloudbreak.api.model.v2.InstanceGroupV2Request) PlacementSettings(com.sequenceiq.cloudbreak.api.model.v2.PlacementSettings) GeneralSettings(com.sequenceiq.cloudbreak.api.model.v2.GeneralSettings) ImageSettings(com.sequenceiq.cloudbreak.api.model.v2.ImageSettings) Parameters(org.testng.annotations.Parameters) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 57 with IntegrationTestContext

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

the class AbstractStackCreationV2Test method authenticationParams.

@BeforeMethod(dependsOnGroups = "V2StackCreationInit")
@Parameters("publicKeyId")
public void authenticationParams(@Optional("") String publicKeyId) {
    IntegrationTestContext itContext = getItContext();
    publicKeyId = StringUtils.hasText(publicKeyId) ? publicKeyId : itContext.getContextParam(CloudbreakV2Constants.SSH_PUBLICKEY_ID);
    Assert.assertNotNull(publicKeyId, "Publickey id is mandatory.");
    StackV2Request stackV2Request = itContext.getContextParam(CloudbreakV2Constants.STACK_CREATION_REQUEST, StackV2Request.class);
    StackAuthenticationRequest stackAuthenticationRequest = new StackAuthenticationRequest();
    stackAuthenticationRequest.setPublicKeyId(publicKeyId);
    stackV2Request.setStackAuthentication(stackAuthenticationRequest);
}
Also used : IntegrationTestContext(com.sequenceiq.it.IntegrationTestContext) StackAuthenticationRequest(com.sequenceiq.cloudbreak.api.model.StackAuthenticationRequest) StackV2Request(com.sequenceiq.cloudbreak.api.model.v2.StackV2Request) Parameters(org.testng.annotations.Parameters) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 58 with IntegrationTestContext

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

the class AbstractStackCreationV2Test method testStackCreation.

@Test
public void testStackCreation() throws Exception {
    // GIVEN
    IntegrationTestContext itContext = getItContext();
    StackV2Request stackV2Request = itContext.getContextParam(CloudbreakV2Constants.STACK_CREATION_REQUEST, StackV2Request.class);
    // WHEN
    String stackId = getCloudbreakClient().stackV2Endpoint().postPrivate(stackV2Request).getId().toString();
    // THEN
    Assert.assertNotNull(stackId);
    itContext.putContextParam(CloudbreakITContextConstants.STACK_ID, stackId, true);
    itContext.putContextParam(CloudbreakV2Constants.STACK_NAME, stackV2Request.getGeneral().getName());
    Map<String, String> desiredStatuses = new HashMap<>();
    desiredStatuses.put("status", "AVAILABLE");
    desiredStatuses.put("clusterStatus", "AVAILABLE");
    CloudbreakUtil.waitAndCheckStatuses(getCloudbreakClient(), stackId, desiredStatuses);
}
Also used : IntegrationTestContext(com.sequenceiq.it.IntegrationTestContext) StackV2Request(com.sequenceiq.cloudbreak.api.model.v2.StackV2Request) HashMap(java.util.HashMap) AbstractCloudbreakIntegrationTest(com.sequenceiq.it.cloudbreak.AbstractCloudbreakIntegrationTest) Test(org.testng.annotations.Test)

Example 59 with IntegrationTestContext

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

the class AbstractStackCreationV2Test method ambariParameters.

@BeforeMethod(dependsOnGroups = "V2StackCreationInit")
@Parameters({ "blueprintName", "enableSecurity", "kerberosMasterKey", "kerberosAdmin", "kerberosPassword" })
public void ambariParameters(@Optional("") String blueprintName, @Optional("false") boolean enableSecurity, @Optional String kerberosMasterKey, @Optional String kerberosAdmin, @Optional String kerberosPassword) {
    IntegrationTestContext itContext = getItContext();
    blueprintName = StringUtils.hasText(blueprintName) ? blueprintName : itContext.getContextParam(CloudbreakV2Constants.SSH_PUBLICKEY_ID);
    Assert.assertNotNull(itContext.getContextParam(CloudbreakITContextConstants.AMBARI_USER_ID), "Ambari user is mandatory.");
    Assert.assertNotNull(itContext.getContextParam(CloudbreakITContextConstants.AMBARI_PASSWORD_ID), "Ambari password is mandatory.");
    Assert.assertNotNull(blueprintName, "blueprint name is mandatory.");
    StackV2Request stackV2Request = itContext.getContextParam(CloudbreakV2Constants.STACK_CREATION_REQUEST, StackV2Request.class);
    ClusterV2Request clusterV2Request = new ClusterV2Request();
    stackV2Request.setCluster(clusterV2Request);
    AmbariV2Request ambariV2Request = new AmbariV2Request();
    clusterV2Request.setAmbari(ambariV2Request);
    ambariV2Request.setBlueprintName(blueprintName);
    ambariV2Request.setUserName(itContext.getContextParam(CloudbreakITContextConstants.AMBARI_USER_ID));
    ambariV2Request.setPassword(itContext.getContextParam(CloudbreakITContextConstants.AMBARI_PASSWORD_ID));
    GatewayJson gatewayJson = new GatewayJson();
    gatewayJson.setEnableGateway(Boolean.FALSE);
    gatewayJson.setExposedServices(ImmutableList.of("ALL"));
    ambariV2Request.setGateway(gatewayJson);
    if (enableSecurity) {
        ambariV2Request.setEnableSecurity(enableSecurity);
        KerberosRequest kerberosRequest = new KerberosRequest();
        kerberosRequest.setMasterKey(kerberosMasterKey);
        kerberosRequest.setAdmin(kerberosAdmin);
        kerberosRequest.setPassword(kerberosPassword);
        ambariV2Request.setKerberos(kerberosRequest);
    }
}
Also used : IntegrationTestContext(com.sequenceiq.it.IntegrationTestContext) StackV2Request(com.sequenceiq.cloudbreak.api.model.v2.StackV2Request) AmbariV2Request(com.sequenceiq.cloudbreak.api.model.v2.AmbariV2Request) KerberosRequest(com.sequenceiq.cloudbreak.api.model.KerberosRequest) ClusterV2Request(com.sequenceiq.cloudbreak.api.model.v2.ClusterV2Request) GatewayJson(com.sequenceiq.cloudbreak.api.model.GatewayJson) Parameters(org.testng.annotations.Parameters) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 60 with IntegrationTestContext

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

the class ExistingSshKeySelectionTest method testSshKeySelection.

@Test
@Parameters({ "credentialName", "region", "availabilityZone", "selectedKeyName" })
public void testSshKeySelection(@Optional("") String credentialName, @Optional("") String region, @Optional("") String availabilityZone, String selectedKeyName) {
    // GIVEN
    IntegrationTestContext itContext = getItContext();
    credentialName = StringUtils.hasText(credentialName) ? credentialName : itContext.getContextParam(CloudbreakV2Constants.CREDENTIAL_NAME);
    region = StringUtils.hasText(region) ? region : itContext.getContextParam(CloudbreakV2Constants.REGION);
    availabilityZone = StringUtils.hasText(availabilityZone) ? availabilityZone : itContext.getContextParam(CloudbreakV2Constants.AVAILABILTYZONE);
    PlatformResourceRequestJson resourceRequestJson = new PlatformResourceRequestJson();
    resourceRequestJson.setCredentialName(credentialName);
    resourceRequestJson.setRegion(region);
    resourceRequestJson.setAvailabilityZone(availabilityZone);
    // WHEN
    PlatformSshKeysResponse response = getCloudbreakClient().connectorV1Endpoint().getCloudSshKeys(resourceRequestJson);
    // THEN
    Set<PlatformSshKeyResponse> regionKeys = response.getSshKeys().get(region);
    Assert.assertNotNull(regionKeys, "keys cannot be null for " + region);
    java.util.Optional<PlatformSshKeyResponse> selected = regionKeys.stream().filter(rk -> rk.getName().equals(selectedKeyName)).findFirst();
    Assert.assertTrue(selected.isPresent(), "the sshkey list doesn't contain [" + selectedKeyName + ']');
    getItContext().putContextParam(CloudbreakV2Constants.SSH_PUBLICKEY_ID, selected.get().getName());
}
Also used : Optional(org.testng.annotations.Optional) PlatformResourceRequestJson(com.sequenceiq.cloudbreak.api.model.PlatformResourceRequestJson) Assert(org.testng.Assert) PlatformSshKeysResponse(com.sequenceiq.cloudbreak.api.model.PlatformSshKeysResponse) AbstractCloudbreakIntegrationTest(com.sequenceiq.it.cloudbreak.AbstractCloudbreakIntegrationTest) Parameters(org.testng.annotations.Parameters) Set(java.util.Set) PlatformSshKeyResponse(com.sequenceiq.cloudbreak.api.model.PlatformSshKeyResponse) Test(org.testng.annotations.Test) IntegrationTestContext(com.sequenceiq.it.IntegrationTestContext) StringUtils(org.springframework.util.StringUtils) IntegrationTestContext(com.sequenceiq.it.IntegrationTestContext) PlatformSshKeysResponse(com.sequenceiq.cloudbreak.api.model.PlatformSshKeysResponse) PlatformResourceRequestJson(com.sequenceiq.cloudbreak.api.model.PlatformResourceRequestJson) PlatformSshKeyResponse(com.sequenceiq.cloudbreak.api.model.PlatformSshKeyResponse) Parameters(org.testng.annotations.Parameters) AbstractCloudbreakIntegrationTest(com.sequenceiq.it.cloudbreak.AbstractCloudbreakIntegrationTest) 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