Search in sources :

Example 1 with CreateDiskRequestData

use of bio.terra.cloudres.azure.resourcemanager.compute.data.CreateDiskRequestData in project terra-workspace-manager by DataBiosphere.

the class CreateAzureDiskStepTest method createDisk.

@Test
void createDisk() throws InterruptedException {
    final ApiAzureDiskCreationParameters creationParameters = ControlledResourceFixtures.getAzureDiskCreationParameters();
    var createAzureDiskStep = new CreateAzureDiskStep(mockAzureConfig, mockCrlService, ControlledResourceFixtures.getAzureDisk(creationParameters.getName(), creationParameters.getRegion(), creationParameters.getSize()));
    final StepResult stepResult = createAzureDiskStep.doStep(mockFlightContext);
    // Verify step returns success
    assertThat(stepResult, equalTo(StepResult.getStepResultSuccess()));
    // Verify Azure create call was made correctly
    verify(mockDiskStage7).create(contextCaptor.capture());
    Context context = contextCaptor.getValue();
    Optional<CreateDiskRequestData> requestDataOpt = context.getValues().values().stream().filter(CreateDiskRequestData.class::isInstance).map(CreateDiskRequestData.class::cast).findFirst();
    CreateDiskRequestData expected = CreateDiskRequestData.builder().setName(creationParameters.getName()).setRegion(Region.fromName(creationParameters.getRegion())).setSize(50).setTenantId(mockAzureCloudContext.getAzureTenantId()).setSubscriptionId(mockAzureCloudContext.getAzureSubscriptionId()).setResourceGroupName(mockAzureCloudContext.getAzureResourceGroupId()).build();
    assertThat(requestDataOpt, equalTo(Optional.of(expected)));
}
Also used : Context(com.azure.core.util.Context) AzureCloudContext(bio.terra.workspace.service.workspace.model.AzureCloudContext) FlightContext(bio.terra.stairway.FlightContext) CreateDiskRequestData(bio.terra.cloudres.azure.resourcemanager.compute.data.CreateDiskRequestData) StepResult(bio.terra.stairway.StepResult) ApiAzureDiskCreationParameters(bio.terra.workspace.generated.model.ApiAzureDiskCreationParameters) Test(org.junit.jupiter.api.Test) BaseAzureTest(bio.terra.workspace.common.BaseAzureTest)

Example 2 with CreateDiskRequestData

use of bio.terra.cloudres.azure.resourcemanager.compute.data.CreateDiskRequestData in project terra-cloud-resource-lib by DataBiosphere.

the class ComputeRequestDataTest method serializeCreateDisk.

@Test
public void serializeCreateDisk() {
    CreateDiskRequestData createDisk = CreateDiskRequestData.builder().setName("my-disk").setTenantId("my-tenant").setSubscriptionId("my-sub").setResourceGroupName("my-rg").setRegion(Region.US_EAST).setSize(500).build();
    assertEquals(ComputeManagerOperation.AZURE_CREATE_DISK, createDisk.cloudOperation());
    assertEquals("{\"tenantId\":\"my-tenant\",\"subscriptionId\":\"my-sub\",\"resourceGroupName\":\"my-rg\",\"name\":\"my-disk\",\"region\":\"eastus\",\"size\":500}", createDisk.serialize().toString());
    assertEquals(Optional.of(new CloudResourceUid().azureDisk(new AzureDisk().resourceGroup(azureResourceGroup(createDisk)).diskName("my-disk"))), createDisk.resourceUidCreation());
}
Also used : CloudResourceUid(bio.terra.janitor.model.CloudResourceUid) CreateDiskRequestData(bio.terra.cloudres.azure.resourcemanager.compute.data.CreateDiskRequestData) AzureDisk(bio.terra.janitor.model.AzureDisk) Test(org.junit.jupiter.api.Test)

Aggregations

CreateDiskRequestData (bio.terra.cloudres.azure.resourcemanager.compute.data.CreateDiskRequestData)2 Test (org.junit.jupiter.api.Test)2 AzureDisk (bio.terra.janitor.model.AzureDisk)1 CloudResourceUid (bio.terra.janitor.model.CloudResourceUid)1 FlightContext (bio.terra.stairway.FlightContext)1 StepResult (bio.terra.stairway.StepResult)1 BaseAzureTest (bio.terra.workspace.common.BaseAzureTest)1 ApiAzureDiskCreationParameters (bio.terra.workspace.generated.model.ApiAzureDiskCreationParameters)1 AzureCloudContext (bio.terra.workspace.service.workspace.model.AzureCloudContext)1 Context (com.azure.core.util.Context)1