Skip to content

Commit

Permalink
Added support for live tests in the STG 74 branch (#15724)
Browse files Browse the repository at this point in the history
  • Loading branch information
gapra-msft authored Sep 30, 2020
1 parent 22b315b commit 7abc8fa
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 21 deletions.
6 changes: 0 additions & 6 deletions eng/pipelines/templates/jobs/archetype-sdk-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,31 @@ parameters:
OSVmImage: 'ubuntu-18.04'
JavaTestVersion: '1.8'
DisplayName: 'Linux - Java 8'
SubscriptionConfiguration: $(sub-config-azure-cloud-test-resources)
AZURE_TEST_HTTP_CLIENTS: netty
macOS - Java 8 (AzureCloud):
OSVmImage: 'macOS-10.15'
JavaTestVersion: '1.8'
DisplayName: 'macOS - Java 8'
SubscriptionConfiguration: $(sub-config-azure-cloud-test-resources)
AZURE_TEST_HTTP_CLIENTS: okhttp
Windows - Java 8 (AzureCloud):
OSVmImage: 'windows-2019'
JavaTestVersion: '1.8'
DisplayName: 'Windows - Java 8'
SubscriptionConfiguration: $(sub-config-azure-cloud-test-resources)
AZURE_TEST_HTTP_CLIENTS: netty
Linux - Java 11 (AzureCloud):
OSVmImage: 'ubuntu-18.04'
JavaTestVersion: '1.11'
DisplayName: 'Linux - Java 11'
SubscriptionConfiguration: $(sub-config-azure-cloud-test-resources)
AZURE_TEST_HTTP_CLIENTS: okhttp
macOS - Java 11 (AzureCloud):
OSVmImage: 'macOS-10.15'
JavaTestVersion: '1.11'
DisplayName: 'macOS - Java 11'
SubscriptionConfiguration: $(sub-config-azure-cloud-test-resources)
AZURE_TEST_HTTP_CLIENTS: netty
Windows - Java 11 (AzureCloud):
OSVmImage: 'windows-2019'
JavaTestVersion: '1.11'
DisplayName: 'Windows - Java 11'
SubscriptionConfiguration: $(sub-config-azure-cloud-test-resources)
AZURE_TEST_HTTP_CLIENTS: okhttp
PreRunSteps: []
PostRunSteps: []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public final class BlobServiceSasSignatureValues {

private final ClientLogger logger = new ClientLogger(BlobServiceSasSignatureValues.class);

private String version;
private final String version = BlobSasServiceVersion.V2019_12_12.getVersion();

private SasProtocol protocol;

Expand Down Expand Up @@ -149,7 +149,6 @@ public BlobServiceSasSignatureValues(String identifier) {
public BlobServiceSasSignatureValues(String version, SasProtocol sasProtocol, OffsetDateTime startTime,
OffsetDateTime expiryTime, String permission, SasIpRange sasIpRange, String identifier, String cacheControl,
String contentDisposition, String contentEncoding, String contentLanguage, String contentType) {
this.version = null;
this.protocol = sasProtocol;
this.startTime = startTime;
this.expiryTime = expiryTime;
Expand Down Expand Up @@ -586,7 +585,6 @@ public BlobServiceSasQueryParameters generateSasQueryParameters(UserDelegationKe
String signature = StorageImplUtils.computeHMac256(
delegationKey.getValue(), stringToSign(delegationKey, canonicalName));


return new BlobServiceSasQueryParameters(this.version, this.protocol, this.startTime, this.expiryTime,
this.sasIpRange, null /* identifier */, this.resource, this.permissions, signature,
this.cacheControl, this.contentDisposition, this.contentEncoding, this.contentLanguage, this.contentType,
Expand All @@ -608,10 +606,6 @@ public BlobServiceSasQueryParameters generateSasQueryParameters(UserDelegationKe
* https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/storage/Azure.Storage.Blobs/src/Sas/BlobSasBuilder.cs
*/
private void ensureState() {
if (version == null) {
version = BlobSasServiceVersion.getLatest().getVersion();
}

if (CoreUtils.isNullOrEmpty(blobName)) {
resource = SAS_CONTAINER_CONSTANT;
} else if (snapshotId != null) {
Expand Down Expand Up @@ -657,7 +651,8 @@ private String stringToSign(String canonicalName) {
this.identifier == null ? "" : this.identifier,
this.sasIpRange == null ? "" : this.sasIpRange.toString(),
this.protocol == null ? "" : this.protocol.toString(),
BlobSasServiceVersion.V2019_12_12.getVersion(), /* Pin down to version so old string to sign works. */
version, /* Pin down to version so old string to sign works. This is reflected in the declaration of
version */
resource,
this.snapshotId == null ? "" : this.snapshotId,
this.cacheControl == null ? "" : this.cacheControl,
Expand All @@ -682,7 +677,8 @@ private String stringToSign(final UserDelegationKey key, String canonicalName) {
key.getSignedVersion() == null ? "" : key.getSignedVersion(),
this.sasIpRange == null ? "" : this.sasIpRange.toString(),
this.protocol == null ? "" : this.protocol.toString(),
BlobSasServiceVersion.V2019_12_12.getVersion(), /* Pin down to version so old string to sign works. */
version, /* Pin down to version so old string to sign works. This is reflected in the declaration of
version */
resource,
this.snapshotId == null ? "" : this.snapshotId,
this.cacheControl == null ? "" : this.cacheControl,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ class BlobAPITest extends APISpec {
headers.getBlobCommittedBlockCount() == null
headers.isServerEncrypted() != null
headers.getBlobContentMD5() == null
headers.getLastAccessedTime()
// headers.getLastAccessedTime() /* TODO (gapra): re-enable when last access time enabled. */
}

def "Download empty file"() {
Expand Down Expand Up @@ -974,7 +974,7 @@ class BlobAPITest extends APISpec {
properties.getTagCount() == 1
properties.getRehydratePriority() == null // tested in setTier rehydrate priority
!properties.isSealed() // tested in AppendBlob. "seal blob"
properties.getLastAccessedTime()
// properties.getLastAccessedTime() /* TODO: re-enable when last access time enabled. */
}

def "Get properties min"() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,7 @@ class ContainerAPITest extends APISpec {
blobs.size() == 4 // Normal, copy, metadata, tags
}

@Requires( { playbackMode() } )
def "List blobs flat options last access time"() {
when:
def b = cc.getBlobClient(generateBlobName()).getBlockBlobClient()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -520,4 +520,22 @@ class APISpec extends Specification {
return leaseID
}
}

static TestMode setupTestMode() {
String testMode = Configuration.getGlobalConfiguration().get(AZURE_TEST_MODE)

if (testMode != null) {
try {
return TestMode.valueOf(testMode.toUpperCase(Locale.US))
} catch (IllegalArgumentException ignore) {
return TestMode.PLAYBACK
}
}

return TestMode.PLAYBACK
}

static boolean playbackMode() {
return setupTestMode() == TestMode.PLAYBACK
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,7 @@ class FileAPITests extends APISpec {
FileTestHelper.deleteFilesIfExists(testFolder.getPath())
}

@Requires( { playbackMode() } )
def "List ranges diff"() {
given:
primaryFileClient.create(1024)
Expand Down Expand Up @@ -839,6 +840,7 @@ class FileAPITests extends APISpec {
FileTestHelper.deleteFilesIfExists(testFolder.getPath())
}

@Requires( { playbackMode() } )
def "List ranges diff lease"() {
given:
def fileName = testResourceName.randomName("file", 60)
Expand Down Expand Up @@ -883,6 +885,7 @@ class FileAPITests extends APISpec {
FileTestHelper.deleteFilesIfExists(testFolder.getPath())
}

@Requires( { playbackMode() } )
def "List ranges diff fail"() {
given:
def fileName = testResourceName.randomName("file", 60)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import com.azure.storage.file.share.models.ShareServiceProperties
import com.azure.storage.file.share.models.ShareSmbSettings
import com.azure.storage.file.share.models.ShareStorageException
import com.azure.storage.file.share.models.SmbMultichannel

import spock.lang.Requires
import spock.lang.Unroll

import java.time.OffsetDateTime
Expand Down Expand Up @@ -233,6 +233,7 @@ class FileServiceAPITests extends APISpec {
FileTestHelper.assertFileServicePropertiesAreEqual(updatedProperties, getPropertiesAfterResponse.getValue())
}

@Requires( { playbackMode() } )
def "Set and get properties premium"() {
given:
def originalProperties = premiumFileServiceClient.getProperties()
Expand Down
39 changes: 36 additions & 3 deletions sdk/storage/test-resources.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"authorizationApiVersion": "2018-09-01-preview",
"blobDataContributorRoleId": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Authorization/roleDefinitions/ba92f5b4-2d11-453d-a403-e96b0029c9fe')]",
"contributorRoleId": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c')]",
"blobDataOwnerRoleId": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Authorization/roleDefinitions/b7e6dc6d-f1e8-4753-8033-0f276bb0955b')]",
"primaryAccountName": "[concat('prim', parameters('baseName'))]",
"secondaryAccountName": "[concat('sec', parameters('baseName'))]",
"premiumAccountName": "[concat('prem', parameters('baseName'))]",
Expand Down Expand Up @@ -64,6 +65,18 @@
"principalId": "[parameters('testApplicationOid')]"
}
},
{
"type": "Microsoft.Authorization/roleAssignments",
"apiVersion": "[variables('authorizationApiVersion')]",
"name": "[guid(concat('blobDataOwnerRoleId', variables('primaryAccountName')))]",
"dependsOn": [
"[variables('primaryAccountName')]"
],
"properties": {
"roleDefinitionId": "[variables('blobDataOwnerRoleId')]",
"principalId": "[parameters('testApplicationOid')]"
}
},
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "[variables('storageApiVersion')]",
Expand Down Expand Up @@ -96,6 +109,20 @@
"accessTier": "Hot"
}
},
{
"type": "Microsoft.Storage/storageAccounts/blobServices",
"apiVersion": "[variables('storageApiVersion')]",
"name": "[concat(variables('primaryAccountName'), '/default')]",
"properties": {
"containerDeleteRetentionPolicy": {
"enabled": true,
"days": 1
}
},
"dependsOn": [
"[variables('primaryAccountName')]"
]
},
{
"type": "Microsoft.Storage/storageAccounts/fileServices",
"apiVersion": "[variables('storageApiVersion')]",
Expand All @@ -105,7 +132,7 @@
"enabled": true,
"days": 1
}
},
},
"dependsOn": [
"[variables('primaryAccountName')]"
]
Expand All @@ -115,14 +142,20 @@
"apiVersion": "[variables('storageApiVersion')]",
"name": "[concat(variables('primaryAccountName'), '/testscope1')]",
"properties": {
}
},
"dependsOn": [
"[variables('primaryAccountName')]"
]
},
{
"type": "Microsoft.Storage/storageAccounts/encryptionScopes",
"apiVersion": "[variables('storageApiVersion')]",
"name": "[concat(variables('primaryAccountName'), '/testscope2')]",
"properties": {
}
},
"dependsOn": [
"[variables('primaryAccountName')]"
]
},
{
"type": "Microsoft.Storage/storageAccounts",
Expand Down

0 comments on commit 7abc8fa

Please sign in to comment.