use of com.google.cloud.storage.BucketInfo.LifecycleRule.LifecycleAction in project terra-workspace-manager by DataBiosphere.
the class GcsApiConversionsTest method testLifecycleActionConversions.
@Test
public void testLifecycleActionConversions() {
final ApiGcpGcsBucketLifecycleRuleAction wsmDeleteAction = toWsmApi(GCS_DELETE_ACTION);
assertEquals(ApiGcpGcsBucketLifecycleRuleActionType.DELETE, wsmDeleteAction.getType());
assertNull(wsmDeleteAction.getStorageClass());
final LifecycleAction gcsDeleteAction = toGcsApi(wsmDeleteAction);
assertEquals(DeleteLifecycleAction.TYPE, gcsDeleteAction.getActionType());
final ApiGcpGcsBucketLifecycleRuleAction wsmSetStorageClassAction = toWsmApi(GCS_SET_STORAGE_CLASS_ACTION);
assertEquals(ApiGcpGcsBucketLifecycleRuleActionType.SET_STORAGE_CLASS, wsmSetStorageClassAction.getType());
assertEquals(ApiGcpGcsBucketDefaultStorageClass.STANDARD, wsmSetStorageClassAction.getStorageClass());
}
use of com.google.cloud.storage.BucketInfo.LifecycleRule.LifecycleAction in project terra-workspace-manager by DataBiosphere.
the class UpdateGcsBucketStepTest method testUndoStep.
@Test
public void testUndoStep() throws InterruptedException, RetryException {
final StepResult result = updateGcsBucketStep.undoStep(mockFlightContext);
verify(mockBuiltBucketCow, times(2)).update();
assertEquals(StepResult.getStepResultSuccess(), result);
final StorageClass storageClass = storageClassCaptor.getValue();
assertEquals(StorageClass.NEARLINE, storageClass);
final List<LifecycleRule> rules = lifecycleRulesCaptor.getValue();
assertThat(rules, hasSize(1));
final LifecycleAction action = rules.get(0).getAction();
assertEquals(SetStorageClassLifecycleAction.TYPE, action.getActionType());
assertEquals(StorageClass.COLDLINE, ((SetStorageClassLifecycleAction) action).getStorageClass());
final LifecycleCondition condition = rules.get(0).getCondition();
assertEquals(45, condition.getAge());
assertEquals(toGoogleDateTime(OFFSET_DATE_TIME_2).getValue(), condition.getCreatedBefore().getValue());
assertEquals(1, condition.getNumberOfNewerVersions());
assertTrue(condition.getIsLive());
assertThat(condition.getMatchesStorageClass(), hasSize(1));
assertEquals(StorageClass.STANDARD, condition.getMatchesStorageClass().get(0));
}
use of com.google.cloud.storage.BucketInfo.LifecycleRule.LifecycleAction in project terra-workspace-manager by DataBiosphere.
the class UpdateGcsBucketStepTest method testDoStep.
@Test
public void testDoStep() throws InterruptedException, RetryException {
final StepResult result = updateGcsBucketStep.doStep(mockFlightContext);
verify(mockBuiltBucketCow, times(2)).update();
assertEquals(StepResult.getStepResultSuccess(), result);
final StorageClass storageClass = storageClassCaptor.getValue();
assertEquals(StorageClass.STANDARD, storageClass);
final List<LifecycleRule> rules = lifecycleRulesCaptor.getValue();
assertThat(rules, hasSize(2));
assertEquals(DeleteLifecycleAction.TYPE, rules.get(0).getAction().getActionType());
final LifecycleCondition rule1condition = rules.get(0).getCondition();
assertEquals(31, rule1condition.getAge());
// TODO: [PF-933] This (and all other date checks in this test) work around the fact that
// Stairway FlightMap loses time zone data at serialization time by normalizing to UTC via call
// to getValue(). Once PF-933 is addressed, these assertions should all revert to apply time
// zone comparison by removing the getValue() call from both sides of the equality assertion.
assertEquals(toGoogleDateTime(OFFSET_DATE_TIME_2).getValue(), rule1condition.getCreatedBefore().getValue());
assertEquals(3, rule1condition.getNumberOfNewerVersions());
assertTrue(rule1condition.getIsLive());
assertThat(rule1condition.getMatchesStorageClass(), hasSize(2));
assertEquals(StorageClass.ARCHIVE, rule1condition.getMatchesStorageClass().get(0));
assertEquals(StorageClass.STANDARD, rule1condition.getMatchesStorageClass().get(1));
final LifecycleAction rule2action = rules.get(1).getAction();
assertEquals(SetStorageClassLifecycleAction.TYPE, rule2action.getActionType());
assertEquals(StorageClass.NEARLINE, ((SetStorageClassLifecycleAction) rule2action).getStorageClass());
final LifecycleCondition rule2condition = rules.get(1).getCondition();
assertEquals(15, rule2condition.getAge());
assertEquals(toGoogleDateTime(OFFSET_DATE_TIME_1).getValue(), rule2condition.getCreatedBefore().getValue());
assertEquals(5, rule2condition.getNumberOfNewerVersions());
assertTrue(rule2condition.getIsLive());
assertThat(rule2condition.getMatchesStorageClass(), hasSize(1));
assertEquals(StorageClass.ARCHIVE, rule2condition.getMatchesStorageClass().get(0));
}
Aggregations