use of com.sequenceiq.cloudbreak.api.model.StackAuthenticationRequest in project cloudbreak by hortonworks.
the class MockStackCreationWithSaltSuccessTest method testStackCreation.
@Test
@Parameters({ "stackName", "region", "onFailureAction", "threshold", "adjustmentType", "variant", "availabilityZone", "persistentStorage", "orchestrator", "mockPort", "sshPort", "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("9443") int mockPort, @Optional("2020") int sshPort, @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()));
igMap.add(instanceGroupRequest);
}
String credentialId = itContext.getContextParam(CloudbreakITContextConstants.CREDENTIAL_ID);
String networkId = itContext.getContextParam(CloudbreakITContextConstants.NETWORK_ID);
StackRequest stackRequest = new StackRequest();
publicKeyFile = StringUtils.hasLength(publicKeyFile) ? publicKeyFile : defaultPublicKeyFile;
String publicKey = ResourceUtil.readStringFromResource(applicationContext, publicKeyFile).replaceAll("\n", "");
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);
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);
}
use of com.sequenceiq.cloudbreak.api.model.StackAuthenticationRequest 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);
}
use of com.sequenceiq.cloudbreak.api.model.StackAuthenticationRequest in project cloudbreak by hortonworks.
the class AwsCloudProvider method stackauth.
@Override
StackAuthenticationRequest stackauth() {
StackAuthenticationRequest stackauth = new StackAuthenticationRequest();
stackauth.setPublicKey(getTestParameter().get(CloudProviderHelper.INTEGRATIONTEST_PUBLIC_KEY_FILE).substring(BEGIN_INDEX));
return stackauth;
}
Aggregations