Search in sources :

Example 6 with ApiGcpAiNotebookInstanceCreationParameters

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

the class CreateAiNotebookInstanceStepTest method setFieldsNoFields.

@Test
public void setFieldsNoFields() {
    Instance instance = CreateAiNotebookInstanceStep.setFields(new ApiGcpAiNotebookInstanceCreationParameters(), "foo@bar.com", new Instance());
    assertThat(instance.getMetadata(), Matchers.aMapWithSize(1));
    assertThat(instance.getMetadata(), Matchers.hasEntry("proxy-mode", "service_" + "account"));
    assertEquals("foo@bar.com", instance.getServiceAccount());
    assertEquals(sa_scopes, instance.getServiceAccountScopes());
    assertEquals(DEFAULT_POST_STARTUP_SCRIPT, instance.getPostStartupScript());
}
Also used : Instance(com.google.api.services.notebooks.v1.model.Instance) ApiGcpAiNotebookInstanceCreationParameters(bio.terra.workspace.generated.model.ApiGcpAiNotebookInstanceCreationParameters) Test(org.junit.jupiter.api.Test) BaseUnitTest(bio.terra.workspace.common.BaseUnitTest)

Example 7 with ApiGcpAiNotebookInstanceCreationParameters

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

the class CreateAiNotebookInstanceStepTest method setFields.

@Test
public void setFields() {
    var creationParameters = new ApiGcpAiNotebookInstanceCreationParameters().postStartupScript("script.sh").machineType("machine-type").installGpuDriver(true).customGpuDriverPath("custom-path").bootDiskType("boot-disk-type").bootDiskSizeGb(111L).dataDiskType("data-disk-type").dataDiskSizeGb(222L).metadata(Map.of("metadata-key", "metadata-value")).acceleratorConfig(new ApiGcpAiNotebookInstanceAcceleratorConfig().coreCount(4L).type("accelerator-type")).vmImage(new ApiGcpAiNotebookInstanceVmImage().projectId("project-id").imageFamily("image-family").imageName("image-name")).containerImage(new ApiGcpAiNotebookInstanceContainerImage().repository("repository").tag("tag"));
    Instance instance = CreateAiNotebookInstanceStep.setFields(creationParameters, "foo@bar.com", new Instance());
    assertEquals("script.sh", instance.getPostStartupScript());
    assertEquals(true, instance.getInstallGpuDriver());
    assertEquals("custom-path", instance.getCustomGpuDriverPath());
    assertEquals("boot-disk-type", instance.getBootDiskType());
    assertEquals(111L, instance.getBootDiskSizeGb());
    assertEquals("data-disk-type", instance.getDataDiskType());
    assertEquals(222L, instance.getDataDiskSizeGb());
    assertThat(instance.getMetadata(), Matchers.aMapWithSize(2));
    // git secrets gets a false positive if 'service_account' is double quoted.
    assertThat(instance.getMetadata(), Matchers.hasEntry("proxy-mode", "service_" + "account"));
    assertThat(instance.getMetadata(), Matchers.hasEntry("metadata-key", "metadata-value"));
    assertEquals("foo@bar.com", instance.getServiceAccount());
    assertEquals(sa_scopes, instance.getServiceAccountScopes());
    assertEquals(4L, instance.getAcceleratorConfig().getCoreCount());
    assertEquals("accelerator-type", instance.getAcceleratorConfig().getType());
    assertEquals("project-id", instance.getVmImage().getProject());
    assertEquals("image-family", instance.getVmImage().getImageFamily());
    assertEquals("image-name", instance.getVmImage().getImageName());
    assertEquals("repository", instance.getContainerImage().getRepository());
    assertEquals("tag", instance.getContainerImage().getTag());
}
Also used : ApiGcpAiNotebookInstanceVmImage(bio.terra.workspace.generated.model.ApiGcpAiNotebookInstanceVmImage) Instance(com.google.api.services.notebooks.v1.model.Instance) ApiGcpAiNotebookInstanceContainerImage(bio.terra.workspace.generated.model.ApiGcpAiNotebookInstanceContainerImage) ApiGcpAiNotebookInstanceCreationParameters(bio.terra.workspace.generated.model.ApiGcpAiNotebookInstanceCreationParameters) ApiGcpAiNotebookInstanceAcceleratorConfig(bio.terra.workspace.generated.model.ApiGcpAiNotebookInstanceAcceleratorConfig) Test(org.junit.jupiter.api.Test) BaseUnitTest(bio.terra.workspace.common.BaseUnitTest)

Aggregations

ApiGcpAiNotebookInstanceCreationParameters (bio.terra.workspace.generated.model.ApiGcpAiNotebookInstanceCreationParameters)7 Test (org.junit.jupiter.api.Test)5 ApiJobControl (bio.terra.workspace.generated.model.ApiJobControl)4 ControlledAiNotebookInstanceResource (bio.terra.workspace.service.resource.controlled.cloud.gcp.ainotebook.ControlledAiNotebookInstanceResource)4 Instance (com.google.api.services.notebooks.v1.model.Instance)4 BaseConnectedTest (bio.terra.workspace.common.BaseConnectedTest)3 DisabledIfEnvironmentVariable (org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable)3 StepStatus (bio.terra.stairway.StepStatus)2 BaseUnitTest (bio.terra.workspace.common.BaseUnitTest)2 JobService (bio.terra.workspace.service.job.JobService)2 CreateAiNotebookInstanceStep (bio.terra.workspace.service.resource.controlled.cloud.gcp.ainotebook.CreateAiNotebookInstanceStep)2 GrantPetUsagePermissionStep (bio.terra.workspace.service.resource.controlled.cloud.gcp.ainotebook.GrantPetUsagePermissionStep)2 HashMap (java.util.HashMap)2 IamCow (bio.terra.cloudres.google.iam.IamCow)1 ServiceAccountName (bio.terra.cloudres.google.iam.ServiceAccountName)1 InstanceName (bio.terra.cloudres.google.notebooks.InstanceName)1 BadRequestException (bio.terra.common.exception.BadRequestException)1 ApiGcpAiNotebookInstanceAcceleratorConfig (bio.terra.workspace.generated.model.ApiGcpAiNotebookInstanceAcceleratorConfig)1 ApiGcpAiNotebookInstanceContainerImage (bio.terra.workspace.generated.model.ApiGcpAiNotebookInstanceContainerImage)1 ApiGcpAiNotebookInstanceVmImage (bio.terra.workspace.generated.model.ApiGcpAiNotebookInstanceVmImage)1