Search in sources :

Example 96 with Stack

use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.

the class TelemetryConfigServiceTest method testCreateTelemetryConfigs.

@Test
public void testCreateTelemetryConfigs() throws Exception {
    // GIVEN
    UserManagementProto.Account account = UserManagementProto.Account.newBuilder().setClouderaManagerLicenseKey("myLicense").build();
    JsonCMLicense license = new JsonCMLicense();
    license.setName("myname");
    license.setUuid("myuuid");
    Stack stack = createStack();
    given(stackService.getStackById(STACK_ID)).willReturn(stack);
    given(entitlementService.useDataBusCNameEndpointEnabled(anyString())).willReturn(false);
    given(dataBusEndpointProvider.getDataBusEndpoint(anyString(), anyBoolean())).willReturn("myendpoint");
    given(vmLogsService.getVmLogs()).willReturn(List.of(new VmLog()));
    given(telemetryCommonConfigService.createTelemetryCommonConfigs(any(), any(), any())).willReturn(new TelemetryCommonConfigView.Builder().build());
    given(cmLicenseParser.parseLicense(anyString())).willReturn(Optional.of(license));
    given(umsClient.getAccountDetails(anyString(), any(), any())).willReturn(account);
    given(fluentConfigService.createFluentConfigs(any(), anyBoolean(), anyBoolean(), isNull(), any())).willReturn(new FluentConfigView.Builder().build());
    given(nodeStatusConfigService.createNodeStatusConfig(isNull(), isNull(), anyBoolean())).willReturn(new NodeStatusConfigView.Builder().build());
    given(monitoringConfigService.createMonitoringConfig(isNull(), any(), isNull(), isNull(), anyBoolean())).willReturn(new MonitoringConfigView.Builder().build());
    // WHEN
    Map<String, SaltPillarProperties> result = underTest.createTelemetryConfigs(STACK_ID, Set.of(TelemetryComponentType.CDP_TELEMETRY));
    // THEN
    verify(fluentConfigService, times(1)).createFluentConfigs(any(), anyBoolean(), anyBoolean(), isNull(), any());
    assertNotNull(result.get("telemetry").getProperties().get("cloudera-manager"));
    assertNotNull(result.get("telemetry").getProperties().get("telemetry"));
}
Also used : VmLog(com.sequenceiq.common.api.telemetry.model.VmLog) UserManagementProto(com.cloudera.thunderhead.service.usermanagement.UserManagementProto) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) JsonCMLicense(com.sequenceiq.cloudbreak.auth.JsonCMLicense) SaltPillarProperties(com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 97 with Stack

use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.

the class UpgradeImageServiceTest method testFindTargetImagesNoNewerImage.

@Test
public void testFindTargetImagesNoNewerImage() {
    Stack stack = new Stack();
    ImageSettingsRequest imageSettingsRequest = new ImageSettingsRequest();
    Image image = createImage("2021-07-01");
    ImageWrapper imageWrapper = new ImageWrapper(image, "catalogURL", "catalogName");
    when(imageService.fetchImagesWrapperAndName(stack, imageSettingsRequest)).thenReturn(List.of(Pair.of(imageWrapper, "imageName")));
    ImageInfoResponse currentImage = new ImageInfoResponse();
    currentImage.setDate("2021-08-21");
    currentImage.setId("111-222");
    List<ImageInfoResponse> targetImages = underTest.findTargetImages(stack, imageSettingsRequest, currentImage);
    assertTrue(targetImages.isEmpty());
}
Also used : ImageInfoResponse(com.sequenceiq.freeipa.api.v1.freeipa.upgrade.model.ImageInfoResponse) ImageSettingsRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest) ImageWrapper(com.sequenceiq.freeipa.dto.ImageWrapper) Image(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 98 with Stack

use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.

the class UpgradeImageServiceTest method testFindTargetImagesImageWithSameId.

@Test
public void testFindTargetImagesImageWithSameId() {
    Stack stack = new Stack();
    ImageSettingsRequest imageSettingsRequest = new ImageSettingsRequest();
    Image image = createImage("2021-09-01");
    ImageWrapper imageWrapper = new ImageWrapper(image, "catalogURL", "catalogName");
    when(imageService.fetchImagesWrapperAndName(stack, imageSettingsRequest)).thenReturn(List.of(Pair.of(imageWrapper, "imageName")));
    ImageInfoResponse currentImage = new ImageInfoResponse();
    currentImage.setDate("2021-08-21");
    currentImage.setId("1234-456");
    List<ImageInfoResponse> targetImages = underTest.findTargetImages(stack, imageSettingsRequest, currentImage);
    assertTrue(targetImages.isEmpty());
}
Also used : ImageInfoResponse(com.sequenceiq.freeipa.api.v1.freeipa.upgrade.model.ImageInfoResponse) ImageSettingsRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest) ImageWrapper(com.sequenceiq.freeipa.dto.ImageWrapper) Image(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 99 with Stack

use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.

the class UpgradeImageServiceTest method testFindTargetImagesCurrentImageMissingDate.

@Test
public void testFindTargetImagesCurrentImageMissingDate() {
    Stack stack = new Stack();
    stack.setCloudPlatform("AWS");
    stack.setRegion("reg");
    ImageSettingsRequest imageSettingsRequest = new ImageSettingsRequest();
    Image image = createImage("2021-09-01");
    ImageWrapper imageWrapper = new ImageWrapper(image, "catalogURL", "catalogName");
    when(imageService.fetchImagesWrapperAndName(stack, imageSettingsRequest)).thenReturn(List.of(Pair.of(imageWrapper, "imageName")));
    ArgumentCaptor<ImageSettingsRequest> captor = ArgumentCaptor.forClass(ImageSettingsRequest.class);
    Image currentImageFromCatalog = createImage("2021-08-01");
    ImageWrapper currentImageWrapperFromCatalog = new ImageWrapper(currentImageFromCatalog, "asdf", "Asdf");
    when(imageService.getImage(captor.capture(), eq(stack.getRegion()), eq(stack.getCloudPlatform().toLowerCase()))).thenReturn(currentImageWrapperFromCatalog);
    ImageInfoResponse currentImage = new ImageInfoResponse();
    currentImage.setId("222-333");
    currentImage.setCatalog("cat");
    currentImage.setCatalogName("catName");
    currentImage.setOs("zOs");
    List<ImageInfoResponse> targetImages = underTest.findTargetImages(stack, imageSettingsRequest, currentImage);
    assertEquals(1, targetImages.size());
    ImageInfoResponse imageInfoResponse = targetImages.get(0);
    assertEquals(imageWrapper.getCatalogName(), imageInfoResponse.getCatalogName());
    assertEquals(imageWrapper.getCatalogUrl(), imageInfoResponse.getCatalog());
    assertEquals(image.getDate(), imageInfoResponse.getDate());
    assertEquals(image.getUuid(), imageInfoResponse.getId());
    assertEquals(image.getOs(), imageInfoResponse.getOs());
    ImageSettingsRequest settingsRequest = captor.getValue();
    assertEquals(currentImage.getCatalog(), settingsRequest.getCatalog());
    assertEquals(currentImage.getId(), settingsRequest.getId());
    assertEquals(currentImage.getOs(), settingsRequest.getOs());
}
Also used : ImageInfoResponse(com.sequenceiq.freeipa.api.v1.freeipa.upgrade.model.ImageInfoResponse) ImageSettingsRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest) ImageWrapper(com.sequenceiq.freeipa.dto.ImageWrapper) Image(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 100 with Stack

use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.

the class UpgradeServiceTest method testUpgradeOptionsCatalogNameFromCurrentImage.

@Test
public void testUpgradeOptionsCatalogNameFromCurrentImage() {
    Stack stack = new Stack();
    when(stackService.getByEnvironmentCrnAndAccountIdWithListsAndMdcContext(ENVIRONMENT_CRN, ACCOUNT_ID)).thenReturn(stack);
    ImageInfoResponse currentImage = new ImageInfoResponse();
    currentImage.setCatalogName("catName");
    when(imageService.fetchCurrentImage(stack)).thenReturn(currentImage);
    ArgumentCaptor<ImageSettingsRequest> captor = ArgumentCaptor.forClass(ImageSettingsRequest.class);
    ImageInfoResponse targetImage = new ImageInfoResponse();
    when(imageService.findTargetImages(eq(stack), captor.capture(), eq(currentImage))).thenReturn(List.of(targetImage));
    FreeIpaUpgradeOptions result = underTest.collectUpgradeOptions(ACCOUNT_ID, ENVIRONMENT_CRN, null);
    assertEquals(currentImage, result.getCurrentImage());
    assertEquals(1, result.getImages().size());
    assertEquals(targetImage, result.getImages().get(0));
    ImageSettingsRequest imageSettingsRequest = captor.getValue();
    assertEquals("catName", imageSettingsRequest.getCatalog());
}
Also used : ImageInfoResponse(com.sequenceiq.freeipa.api.v1.freeipa.upgrade.model.ImageInfoResponse) ImageSettingsRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest) FreeIpaUpgradeOptions(com.sequenceiq.freeipa.api.v1.freeipa.upgrade.model.FreeIpaUpgradeOptions) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Aggregations

Stack (com.sequenceiq.freeipa.entity.Stack)468 Test (org.junit.jupiter.api.Test)237 InstanceMetaData (com.sequenceiq.freeipa.entity.InstanceMetaData)107 FreeIpa (com.sequenceiq.freeipa.entity.FreeIpa)63 Map (java.util.Map)63 Bean (org.springframework.context.annotation.Bean)50 StackContext (com.sequenceiq.freeipa.flow.stack.StackContext)45 StackEvent (com.sequenceiq.freeipa.flow.stack.StackEvent)41 List (java.util.List)37 InstanceGroup (com.sequenceiq.freeipa.entity.InstanceGroup)34 Inject (javax.inject.Inject)30 CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)29 Collectors (java.util.stream.Collectors)29 Logger (org.slf4j.Logger)29 LoggerFactory (org.slf4j.LoggerFactory)29 Set (java.util.Set)28 GatewayConfig (com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)25 FreeIpaClient (com.sequenceiq.freeipa.client.FreeIpaClient)25 ImageSettingsRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest)24 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)23