Skip to content

Commit cf747e6

Browse files
kushagraThaparsimorenoh
authored andcommitted
Added Emulator CI and additional tests for Azure Cosmos SDK (Azure#33363)
* Added Cross partition query tests for sync and async APIs * Added license header for new files * Updated database and container creation * Updated python tests with setup and tear down * Fixed some tests cases * Fixed spelling * Added emulator CI * Removed python 3.7 emulator tests config * Removed collection crud tests from emulator * Updated some collection heavy tests to skip for emulator * Fixing python 3.10 * Marking test_computed_properties async test to run only in live tests * Fixed emulator tests with pytest fixtures * Fixed more emulator tests with pytest fixtures * Fixed more emulator tests with pytest fixtures * Fixed more emulator tests with pytest fixtures and updated azure core min version * Fixed flaky tests * Updated stored procedure create calls * Fixing sproc test * Fixing trigger test * Fixing flaky live ci tests * Fixing max parallel and removed python 3.11 for cosmos emulator windows as there is a python open issue * Added MIT license header * Update sdk/cosmos/azure-cosmos/test/test_partition_split_query.py --------- Co-authored-by: Simon Moreno <[email protected]>
1 parent a1e0020 commit cf747e6

File tree

64 files changed

+4003
-4177
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+4003
-4177
lines changed

.vscode/cspell.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1417,7 +1417,8 @@
14171417
"Docoptype",
14181418
"mycontainer",
14191419
"iscontinuationexpected",
1420-
"aalapatirvbd"
1420+
"aalapatirvbd",
1421+
"unconfigure"
14211422
]
14221423
},
14231424
{

eng/pipelines/templates/stages/cosmos-sdk-client.yml

+15-40
Original file line numberDiff line numberDiff line change
@@ -5,53 +5,28 @@ parameters:
55
- name: ServiceDirectory
66
type: string
77
default: not-specified
8-
- name: EmulatorMsiUrl
9-
type: string
10-
default: https://aka.ms/cosmosdb-emulator
118
- name: InjectedPackages
129
type: string
1310
default: ''
14-
- name: EmulatorStartParameters
15-
type: string
16-
default: ''
1711
- name: TestProxy
1812
type: boolean
1913
default: false
2014

2115
extends:
2216
template: /eng/pipelines/templates/stages/archetype-sdk-client.yml
2317
parameters:
24-
ServiceDirectory: ${{ parameters.ServiceDirectory }}
25-
# Skip emulator tests in the CI run
26-
TestMarkArgument: not cosmosEmulator
27-
InjectedPackages: ${{parameters.InjectedPackages}}
28-
Artifacts: ${{parameters.Artifacts}}
29-
30-
# - stage: Test_Emulator
31-
# dependsOn: []
32-
# jobs:
33-
# - job: Emulator
34-
# strategy:
35-
# matrix:
36-
# Windows_Python36:
37-
# OSVmImage: 'windows-2022'
38-
# PythonVersion: '3.6'
39-
# pool:
40-
# vmImage: $(OSVmImage)
41-
#
42-
# steps:
43-
# - template: /eng/common/pipelines/templates/steps/cosmos-emulator.yml
44-
# parameters:
45-
# EmulatorMsiUrl: ${{ parameters.EmulatorMsiUrl }}
46-
# StartParameters: ${{ parameters.EmulatorStartParameters }}
47-
#
48-
# - template: /eng/pipelines/templates/steps/build-test.yml
49-
# parameters:
50-
# TestMarkArgument: not globaldb
51-
# EnvVars:
52-
# ACCOUNT_HOST: https://localhost:8081/
53-
# ServiceDirectory: ${{ parameters.ServiceDirectory }}
54-
# PythonVersion: $(PythonVersion)
55-
# OSVmImage: $(OSVmImage)
56-
# ToxTestEnv: 'whl,sdist'
57-
# InjectedPackages: ${{parameters.InjectedPackages}}
18+
# Run only emulator tests in Emulator CI
19+
TestMarkArgument: cosmosEmulator
20+
ServiceDirectory: cosmos
21+
BeforeTestSteps:
22+
- template: /eng/common/pipelines/templates/steps/cosmos-emulator.yml
23+
parameters:
24+
StartParameters: '/noexplorer /noui /enablepreview /EnableSqlComputeEndpoint /SqlComputePort=9999 /disableratelimiting /partitioncount=50 /consistency=Session'
25+
MatrixConfigs:
26+
- Name: Python_cosmos_emulator
27+
Path: sdk/cosmos/cosmos-emulator-matrix.json
28+
Selection: all
29+
GenerateVMJobs: true
30+
Artifacts:
31+
- name: azure-cosmos
32+
safeName: azurecosmos

sdk/cosmos/azure-cosmos/azure/cosmos/_default_retry_policy.py

+1-19
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,5 @@
11
# The MIT License (MIT)
2-
# Copyright (c) 2017 Microsoft Corporation
3-
4-
# Permission is hereby granted, free of charge, to any person obtaining a copy
5-
# of this software and associated documentation files (the "Software"), to deal
6-
# in the Software without restriction, including without limitation the rights
7-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8-
# copies of the Software, and to permit persons to whom the Software is
9-
# furnished to do so, subject to the following conditions:
10-
11-
# The above copyright notice and this permission notice shall be included in all
12-
# copies or substantial portions of the Software.
13-
14-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20-
# SOFTWARE.
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
213

224
"""Internal class for connection reset retry policy implementation in the Azure
235
Cosmos database service.

sdk/cosmos/azure-cosmos/azure/cosmos/_execution_context/aggregators.py

+1-19
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,5 @@
11
# The MIT License (MIT)
2-
# Copyright (c) 2017 Microsoft Corporation
3-
4-
# Permission is hereby granted, free of charge, to any person obtaining a copy
5-
# of this software and associated documentation files (the "Software"), to deal
6-
# in the Software without restriction, including without limitation the rights
7-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8-
# copies of the Software, and to permit persons to whom the Software is
9-
# furnished to do so, subject to the following conditions:
10-
11-
# The above copyright notice and this permission notice shall be included in all
12-
# copies or substantial portions of the Software.
13-
14-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20-
# SOFTWARE.
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
213

224
"""Internal class for aggregation queries implementation in the Azure Cosmos
235
database service.

sdk/cosmos/azure-cosmos/azure/cosmos/_timeout_failover_retry_policy.py

+1-19
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,5 @@
11
# The MIT License (MIT)
2-
# Copyright (c) 2017 Microsoft Corporation
3-
4-
# Permission is hereby granted, free of charge, to any person obtaining a copy
5-
# of this software and associated documentation files (the "Software"), to deal
6-
# in the Software without restriction, including without limitation the rights
7-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8-
# copies of the Software, and to permit persons to whom the Software is
9-
# furnished to do so, subject to the following conditions:
10-
11-
# The above copyright notice and this permission notice shall be included in all
12-
# copies or substantial portions of the Software.
13-
14-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20-
# SOFTWARE.
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
213

224
"""Internal class for timeout failover retry policy implementation in the Azure
235
Cosmos database service.

sdk/cosmos/azure-cosmos/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
packages=find_packages(exclude=exclude_packages),
7474
python_requires=">=3.8",
7575
install_requires=[
76-
"azure-core<2.0.0,>=1.25.0",
76+
"azure-core<2.0.0,>=1.25.1",
7777
"typing-extensions>=4.6.0",
7878
],
7979
)

sdk/cosmos/azure-cosmos/test/cleanup.py

-36
This file was deleted.
+32-27
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,41 @@
11
# The MIT License (MIT)
2-
# Copyright (c) 2017 Microsoft Corporation
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
33

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

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

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

22-
# pytest fixture 'teardown' is called at the end of a test run to clean up resources
10+
def pytest_configure(config):
11+
"""
12+
Allows plugins and conftest files to perform initial configuration.
13+
This hook is called for every plugin and initial conftest
14+
file after command line options have been parsed.
15+
"""
16+
17+
18+
def pytest_sessionstart(session):
19+
"""
20+
Called after the Session object has been created and
21+
before performing collection and entering the run test loop.
22+
"""
23+
config = test_config.TestConfig
24+
config.create_database_if_not_exist(cosmos_sync_client)
25+
config.create_single_partition_container_if_not_exist(cosmos_sync_client)
26+
config.create_multi_partition_container_if_not_exist(cosmos_sync_client)
2327

24-
import test_config
25-
import pytest
26-
import cleanup
2728

28-
@pytest.fixture(scope="session")
29-
def teardown(request):
29+
def pytest_sessionfinish(session, exitstatus):
30+
"""
31+
Called after whole test run finished, right before
32+
returning the exit status to the system.
33+
"""
34+
config = test_config.TestConfig
35+
config.try_delete_database(cosmos_sync_client)
3036

31-
def delete_test_database():
32-
config = test_config._test_config
33-
cleanup.delete_database(config.TEST_DATABASE_ID)
3437

35-
request.addfinalizer(delete_test_database)
36-
return None
38+
def pytest_unconfigure(config):
39+
"""
40+
called before test process is exited.
41+
"""

0 commit comments

Comments
 (0)