Search in sources :

Example 1 with ApiAzureIpCreationParameters

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

the class CreateAzureRelayNamespaceStepTest method createRelayNamespace_alreadyExists.

@Test
public void createRelayNamespace_alreadyExists() throws InterruptedException {
    final ApiAzureIpCreationParameters creationParameters = ControlledResourceFixtures.getAzureIpCreationParameters();
    CreateAzureRelayNamespaceStep createStep = new CreateAzureRelayNamespaceStep(mockAzureConfig, mockCrlService, ControlledResourceFixtures.getAzureRelayNamespace(creationParameters.getName(), creationParameters.getRegion()));
    // Stub creation to throw Conflict exception.
    when(mockStage3.create(any(Context.class))).thenThrow(mockException);
    final StepResult stepResult = createStep.doStep(mockFlightContext);
    // Verify step still returns success
    assertThat(stepResult, equalTo(StepResult.getStepResultSuccess()));
}
Also used : ApiAzureIpCreationParameters(bio.terra.workspace.generated.model.ApiAzureIpCreationParameters) Context(com.azure.core.util.Context) AzureCloudContext(bio.terra.workspace.service.workspace.model.AzureCloudContext) FlightContext(bio.terra.stairway.FlightContext) StepResult(bio.terra.stairway.StepResult) Test(org.junit.jupiter.api.Test) BaseAzureTest(bio.terra.workspace.common.BaseAzureTest)

Example 2 with ApiAzureIpCreationParameters

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

the class CreateAzureIpStepTest method createIp_alreadyExists.

@Test
public void createIp_alreadyExists() throws InterruptedException {
    final ApiAzureIpCreationParameters creationParameters = ControlledResourceFixtures.getAzureIpCreationParameters();
    CreateAzureIpStep createAzureIpStep = new CreateAzureIpStep(mockAzureConfig, mockCrlService, ControlledResourceFixtures.getAzureIp(creationParameters.getName(), creationParameters.getRegion()));
    // Stub creation to throw Conflict exception.
    when(mockIpStage3.create(any(Context.class))).thenThrow(mockException);
    final StepResult stepResult = createAzureIpStep.doStep(mockFlightContext);
    // Verify step still returns success
    assertThat(stepResult, equalTo(StepResult.getStepResultSuccess()));
}
Also used : ApiAzureIpCreationParameters(bio.terra.workspace.generated.model.ApiAzureIpCreationParameters) Context(com.azure.core.util.Context) AzureCloudContext(bio.terra.workspace.service.workspace.model.AzureCloudContext) FlightContext(bio.terra.stairway.FlightContext) StepResult(bio.terra.stairway.StepResult) Test(org.junit.jupiter.api.Test) BaseAzureTest(bio.terra.workspace.common.BaseAzureTest)

Example 3 with ApiAzureIpCreationParameters

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

the class CreateAzureIpStepTest method createIp.

@Test
void createIp() throws InterruptedException {
    final ApiAzureIpCreationParameters creationParameters = ControlledResourceFixtures.getAzureIpCreationParameters();
    CreateAzureIpStep createAzureIpStep = new CreateAzureIpStep(mockAzureConfig, mockCrlService, ControlledResourceFixtures.getAzureIp(creationParameters.getName(), creationParameters.getRegion()));
    final StepResult stepResult = createAzureIpStep.doStep(mockFlightContext);
    // Verify step returns success
    assertThat(stepResult, equalTo(StepResult.getStepResultSuccess()));
    // Verify Azure create call was made correctly
    verify(mockIpStage3).create(contextCaptor.capture());
    Context context = contextCaptor.getValue();
    Optional<CreatePublicIpRequestData> publicIpRequestDataOpt = context.getValues().values().stream().filter(CreatePublicIpRequestData.class::isInstance).map(CreatePublicIpRequestData.class::cast).findFirst();
    CreatePublicIpRequestData expected = CreatePublicIpRequestData.builder().setName(creationParameters.getName()).setRegion(Region.fromName(creationParameters.getRegion())).setIpAllocationMethod(IpAllocationMethod.DYNAMIC).setTenantId(mockAzureCloudContext.getAzureTenantId()).setSubscriptionId(mockAzureCloudContext.getAzureSubscriptionId()).setResourceGroupName(mockAzureCloudContext.getAzureResourceGroupId()).build();
    assertThat(publicIpRequestDataOpt, equalTo(Optional.of(expected)));
}
Also used : ApiAzureIpCreationParameters(bio.terra.workspace.generated.model.ApiAzureIpCreationParameters) Context(com.azure.core.util.Context) AzureCloudContext(bio.terra.workspace.service.workspace.model.AzureCloudContext) FlightContext(bio.terra.stairway.FlightContext) CreatePublicIpRequestData(bio.terra.cloudres.azure.resourcemanager.compute.data.CreatePublicIpRequestData) StepResult(bio.terra.stairway.StepResult) Test(org.junit.jupiter.api.Test) BaseAzureTest(bio.terra.workspace.common.BaseAzureTest)

