use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.instancegroup.instancemetadata.InstanceMetaDataV4Response in project cloudbreak by hortonworks.
the class MockStackResponseGenerator method getMockStackV4ResponseWithStoppedAndRunningNodes.
public static StackV4Response getMockStackV4ResponseWithStoppedAndRunningNodes(String clusterCrn, String hostGroup, String fqdnBase, int runningHostGroupNodeCount, int stoppedHostGroupNodeCount) {
List<InstanceGroupV4Response> instanceGroupV4Responses = new ArrayList<>();
InstanceMetaDataV4Response master1 = new InstanceMetaDataV4Response();
master1.setDiscoveryFQDN("master1");
master1.setInstanceId("test_instanceid" + "master1");
instanceGroupV4Responses.add(instanceGroup("master", awsTemplate(), Set.of(master1)));
InstanceMetaDataV4Response worker1 = new InstanceMetaDataV4Response();
worker1.setDiscoveryFQDN("worker1");
worker1.setInstanceId("test_instanceid" + "worker1");
InstanceMetaDataV4Response worker2 = new InstanceMetaDataV4Response();
worker2.setDiscoveryFQDN("worker2");
worker2.setInstanceId("test_instanceid" + "worker2");
instanceGroupV4Responses.add(instanceGroup("worker", awsTemplate(), Set.of(worker1, worker2)));
Set<InstanceMetaDataV4Response> instanceMetadata = new HashSet<>();
int i;
for (i = 0; i < runningHostGroupNodeCount; ++i) {
InstanceMetaDataV4Response metadata1 = new InstanceMetaDataV4Response();
metadata1.setDiscoveryFQDN(fqdnBase + i);
metadata1.setInstanceId("test_instanceid_" + hostGroup + i);
metadata1.setInstanceStatus(InstanceStatus.SERVICES_HEALTHY);
instanceMetadata.add(metadata1);
}
for (i = 0; i < stoppedHostGroupNodeCount; ++i) {
InstanceMetaDataV4Response metadata1 = new InstanceMetaDataV4Response();
metadata1.setDiscoveryFQDN(fqdnBase + runningHostGroupNodeCount + i);
metadata1.setInstanceId("test_instanceid_" + hostGroup + (runningHostGroupNodeCount + i));
metadata1.setInstanceStatus(InstanceStatus.STOPPED);
instanceMetadata.add(metadata1);
}
instanceGroupV4Responses.add(instanceGroup(hostGroup, awsTemplate(), instanceMetadata));
StackV4Response mockResponse = new StackV4Response();
mockResponse.setCrn(clusterCrn);
mockResponse.setInstanceGroups(instanceGroupV4Responses);
mockResponse.setNodeCount(instanceGroupV4Responses.stream().flatMap(ig -> ig.getMetadata().stream()).collect(Collectors.counting()).intValue());
mockResponse.setCloudPlatform(CloudPlatform.AWS);
return mockResponse;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.instancegroup.instancemetadata.InstanceMetaDataV4Response 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.cloudbreak.api.endpoint.v4.stacks.response.instancegroup.instancemetadata.InstanceMetaDataV4Response in project cloudbreak by hortonworks.
the class InstanceUtilTest method fillWithNullInstanceIds.
private void fillWithNullInstanceIds(InstanceGroupV4Response group) {
group.setMetadata(Sets.newHashSet());
InstanceMetaDataV4Response metaDataV4Response = new InstanceMetaDataV4Response();
metaDataV4Response.setInstanceId(null);
InstanceMetaDataV4Response metaDataV4Response2 = new InstanceMetaDataV4Response();
metaDataV4Response2.setInstanceId(null);
group.getMetadata().add(metaDataV4Response);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.instancegroup.instancemetadata.InstanceMetaDataV4Response in project cloudbreak by hortonworks.
the class InstanceMetaDataToInstanceMetaDataV4ResponseConverterTest method convertTest.
@ParameterizedTest(name = "{0}")
@MethodSource("convertTestDataProvider")
void convertTest(String testCaseName, String publicIp, String privateIp, String publicIpExpected) {
InstanceMetaData instanceMetaData = createInstanceMetaData(publicIp, privateIp);
InstanceMetaDataV4Response result = underTest.convert(instanceMetaData);
assertThat(result).isNotNull();
assertThat(result.getPrivateIp()).isEqualTo(privateIp);
assertThat(result.getPublicIp()).isEqualTo(publicIpExpected);
assertThat(result.getSshPort()).isEqualTo(SSH_PORT);
assertThat(result.getAmbariServer()).isEqualTo(AMBARI_SERVER);
assertThat(result.getInstanceId()).isEqualTo(INSTANCE_ID);
assertThat(result.getDiscoveryFQDN()).isEqualTo(DISCOVERY_FQDN);
assertThat(result.getInstanceGroup()).isEqualTo(INSTANCE_GROUP);
assertThat(result.getSubnetId()).isEqualTo(SUBNET_ID);
assertThat(result.getAvailabilityZone()).isEqualTo(AVAILABILITY_ZONE);
assertThat(result.getRackId()).isEqualTo(RACK_ID);
assertThat(result.getInstanceStatus()).isEqualTo(INSTANCE_STATUS);
assertThat(result.getInstanceType()).isEqualTo(INSTANCE_METADATA_TYPE);
assertThat(result.getLifeCycle()).isEqualTo(LIFE_CYCLE);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.instancegroup.instancemetadata.InstanceMetaDataV4Response in project cloudbreak by hortonworks.
the class InstanceGroupToInstanceGroupV4ResponseConverterTest method getInstanceMetaData.
private InstanceMetaDataV4Response getInstanceMetaData(InstanceMetaData instanceMetaData) {
InstanceMetaDataV4Response response = new InstanceMetaDataV4Response();
response.setPublicIp(instanceMetaData.getPublicIp());
response.setAmbariServer(instanceMetaData.getAmbariServer());
response.setDiscoveryFQDN(instanceMetaData.getDiscoveryFQDN());
response.setInstanceGroup(instanceMetaData.getInstanceGroupName());
response.setInstanceStatus(instanceMetaData.getInstanceStatus());
response.setInstanceId(instanceMetaData.getInstanceId());
response.setInstanceType(instanceMetaData.getInstanceMetadataType());
response.setPrivateIp(instanceMetaData.getPrivateIp());
response.setSshPort(instanceMetaData.getSshPort());
return response;
}
Aggregations