use of bio.terra.workspace.generated.model.ApiGcpBigQueryDatasetUpdateParameters in project terra-workspace-manager by DataBiosphere.
the class ControlledResourceServiceTest method updateBqDatasetUndo.
@Test
@DisabledIfEnvironmentVariable(named = "TEST_ENV", matches = BUFFER_SERVICE_DISABLED_ENVS_REG_EX)
void updateBqDatasetUndo() throws Exception {
// create the dataset
String datasetId = ControlledResourceFixtures.uniqueDatasetId();
String location = "us-central1";
Integer initialDefaultTableLifetime = 4800;
Integer initialDefaultPartitionLifetime = 4801;
ApiGcpBigQueryDatasetCreationParameters creationParameters = new ApiGcpBigQueryDatasetCreationParameters().datasetId(datasetId).location(location).defaultTableLifetime(initialDefaultTableLifetime).defaultPartitionLifetime(initialDefaultPartitionLifetime);
ControlledBigQueryDatasetResource resource = ControlledResourceFixtures.makeDefaultControlledBigQueryBuilder(workspace.getWorkspaceId()).datasetName(datasetId).build();
ControlledBigQueryDatasetResource createdDataset = controlledResourceService.createControlledResourceSync(resource, null, user.getAuthenticatedRequest(), creationParameters).castByEnum(WsmResourceType.CONTROLLED_GCP_BIG_QUERY_DATASET);
assertEquals(resource, createdDataset);
// Test idempotency of dataset-specific steps by retrying them once.
Map<String, StepStatus> retrySteps = new HashMap<>();
retrySteps.put(RetrieveBigQueryDatasetCloudAttributesStep.class.getName(), StepStatus.STEP_RESULT_FAILURE_RETRY);
retrySteps.put(UpdateBigQueryDatasetStep.class.getName(), StepStatus.STEP_RESULT_FAILURE_RETRY);
jobService.setFlightDebugInfoForTest(FlightDebugInfo.newBuilder().lastStepFailure(true).undoStepFailures(retrySteps).build());
// update the dataset
ApiGcpBigQueryDatasetUpdateParameters updateParameters = new ApiGcpBigQueryDatasetUpdateParameters().defaultTableLifetime(3600).defaultPartitionLifetime(3601);
// Service methods which wait for a flight to complete will throw an
// InvalidResultStateException when that flight fails without a cause, which occurs when a
// flight fails via debugInfo.
assertThrows(InvalidResultStateException.class, () -> controlledResourceService.updateBqDataset(resource, updateParameters, user.getAuthenticatedRequest(), "NEW_updateBqDatasetUndo", "new resource description"));
// check the properties stored on the cloud were not updated
validateBigQueryDatasetCloudMetadata(projectId, createdDataset.getDatasetName(), location, initialDefaultTableLifetime, initialDefaultPartitionLifetime);
// check the properties stored in WSM were not updated
ControlledBigQueryDatasetResource fetchedResource = controlledResourceService.getControlledResource(workspace.getWorkspaceId(), resource.getResourceId(), user.getAuthenticatedRequest()).castByEnum(WsmResourceType.CONTROLLED_GCP_BIG_QUERY_DATASET);
assertEquals(resource.getName(), fetchedResource.getName());
assertEquals(resource.getDescription(), fetchedResource.getDescription());
}
use of bio.terra.workspace.generated.model.ApiGcpBigQueryDatasetUpdateParameters in project terra-workspace-manager by DataBiosphere.
the class ControlledResourceServiceTest method createGetUpdateDeleteBqDataset.
@Test
@DisabledIfEnvironmentVariable(named = "TEST_ENV", matches = BUFFER_SERVICE_DISABLED_ENVS_REG_EX)
void createGetUpdateDeleteBqDataset() throws Exception {
String datasetId = "my_test_dataset";
String location = "us-central1";
ApiGcpBigQueryDatasetCreationParameters creationParameters = new ApiGcpBigQueryDatasetCreationParameters().datasetId(datasetId).location(location);
ControlledBigQueryDatasetResource resource = ControlledResourceFixtures.makeDefaultControlledBigQueryBuilder(workspace.getWorkspaceId()).datasetName(datasetId).build();
ControlledBigQueryDatasetResource createdDataset = controlledResourceService.createControlledResourceSync(resource, null, user.getAuthenticatedRequest(), creationParameters).castByEnum(WsmResourceType.CONTROLLED_GCP_BIG_QUERY_DATASET);
assertEquals(resource, createdDataset);
ControlledBigQueryDatasetResource fetchedDataset = controlledResourceService.getControlledResource(workspace.getWorkspaceId(), resource.getResourceId(), user.getAuthenticatedRequest()).castByEnum(WsmResourceType.CONTROLLED_GCP_BIG_QUERY_DATASET);
assertEquals(resource, fetchedDataset);
String newName = "NEW_createGetUpdateDeleteBqDataset";
String newDescription = "new resource description";
Integer newDefaultTableLifetime = 3600;
Integer newDefaultPartitionLifetime = 3601;
ApiGcpBigQueryDatasetUpdateParameters updateParameters = new ApiGcpBigQueryDatasetUpdateParameters().defaultTableLifetime(newDefaultTableLifetime).defaultPartitionLifetime(newDefaultPartitionLifetime);
controlledResourceService.updateBqDataset(fetchedDataset, updateParameters, user.getAuthenticatedRequest(), newName, newDescription);
ControlledBigQueryDatasetResource updatedResource = controlledResourceService.getControlledResource(workspace.getWorkspaceId(), resource.getResourceId(), user.getAuthenticatedRequest()).castByEnum(WsmResourceType.CONTROLLED_GCP_BIG_QUERY_DATASET);
assertEquals(newName, updatedResource.getName());
assertEquals(newDescription, updatedResource.getDescription());
Dataset updatedDatasetFromCloud = crlService.createWsmSaBigQueryCow().datasets().get(projectId, datasetId).execute();
assertEquals(newDefaultTableLifetime * 1000L, updatedDatasetFromCloud.getDefaultTableExpirationMs());
assertEquals(newDefaultPartitionLifetime * 1000L, updatedDatasetFromCloud.getDefaultPartitionExpirationMs());
controlledResourceService.deleteControlledResourceSync(resource.getWorkspaceId(), resource.getResourceId(), user.getAuthenticatedRequest());
assertThrows(ResourceNotFoundException.class, () -> controlledResourceService.getControlledResource(workspace.getWorkspaceId(), resource.getResourceId(), user.getAuthenticatedRequest()));
features.setAlpha1Enabled(true);
StairwayTestUtils.enumerateJobsDump(alpha1Service, workspace.getWorkspaceId(), user.getAuthenticatedRequest());
}
use of bio.terra.workspace.generated.model.ApiGcpBigQueryDatasetUpdateParameters in project terra-workspace-manager by DataBiosphere.
the class ControlledResourceServiceTest method updateBqDatasetDo.
@Test
@DisabledIfEnvironmentVariable(named = "TEST_ENV", matches = BUFFER_SERVICE_DISABLED_ENVS_REG_EX)
void updateBqDatasetDo() throws Exception {
// create the dataset
String datasetId = ControlledResourceFixtures.uniqueDatasetId();
String location = "us-central1";
ApiGcpBigQueryDatasetCreationParameters creationParameters = new ApiGcpBigQueryDatasetCreationParameters().datasetId(datasetId).location(location);
ControlledBigQueryDatasetResource resource = ControlledResourceFixtures.makeDefaultControlledBigQueryBuilder(workspace.getWorkspaceId()).datasetName(datasetId).build();
ControlledBigQueryDatasetResource createdDataset = controlledResourceService.createControlledResourceSync(resource, null, user.getAuthenticatedRequest(), creationParameters).castByEnum(WsmResourceType.CONTROLLED_GCP_BIG_QUERY_DATASET);
assertEquals(resource, createdDataset);
// Test idempotency of dataset-specific steps by retrying them once.
Map<String, StepStatus> retrySteps = new HashMap<>();
retrySteps.put(RetrieveBigQueryDatasetCloudAttributesStep.class.getName(), StepStatus.STEP_RESULT_FAILURE_RETRY);
retrySteps.put(UpdateBigQueryDatasetStep.class.getName(), StepStatus.STEP_RESULT_FAILURE_RETRY);
jobService.setFlightDebugInfoForTest(FlightDebugInfo.newBuilder().doStepFailures(retrySteps).build());
// update the dataset
String newName = "NEW_updateBqDatasetDo";
String newDescription = "new resource description";
Integer newDefaultTableLifetime = 3600;
Integer newDefaultPartitionLifetime = 3601;
ApiGcpBigQueryDatasetUpdateParameters updateParameters = new ApiGcpBigQueryDatasetUpdateParameters().defaultTableLifetime(newDefaultTableLifetime).defaultPartitionLifetime(newDefaultPartitionLifetime);
controlledResourceService.updateBqDataset(resource, updateParameters, user.getAuthenticatedRequest(), newName, newDescription);
// check the properties stored on the cloud were updated
validateBigQueryDatasetCloudMetadata(projectId, createdDataset.getDatasetName(), location, newDefaultTableLifetime, newDefaultPartitionLifetime);
// check the properties stored in WSM were updated
ControlledBigQueryDatasetResource fetchedResource = controlledResourceService.getControlledResource(workspace.getWorkspaceId(), resource.getResourceId(), user.getAuthenticatedRequest()).castByEnum(WsmResourceType.CONTROLLED_GCP_BIG_QUERY_DATASET);
assertEquals(newName, fetchedResource.getName());
assertEquals(newDescription, fetchedResource.getDescription());
}
use of bio.terra.workspace.generated.model.ApiGcpBigQueryDatasetUpdateParameters in project terra-workspace-manager by DataBiosphere.
the class ControlledResourceServiceTest method updateBqDatasetWithInvalidExpirationTimes.
@Test
@DisabledIfEnvironmentVariable(named = "TEST_ENV", matches = BUFFER_SERVICE_DISABLED_ENVS_REG_EX)
void updateBqDatasetWithInvalidExpirationTimes() throws Exception {
// create the dataset, with expiration times initially undefined
String datasetId = ControlledResourceFixtures.uniqueDatasetId();
String location = "us-central1";
ApiGcpBigQueryDatasetCreationParameters creationParameters = new ApiGcpBigQueryDatasetCreationParameters().datasetId(datasetId).location(location);
ControlledBigQueryDatasetResource resource = ControlledResourceFixtures.makeDefaultControlledBigQueryBuilder(workspace.getWorkspaceId()).datasetName(datasetId).build();
ControlledBigQueryDatasetResource createdDataset = controlledResourceService.createControlledResourceSync(resource, null, user.getAuthenticatedRequest(), creationParameters).castByEnum(WsmResourceType.CONTROLLED_GCP_BIG_QUERY_DATASET);
// make an update request to set the table expiration time to an invalid value (<3600)
final ApiGcpBigQueryDatasetUpdateParameters updateParameters = new ApiGcpBigQueryDatasetUpdateParameters().defaultTableLifetime(3000).defaultPartitionLifetime(3601);
assertThrows(BadRequestException.class, () -> controlledResourceService.updateBqDataset(resource, updateParameters, user.getAuthenticatedRequest(), null, null));
// check the expiration times stored on the cloud are still undefined, because the update above
// failed
validateBigQueryDatasetCloudMetadata(projectId, createdDataset.getDatasetName(), location, null, null);
// make another update request to set the partition expiration time to an invalid value (<0)
final ApiGcpBigQueryDatasetUpdateParameters updateParameters2 = new ApiGcpBigQueryDatasetUpdateParameters().defaultTableLifetime(3600).defaultPartitionLifetime(-2);
assertThrows(BadRequestException.class, () -> controlledResourceService.updateBqDataset(resource, updateParameters2, user.getAuthenticatedRequest(), null, null));
// check the expiration times stored on the cloud are still undefined, because the update above
// failed
validateBigQueryDatasetCloudMetadata(projectId, createdDataset.getDatasetName(), location, null, null);
}
use of bio.terra.workspace.generated.model.ApiGcpBigQueryDatasetUpdateParameters in project terra-workspace-manager by DataBiosphere.
the class UpdateBigQueryDatasetStep method doStep.
@Override
public StepResult doStep(FlightContext flightContext) throws InterruptedException, RetryException {
final FlightMap inputMap = flightContext.getInputParameters();
final ApiGcpBigQueryDatasetUpdateParameters updateParameters = inputMap.get(UPDATE_PARAMETERS, ApiGcpBigQueryDatasetUpdateParameters.class);
return updateDataset(updateParameters);
}
Aggregations