Skip to content
24 changes: 24 additions & 0 deletions sdk/storage/azure-storage-blob/tests/_shared/service_versions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from enum import Enum


class ServiceVersion(str, Enum):

V2019_02_02 = "2019-02-02"
V2019_07_07 = "2019-07-07"
V2019_10_10 = "2019-10-10"
V2019_12_12 = "2019-12-12"
V2020_02_10 = "2020-02-10"
V2020_04_08 = "2020-04-08"
V2020_06_12 = "2020-06-12"
V2020_08_04 = "2020-08-04"
# '2019-02-02',
# '2019-07-07',
# '2019-10-10',
# '2019-12-12',
# '2020-02-10',
# '2020-04-08',
# '2020-06-12',
# '2020-08-04'

LATEST_SERVICE_VERSION = ServiceVersion.V2020_08_04
LATEST_SERVICE_VERSION_PLUS_1 = ServiceVersion.V2020_06_12
20 changes: 19 additions & 1 deletion sdk/storage/azure-storage-blob/tests/_shared/testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import zlib
import math
import sys
import string
import os
import random
import re
import logging
Expand Down Expand Up @@ -50,6 +50,8 @@
except ImportError:
from devtools_testutils import mgmt_settings_fake as settings

from .service_versions import LATEST_SERVICE_VERSION, ServiceVersion, LATEST_SERVICE_VERSION_PLUS_1

import pytest


Expand Down Expand Up @@ -310,6 +312,22 @@ def generate_sas_token(self):
def generate_fake_token(self):
return FakeTokenCredential()

def _get_service_version(self, **kwargs):
env_version = os.environ.get("AZURE_LIVE_TEST_SERVICE_VERSION", LATEST_SERVICE_VERSION)# ServiceVersion.V2020_04_08)
return kwargs.pop("service_version", env_version)

def create_storage_client(self, client, *args, **kwargs):
kwargs["api_version"] = self._get_service_version(**kwargs)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in nightly pipeline we'd like clients to pick the default, i.e. env variable is empty.
does this code achieve this by leaving "api_version" kwarg empty or we need some "if" here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the environment variable is empty, it will default to LATEST_SERVICE_VERSION

return client(*args, **kwargs)
Comment thread
seankane-msft marked this conversation as resolved.

def create_storage_client_from_conn_str(self, client, *args, **kwargs):
kwargs["api_version"] = self._get_service_version(**kwargs)
return client.from_connection_string(*args, **kwargs)

def create_storage_client(self, client, *args, **kwargs):
kwargs["api_version"] = self._get_service_version(**kwargs)
return client(*args, **kwargs)


def not_for_emulator(test):
def skip_test_if_targeting_emulator(self):
Expand Down
2 changes: 1 addition & 1 deletion sdk/storage/azure-storage-blob/tests/test_blob_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
class StorageBlobTagsTest(StorageTestCase):

def _setup(self, storage_account, key):
self.bsc = BlobServiceClient(self.account_url(storage_account, "blob"), credential=key)
self.bsc = self.create_storage_client(BlobServiceClient, self.account_url(storage_account, "blob"), credential=key)
self.container_name = self.get_resource_name("container")
if self.is_live:
container = self.bsc.get_container_client(self.container_name)
Expand Down
20 changes: 20 additions & 0 deletions sdk/storage/platform-matrix-all-versions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"matrix": {
"Agent": {
"ubuntu-18.04": { "OSVmImage": "MMSUbuntu18.04", "Pool": "azsdk-pool-mms-ubuntu-1804-general" },
"windows-2019": { "OSVmImage": "MMS2019", "Pool": "azsdk-pool-mms-win-2019-general" }
},
"JavaTestVersion": [ "1.8", "1.11" ],
"AZURE_TEST_HTTP_CLIENTS": [ "okhttp", "netty" ],
"TestGoals": "surefire:test",
"AZURE_LIVE_TEST_SERVICE_VERSION": [
"V2019_02_02",
"V2019_07_07",
"V2019_12_12",
"V2020_02_10",
"V2020_04_08",
"V2020_06_12",
"V2020_08_04"
]
}
}
20 changes: 20 additions & 0 deletions sdk/storage/platform-matrix.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"matrix": {
"$IMPORT": "eng/pipelines/templates/stages/platform-matrix.json"
},
"exclude": [
{ "OSVmImage": "macOS-10.15" }
],
"include": [
{
"Agent": { "macOS-10.15": { "OSVmImage": "macOS-10.15", "Pool": "Azure Pipelines" } },
"JavaTestVersion": "1.8",
"AZURE_TEST_HTTP_CLIENTS": "netty"
Comment thread
seankane-msft marked this conversation as resolved.
Outdated
},
{
"Agent": { "macOS-10.15": { "OSVmImage": "macOS-10.15", "Pool": "Azure Pipelines" } },
"JavaTestVersion": "1.11",
"AZURE_TEST_HTTP_CLIENTS": "okhttp"
}
]
}
11 changes: 11 additions & 0 deletions sdk/storage/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@ stages:
MatrixReplace:
# Use dedicated storage pool in canadacentral with higher memory capacity
- Pool=(.*)-general/$1-storage
MatrixConfigs:
- ${{ if contains(variables['Build.DefinitionName'], 'tests-weekly') }}:
- Name: Storage_all_versions_live_test
Path: sdk/storage/platform-matrix-all-versions.json
Selection: sparse
GenerateVMJobs: true
- ${{ if not(contains(variables['Build.DefinitionName'], 'tests-weekly')) }}:
- Name: Storage_live_test
Path: sdk/storage/platform-matrix.json
Comment thread
seankane-msft marked this conversation as resolved.
Outdated
Selection: sparse
GenerateVMJobs: true
EnvVars:
STORAGE_ACCOUNT_NAME: $(python-storage-storage-account-name)
STORAGE_ACCOUNT_KEY: $(python-storage-storage-account-key)
Expand Down