diff --git a/eng/pipelines/templates/jobs/archetype-sdk-tests.yml b/eng/pipelines/templates/jobs/archetype-sdk-tests.yml index ff12fe009baf..9b0af542709a 100644 --- a/eng/pipelines/templates/jobs/archetype-sdk-tests.yml +++ b/eng/pipelines/templates/jobs/archetype-sdk-tests.yml @@ -4,6 +4,7 @@ parameters: MaxParallel: 0 BeforeTestSteps: [] BuildTargetingString: 'azure-*' + TestMarkArgument: '' Matrix: Linux_Python35: OSName: 'Linux' @@ -22,6 +23,7 @@ jobs: - job: 'Test' variables: skipComponentGovernanceDetection: true + CoverageArg: --disablecov timeoutInMinutes: 120 strategy: @@ -37,9 +39,10 @@ jobs: parameters: BuildTargetingString: ${{ parameters.BuildTargetingString }} ServiceDirectory: ${{ parameters.ServiceDirectory }} - CoverageArg: '--disablecov' + CoverageArg: $(CoverageArg) EnvVars: ${{ parameters.EnvVars }} BeforeTestSteps: ${{ parameters.BeforeTestSteps }} PythonVersion: $(PythonVersion) OSName: $(OSName) ToxTestEnv: "whl" + TestMarkArgument: ${{ parameters.TestMarkArgument }} diff --git a/eng/pipelines/templates/stages/cosmos-sdk-client.yml b/eng/pipelines/templates/stages/cosmos-sdk-client.yml new file mode 100644 index 000000000000..9019431fad73 --- /dev/null +++ b/eng/pipelines/templates/stages/cosmos-sdk-client.yml @@ -0,0 +1,44 @@ +parameters: + Artifacts: [] + ServiceDirectory: not-specified + EmulatorMsiUrl: 'https://aka.ms/cosmosdb-emulator' + EmulatorStartParameters: '' + +stages: + - stage: Build + jobs: + - template: ../jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: ${{ parameters.ServiceDirectory }} + # Skip emulator tests in the CI run + TestMarkArgument: not cosmosEmulator + + - job: Emulator + strategy: + matrix: + Windows_Python35: + OSVmImage: 'windows-2019' + OSName: Windows + PythonVersion: '3.5' + Windows_Python27: + OSVmImage: 'windows-2019' + OSName: Windows + PythonVersion: '2.7' + pool: + vmImage: $(OSVmImage) + + steps: + - template: eng/pipelines/templates/steps/cosmos-emulator.yml@azure-sdk-tools + parameters: + EmulatorMsiUrl: ${{ parameters.EmulatorMsiUrl }} + StartParameters: ${{ parameters.EmulatorStartParameters }} + + - template: ../steps/build-test.yml + parameters: + TestMarkArgument: not globaldb + EnvVars: + ACCOUNT_HOST: https://localhost:8081/ + ServiceDirectory: ${{ parameters.ServiceDirectory }} + PythonVersion: $(PythonVersion) + OSName: $(OSName) + ToxTestEnv: 'whl,sdist' diff --git a/sdk/cosmos/.azure-pipelines/cosmos.live.yml b/sdk/cosmos/.azure-pipelines/cosmos.live.yml deleted file mode 100644 index d94f412f41a8..000000000000 --- a/sdk/cosmos/.azure-pipelines/cosmos.live.yml +++ /dev/null @@ -1,105 +0,0 @@ -trigger: none - -pr: - branches: - include: - - master - - feature/* - - hotfix/* - - release/* - - restapi* - paths: - include: - - sdk/cosmos - -jobs: - - job: 'Emulator' - - timeoutInMinutes: 120 - continueOnError: false - strategy: - maxParallel: 1 - matrix: - Windows_Python35: - OSVmImage: 'windows-2019' - PythonVersion: '3.5' - Windows_Python27: - OSVmImage: 'windows-2019' - PythonVersion: '2.7' - - pool: - vmImage: $(OSVmImage) - - steps: - - task: PowerShell@1 - displayName: 'Download Public Cosmos Emulator' - inputs: - scriptType: inlineScript - inlineScript: | - Write-Host "Downloading Cosmos Emulator - $(EmulatorMsiUrl)" - wget "$(EmulatorMsiUrl)" -outfile "$env:temp\azure-cosmosdb-emulator.msi" - Write-Host "Finished Downloading Cosmos Emulator - $env:temp\azure-cosmosdb-emulator.msi" - dir "$env:temp" - - - task: CmdLine@2 - displayName: 'Cleanup already installed Azure Cosmos DB Emulator' - inputs: - script: | - echo "Deleting Azure Cosmos DB Emulator directory" - dir "%ProgramFiles%\" - rmdir /Q /S "%ProgramFiles%\Azure Cosmos DB Emulator" - echo "Directory after deleting" - dir "%ProgramFiles%\" - - - task: CmdLine@2 - displayName: 'Install Public Cosmos DB Emulator' - inputs: - script: | - choco install lessmsi - choco upgrade lessmsi - echo "Checking directory" - dir "%ProgramFiles%" - mkdir "%TEMP%\Azure Cosmos DB Emulator" - lessmsi x "%TEMP%\azure-cosmosdb-emulator.msi" "%TEMP%\Azure Cosmos DB Emulator\" - dir "%TEMP%" - dir "%Temp%\Azure Cosmos DB Emulator\" - - - task: PowerShell@1 - displayName: 'Run Public Cosmos DB Emulator' - inputs: - scriptType: inlineScript - inlineScript: | - dir "$env:Temp\" - dir "$env:Temp\Azure Cosmos DB Emulator" - dir "$env:Temp\Azure Cosmos DB Emulator\SourceDir\" - dir "$env:Temp\Azure Cosmos DB Emulator\SourceDir\Azure Cosmos DB Emulator" - Write-Host "Starting Comsos DB Emulator" - Start-Process "$env:Temp\Azure Cosmos DB Emulator\SourceDir\Azure Cosmos DB Emulator\CosmosDB.Emulator.exe" "/NoExplorer /NoUI" -Verb RunAs - - - task: UsePythonVersion@0 - displayName: 'Use Python $(PythonVersion)' - inputs: - versionSpec: $(PythonVersion) - - - script: | - python -m pip install --upgrade pip - pip install setuptools --upgrade - python scripts/dev_setup.py --packageList azure-cosmos - displayName: 'Set up Environment' - - - task: PowerShell@1 - displayName: 'Run Python Tests' - inputs: - scriptType: inlineScript - inlineScript: | - pytest --junitxml=sdk/cosmos/azure-cosmos/Test-junit.xml --verbose sdk/cosmos/azure-cosmos/test -k "not globaldb" - env: - ACCOUNT_KEY: $(python-cosmos-live-account-key) - ACCOUNT_HOST: $(python-cosmos-live-account-host) - condition: succeededOrFailed() - - - task: PublishTestResults@2 - displayName: 'Publish Python Test Results' - inputs: - testResultsFiles: '**\TEST-*.xml' - testRunTitle: 'Cosmos $(OSName) Node $(PythonVersion) - Python' diff --git a/sdk/cosmos/.azure-pipelines/cosmos.test.yml b/sdk/cosmos/.azure-pipelines/cosmos.test.yml deleted file mode 100644 index 322faa0baa6c..000000000000 --- a/sdk/cosmos/.azure-pipelines/cosmos.test.yml +++ /dev/null @@ -1,103 +0,0 @@ -trigger: none - -pr: - branches: - include: - - master - - feature/* - - hotfix/* - - release/* - - restapi* - paths: - include: - - sdk/cosmos - -jobs: - - job: 'Emulator' - - timeoutInMinutes: 120 - continueOnError: false - strategy: - matrix: - Windows_Python35: - OSVmImage: 'windows-2019' - PythonVersion: '3.5' - Windows_Python27: - OSVmImage: 'windows-2019' - PythonVersion: '2.7' - - pool: - vmImage: $(OSVmImage) - - steps: - - task: PowerShell@1 - displayName: 'Download Public Cosmos Emulator' - inputs: - scriptType: inlineScript - inlineScript: | - Write-Host "Downloading Cosmos Emulator - $(EmulatorMsiUrl)" - wget "$(EmulatorMsiUrl)" -outfile "$env:temp\azure-cosmosdb-emulator.msi" - Write-Host "Finished Downloading Cosmos Emulator - $env:temp\azure-cosmosdb-emulator.msi" - dir "$env:temp" - - - task: CmdLine@2 - displayName: 'Cleanup already installed Azure Cosmos DB Emulator' - inputs: - script: | - echo "Deleting Azure Cosmos DB Emulator directory" - dir "%ProgramFiles%\" - rmdir /Q /S "%ProgramFiles%\Azure Cosmos DB Emulator" - echo "Directory after deleting" - dir "%ProgramFiles%\" - - - task: CmdLine@2 - displayName: 'Install Public Cosmos DB Emulator' - inputs: - script: | - choco install lessmsi - choco upgrade lessmsi - echo "Checking directory" - dir "%ProgramFiles%" - mkdir "%TEMP%\Azure Cosmos DB Emulator" - lessmsi x "%TEMP%\azure-cosmosdb-emulator.msi" "%TEMP%\Azure Cosmos DB Emulator\" - dir "%TEMP%" - dir "%Temp%\Azure Cosmos DB Emulator\" - - - task: PowerShell@1 - displayName: 'Run Public Cosmos DB Emulator' - inputs: - scriptType: inlineScript - inlineScript: | - dir "$env:Temp\" - dir "$env:Temp\Azure Cosmos DB Emulator" - dir "$env:Temp\Azure Cosmos DB Emulator\SourceDir\" - dir "$env:Temp\Azure Cosmos DB Emulator\SourceDir\Azure Cosmos DB Emulator" - Write-Host "Starting Comsos DB Emulator" - Start-Process "$env:Temp\Azure Cosmos DB Emulator\SourceDir\Azure Cosmos DB Emulator\CosmosDB.Emulator.exe" "/NoExplorer /NoUI" -Verb RunAs - - - task: UsePythonVersion@0 - displayName: 'Use Python $(PythonVersion)' - inputs: - versionSpec: $(PythonVersion) - - - script: | - python -m pip install --upgrade pip - pip install setuptools --upgrade - python scripts/dev_setup.py --packageList azure-cosmos - displayName: 'Set up Environment' - - - task: PowerShell@1 - displayName: 'Run Python Tests' - inputs: - scriptType: inlineScript - inlineScript: | - $env:ACCOUNT_HOST="https://localhost:8081/" - cmd /c 'pytest --junitxml=sdk/cosmos/azure-cosmos/Test-junit.xml --verbose sdk/cosmos/azure-cosmos/test -k "not globaldb"' - - condition: succeededOrFailed() - - - task: PublishTestResults@2 - displayName: 'Publish Python Test Results' - inputs: - testResultsFiles: '**\TEST-*.xml' - testRunTitle: 'Cosmos $(OSName) Node $(PythonVersion) - Python' diff --git a/sdk/cosmos/azure-cosmos/test/globaldb_mock_tests.py b/sdk/cosmos/azure-cosmos/test/globaldb_mock_tests.py index 886e842be63c..98e9e2e68bb7 100644 --- a/sdk/cosmos/azure-cosmos/test/globaldb_mock_tests.py +++ b/sdk/cosmos/azure-cosmos/test/globaldb_mock_tests.py @@ -32,7 +32,7 @@ from azure.cosmos import _retry_utility import test_config -pytestmark = pytest.mark.cosmosEmulator +pytestmark = [pytest.mark.cosmosEmulator, pytest.mark.globaldb] location_changed = False diff --git a/sdk/cosmos/azure-cosmos/test/globaldb_tests.py b/sdk/cosmos/azure-cosmos/test/globaldb_tests.py index fc9e5d194f38..00c29b334532 100644 --- a/sdk/cosmos/azure-cosmos/test/globaldb_tests.py +++ b/sdk/cosmos/azure-cosmos/test/globaldb_tests.py @@ -35,7 +35,7 @@ from azure.cosmos.http_constants import HttpHeaders, StatusCodes, SubStatusCodes import test_config -pytestmark = pytest.mark.cosmosEmulator +pytestmark = [pytest.mark.cosmosEmulator, pytest.mark.globaldb] #IMPORTANT NOTES: diff --git a/sdk/cosmos/ci.yml b/sdk/cosmos/ci.yml index 2d6127966dc2..aebb31536819 100644 --- a/sdk/cosmos/ci.yml +++ b/sdk/cosmos/ci.yml @@ -1,6 +1,13 @@ # DO NOT EDIT THIS FILE # This file is generated automatically and any changes will be lost. +resources: + repositories: + - repository: azure-sdk-tools + type: github + name: Azure/azure-sdk-tools + endpoint: azure + trigger: branches: include: @@ -21,8 +28,7 @@ pr: include: - sdk/cosmos/ -jobs: -- template: ../../eng/pipelines/templates/jobs/archetype-sdk-client.yml +stages: +- template: ../../eng/pipelines/templates/stages/cosmos-sdk-client.yml parameters: ServiceDirectory: cosmos - TestMarkArgument: not cosmosEmulator \ No newline at end of file diff --git a/sdk/cosmos/tests.yml b/sdk/cosmos/tests.yml new file mode 100644 index 000000000000..0fa2551c7626 --- /dev/null +++ b/sdk/cosmos/tests.yml @@ -0,0 +1,28 @@ +trigger: none + +jobs: + - template: ../../eng/pipelines/templates/jobs/archetype-sdk-tests.yml + parameters: + MaxParallel: 1 + Matrix: + Linux_Python35: + OSName: 'Linux' + OSVmImage: 'ubuntu-16.04' + PythonVersion: '3.5' + MacOs_Python37: + OSName: 'MacOS' + OSVmImage: 'macOS-10.14' + PythonVersion: '3.7' + Windows_Python27: + OSName: 'Windows' + OSVmImage: 'windows-2019' + PythonVersion: '2.7' + Linux_Pypy3: + OSName: 'Linux' + OSVmImage: 'ubuntu-16.04' + PythonVersion: 'pypy3' + ServiceDirectory: cosmos + TestMarkArgument: not globaldb + EnvVars: + ACCOUNT_KEY: $(python-cosmos-live-account-key) + ACCOUNT_HOST: $(python-cosmos-live-account-host)