Search in sources :

Example 6 with CloningInstructionsEnum

use of bio.terra.workspace.model.CloningInstructionsEnum in project terra-cli by DataBiosphere.

the class GcpNotebookControlled method overrideLocationAndInstanceId.

@Test
@DisplayName("override the default location and instance id")
void overrideLocationAndInstanceId() throws IOException {
    workspaceCreator.login();
    // `terra workspace set --id=$id`
    TestCommand.runCommandExpectSuccess("workspace", "set", "--id=" + getWorkspaceId());
    // `terra resource create gcp-notebook --name=$name
    // --cloning=$cloning --description=$description
    // --location=$location --instance-id=$instanceId`
    String name = "overrideLocationAndInstanceId";
    CloningInstructionsEnum cloning = CloningInstructionsEnum.REFERENCE;
    String description = "\"override default location and instance id\"";
    String location = "us-central1-b";
    // instance id must start with a letter
    String instanceId = "a" + UUID.randomUUID().toString();
    UFGcpNotebook createdNotebook = TestCommand.runAndParseCommandExpectSuccess(UFGcpNotebook.class, "resource", "create", "gcp-notebook", "--name=" + name, "--cloning=" + cloning, "--description=" + description, "--location=" + location, "--instance-id=" + instanceId);
    // check that the properties match
    assertEquals(name, createdNotebook.name, "create output matches name");
    assertEquals(cloning, createdNotebook.cloningInstructions, "create output matches cloning");
    assertEquals(description, createdNotebook.description, "create output matches description");
    assertEquals(location, createdNotebook.location, "create output matches location");
    assertEquals(instanceId, createdNotebook.instanceId, "create output matches instance id");
    // gcp notebooks are always private
    assertEquals(AccessScope.PRIVATE_ACCESS, createdNotebook.accessScope, "create output matches access");
    assertEquals(workspaceCreator.email.toLowerCase(), createdNotebook.privateUserName.toLowerCase(), "create output matches private user name");
    // `terra resource describe --name=$name --format=json`
    UFGcpNotebook describeResource = TestCommand.runAndParseCommandExpectSuccess(UFGcpNotebook.class, "resource", "describe", "--name=" + name);
    // check that the properties match
    assertEquals(name, describeResource.name, "describe resource output matches name");
    assertEquals(cloning, describeResource.cloningInstructions, "describe output matches cloning");
    assertEquals(description, describeResource.description, "describe output matches description");
    assertEquals(location, describeResource.location, "describe resource output matches location");
    assertEquals(instanceId, describeResource.instanceId, "describe resource output matches instance id");
    // gcp notebooks are always private
    assertEquals(AccessScope.PRIVATE_ACCESS, describeResource.accessScope, "describe output matches access");
    assertEquals(workspaceCreator.email.toLowerCase(), describeResource.privateUserName.toLowerCase(), "describe output matches private user name");
}
Also used : CloningInstructionsEnum(bio.terra.workspace.model.CloningInstructionsEnum) UFGcpNotebook(bio.terra.cli.serialization.userfacing.resource.UFGcpNotebook) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 7 with CloningInstructionsEnum

use of bio.terra.workspace.model.CloningInstructionsEnum in project terra-cli by DataBiosphere.

the class BqDatasetReferenced method addWithAllOptions.

@Test
@DisplayName("add a referenced dataset, specifying all options")
void addWithAllOptions() throws IOException {
    workspaceCreator.login();
    // `terra workspace set --id=$id`
    TestCommand.runCommandExpectSuccess("workspace", "set", "--id=" + getWorkspaceId());
    // `terra resource add-ref bq-dataset --name=$name --project-id=$projectId
    // --dataset-id=$datasetId --cloning=$cloning
    // --description=$description --format=json`
    String name = "addWithAllOptions";
    CloningInstructionsEnum cloning = CloningInstructionsEnum.NOTHING;
    String description = "add with all options";
    UFBqDataset addedDataset = TestCommand.runAndParseCommandExpectSuccess(UFBqDataset.class, "resource", "add-ref", "bq-dataset", "--name=" + name, "--project-id=" + externalDataset.getProjectId(), "--dataset-id=" + externalDataset.getDatasetId(), "--cloning=" + cloning, "--description=" + description);
    // check that the properties match
    assertEquals(name, addedDataset.name, "add ref output matches name");
    assertEquals(externalDataset.getProjectId(), addedDataset.projectId, "add ref output matches project id");
    assertEquals(externalDataset.getDatasetId(), addedDataset.datasetId, "add ref output matches dataset id");
    assertEquals(cloning, addedDataset.cloningInstructions, "add ref output matches cloning");
    assertEquals(description, addedDataset.description, "add ref output matches description");
    // `terra resource describe --name=$name --format=json`
    UFBqDataset describeResource = TestCommand.runAndParseCommandExpectSuccess(UFBqDataset.class, "resource", "describe", "--name=" + name);
    // check that the properties match
    assertEquals(name, describeResource.name, "describe resource output matches name");
    assertEquals(externalDataset.getProjectId(), describeResource.projectId, "describe resource output matches project id");
    assertEquals(externalDataset.getDatasetId(), describeResource.datasetId, "describe resource output matches dataset id");
    assertEquals(cloning, describeResource.cloningInstructions, "describe output matches cloning");
    assertEquals(description, describeResource.description, "describe output matches description");
    // `terra resources delete --name=$name`
    TestCommand.runCommandExpectSuccess("resource", "delete", "--name=" + name, "--quiet");
}
Also used : CloningInstructionsEnum(bio.terra.workspace.model.CloningInstructionsEnum) UFBqDataset(bio.terra.cli.serialization.userfacing.resource.UFBqDataset) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 8 with CloningInstructionsEnum