Example 4 with ApiAzureIpCreationParameters

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

the class CreateAndDeleteAzureControlledResourceFlightTest method createIp.

ControlledAzureIpResource createIp(UUID workspaceId, AuthenticatedUserRequest userRequest) throws InterruptedException {
    final ApiAzureIpCreationParameters ipCreationParameters = ControlledResourceFixtures.getAzureIpCreationParameters();
    // TODO: make this application-private resource once the POC supports it
    final UUID resourceId = UUID.randomUUID();
    ControlledAzureIpResource resource = ControlledAzureIpResource.builder().common(ControlledResourceFields.builder().workspaceId(workspaceId).resourceId(resourceId).name(getAzureName("ip")).description(getAzureName("ip-desc")).cloningInstructions(CloningInstructions.COPY_RESOURCE).accessScope(AccessScopeType.fromApi(ApiAccessScope.SHARED_ACCESS)).managedBy(ManagedByType.fromApi(ApiManagedBy.USER)).build()).ipName(ipCreationParameters.getName()).region(ipCreationParameters.getRegion()).build();
    // Submit an IP 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 : ApiAzureIpCreationParameters(bio.terra.workspace.generated.model.ApiAzureIpCreationParameters) ControlledAzureIpResource(bio.terra.workspace.service.resource.controlled.cloud.azure.ip.ControlledAzureIpResource) FlightState(bio.terra.stairway.FlightState) UUID(java.util.UUID)

Example 5 with ApiAzureIpCreationParameters

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

the class GetAzureIpStepTest method getIp_alreadyExists.

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

Aggregations

ApiAzureIpCreationParameters (bio.terra.workspace.generated.model.ApiAzureIpCreationParameters)9 Test (org.junit.jupiter.api.Test)8 BaseAzureTest (bio.terra.workspace.common.BaseAzureTest)7 StepResult (bio.terra.stairway.StepResult)6 FlightContext (bio.terra.stairway.FlightContext)3 ControlledAzureIpResource (bio.terra.workspace.service.resource.controlled.cloud.azure.ip.ControlledAzureIpResource)3 AzureCloudContext (bio.terra.workspace.service.workspace.model.AzureCloudContext)3 Context (com.azure.core.util.Context)3 UUID (java.util.UUID)3 FlightState (bio.terra.stairway.FlightState)2 AuthenticatedUserRequest (bio.terra.workspace.service.iam.AuthenticatedUserRequest)2 CreatePublicIpRequestData (bio.terra.cloudres.azure.resourcemanager.compute.data.CreatePublicIpRequestData)1 BaseConnectedTest (bio.terra.workspace.common.BaseConnectedTest)1 ApiAzureDiskCreationParameters (bio.terra.workspace.generated.model.ApiAzureDiskCreationParameters)1 ApiAzureNetworkCreationParameters (bio.terra.workspace.generated.model.ApiAzureNetworkCreationParameters)1 ApiAzureVmCreationParameters (bio.terra.workspace.generated.model.ApiAzureVmCreationParameters)1 ControlledAzureDiskResource (bio.terra.workspace.service.resource.controlled.cloud.azure.disk.ControlledAzureDiskResource)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