Search in sources :

Example 6 with ApiAzureDiskCreationParameters

use of bio.terra.workspace.generated.model.ApiAzureDiskCreationParameters in project terra-workspace-manager by DataBiosphere.

the class CreateAndDeleteAzureControlledResourceFlightTest method createDisk.

private ControlledAzureDiskResource createDisk(UUID workspaceId, AuthenticatedUserRequest userRequest) throws InterruptedException {
    final ApiAzureDiskCreationParameters creationParameters = ControlledResourceFixtures.getAzureDiskCreationParameters();
    // TODO: make this application-private resource once the POC supports it
    final UUID resourceId = UUID.randomUUID();
    ControlledAzureDiskResource resource = ControlledAzureDiskResource.builder().common(ControlledResourceFields.builder().workspaceId(workspaceId).resourceId(resourceId).name(getAzureName("disk")).description(getAzureName("disk-desc")).cloningInstructions(CloningInstructions.COPY_RESOURCE).accessScope(AccessScopeType.fromApi(ApiAccessScope.SHARED_ACCESS)).managedBy(ManagedByType.fromApi(ApiManagedBy.USER)).build()).diskName(creationParameters.getName()).region(creationParameters.getRegion()).size(creationParameters.getSize()).build();
    // Submit a Disk creation flight.
    FlightState flightState = StairwayTestUtils.blockUntilFlightCompletes(jobService.getStairway(), CreateControlledResourceFlight.class, azureTestUtils.createControlledResourceInputParameters(workspaceId, userRequest, resource), STAIRWAY_FLIGHT_TIMEOUT, null);
    assertEquals(FlightStatus.SUCCESS, flightState.getFlightStatus());
    return resource;
}
Also used : FlightState(bio.terra.stairway.FlightState) ControlledAzureDiskResource(bio.terra.workspace.service.resource.controlled.cloud.azure.disk.ControlledAzureDiskResource) UUID(java.util.UUID) ApiAzureDiskCreationParameters(bio.terra.workspace.generated.model.ApiAzureDiskCreationParameters)

Example 7 with ApiAzureDiskCreationParameters

use of bio.terra.workspace.generated.model.ApiAzureDiskCreationParameters in project terra-workspace-manager by DataBiosphere.

the class GetAzureDiskStepTest method getDisk_alreadyExists.

@Test
public void getDisk_alreadyExists() throws InterruptedException {
    final ApiAzureDiskCreationParameters creationParameters = ControlledResourceFixtures.getAzureDiskCreationParameters();
    GetAzureDiskStep step = new GetAzureDiskStep(mockAzureConfig, mockCrlService, ControlledResourceFixtures.getAzureDisk(creationParameters.getName(), creationParameters.getRegion(), creationParameters.getSize()));
    when(mockDisks.getByResourceGroup(mockAzureCloudContext.getAzureResourceGroupId(), creationParameters.getName())).thenReturn(mockDisk);
    final StepResult stepResult = step.doStep(mockFlightContext);
    // Verify step returns error
    assertThat(stepResult.getStepStatus(), equalTo(StepStatus.STEP_RESULT_FAILURE_FATAL));
    assertThat(stepResult.getException().get(), instanceOf(DuplicateResourceException.class));
}
Also used : StepResult(bio.terra.stairway.StepResult) ApiAzureDiskCreationParameters(bio.terra.workspace.generated.model.ApiAzureDiskCreationParameters) DuplicateResourceException(bio.terra.workspace.service.resource.exception.DuplicateResourceException) Test(org.junit.jupiter.api.Test) BaseAzureTest(bio.terra.workspace.common.BaseAzureTest)

Example 8 with ApiAzureDiskCreationParameters

use of bio.terra.workspace.generated.model.ApiAzureDiskCreationParameters in project terra-workspace-manager by DataBiosphere.

the class GetAzureDiskStepTest method getDisk_doesNotExist.

@Test
public void getDisk_doesNotExist() throws InterruptedException {
    final ApiAzureDiskCreationParameters creationParameters = ControlledResourceFixtures.getAzureDiskCreationParameters();
    GetAzureDiskStep step = new GetAzureDiskStep(mockAzureConfig, mockCrlService, ControlledResourceFixtures.getAzureDisk(creationParameters.getName(), creationParameters.getRegion(), creationParameters.getSize()));
    when(mockDisks.getByResourceGroup(mockAzureCloudContext.getAzureResourceGroupId(), creationParameters.getName())).thenThrow(mockException);
    final StepResult stepResult = step.doStep(mockFlightContext);
    // Verify step returns success
    assertThat(stepResult, equalTo(StepResult.getStepResultSuccess()));
}
Also used : StepResult(bio.terra.stairway.StepResult) ApiAzureDiskCreationParameters(bio.terra.workspace.generated.model.ApiAzureDiskCreationParameters) Test(org.junit.jupiter.api.Test) BaseAzureTest(bio.terra.workspace.common.BaseAzureTest)

Aggregations

ApiAzureDiskCreationParameters (bio.terra.workspace.generated.model.ApiAzureDiskCreationParameters)8 Test (org.junit.jupiter.api.Test)7 BaseAzureTest (bio.terra.workspace.common.BaseAzureTest)6 StepResult (bio.terra.stairway.StepResult)5 ControlledAzureDiskResource (bio.terra.workspace.service.resource.controlled.cloud.azure.disk.ControlledAzureDiskResource)3 UUID (java.util.UUID)3 FlightContext (bio.terra.stairway.FlightContext)2 FlightState (bio.terra.stairway.FlightState)2 AuthenticatedUserRequest (bio.terra.workspace.service.iam.AuthenticatedUserRequest)2 AzureCloudContext (bio.terra.workspace.service.workspace.model.AzureCloudContext)2 Context (com.azure.core.util.Context)2 CreateDiskRequestData (bio.terra.cloudres.azure.resourcemanager.compute.data.CreateDiskRequestData)1 BaseConnectedTest (bio.terra.workspace.common.BaseConnectedTest)1 ApiAzureIpCreationParameters (bio.terra.workspace.generated.model.ApiAzureIpCreationParameters)1 ApiAzureNetworkCreationParameters (bio.terra.workspace.generated.model.ApiAzureNetworkCreationParameters)1 ApiAzureVmCreationParameters (bio.terra.workspace.generated.model.ApiAzureVmCreationParameters)1 ControlledAzureIpResource (bio.terra.workspace.service.resource.controlled.cloud.azure.ip.ControlledAzureIpResource)1 ControlledAzureNetworkResource (bio.terra.workspace.service.resource.controlled.cloud.azure.network.ControlledAzureNetworkResource)1 ControlledAzureVmResource (bio.terra.workspace.service.resource.controlled.cloud.azure.vm.ControlledAzureVmResource)1 ControlledResource (bio.terra.workspace.service.resource.controlled.model.ControlledResource)1