use of bio.terra.workspace.model.CloningInstructionsEnum in project terra-cli by DataBiosphere.

the class BqTableReferenced method addWithAllOptions.

@Test
@DisplayName("add a referenced data table, specifying all options")
void addWithAllOptions() throws IOException {
    workspaceCreator.login();
    // `terra workspace set --id=$id`
    TestCommand.runCommandExpectSuccess("workspace", "set", "--id=" + getWorkspaceId());
    // `terra resource add-ref bq-table --name=$name --project-id=$projectId
    // --dataset-id=$datasetId --cloning=$cloning
    // --description=$description --format=json`
    String name = "addWithAllOptions";
    CloningInstructionsEnum cloning = CloningInstructionsEnum.NOTHING;
    String description = "add with all options";
    UFBqTable addedDataTable = TestCommand.runAndParseCommandExpectSuccess(UFBqTable.class, "resource", "add-ref", "bq-table", "--name=" + name, "--project-id=" + externalDataset.getProjectId(), "--dataset-id=" + externalDataset.getDatasetId(), "--table-id=" + externalDataTableName, "--cloning=" + cloning, "--description=" + description);
    // check that the properties match
    assertEquals(name, addedDataTable.name, "add ref output matches name");
    assertEquals(externalDataset.getProjectId(), addedDataTable.projectId, "add ref output matches project id");
    assertEquals(externalDataset.getDatasetId(), addedDataTable.datasetId, "add ref output matches dataset id");
    assertEquals(externalDataTableName, addedDataTable.dataTableId, "add ref output matches data table id");
    assertEquals(cloning, addedDataTable.cloningInstructions, "add ref output matches cloning");
    assertEquals(description, addedDataTable.description, "add ref output matches description");
    // `terra resource describe --name=$name --format=json`
    UFBqTable describeResource = TestCommand.runAndParseCommandExpectSuccess(UFBqTable.class, "resource", "describe", "--name=" + name);
    // check that the properties match
    assertEquals(name, describeResource.name, "describe resource output matches name");
    assertEquals(externalDataset.getProjectId(), describeResource.projectId, "describe resource output matches project id");
    assertEquals(externalDataset.getDatasetId(), describeResource.datasetId, "describe resource output matches dataset id");
    assertEquals(externalDataTableName, describeResource.dataTableId, "describe resource output matches data table id");
    assertEquals(cloning, describeResource.cloningInstructions, "describe output matches cloning");
    assertEquals(description, describeResource.description, "describe output matches description");
    // `terra resources delete --name=$name`
    TestCommand.runCommandExpectSuccess("resource", "delete", "--name=" + name, "--quiet");
}
Also used : CloningInstructionsEnum(bio.terra.workspace.model.CloningInstructionsEnum) UFBqTable(bio.terra.cli.serialization.userfacing.resource.UFBqTable) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

CloningInstructionsEnum (bio.terra.workspace.model.CloningInstructionsEnum)8 DisplayName (org.junit.jupiter.api.DisplayName)8 Test (org.junit.jupiter.api.Test)8 UFBqDataset (bio.terra.cli.serialization.userfacing.resource.UFBqDataset)2 UFGcsBucket (bio.terra.cli.serialization.userfacing.resource.UFGcsBucket)2 AccessScope (bio.terra.workspace.model.AccessScope)2 UFWorkspace (bio.terra.cli.serialization.userfacing.UFWorkspace)1 GcsStorageClass (bio.terra.cli.serialization.userfacing.input.GcsStorageClass)1 UFBqTable (bio.terra.cli.serialization.userfacing.resource.UFBqTable)1 UFGcpNotebook (bio.terra.cli.serialization.userfacing.resource.UFGcpNotebook)1 UFGcsObject (bio.terra.cli.serialization.userfacing.resource.UFGcsObject)1 UFGitRepo (bio.terra.cli.serialization.userfacing.resource.UFGitRepo)1 Dataset (com.google.cloud.bigquery.Dataset)1 Bucket (com.google.cloud.storage.Bucket)1