Skip to content

Commit

Permalink
adding over test changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ibrahimrabab committed May 13, 2022
1 parent 305e46a commit d499203
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import com.azure.storage.blob.models.BlobServiceProperties
import com.azure.storage.blob.models.BlobSignedIdentifier
import com.azure.storage.blob.models.BlobStorageException
import com.azure.storage.blob.models.CustomerProvidedKey
import com.azure.storage.blob.models.GeoReplicationStatus
import com.azure.storage.blob.models.ListBlobContainersOptions
import com.azure.storage.blob.models.ParallelTransferOptions
import com.azure.storage.blob.models.StaticWebsite
Expand Down Expand Up @@ -763,7 +764,14 @@ class ServiceAPITest extends APISpec {
response.getHeaders().getValue("x-ms-request-id") != null
response.getHeaders().getValue("Date") != null
response.getValue().getGeoReplication().getStatus() != null
response.getValue().getGeoReplication().getLastSyncTime() != null

// The LastSyncTime will return a DateTimeRfc1123 if the replication status is LIVE
// but there are two other statuses, unavailable and bootstrap, which will return null.
if (response.getValue().getGeoReplication().getStatus() == GeoReplicationStatus.LIVE) {
assert response.getValue().getGeoReplication().getLastSyncTime() != null
} else {
assert response.getValue().getGeoReplication().getLastSyncTime() == null
}
}

def "Get stats min"() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import com.azure.storage.blob.models.*
import com.azure.storage.blob.options.BlobQueryOptions
import com.azure.storage.common.implementation.Constants
import com.azure.storage.common.test.shared.extensions.LiveOnly
import com.azure.storage.common.test.shared.extensions.PlaybackOnly

import com.azure.storage.common.test.shared.extensions.RequiredServiceVersion
import reactor.core.Exceptions
import spock.lang.Retry
Expand Down Expand Up @@ -426,6 +428,7 @@ class BlobBaseAPITest extends APISpec {

@RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "V2019_12_12")
@Retry(count = 5, delay = 5, condition = { environment.testMode == TestMode.LIVE })
@PlaybackOnly(expiryTime = "2022-05-18")
def "Query Input csv Output arrow"() {
setup:
BlobQueryDelimitedSerialization inSer = new BlobQueryDelimitedSerialization()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
@Target({ElementType.TYPE, ElementType.METHOD})
@ExtensionAnnotation(PlaybackOnlyExtension.class)
public @interface PlaybackOnly {
String expiryTime() default "";
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,18 @@
import org.spockframework.runtime.model.FeatureInfo;
import org.spockframework.runtime.model.SpecInfo;

import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;


public class PlaybackOnlyExtension implements IAnnotationDrivenExtension<PlaybackOnly> {

@Override
public void visitFeatureAnnotation(PlaybackOnly annotation, FeatureInfo feature) {
validateExpiryTime(annotation);

TestMode testMode = TestEnvironment.getInstance().getTestMode();
if (testMode != TestMode.PLAYBACK) {
feature.skip(String.format("Test ignored in %s mode", testMode));
Expand All @@ -21,9 +29,24 @@ public void visitFeatureAnnotation(PlaybackOnly annotation, FeatureInfo feature)

@Override
public void visitSpecAnnotation(PlaybackOnly annotation, SpecInfo spec) {
validateExpiryTime(annotation);

TestMode testMode = TestEnvironment.getInstance().getTestMode();
if (testMode != TestMode.PLAYBACK) {
spec.skip(String.format("Test ignored in %s mode", testMode));
}
}

private void validateExpiryTime(PlaybackOnly annotation) {
String expiryStr = annotation.expiryTime();
if ("".equals(expiryStr)) {
return;
}
OffsetDateTime expiry = LocalDate.parse(expiryStr, DateTimeFormatter.ofPattern("yyyy-MM-dd")).atTime(0, 0)
.atZone(ZoneId.of(ZoneId.SHORT_IDS.get("PST"))).toOffsetDateTime();
OffsetDateTime now = OffsetDateTime.now(ZoneId.of(ZoneId.SHORT_IDS.get("PST")));
if (now.isAfter(expiry)) {
throw new RuntimeException("PlaybackOnly has expired. Test must be reenabled");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@ import com.azure.storage.blob.models.BlobStorageException
import com.azure.storage.common.ParallelTransferOptions
import com.azure.storage.common.ProgressReceiver
import com.azure.storage.common.implementation.Constants
import com.azure.storage.common.sas.AccountSasPermission
import com.azure.storage.common.sas.AccountSasResourceType
import com.azure.storage.common.sas.AccountSasService
import com.azure.storage.common.sas.AccountSasSignatureValues
import com.azure.storage.common.test.shared.extensions.LiveOnly
import com.azure.storage.common.test.shared.extensions.PlaybackOnly

import com.azure.storage.common.test.shared.extensions.RequiredServiceVersion
import com.azure.storage.common.test.shared.policy.MockFailureResponsePolicy
import com.azure.storage.common.test.shared.policy.MockRetryRangeResponsePolicy
Expand Down Expand Up @@ -3414,6 +3412,7 @@ class FileAPITest extends APISpec {

@RequiredServiceVersion(clazz = DataLakeServiceVersion.class, min = "V2019_12_12")
@Retry(count = 5, delay = 5, condition = { environment.testMode == TestMode.LIVE })
@PlaybackOnly(expiryTime = "2022-05-18")
def "Query Input csv Output arrow"() {
setup:
FileQueryDelimitedSerialization inSer = new FileQueryDelimitedSerialization()
Expand Down

0 comments on commit d499203

Please sign in to comment.