use of com.sequenceiq.it.cloudbreak.context.Description in project cloudbreak by hortonworks.
the class AwsYcloudHybridCloudTest method testCreateSdxOnChildEnvironment.
@Test(dataProvider = TEST_CONTEXT)
@UseSpotInstances
@Description(given = "there is a running cloudbreak with parent-child environments ", when = "a valid SDX create request is sent to the child environment ", then = "SDX is created and instances are accessible via ssh by valid username and password ", and = "instances are not accessible via ssh by invalid username and password")
public void testCreateSdxOnChildEnvironment(TestContext testContext) {
String sdxInternal = resourcePropertyProvider().getName(CHILD_CLOUD_PLATFORM);
String clouderaManager = resourcePropertyProvider().getName(CHILD_CLOUD_PLATFORM);
String cluster = resourcePropertyProvider().getName(CHILD_CLOUD_PLATFORM);
String cmProduct = resourcePropertyProvider().getName(CHILD_CLOUD_PLATFORM);
String stack = resourcePropertyProvider().getName(CHILD_CLOUD_PLATFORM);
AtomicReference<String> cdhVersion = new AtomicReference<>();
AtomicReference<String> cdhParcel = new AtomicReference<>();
String runtimeVersion = commonClusterManagerProperties().getRuntimeVersion();
testContext.given(StackMatrixTestDto.class, CHILD_CLOUD_PLATFORM).when(utilTestClient.stackMatrixV4()).then((tc, dto, client) -> {
ClouderaManagerStackDescriptorV4Response response = dto.getResponse().getCdh().get(runtimeVersion);
cdhVersion.set(response.getVersion());
cdhParcel.set(response.getRepository().getStack().get(REDHAT7));
return dto;
}).validate();
testContext.given("telemetry", TelemetryTestDto.class).withLogging(CHILD_CLOUD_PLATFORM).withReportClusterLogs().given(cmProduct, ClouderaManagerProductTestDto.class, CHILD_CLOUD_PLATFORM).withName(CDH).withVersion(cdhVersion.get()).withParcel(cdhParcel.get()).given(clouderaManager, ClouderaManagerTestDto.class, CHILD_CLOUD_PLATFORM).withClouderaManagerProduct(cmProduct).given(cluster, ClusterTestDto.class, CHILD_CLOUD_PLATFORM).withBlueprintName(getDefaultSDXBlueprintName()).withValidateBlueprint(Boolean.FALSE).withClouderaManager(clouderaManager).given(MASTER_INSTANCE_GROUP, InstanceGroupTestDto.class, CHILD_CLOUD_PLATFORM).withHostGroup(MASTER).withNodeCount(1).given(IDBROKER_INSTANCE_GROUP, InstanceGroupTestDto.class, CHILD_CLOUD_PLATFORM).withHostGroup(IDBROKER).withNodeCount(1).given(STACK_AUTHENTICATION, StackAuthenticationTestDto.class, CHILD_CLOUD_PLATFORM).given(stack, StackTestDto.class, CHILD_CLOUD_PLATFORM).withCluster(cluster).withInstanceGroups(MASTER_INSTANCE_GROUP, IDBROKER_INSTANCE_GROUP).withStackAuthentication(STACK_AUTHENTICATION).withTelemetry("telemetry").given(sdxInternal, SdxInternalTestDto.class, CHILD_CLOUD_PLATFORM).withStackRequest(key(cluster), key(stack)).withEnvironmentKey(RunningParameter.key(CHILD_ENVIRONMENT_KEY)).when(sdxTestClient.createInternal(), key(sdxInternal)).await(SdxClusterStatusResponse.RUNNING).awaitForHealthyInstances().then((tc, dto, client) -> {
String environmentCrn = dto.getResponse().getEnvironmentCrn();
com.sequenceiq.freeipa.api.client.FreeIpaClient freeIpaClient = tc.getMicroserviceClient(FreeIpaClient.class).getDefaultClient();
checkUserSyncState(environmentCrn, freeIpaClient);
String username = testContext.getActingUserCrn().getResource();
String sanitizedUserName = SanitizerUtil.sanitizeWorkloadUsername(username);
for (InstanceGroupV4Response ig : dto.getResponse().getStackV4Response().getInstanceGroups()) {
for (InstanceMetaDataV4Response i : ig.getMetadata()) {
String ip = i.getPublicIp();
LOGGER.info("Trying to ssh with user {} into instance: {}", sanitizedUserName, OBJECT_MAPPER.writeValueAsString(i));
testShhAuthenticationSuccessful(sanitizedUserName, ip);
testShhAuthenticationFailure(sanitizedUserName, ip);
}
}
return dto;
}).given(CHILD_ENVIRONMENT_KEY, EnvironmentTestDto.class, CHILD_CLOUD_PLATFORM).when(environmentTestClient.cascadingDelete(), RunningParameter.key(CHILD_ENVIRONMENT_KEY)).await(EnvironmentStatus.ARCHIVED, RunningParameter.key(CHILD_ENVIRONMENT_KEY)).validate();
}
use of com.sequenceiq.it.cloudbreak.context.Description in project cloudbreak by hortonworks.
the class ChangeImageCatalogTest method testChangeDataLakeImageCatalogFails.
@Test(dataProvider = TEST_CONTEXT_WITH_MOCK)
@Description(given = "there is a running DataLake created by ENV_CREATOR_A and image catalogs created by ENV_CREATOR_A and ENV_CREATOR_B", when = "a change image catalog request is sent", then = "ENV_CREATOR_B should get forbidden excepion by using any image catalog")
public void testChangeDataLakeImageCatalogFails(MockedTestContext testContext) {
useRealUmsUser(testContext, AuthUserKeys.ENV_CREATOR_A);
createDefaultImageCatalog(testContext);
testContext.given(CredentialTestDto.class).when(credentialTestClient.create()).given(EnvironmentTestDto.class).when(environmentTestClient.create()).await(EnvironmentStatus.AVAILABLE).given(SdxInternalTestDto.class).when(sdxTestClient.createInternal()).await(SdxClusterStatusResponse.RUNNING).when(sdxTestClient.detailedDescribeInternal()).validate();
ImageCatalogTestDto imageCatalogA = resourceCreator.createNewImageCatalog(testContext);
useRealUmsUser(testContext, AuthUserKeys.ENV_CREATOR_B);
ImageCatalogTestDto imageCatalogB = resourceCreator.createNewImageCatalog(testContext);
// ENV_CREATOR_B can't change DL image catalog in case of DL is created by ENV_CREATOR_A
testContext.given(SdxChangeImageCatalogTestDto.class).withImageCatalog(imageCatalogB.getName()).whenException(sdxTestClient.changeImageCatalog(), ForbiddenException.class, expectedMessage("Doesn't have 'datalake/changeImageCatalog' right on any of the environment[(]s[)] " + environmentDatalakePattern(testContext) + " or on .*")).validate();
// ENV_CREATOR_B can't change ENV_CREATOR_A's DH image catalog in case of having environment admin right but the catalog is created by ENV_CREATOR_A
testContext.given(UmsTestDto.class).assignTarget(EnvironmentTestDto.class.getSimpleName()).withEnvironmentAdmin().when(umsTestClient.assignResourceRole(AuthUserKeys.ENV_CREATOR_B, regionAwareInternalCrnGeneratorFactory)).given(SdxChangeImageCatalogTestDto.class).withImageCatalog(imageCatalogA.getName()).whenException(sdxTestClient.changeImageCatalog(), ForbiddenException.class, expectedMessage("Doesn't have 'environments/useSharedResource' right on imageCatalog .*")).validate();
}
use of com.sequenceiq.it.cloudbreak.context.Description in project cloudbreak by hortonworks.
the class ChangeImageCatalogTest method testChangeDataHubImageCatalogFails.
@Test(dataProvider = TEST_CONTEXT_WITH_MOCK)
@Description(given = "there is a running DataHub created by ENV_CREATOR_A and image catalogs created by ENV_CREATOR_A and ENV_CREATOR_B", when = "a change image catalog request is sent", then = "ENV_CREATOR_B should get forbidden excepion by using any image catalog")
public void testChangeDataHubImageCatalogFails(MockedTestContext testContext) {
useRealUmsUser(testContext, AuthUserKeys.ENV_CREATOR_A);
createDefaultImageCatalog(testContext);
testContext.given(CredentialTestDto.class).when(credentialTestClient.create()).given(EnvironmentTestDto.class).when(environmentTestClient.create()).await(EnvironmentStatus.AVAILABLE).given(FreeIpaTestDto.class).when(freeIpaTestClient.create()).await(Status.AVAILABLE).given(SdxInternalTestDto.class).when(sdxTestClient.createInternal()).await(SdxClusterStatusResponse.RUNNING).when(sdxTestClient.detailedDescribeInternal()).given(DistroXTestDto.class).when(distroXClient.create()).await(STACK_AVAILABLE, RunningParameter.who(cloudbreakActor.useRealUmsUser(AuthUserKeys.ACCOUNT_ADMIN))).validate();
ImageCatalogTestDto imageCatalogA = resourceCreator.createNewImageCatalog(testContext);
useRealUmsUser(testContext, AuthUserKeys.ENV_CREATOR_B);
ImageCatalogTestDto imageCatalogB = resourceCreator.createNewImageCatalog(testContext);
// ENV_CREATOR_B can't change DH image catalog in case of DH is created by ENV_CREATOR_A
testContext.given(DistroXChangeImageCatalogTestDto.class).withImageCatalog(imageCatalogB.getName()).whenException(distroXClient.changeImageCatalog(), ForbiddenException.class, expectedMessage("Doesn't have " + "'datahub/changeImageCatalog' right on any of the environment[(]s[)] " + "[\\[]crn: crn:cdp:environments:us-west-1:.*:environment:.*[]] or on .*")).validate();
// ENV_CREATOR_B can't change ENV_CREATOR_A's DH image catalog in case of having environment admin right but the catalog is created by ENV_CREATOR_A
testContext.given(UmsTestDto.class).assignTarget(EnvironmentTestDto.class.getSimpleName()).withEnvironmentAdmin().when(umsTestClient.assignResourceRole(AuthUserKeys.ENV_CREATOR_B, regionAwareInternalCrnGeneratorFactory)).given(DistroXChangeImageCatalogTestDto.class).withImageCatalog(imageCatalogA.getName()).whenException(distroXClient.changeImageCatalog(), ForbiddenException.class, expectedMessage("Doesn't have 'environments/useSharedResource' right on imageCatalog .*")).validate();
}
use of com.sequenceiq.it.cloudbreak.context.Description in project cloudbreak by hortonworks.
the class DistroXScaleEdgeCasesTest method testCreateDistroxAndRemoveLostNode.
@Test(dataProvider = TEST_CONTEXT)
@Description(given = "a running environment", when = "a valid DistroX create request is sent and one random worker node removed from provider", then = "lost node should be removable from cluster")
public void testCreateDistroxAndRemoveLostNode(TestContext testContext) {
testContext.given(DistroXTestDto.class).when(distroXTestClient.create()).await(STACK_AVAILABLE).then((tc, testDto, client) -> {
CloudFunctionality cloudFunctionality = tc.getCloudProvider().getCloudFunctionality();
List<String> instancesToDelete = distroxUtil.getInstanceIds(testDto, client, WORKER.getName()).stream().limit(1).collect(Collectors.toList());
cloudFunctionality.deleteInstances(testDto.getName(), instancesToDelete);
testDto.setInstanceIdsForActions(List.of(instancesToDelete.iterator().next()));
return testDto;
}).awaitForActionedInstances(DELETED_ON_PROVIDER_SIDE).when(distroXTestClient.removeInstances()).awaitForFlow().validate();
}
use of com.sequenceiq.it.cloudbreak.context.Description in project cloudbreak by hortonworks.
the class DistroXRepairTests method testEphemeralDistroXMasterRepairWithTerminatedEC2Instances.
@Test(dataProvider = TEST_CONTEXT)
@UseSpotInstances
@Description(given = "there is a running Cloudbreak, and an environment with SDX and DistroX cluster in available state", when = "recovery called on the MASTER host group of DistroX cluster, where the EC2 instance had been terminated", then = "DistroX recovery should be successful, the cluster should be up and running")
public void testEphemeralDistroXMasterRepairWithTerminatedEC2Instances(TestContext testContext) {
String distrox = resourcePropertyProvider().getName();
List<String> actualVolumeIds = new ArrayList<>();
List<String> expectedVolumeIds = new ArrayList<>();
String username = testContext.getActingUserCrn().getResource();
String sanitizedUserName = SanitizerUtil.sanitizeWorkloadUsername(username);
testContext.given(distrox, DistroXTestDto.class).withInstanceGroupsEntity(new DistroXInstanceGroupsBuilder(testContext).defaultHostGroup().withStorageOptimizedInstancetype().build()).when(distroXTestClient.create(), key(distrox)).await(STACK_AVAILABLE).awaitForHealthyInstances().then(this::verifyMountedDisks).then((tc, testDto, client) -> {
CloudFunctionality cloudFunctionality = tc.getCloudProvider().getCloudFunctionality();
List<String> instancesToDelete = distroxUtil.getInstanceIds(testDto, client, MASTER.getName());
expectedVolumeIds.addAll(cloudFunctionality.listInstanceVolumeIds(testDto.getName(), instancesToDelete));
cloudFunctionality.deleteInstances(testDto.getName(), instancesToDelete);
return testDto;
}).awaitForHostGroup(MASTER.getName(), InstanceStatus.DELETED_ON_PROVIDER_SIDE).when(distroXTestClient.repair(MASTER), key(distrox)).await(STACK_AVAILABLE, key(distrox)).awaitForHealthyInstances().then(this::verifyMountedDisks).then((tc, testDto, client) -> clouderaManagerUtil.checkClouderaManagerYarnNodemanagerRoleConfigGroups(testDto, sanitizedUserName, MOCK_UMS_PASSWORD)).then((tc, testDto, client) -> {
CloudFunctionality cloudFunctionality = tc.getCloudProvider().getCloudFunctionality();
List<String> instanceIds = distroxUtil.getInstanceIds(testDto, client, MASTER.getName());
actualVolumeIds.addAll(cloudFunctionality.listInstanceVolumeIds(testDto.getName(), instanceIds));
return testDto;
}).then((tc, testDto, client) -> VolumeUtils.compareVolumeIdsAfterRepair(testDto, actualVolumeIds, expectedVolumeIds)).validate();
}
Aggregations