use of com.sequenceiq.it.cloudbreak.dto.distrox.DistroXTestDto 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.dto.distrox.DistroXTestDto 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.dto.distrox.DistroXTestDto 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.dto.distrox.DistroXTestDto in project cloudbreak by hortonworks.
the class ClouderaManagerClientActions method checkCmServicesStartedSuccessfully.
public DistroXTestDto checkCmServicesStartedSuccessfully(DistroXTestDto testDto, String user, String password) {
String serverIp = testDto.getResponse().getCluster().getServerIp();
ApiClient apiClient = getCmApiClientWithTimeoutDisabledDirect(serverIp, testDto.getName(), V_43, user, password);
// CHECKSTYLE:OFF
HostsResourceApi hostsResourceApi = new HostsResourceApi(apiClient);
// CHECKSTYLE:ON
try {
Set<String> masterHostnames = testDto.getResponse().getInstanceGroups().stream().filter(ig -> "master".equals(ig.getName())).flatMap(ig -> ig.getMetadata().stream()).map(InstanceMetaDataV4Response::getDiscoveryFQDN).collect(Collectors.toSet());
List<ApiHost> apiHosts = hostsResourceApi.readHosts(null, null, "FULL_WITH_HEALTH_CHECK_EXPLANATION").getItems();
Set<String> servicesNotStarted = apiHosts.stream().filter(apiHost -> masterHostnames.contains(apiHost.getHostname())).flatMap(apiHost -> collectNotStartedServicesOnHost(apiHost).stream()).filter(serviceName -> REQUIRED_SERVICES.contains(serviceName)).collect(Collectors.toSet());
if (!servicesNotStarted.isEmpty()) {
LOGGER.error("There are not started required services: {}", servicesNotStarted);
throw new TestFailException(String.format("There are not started required services: %s", servicesNotStarted));
}
} catch (ApiException e) {
LOGGER.error("Exception when calling HostsResourceApi#readHosts. Response: {}", e.getResponseBody(), e);
String message = format("Exception when calling HostsResourceApi#readHosts at %s. Response: %s", apiClient.getBasePath(), e.getResponseBody());
throw new TestFailException(message, e);
} catch (Exception e) {
LOGGER.error("Can't read host statuses at: '{}'!", apiClient.getBasePath());
throw new TestFailException("Can't read host statuses at: " + apiClient.getBasePath(), e);
}
return testDto;
}
use of com.sequenceiq.it.cloudbreak.dto.distrox.DistroXTestDto in project cloudbreak by hortonworks.
the class SshJClientActions method checkMeteringStatus.
public DistroXTestDto checkMeteringStatus(DistroXTestDto testDto, List<InstanceGroupV4Response> instanceGroups, List<String> hostGroupNames) {
String meteringStatusCommand = "sudo cdp-doctor metering status --format json";
Map<String, Pair<Integer, String>> meteringStatusReportByIp = getInstanceGroupIps(instanceGroups, hostGroupNames, false).stream().collect(Collectors.toMap(ip -> ip, ip -> executeSshCommand(ip, meteringStatusCommand)));
for (Entry<String, Pair<Integer, String>> meteringStatusReport : meteringStatusReportByIp.entrySet()) {
List<Integer> heartbeatEventCounts = new Json(meteringStatusReport.getValue().getValue()).getMap().entrySet().stream().filter(status -> String.valueOf(status.getKey()).contains("heartbeatEventCount")).map(Entry::getValue).collect(Collectors.toList()).stream().map(countObject -> (Integer) countObject).collect(Collectors.toList());
LOGGER.info(format("heartbeatEventCounts: %s", heartbeatEventCounts));
Log.log(LOGGER, format(" Found '%s' Metering Heartbeat Events at '%s' instance. ", heartbeatEventCounts, meteringStatusReport.getKey()));
if (CollectionUtils.isEmpty(heartbeatEventCounts) || heartbeatEventCounts.contains(0)) {
LOGGER.error("Metering Heartbeat Events does NOT generated on '{}' instance!", meteringStatusReport.getKey());
throw new TestFailException(format("Metering Heartbeat Events does NOT generated on '%s' instance!", meteringStatusReport.getKey()));
}
}
for (Entry<String, Pair<Integer, String>> meteringStatusReport : meteringStatusReportByIp.entrySet()) {
List<String> heartbeatStatusesNotOk = new Json(meteringStatusReport.getValue().getValue()).getMap().entrySet().stream().filter(status -> String.valueOf(status.getValue()).contains("NOK")).map(Entry::getKey).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(heartbeatStatusesNotOk)) {
heartbeatStatusesNotOk.forEach(event -> {
if (StringUtils.containsIgnoreCase(event, "databusReachable")) {
Log.log(LOGGER, format(" Found 'databusReachable' status is not OK at '%s' instance. However this is acceptable!", meteringStatusReport.getKey()));
LOGGER.warn("Found 'databusReachable' status is not OK at '{}' instance. However this is acceptable!", meteringStatusReport.getKey());
} else {
Log.log(LOGGER, format(" Found '%s' not OK at '%s' instance. ", event, meteringStatusReport.getKey()));
LOGGER.error("There is 'Not OK' Metering Heartbeat status {} is present on '{}' instance!", event, meteringStatusReport.getKey());
throw new TestFailException(format("There is 'Not OK' Metering Heartbeat status %s is present on '%s' instance!", event, meteringStatusReport.getKey()));
}
});
}
}
return testDto;
}
Aggregations