Skip to content

Added Emulator CI and additional tests for Azure Cosmos SDK #33363

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b2cb0a5
Added Cross partition query tests for sync and async APIs
kushagraThapar Dec 1, 2023
a3fcabb
Added license header for new files
kushagraThapar Dec 1, 2023
bc81ab2
Updated database and container creation
kushagraThapar Dec 4, 2023
187b3d2
Updated python tests with setup and tear down
kushagraThapar Dec 8, 2023
f589e48
Fixed some tests cases
kushagraThapar Dec 8, 2023
40cf21e
Fixed spelling
kushagraThapar Dec 8, 2023
998b997
Added emulator CI
kushagraThapar Dec 12, 2023
f7d9ca4
Merged latest main and resolved conflicts
kushagraThapar Jan 12, 2024
cbaf26e
Removed python 3.7 emulator tests config
kushagraThapar Jan 12, 2024
d1434ae
Removed collection crud tests from emulator
kushagraThapar Jan 17, 2024
ade8a78
Merged latest main and resolved conflicts
kushagraThapar Jan 17, 2024
c7ccc22
Updated some collection heavy tests to skip for emulator
kushagraThapar Jan 17, 2024
cafc996
Fixing python 3.10
kushagraThapar Jan 18, 2024
b763f8b
Marking test_computed_properties async test to run only in live tests
kushagraThapar Jan 22, 2024
d95157a
Merge branch 'main' into azure_cosmos_add_cross_partition_query_tests
kushagraThapar Jan 22, 2024
7a34c7e
Fixed emulator tests with pytest fixtures
kushagraThapar Jan 29, 2024
c05e65c
Fixed more emulator tests with pytest fixtures
kushagraThapar Jan 30, 2024
6252619
Fixed more emulator tests with pytest fixtures
kushagraThapar Jan 31, 2024
420d639
Fixed more emulator tests with pytest fixtures and updated azure core…
kushagraThapar Feb 1, 2024
acbb98a
Fixed flaky tests
kushagraThapar Feb 1, 2024
a64f69c
Updated stored procedure create calls
kushagraThapar Feb 1, 2024
06d708c
Fixing sproc test
kushagraThapar Feb 2, 2024
1b85744
Fixing trigger test
kushagraThapar Feb 2, 2024
9b93a8f
Fixing flaky live ci tests
kushagraThapar Feb 5, 2024
499ef27
Fixing max parallel and removed python 3.11 for cosmos emulator windo…
kushagraThapar Feb 5, 2024
8198961
Added MIT license header
kushagraThapar Feb 7, 2024
b51d6f6
Update sdk/cosmos/azure-cosmos/test/test_partition_split_query.py
simorenoh Feb 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .vscode/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -1406,7 +1406,8 @@
"Docoptype",
"mycontainer",
"iscontinuationexpected",
"aalapatirvbd"
"aalapatirvbd",
"unconfigure"
]
},
{
Expand Down
55 changes: 15 additions & 40 deletions eng/pipelines/templates/stages/cosmos-sdk-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,53 +5,28 @@ parameters:
- name: ServiceDirectory
type: string
default: not-specified
- name: EmulatorMsiUrl
type: string
default: https://aka.ms/cosmosdb-emulator
- name: InjectedPackages
type: string
default: ''
- name: EmulatorStartParameters
type: string
default: ''
- name: TestProxy
type: boolean
default: false

extends:
template: /eng/pipelines/templates/stages/archetype-sdk-client.yml
parameters:
ServiceDirectory: ${{ parameters.ServiceDirectory }}
# Skip emulator tests in the CI run
TestMarkArgument: not cosmosEmulator
InjectedPackages: ${{parameters.InjectedPackages}}
Artifacts: ${{parameters.Artifacts}}

# - stage: Test_Emulator
# dependsOn: []
# jobs:
# - job: Emulator
# strategy:
# matrix:
# Windows_Python36:
# OSVmImage: 'windows-2022'
# PythonVersion: '3.6'
# pool:
# vmImage: $(OSVmImage)
#
# steps:
# - template: /eng/common/pipelines/templates/steps/cosmos-emulator.yml
# parameters:
# EmulatorMsiUrl: ${{ parameters.EmulatorMsiUrl }}
# StartParameters: ${{ parameters.EmulatorStartParameters }}
#
# - template: /eng/pipelines/templates/steps/build-test.yml
# parameters:
# TestMarkArgument: not globaldb
# EnvVars:
# ACCOUNT_HOST: https://localhost:8081/
# ServiceDirectory: ${{ parameters.ServiceDirectory }}
# PythonVersion: $(PythonVersion)
# OSVmImage: $(OSVmImage)
# ToxTestEnv: 'whl,sdist'
# InjectedPackages: ${{parameters.InjectedPackages}}
# Run only emulator tests in Emulator CI
TestMarkArgument: cosmosEmulator
ServiceDirectory: cosmos
BeforeTestSteps:
- template: /eng/common/pipelines/templates/steps/cosmos-emulator.yml
parameters:
StartParameters: '/noexplorer /noui /enablepreview /EnableSqlComputeEndpoint /SqlComputePort=9999 /disableratelimiting /partitioncount=50 /consistency=Session'
MatrixConfigs:
- Name: Python_cosmos_emulator
Path: sdk/cosmos/cosmos-emulator-matrix.json
Selection: all
GenerateVMJobs: true
Artifacts:
- name: azure-cosmos
safeName: azurecosmos
20 changes: 1 addition & 19 deletions sdk/cosmos/azure-cosmos/azure/cosmos/_default_retry_policy.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,5 @@
# The MIT License (MIT)
# Copyright (c) 2017 Microsoft Corporation

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:

# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# Copyright (c) Microsoft Corporation. All rights reserved.

"""Internal class for connection reset retry policy implementation in the Azure
Cosmos database service.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,5 @@
# The MIT License (MIT)
# Copyright (c) 2017 Microsoft Corporation

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:

# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# Copyright (c) Microsoft Corporation. All rights reserved.

"""Internal class for aggregation queries implementation in the Azure Cosmos
database service.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,5 @@
# The MIT License (MIT)
# Copyright (c) 2017 Microsoft Corporation

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:

# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# Copyright (c) Microsoft Corporation. All rights reserved.

"""Internal class for timeout failover retry policy implementation in the Azure
Cosmos database service.
Expand Down
2 changes: 1 addition & 1 deletion sdk/cosmos/azure-cosmos/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
packages=find_packages(exclude=exclude_packages),
python_requires=">=3.8",
install_requires=[
"azure-core<2.0.0,>=1.25.0",
"azure-core<2.0.0,>=1.25.1",
"typing-extensions>=4.6.0",
],
)
36 changes: 0 additions & 36 deletions sdk/cosmos/azure-cosmos/test/cleanup.py

This file was deleted.

59 changes: 32 additions & 27 deletions sdk/cosmos/azure-cosmos/test/conftest.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,41 @@
# The MIT License (MIT)
# Copyright (c) 2017 Microsoft Corporation
# Copyright (c) Microsoft Corporation. All rights reserved.

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
import test_config
from azure.cosmos import CosmosClient as CosmosSyncClient

# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
cosmos_sync_client = CosmosSyncClient(test_config.TestConfig.host, test_config.TestConfig.masterKey)

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE

# pytest fixture 'teardown' is called at the end of a test run to clean up resources
def pytest_configure(config):
"""
Allows plugins and conftest files to perform initial configuration.
This hook is called for every plugin and initial conftest
file after command line options have been parsed.
"""


def pytest_sessionstart(session):
"""
Called after the Session object has been created and
before performing collection and entering the run test loop.
"""
config = test_config.TestConfig
config.create_database_if_not_exist(cosmos_sync_client)
config.create_single_partition_container_if_not_exist(cosmos_sync_client)
config.create_multi_partition_container_if_not_exist(cosmos_sync_client)

import test_config
import pytest
import cleanup

@pytest.fixture(scope="session")
def teardown(request):
def pytest_sessionfinish(session, exitstatus):
"""
Called after whole test run finished, right before
returning the exit status to the system.
"""
config = test_config.TestConfig
config.try_delete_database(cosmos_sync_client)

def delete_test_database():
config = test_config._test_config
cleanup.delete_database(config.TEST_DATABASE_ID)

request.addfinalizer(delete_test_database)
return None
def pytest_unconfigure(config):
"""
called before test process is exited.
"""
Loading