From e01ffa0d883c90dcf2eb1ccf0b56048b8ef7cf14 Mon Sep 17 00:00:00 2001 From: antisch Date: Mon, 28 Oct 2019 12:05:57 -0700 Subject: [PATCH 1/4] Cosmos live test fixes --- sdk/cosmos/azure-cosmos/test/crud_tests.py | 5 +++++ sdk/cosmos/azure-cosmos/test/query_tests.py | 5 +---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/sdk/cosmos/azure-cosmos/test/crud_tests.py b/sdk/cosmos/azure-cosmos/test/crud_tests.py index 4bb00b7c78de..9fc00111fd6d 100644 --- a/sdk/cosmos/azure-cosmos/test/crud_tests.py +++ b/sdk/cosmos/azure-cosmos/test/crud_tests.py @@ -1977,6 +1977,11 @@ def _test_create_indexing_policy_with_composite_and_spatial_indexes(self, is_nam container_definition = {'id': container_id, 'indexingPolicy': indexing_policy} created_container = self.client.CreateContainer(self.GetDatabaseLink(db, is_name_based), container_definition) read_indexing_policy = created_container['indexingPolicy'] + + # All types are returned for spatial Indexes + indexing_policy['spatialIndexes'][0]['types'].append('MultiPolygon') + indexing_policy['spatialIndexes'][1]['types'].insert(0, 'Point') + self.assertListEqual(indexing_policy['spatialIndexes'], read_indexing_policy['spatialIndexes']) self.assertListEqual(indexing_policy['compositeIndexes'], read_indexing_policy['compositeIndexes']) self.client.DeleteContainer(created_container['_self']) diff --git a/sdk/cosmos/azure-cosmos/test/query_tests.py b/sdk/cosmos/azure-cosmos/test/query_tests.py index 8dbe6a01e815..ef4497728981 100644 --- a/sdk/cosmos/azure-cosmos/test/query_tests.py +++ b/sdk/cosmos/azure-cosmos/test/query_tests.py @@ -190,10 +190,7 @@ def test_max_item_count_honored_in_order_by_query(self): max_item_count=1, enable_cross_partition_query=True ) - if 'localhost' in self.host or '127.0.0.1' in self.host: # TODO: Differing result between live and emulator - self.validate_query_requests_count(query_iterable, 15 * 2 + 1) - else: - self.validate_query_requests_count(query_iterable, 17 * 2 + 1) + self.validate_query_requests_count(query_iterable, 15 * 2 + 1) query_iterable = created_collection.query_items( query=query, From 9a9e393985cad0729b1612b29f6e9b685af042ae Mon Sep 17 00:00:00 2001 From: antisch Date: Mon, 28 Oct 2019 13:02:09 -0700 Subject: [PATCH 2/4] Another test fix --- sdk/cosmos/azure-cosmos/test/crud_tests.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sdk/cosmos/azure-cosmos/test/crud_tests.py b/sdk/cosmos/azure-cosmos/test/crud_tests.py index 9fc00111fd6d..2d612855ba7c 100644 --- a/sdk/cosmos/azure-cosmos/test/crud_tests.py +++ b/sdk/cosmos/azure-cosmos/test/crud_tests.py @@ -1908,6 +1908,11 @@ def test_create_indexing_policy_with_composite_and_spatial_indexes(self): ) created_properties = created_container.read() read_indexing_policy = created_properties['indexingPolicy'] + + # All types are returned for spatial Indexes + indexing_policy['spatialIndexes'][0]['types'].append('MultiPolygon') + indexing_policy['spatialIndexes'][1]['types'].insert(0, 'Point') + self.assertListEqual(indexing_policy['spatialIndexes'], read_indexing_policy['spatialIndexes']) self.assertListEqual(indexing_policy['compositeIndexes'], read_indexing_policy['compositeIndexes']) db.delete_container(container=created_container) From eebadad76a341385b0ffe7ce1b86d58006e45bb3 Mon Sep 17 00:00:00 2001 From: antisch Date: Tue, 29 Oct 2019 11:33:38 -0700 Subject: [PATCH 3/4] Update tests for old emulator --- sdk/cosmos/azure-cosmos/test/crud_tests.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sdk/cosmos/azure-cosmos/test/crud_tests.py b/sdk/cosmos/azure-cosmos/test/crud_tests.py index 2d612855ba7c..879b91f5b6fc 100644 --- a/sdk/cosmos/azure-cosmos/test/crud_tests.py +++ b/sdk/cosmos/azure-cosmos/test/crud_tests.py @@ -1909,11 +1909,14 @@ def test_create_indexing_policy_with_composite_and_spatial_indexes(self): created_properties = created_container.read() read_indexing_policy = created_properties['indexingPolicy'] - # All types are returned for spatial Indexes - indexing_policy['spatialIndexes'][0]['types'].append('MultiPolygon') - indexing_policy['spatialIndexes'][1]['types'].insert(0, 'Point') + if 'localhost' in self.host or '127.0.0.1' in self.host: # TODO: Differing result between live and emulator + self.assertListEqual(indexing_policy['spatialIndexes'], read_indexing_policy['spatialIndexes']) + else: + # All types are returned for spatial Indexes + indexing_policy['spatialIndexes'][0]['types'].append('MultiPolygon') + indexing_policy['spatialIndexes'][1]['types'].insert(0, 'Point') + self.assertListEqual(indexing_policy['spatialIndexes'], read_indexing_policy['spatialIndexes']) - self.assertListEqual(indexing_policy['spatialIndexes'], read_indexing_policy['spatialIndexes']) self.assertListEqual(indexing_policy['compositeIndexes'], read_indexing_policy['compositeIndexes']) db.delete_container(container=created_container) From 39f65ed987d8be96ac1562cd305811ae5d4b8968 Mon Sep 17 00:00:00 2001 From: antisch Date: Tue, 29 Oct 2019 13:22:07 -0700 Subject: [PATCH 4/4] Removed disabled tests --- sdk/cosmos/azure-cosmos/test/crud_tests.py | 74 ---------------------- 1 file changed, 74 deletions(-) diff --git a/sdk/cosmos/azure-cosmos/test/crud_tests.py b/sdk/cosmos/azure-cosmos/test/crud_tests.py index 879b91f5b6fc..be096b96594e 100644 --- a/sdk/cosmos/azure-cosmos/test/crud_tests.py +++ b/sdk/cosmos/azure-cosmos/test/crud_tests.py @@ -1920,80 +1920,6 @@ def test_create_indexing_policy_with_composite_and_spatial_indexes(self): self.assertListEqual(indexing_policy['compositeIndexes'], read_indexing_policy['compositeIndexes']) db.delete_container(container=created_container) - def disabled_test_create_indexing_policy_with_composite_and_spatial_indexes_self_link(self): - self._test_create_indexing_policy_with_composite_and_spatial_indexes(False) - - def disabled_test_create_indexing_policy_with_composite_and_spatial_indexes_name_based(self): - self._test_create_indexing_policy_with_composite_and_spatial_indexes(True) - - def _test_create_indexing_policy_with_composite_and_spatial_indexes(self, is_name_based): - # create database - db = self.databaseForTest - - indexing_policy = { - "spatialIndexes": [ - { - "path": "/path0/*", - "types": [ - "Point", - "LineString", - "Polygon" - ] - }, - { - "path": "/path1/*", - "types": [ - "LineString", - "Polygon", - "MultiPolygon" - ] - } - ], - "compositeIndexes": [ - [ - { - "path": "/path1", - "order": "ascending" - }, - { - "path": "/path2", - "order": "descending" - }, - { - "path": "/path3", - "order": "ascending" - } - ], - [ - { - "path": "/path4", - "order": "ascending" - }, - { - "path": "/path5", - "order": "descending" - }, - { - "path": "/path6", - "order": "ascending" - } - ] - ] - } - - container_id = 'composite_index_spatial_index' + str(uuid.uuid4()) - container_definition = {'id': container_id, 'indexingPolicy': indexing_policy} - created_container = self.client.CreateContainer(self.GetDatabaseLink(db, is_name_based), container_definition) - read_indexing_policy = created_container['indexingPolicy'] - - # All types are returned for spatial Indexes - indexing_policy['spatialIndexes'][0]['types'].append('MultiPolygon') - indexing_policy['spatialIndexes'][1]['types'].insert(0, 'Point') - - self.assertListEqual(indexing_policy['spatialIndexes'], read_indexing_policy['spatialIndexes']) - self.assertListEqual(indexing_policy['compositeIndexes'], read_indexing_policy['compositeIndexes']) - self.client.DeleteContainer(created_container['_self']) - def _check_default_indexing_policy_paths(self, indexing_policy): def __get_first(array): if array: