use of com.sequenceiq.it.cloudbreak.context.TestContext in project cloudbreak by hortonworks.
the class TagsUtilTest method verifyCreatorWithCdpCrnButTestContextHasAltusCrn.
@Test
void verifyCreatorWithCdpCrnButTestContextHasAltusCrn() {
DistroXTestDto testDto = new DistroXTestDto(mock(TestContext.class));
StackV4Response response = new StackV4Response();
TagsV4Response tags = new TagsV4Response();
tags.setUserDefined(Map.of(TagsUtil.TEST_NAME_TAG, TEST_NAME));
tags.setDefaults(DEFAULT_TAGS);
response.setTags(tags);
testDto.setResponse(response);
when(testContext.getActingUserCrn()).thenReturn(Crn.fromString("crn:altus:iam:us-west-1:qe-gcp:user:cloudbreak-qe@hortonworks.com"));
when(gcpLabelUtil.transformLabelKeyOrValue(anyString())).thenReturn(CLOUDERA_CREATOR_RESOURCE_NAME_TAG_KEY);
assertThatCode(() -> underTest.verifyTags(testDto, testContext)).doesNotThrowAnyException();
}
use of com.sequenceiq.it.cloudbreak.context.TestContext in project cloudbreak by hortonworks.
the class TagsUtilTest method verifyTagsShouldFailAbstractTestDtoDoesNotHaveAllNeededTags.
@Test
void verifyTagsShouldFailAbstractTestDtoDoesNotHaveAllNeededTags() {
DistroXTestDto testDto = new DistroXTestDto(mock(TestContext.class));
StackV4Response response = new StackV4Response();
TagsV4Response tags = new TagsV4Response();
tags.setUserDefined(Map.of(TagsUtil.TEST_NAME_TAG, TEST_NAME));
Map<String, String> defaultTags = new HashMap<>(DEFAULT_TAGS);
defaultTags.remove("owner");
tags.setDefaults(defaultTags);
response.setTags(tags);
testDto.setResponse(response);
String expectedMsg = String.format(TagsUtil.TAG_VALUE_IS_NULL_FAILURE_PATTERN, OWNER_TAG_KEY);
assertThatThrownBy(() -> underTest.verifyTags(testDto, testContext)).hasMessageContaining(expectedMsg).matches(e -> !e.getMessage().contains(TagsUtil.MISSING_TEST_NAME_TAG_MESSAGE)).matches(e -> defaultTags.keySet().stream().noneMatch(tag -> e.getMessage().contains(tag)));
}
use of com.sequenceiq.it.cloudbreak.context.TestContext in project cloudbreak by hortonworks.
the class TagsUtilTest method verifyCreatorAsGcpLabelTransformedValue.
@Test
void verifyCreatorAsGcpLabelTransformedValue() {
DistroXTestDto testDto = new DistroXTestDto(mock(TestContext.class));
StackV4Response response = new StackV4Response();
TagsV4Response tags = new TagsV4Response();
tags.setUserDefined(Map.of(TagsUtil.TEST_NAME_TAG, TEST_NAME));
Map<String, String> defaultTags = new HashMap<>(DEFAULT_TAGS);
defaultTags.put(CLOUDERA_CREATOR_RESOURCE_NAME_TAG_KEY, ACTING_USER_CRN);
tags.setDefaults(defaultTags);
response.setTags(tags);
testDto.setResponse(response);
when(gcpLabelUtil.transformLabelKeyOrValue(anyString())).thenReturn(CLOUDERA_CREATOR_RESOURCE_NAME_TAG_KEY);
assertThatCode(() -> underTest.verifyTags(testDto, testContext)).doesNotThrowAnyException();
}
use of com.sequenceiq.it.cloudbreak.context.TestContext in project cloudbreak by hortonworks.
the class SdxBackupRestoreTest method testSDXBackupRestoreCanBeSuccessful.
@Test(dataProvider = TEST_CONTEXT)
@UseSpotInstances
@Description(given = "there is a running Manowar SDX cluster in available state", when = "a basic SDX backup then restore request has been sent", then = "SDX restore should be done successfully")
public void testSDXBackupRestoreCanBeSuccessful(TestContext testContext) {
SdxInternalTestDto sdxInternalTestDto = testContext.given(SdxInternalTestDto.class);
String cloudStorageBaseLocation = sdxInternalTestDto.getResponse().getCloudStorageBaseLocation();
String backupObject = "backups";
testContext.given(SdxInternalTestDto.class).when(sdxTestClient.syncInternal()).await(SdxClusterStatusResponse.RUNNING).awaitForHealthyInstances().when(sdxTestClient.backupInternal(StringUtils.join(List.of(cloudStorageBaseLocation, backupObject), "/"), null)).await(SdxClusterStatusResponse.RUNNING).awaitForHealthyInstances().then(this::validateDatalakeBackupStatus).then(this::validateDatalakeStatus).then((tc, testDto, client) -> {
getCloudFunctionality(tc).cloudStorageListContainer(cloudStorageBaseLocation, backupObject, true);
return testDto;
}).validate();
testContext.given(SdxInternalTestDto.class).when(sdxTestClient.restoreInternal(backupId, null)).await(SdxClusterStatusResponse.RUNNING).awaitForHealthyInstances().then(this::validateDatalakeRestoreStatus).then(this::validateDatalakeStatus).validate();
}
use of com.sequenceiq.it.cloudbreak.context.TestContext 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();
}
Aggregations