use of com.sequenceiq.sdx.api.model.SdxDatabaseRequest in project cloudbreak by hortonworks.
the class SdxExternalDatabaseConfigurerTest method whenPlatformIsAwsAndCreateShouldCreateDatabase.
@Test
public void whenPlatformIsAwsAndCreateShouldCreateDatabase() {
CloudPlatform cloudPlatform = CloudPlatform.AWS;
when(platformConfig.isExternalDatabaseSupportedOrExperimental(cloudPlatform)).thenReturn(true);
SdxDatabaseRequest dbRequest = new SdxDatabaseRequest();
dbRequest.setAvailabilityType(SdxDatabaseAvailabilityType.HA);
SdxCluster sdxCluster = new SdxCluster();
underTest.configure(cloudPlatform, dbRequest, sdxCluster);
assertEquals(true, sdxCluster.isCreateDatabase());
assertEquals(SdxDatabaseAvailabilityType.HA, sdxCluster.getDatabaseAvailabilityType());
}
use of com.sequenceiq.sdx.api.model.SdxDatabaseRequest in project cloudbreak by hortonworks.
the class InternalSdxRepairWithRecipeTest method testSDXMultiRepairIDBRokerAndMasterWithRecipeFile.
@Test(dataProvider = TEST_CONTEXT)
@Description(given = "there is a running Cloudbreak, and an SDX cluster in available state", when = "recovery called on the IDBROKER and MASTER host group, where the EC2 instance had been stopped", then = "SDX recovery should be successful, the cluster should be up and running")
public void testSDXMultiRepairIDBRokerAndMasterWithRecipeFile(TestContext testContext) throws IOException {
String sdxInternal = resourcePropertyProvider().getName();
String cluster = resourcePropertyProvider().getName();
String clouderaManager = resourcePropertyProvider().getName();
String recipeName = resourcePropertyProvider().getName();
String stack = resourcePropertyProvider().getName();
String filePath = "/post-install";
String fileName = "post-install";
String masterInstanceGroup = "master";
String idbrokerInstanceGroup = "idbroker";
SdxDatabaseRequest sdxDatabaseRequest = new SdxDatabaseRequest();
sdxDatabaseRequest.setAvailabilityType(SdxDatabaseAvailabilityType.NONE);
testContext.given(clouderaManager, ClouderaManagerTestDto.class).given(cluster, ClusterTestDto.class).withBlueprintName(getDefaultSDXBlueprintName()).withValidateBlueprint(Boolean.FALSE).withClouderaManager(clouderaManager).given(RecipeTestDto.class).withName(recipeName).withContent(generateRecipeContent()).withRecipeType(POST_CLOUDERA_MANAGER_START).when(recipeTestClient.createV4()).given(masterInstanceGroup, InstanceGroupTestDto.class).withHostGroup(MASTER).withNodeCount(1).withRecipes(recipeName).given(idbrokerInstanceGroup, InstanceGroupTestDto.class).withHostGroup(IDBROKER).withNodeCount(1).withRecipes(recipeName).given(stack, StackTestDto.class).withCluster(cluster).withInstanceGroups(masterInstanceGroup, idbrokerInstanceGroup).given(sdxInternal, SdxInternalTestDto.class).withCloudStorage(getCloudStorageRequest(testContext)).withDatabase(sdxDatabaseRequest).withStackRequest(key(cluster), key(stack)).when(sdxTestClient.createInternal(), key(sdxInternal)).await(SdxClusterStatusResponse.RUNNING).awaitForHealthyInstances().then((tc, testDto, client) -> {
return sshJUtil.checkFilesOnHostByNameAndPath(testDto, getInstanceGroups(testDto, client), List.of(MASTER.getName(), IDBROKER.getName()), filePath, fileName, 1, null, null);
}).then((tc, testDto, client) -> {
List<String> instanceIdsToStop = sdxUtil.getInstanceIds(testDto, client, MASTER.getName());
instanceIdsToStop.addAll(sdxUtil.getInstanceIds(testDto, client, IDBROKER.getName()));
getCloudFunctionality(tc).stopInstances(testDto.getName(), instanceIdsToStop);
return testDto;
}).awaitForStoppedInstances().when(sdxTestClient.repairInternal(MASTER.getName(), IDBROKER.getName()), key(sdxInternal)).await(SdxClusterStatusResponse.REPAIR_IN_PROGRESS, key(sdxInternal).withWaitForFlow(Boolean.FALSE)).await(SdxClusterStatusResponse.RUNNING, key(sdxInternal)).awaitForHealthyInstances().then((tc, testDto, client) -> {
return sshJUtil.checkFilesOnHostByNameAndPath(testDto, getInstanceGroups(testDto, client), List.of(MASTER.getName(), IDBROKER.getName()), filePath, fileName, 1, null, null);
}).validate();
}
use of com.sequenceiq.sdx.api.model.SdxDatabaseRequest in project cloudbreak by hortonworks.
the class MockSdxRepairTests method repairTerminatedMasterAndItFailedButInstanceShouldBeDeletedOnProviderSide.
@Test(dataProvider = TEST_CONTEXT_WITH_MOCK)
@Description(given = "there is a running Cloudbreak", when = "terminate instances and repair an sdx cluster", then = "repair should fail and repaired instance should be in deleted on provider side")
public void repairTerminatedMasterAndItFailedButInstanceShouldBeDeletedOnProviderSide(MockedTestContext testContext) {
String sdxInternal = resourcePropertyProvider().getName();
String networkKey = "someOtherNetwork";
SdxDatabaseRequest sdxDatabaseRequest = new SdxDatabaseRequest();
sdxDatabaseRequest.setAvailabilityType(SdxDatabaseAvailabilityType.NON_HA);
CustomDomainSettingsV4Request customDomain = new CustomDomainSettingsV4Request();
customDomain.setDomainName("dummydomainname");
customDomain.setHostname("dummyhostname");
customDomain.setClusterNameAsSubdomain(true);
customDomain.setHostgroupNameAsHostname(true);
testContext.given(networkKey, EnvironmentNetworkTestDto.class).withMock(new EnvironmentNetworkMockParams()).given(EnvironmentTestDto.class).withNetwork(networkKey).withCreateFreeIpa(Boolean.TRUE).withName(resourcePropertyProvider().getEnvironmentName()).when(getEnvironmentTestClient().create()).await(EnvironmentStatus.AVAILABLE).given(FreeIpaTestDto.class).when(freeIpaTestClient.create()).await(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.Status.AVAILABLE).given(sdxInternal, SdxInternalTestDto.class).withDatabase(sdxDatabaseRequest).withCustomDomain(customDomain).when(sdxTestClient.createInternal(), key(sdxInternal)).await(SdxClusterStatusResponse.RUNNING, key(sdxInternal)).then((tc, testDto, client) -> {
List<String> instancesToDelete = new ArrayList<>(sdxUtil.getInstanceIds(testDto, client, MASTER.getName()));
instancesToDelete.forEach(instanceId -> getExecuteQueryToMockInfrastructure().call("/" + testDto.getCrn() + "/spi/" + instanceId + "/terminate", w -> w));
getExecuteQueryToMockInfrastructure().executeMethod(Method.build("POST"), "/" + testDto.getCrn() + "/spi/disable_add_instance", new HashMap<>(), null, response -> {
}, w -> w);
return testDto;
}).await(SdxClusterStatusResponse.NODE_FAILURE, pollingInterval(Duration.ofSeconds(POLLING_INTERVAL_FOR_REPAIR_SECONDS))).when(sdxTestClient.repairInternal(MASTER.getName()), key(sdxInternal)).awaitForMasterDeletedOnProvider().awaitForFlowFail().then((tc, testDto, client) -> {
getExecuteQueryToMockInfrastructure().executeMethod(Method.build("POST"), "/" + testDto.getCrn() + "/spi/enable_add_instance", new HashMap<>(), null, response -> {
}, w -> w);
return testDto;
}).when(sdxTestClient.repairInternal(MASTER.getName()), key(sdxInternal)).await(SdxClusterStatusResponse.RUNNING, key(sdxInternal)).validate();
}
use of com.sequenceiq.sdx.api.model.SdxDatabaseRequest in project cloudbreak by hortonworks.
the class MockSdxRepairTests method testRepair.
public void testRepair(MockedTestContext testContext, List<HostGroupType> hostGroups, Consumer<String> actionOnNode, SdxClusterStatusResponse stateBeforeRepair) {
String sdxInternal = resourcePropertyProvider().getName();
String networkKey = "someOtherNetwork";
SdxDatabaseRequest sdxDatabaseRequest = new SdxDatabaseRequest();
sdxDatabaseRequest.setAvailabilityType(SdxDatabaseAvailabilityType.NON_HA);
CustomDomainSettingsV4Request customDomain = new CustomDomainSettingsV4Request();
customDomain.setDomainName("dummydomainname");
customDomain.setHostname("dummyhostname");
customDomain.setClusterNameAsSubdomain(true);
customDomain.setHostgroupNameAsHostname(true);
testContext.given(networkKey, EnvironmentNetworkTestDto.class).withMock(new EnvironmentNetworkMockParams()).given(EnvironmentTestDto.class).withNetwork(networkKey).withCreateFreeIpa(Boolean.TRUE).withName(resourcePropertyProvider().getEnvironmentName()).when(getEnvironmentTestClient().create()).await(EnvironmentStatus.AVAILABLE).given(FreeIpaTestDto.class).when(freeIpaTestClient.create()).await(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.Status.AVAILABLE).given(sdxInternal, SdxInternalTestDto.class).withDatabase(sdxDatabaseRequest).withCustomDomain(customDomain).when(sdxTestClient.createInternal(), key(sdxInternal)).await(SdxClusterStatusResponse.RUNNING, key(sdxInternal)).then((tc, testDto, client) -> {
List<String> instancesToDelete = new ArrayList<>();
for (HostGroupType hostGroupType : hostGroups) {
instancesToDelete.addAll(sdxUtil.getInstanceIds(testDto, client, hostGroupType.getName()));
}
instancesToDelete.forEach(instanceId -> actionOnNode.accept("/" + testDto.getCrn() + "/spi/" + instanceId));
return testDto;
}).await(stateBeforeRepair, pollingInterval(Duration.ofSeconds(POLLING_INTERVAL_FOR_REPAIR_SECONDS))).when(sdxTestClient.repairInternal(hostGroups.stream().map(HostGroupType::getName).toArray(String[]::new)), key(sdxInternal)).await(SdxClusterStatusResponse.RUNNING, key(sdxInternal)).validate();
}
use of com.sequenceiq.sdx.api.model.SdxDatabaseRequest in project cloudbreak by hortonworks.
the class SdxRangerRazEnabledTests method testCreateSdxWithRangerRaz.
@Test(dataProvider = TEST_CONTEXT)
@Description(given = "there is a running Cloudbreak", when = "enableRangerRaz is called when Raz is installed", then = "rangerRazEnabled is set for Sdx")
public void testCreateSdxWithRangerRaz(TestContext testContext) {
String sdx = resourcePropertyProvider().getName();
SdxDatabaseRequest sdxDatabaseRequest = new SdxDatabaseRequest();
sdxDatabaseRequest.setAvailabilityType(SdxDatabaseAvailabilityType.NONE);
testContext.given(SdxTestDto.class).withExternalDatabase(sdxDatabaseRequest).withCloudStorage(getCloudStorageRequest(testContext)).withRangerRazEnabled(Boolean.TRUE).when(sdxTestClient.create(), key(sdx)).await(SdxClusterStatusResponse.RUNNING).awaitForHealthyInstances().when(sdxTestClient.enableRangerRaz()).then((tc, testDto, client) -> {
final boolean rangerRazEnabled = testDto.getResponse().getRangerRazEnabled();
if (!rangerRazEnabled) {
throw new TestFailException("Ranger raz was not enabled!");
}
return testDto;
}).validate();
}
Aggregations