From f3144dc21c90d9a1a659c6277d472dbab85083f1 Mon Sep 17 00:00:00 2001 From: swathipil <76007337+swathipil@users.noreply.github.com> Date: Tue, 21 Sep 2021 17:13:31 -0700 Subject: [PATCH] [SchemaRegistry] remove cache from client (#20760) * remove cache from client * changelog --- .../azure-schemaregistry/CHANGELOG.md | 1 + .../schemaregistry/_schema_registry_client.py | 69 +++------- .../aio/_schema_registry_client_async.py | 69 +++------- ...egistry_async.test_schema_basic_async.yaml | 44 ++++-- ....test_schema_negative_no_schema_async.yaml | 12 +- ...ry_async.test_schema_same_twice_async.yaml | 16 +-- ...gistry_async.test_schema_update_async.yaml | 100 +++----------- .../async_tests/test_schema_registry_async.py | 45 +------ ...est_schema_registry.test_schema_basic.yaml | 58 ++++++-- ...gistry.test_schema_negative_no_schema.yaml | 12 +- ...chema_registry.test_schema_same_twice.yaml | 16 +-- ...st_schema_registry.test_schema_update.yaml | 126 +++--------------- .../tests/test_schema_registry.py | 44 ------ 13 files changed, 187 insertions(+), 425 deletions(-) diff --git a/sdk/schemaregistry/azure-schemaregistry/CHANGELOG.md b/sdk/schemaregistry/azure-schemaregistry/CHANGELOG.md index 8a35560abc10..4cffbf0a375f 100644 --- a/sdk/schemaregistry/azure-schemaregistry/CHANGELOG.md +++ b/sdk/schemaregistry/azure-schemaregistry/CHANGELOG.md @@ -19,6 +19,7 @@ ### Other Changes - Updated azure-core dependency to 1.17.1. +- Removed caching support of registered schemas so requests are sent to the service to register schemas, get schema properties, and get schemas. ## 1.0.0b2 (2021-08-17) diff --git a/sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/_schema_registry_client.py b/sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/_schema_registry_client.py index 1c28f6b71ed7..f48234650710 100644 --- a/sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/_schema_registry_client.py +++ b/sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/_schema_registry_client.py @@ -64,8 +64,6 @@ def __init__(self, endpoint, credential, **kwargs): self._generated_client = AzureSchemaRegistry( credential=credential, endpoint=endpoint, **kwargs ) - self._description_to_properties = {} - self._id_to_schema = {} def __enter__(self): # type: () -> SchemaRegistryClient @@ -128,20 +126,7 @@ def register_schema( response = self._generated_client.send_request(request) response.raise_for_status() - schema_properties = _parse_response_schema_properties(response) - - schema_description = ( - group_name, - name, - content, - serialization_type, - ) - self._id_to_schema[schema_properties.id] = Schema( - content, schema_properties - ) - self._description_to_properties[schema_description] = schema_properties - - return schema_properties + return _parse_response_schema_properties(response) def get_schema(self, id, **kwargs): # pylint:disable=redefined-builtin # type: (str, Any) -> Schema @@ -162,15 +147,10 @@ def get_schema(self, id, **kwargs): # pylint:disable=redefined-builtin :caption: Get schema by id. """ - try: - return self._id_to_schema[id] - except KeyError: - request = schema_rest.build_get_by_id_request(schema_id=id) - response = self._generated_client.send_request(request, **kwargs) - response.raise_for_status() - schema = _parse_response_schema(response) - self._id_to_schema[id] = schema - return schema + request = schema_rest.build_get_by_id_request(schema_id=id) + response = self._generated_client.send_request(request, **kwargs) + response.raise_for_status() + return _parse_response_schema(response) def get_schema_properties( self, group_name, name, content, serialization_type, **kwargs @@ -204,30 +184,15 @@ def get_schema_properties( except AttributeError: pass - try: - properties = self._description_to_properties[ - (group_name, name, content, serialization_type) - ] - return properties - except KeyError: - request = schema_rest.build_query_id_by_content_request( - group_name=group_name, - schema_name=name, - content=content, - serialization_type=serialization_type, - content_type=kwargs.pop("content_type", "application/json"), - **kwargs - ) - - response = self._generated_client.send_request(request, **kwargs) - response.raise_for_status() - schema_properties = _parse_response_schema_properties(response) - - if not self._id_to_schema.get(schema_properties.id): - self._id_to_schema[schema_properties.id] = Schema(content, schema_properties) - else: - schema_properties = self._id_to_schema[schema_properties.id].properties - self._description_to_properties[ - (group_name, name, content, serialization_type) - ] = schema_properties - return schema_properties + request = schema_rest.build_query_id_by_content_request( + group_name=group_name, + schema_name=name, + content=content, + serialization_type=serialization_type, + content_type=kwargs.pop("content_type", "application/json"), + **kwargs + ) + + response = self._generated_client.send_request(request, **kwargs) + response.raise_for_status() + return _parse_response_schema_properties(response) diff --git a/sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/aio/_schema_registry_client_async.py b/sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/aio/_schema_registry_client_async.py index aa5531cc7a6a..f9de1bbc2d5f 100644 --- a/sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/aio/_schema_registry_client_async.py +++ b/sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/aio/_schema_registry_client_async.py @@ -65,8 +65,6 @@ def __init__( **kwargs: Any ) -> None: self._generated_client = AzureSchemaRegistry(credential, endpoint, **kwargs) - self._description_to_properties = {} - self._id_to_schema = {} async def __aenter__(self): await self._generated_client.__aenter__() @@ -128,20 +126,7 @@ async def register_schema( response = await self._generated_client.send_request(request) response.raise_for_status() - schema_properties = _parse_response_schema_properties(response) - - schema_description = ( - group_name, - name, - content, - serialization_type, - ) - self._id_to_schema[schema_properties.id] = Schema( - content, schema_properties - ) - self._description_to_properties[schema_description] = schema_properties - - return schema_properties + return _parse_response_schema_properties(response) async def get_schema( self, @@ -165,15 +150,10 @@ async def get_schema( :caption: Get schema by id. """ - try: - return self._id_to_schema[id] - except KeyError: - request = schema_rest.build_get_by_id_request(schema_id=id) - response = await self._generated_client.send_request(request, **kwargs) - response.raise_for_status() - schema = _parse_response_schema(response) - self._id_to_schema[id] = schema - return schema + request = schema_rest.build_get_by_id_request(schema_id=id) + response = await self._generated_client.send_request(request, **kwargs) + response.raise_for_status() + return _parse_response_schema(response) async def get_schema_properties( self, @@ -209,30 +189,15 @@ async def get_schema_properties( except AttributeError: pass - try: - properties = self._description_to_properties[ - (group_name, name, content, serialization_type) - ] - return properties - except KeyError: - request = schema_rest.build_query_id_by_content_request( - group_name=group_name, - schema_name=name, - content=content, - serialization_type=serialization_type, - content_type=kwargs.pop("content_type", "application/json"), - **kwargs - ) - - response = await self._generated_client.send_request(request, **kwargs) - response.raise_for_status() - schema_properties = _parse_response_schema_properties(response) - - if not self._id_to_schema.get(schema_properties.id): - self._id_to_schema[schema_properties.id] = Schema(content, schema_properties) - else: - schema_properties = self._id_to_schema[schema_properties.id].properties - self._description_to_properties[ - (group_name, name, content, serialization_type) - ] = schema_properties - return schema_properties + request = schema_rest.build_query_id_by_content_request( + group_name=group_name, + schema_name=name, + content=content, + serialization_type=serialization_type, + content_type=kwargs.pop("content_type", "application/json"), + **kwargs + ) + + response = await self._generated_client.send_request(request, **kwargs) + response.raise_for_status() + return _parse_response_schema_properties(response) diff --git a/sdk/schemaregistry/azure-schemaregistry/tests/async_tests/recordings/test_schema_registry_async.test_schema_basic_async.yaml b/sdk/schemaregistry/azure-schemaregistry/tests/async_tests/recordings/test_schema_registry_async.test_schema_basic_async.yaml index f9cf0fca7608..9b3e501481e5 100644 --- a/sdk/schemaregistry/azure-schemaregistry/tests/async_tests/recordings/test_schema_registry_async.test_schema_basic_async.yaml +++ b/sdk/schemaregistry/azure-schemaregistry/tests/async_tests/recordings/test_schema_registry_async.test_schema_basic_async.yaml @@ -16,13 +16,13 @@ interactions: uri: https://fake_resource.servicebus.windows.net/$schemagroups/fakegroup/schemas/test-schema-basic-asynce5e1482?api-version=2020-09-01-preview response: body: - string: '{"id":"c87ba6c2c15e4645b3665802159c6b37"}' + string: '{"id":"d919a8923e2446e69614c0220d967dd7"}' headers: content-type: application/json - date: Fri, 03 Sep 2021 21:37:45 GMT + date: Mon, 20 Sep 2021 20:08:28 GMT location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/fakegroup/schemas/test-schema-basic-asynce5e1482/versions/1?api-version=2020-09-01-preview - schema-id: c87ba6c2c15e4645b3665802159c6b37 - schema-id-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/c87ba6c2c15e4645b3665802159c6b37?api-version=2020-09-01-preview + schema-id: d919a8923e2446e69614c0220d967dd7 + schema-id-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/d919a8923e2446e69614c0220d967dd7?api-version=2020-09-01-preview schema-version: '1' schema-versions-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/swathip-test-schema/schemas/test-schema-basic-asynce5e1482/versions?api-version=2020-09-01-preview serialization-type: Avro @@ -33,6 +33,34 @@ interactions: code: 200 message: OK url: https://swathip-test-eventhubs.servicebus.windows.net/$schemagroups/swathip-test-schema/schemas/test-schema-basic-asynce5e1482?api-version=2020-09-01-preview +- request: + body: null + headers: + Accept: + - text/plain; charset=utf-8 + User-Agent: + - azsdk-python-azureschemaregistry/1.0.0b3 Python/3.9.0 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://fake_resource.servicebus.windows.net/$schemagroups/getSchemaById/d919a8923e2446e69614c0220d967dd7?api-version=2020-09-01-preview + response: + body: + string: '{"namespace":"example.avro","type":"record","name":"User","fields":[{"name":"name","type":"string"},{"name":"favorite_number","type":["int","null"]},{"name":"favorite_color","type":["string","null"]}]}' + headers: + content-type: application/json + date: Mon, 20 Sep 2021 20:08:29 GMT + location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/fakegroup/schemas/test-schema-basic-asynce5e1482/versions/1?api-version=2020-09-01-preview + schema-id: d919a8923e2446e69614c0220d967dd7 + schema-id-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/d919a8923e2446e69614c0220d967dd7?api-version=2020-09-01-preview + schema-version: '1' + schema-versions-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/swathip-test-schema/schemas/test-schema-basic-asynce5e1482/versions?api-version=2020-09-01-preview + serialization-type: Avro + server: Microsoft-HTTPAPI/2.0 + strict-transport-security: max-age=31536000 + transfer-encoding: chunked + status: + code: 200 + message: OK + url: https://swathip-test-eventhubs.servicebus.windows.net/$schemagroups/getSchemaById/d919a8923e2446e69614c0220d967dd7?api-version=2020-09-01-preview - request: body: '{"namespace":"example.avro","type":"record","name":"User","fields":[{"name":"name","type":"string"},{"name":"favorite_number","type":["int","null"]},{"name":"favorite_color","type":["string","null"]}]}' headers: @@ -50,13 +78,13 @@ interactions: uri: https://fake_resource.servicebus.windows.net/$schemagroups/fakegroup/schemas/test-schema-basic-asynce5e1482?api-version=2020-09-01-preview response: body: - string: '{"id":"c87ba6c2c15e4645b3665802159c6b37"}' + string: '{"id":"d919a8923e2446e69614c0220d967dd7"}' headers: content-type: application/json - date: Fri, 03 Sep 2021 21:37:45 GMT + date: Mon, 20 Sep 2021 20:08:30 GMT location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/fakegroup/schemas/test-schema-basic-asynce5e1482/versions/1?api-version=2020-09-01-preview - schema-id: c87ba6c2c15e4645b3665802159c6b37 - schema-id-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/c87ba6c2c15e4645b3665802159c6b37?api-version=2020-09-01-preview + schema-id: d919a8923e2446e69614c0220d967dd7 + schema-id-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/d919a8923e2446e69614c0220d967dd7?api-version=2020-09-01-preview schema-version: '1' schema-versions-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/swathip-test-schema/schemas/test-schema-basic-asynce5e1482/versions?api-version=2020-09-01-preview serialization-type: Avro diff --git a/sdk/schemaregistry/azure-schemaregistry/tests/async_tests/recordings/test_schema_registry_async.test_schema_negative_no_schema_async.yaml b/sdk/schemaregistry/azure-schemaregistry/tests/async_tests/recordings/test_schema_registry_async.test_schema_negative_no_schema_async.yaml index c190d43ab754..82908a211808 100644 --- a/sdk/schemaregistry/azure-schemaregistry/tests/async_tests/recordings/test_schema_registry_async.test_schema_negative_no_schema_async.yaml +++ b/sdk/schemaregistry/azure-schemaregistry/tests/async_tests/recordings/test_schema_registry_async.test_schema_negative_no_schema_async.yaml @@ -11,12 +11,12 @@ interactions: response: body: string: '{"Code":400,"Detail":"SubCode=40000, UnknownType:The request is invalid. - [MGResponseHttpError=BadRequest]. TrackingId:faf1cce9-f0c7-4dfb-bdcc-4410c3f74b30_G29, + [MGResponseHttpError=BadRequest]. TrackingId:4f653bc2-9ef4-4b83-8632-3aa321d9b8e5_G29, SystemTracker:swathip-test-eventhubs.servicebus.windows.net:$schemagroups\/getSchemaById\/a, - Timestamp:2021-09-03T21:37:47"}' + Timestamp:2021-09-20T20:08:31"}' headers: content-type: application/json - date: Fri, 03 Sep 2021 21:37:47 GMT + date: Mon, 20 Sep 2021 20:08:30 GMT server: Microsoft-HTTPAPI/2.0 strict-transport-security: max-age=31536000 transfer-encoding: chunked @@ -36,11 +36,11 @@ interactions: response: body: string: '{"Code":404,"Detail":"Schema id aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa does - not exist. TrackingId:520d7a70-c165-4edd-8855-046ff6be2f72_G29, SystemTracker:swathip-test-eventhubs.servicebus.windows.net:$schemagroups\/getSchemaById\/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, - Timestamp:2021-09-03T21:37:48"}' + not exist. TrackingId:79cdec74-b17a-4334-a0bd-0ceeb9253ca4_G29, SystemTracker:swathip-test-eventhubs.servicebus.windows.net:$schemagroups\/getSchemaById\/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, + Timestamp:2021-09-20T20:08:31"}' headers: content-type: application/json - date: Fri, 03 Sep 2021 21:37:47 GMT + date: Mon, 20 Sep 2021 20:08:31 GMT server: Microsoft-HTTPAPI/2.0 strict-transport-security: max-age=31536000 transfer-encoding: chunked diff --git a/sdk/schemaregistry/azure-schemaregistry/tests/async_tests/recordings/test_schema_registry_async.test_schema_same_twice_async.yaml b/sdk/schemaregistry/azure-schemaregistry/tests/async_tests/recordings/test_schema_registry_async.test_schema_same_twice_async.yaml index 25fe86bf5574..90e06c4f36d3 100644 --- a/sdk/schemaregistry/azure-schemaregistry/tests/async_tests/recordings/test_schema_registry_async.test_schema_same_twice_async.yaml +++ b/sdk/schemaregistry/azure-schemaregistry/tests/async_tests/recordings/test_schema_registry_async.test_schema_same_twice_async.yaml @@ -16,13 +16,13 @@ interactions: uri: https://fake_resource.servicebus.windows.net/$schemagroups/fakegroup/schemas/test-schema-twice-async7bfd16a1?api-version=2020-09-01-preview response: body: - string: '{"id":"99a89631052e4a22a9fca816cbd2761a"}' + string: '{"id":"d6fb6739c94a45328ee36d163a7ee4de"}' headers: content-type: application/json - date: Fri, 03 Sep 2021 21:37:54 GMT + date: Mon, 20 Sep 2021 20:08:37 GMT location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/fakegroup/schemas/test-schema-twice-async7bfd16a1/versions/1?api-version=2020-09-01-preview - schema-id: 99a89631052e4a22a9fca816cbd2761a - schema-id-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/99a89631052e4a22a9fca816cbd2761a?api-version=2020-09-01-preview + schema-id: d6fb6739c94a45328ee36d163a7ee4de + schema-id-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/d6fb6739c94a45328ee36d163a7ee4de?api-version=2020-09-01-preview schema-version: '1' schema-versions-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/swathip-test-schema/schemas/test-schema-twice-async7bfd16a1/versions?api-version=2020-09-01-preview serialization-type: Avro @@ -50,13 +50,13 @@ interactions: uri: https://fake_resource.servicebus.windows.net/$schemagroups/fakegroup/schemas/test-schema-twice-async7bfd16a1?api-version=2020-09-01-preview response: body: - string: '{"id":"99a89631052e4a22a9fca816cbd2761a"}' + string: '{"id":"d6fb6739c94a45328ee36d163a7ee4de"}' headers: content-type: application/json - date: Fri, 03 Sep 2021 21:37:55 GMT + date: Mon, 20 Sep 2021 20:08:38 GMT location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/fakegroup/schemas/test-schema-twice-async7bfd16a1/versions/1?api-version=2020-09-01-preview - schema-id: 99a89631052e4a22a9fca816cbd2761a - schema-id-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/99a89631052e4a22a9fca816cbd2761a?api-version=2020-09-01-preview + schema-id: d6fb6739c94a45328ee36d163a7ee4de + schema-id-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/d6fb6739c94a45328ee36d163a7ee4de?api-version=2020-09-01-preview schema-version: '1' schema-versions-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/swathip-test-schema/schemas/test-schema-twice-async7bfd16a1/versions?api-version=2020-09-01-preview serialization-type: Avro diff --git a/sdk/schemaregistry/azure-schemaregistry/tests/async_tests/recordings/test_schema_registry_async.test_schema_update_async.yaml b/sdk/schemaregistry/azure-schemaregistry/tests/async_tests/recordings/test_schema_registry_async.test_schema_update_async.yaml index e220c13d7e0b..f8d99055d4cc 100644 --- a/sdk/schemaregistry/azure-schemaregistry/tests/async_tests/recordings/test_schema_registry_async.test_schema_update_async.yaml +++ b/sdk/schemaregistry/azure-schemaregistry/tests/async_tests/recordings/test_schema_registry_async.test_schema_update_async.yaml @@ -16,14 +16,14 @@ interactions: uri: https://fake_resource.servicebus.windows.net/$schemagroups/fakegroup/schemas/test-schema-update-async24591503?api-version=2020-09-01-preview response: body: - string: '{"id":"ff159041473444f1a972100623c394fd"}' + string: '{"id":"9bc6877fc0a5427c9c1dd672d84ef8e4"}' headers: content-type: application/json - date: Fri, 03 Sep 2021 21:37:56 GMT - location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/fakegroup/schemas/test-schema-update-async24591503/versions/3?api-version=2020-09-01-preview - schema-id: ff159041473444f1a972100623c394fd - schema-id-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/ff159041473444f1a972100623c394fd?api-version=2020-09-01-preview - schema-version: '3' + date: Mon, 20 Sep 2021 20:08:39 GMT + location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/fakegroup/schemas/test-schema-update-async24591503/versions/1?api-version=2020-09-01-preview + schema-id: 9bc6877fc0a5427c9c1dd672d84ef8e4 + schema-id-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/9bc6877fc0a5427c9c1dd672d84ef8e4?api-version=2020-09-01-preview + schema-version: '1' schema-versions-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/swathip-test-schema/schemas/test-schema-update-async24591503/versions?api-version=2020-09-01-preview serialization-type: Avro server: Microsoft-HTTPAPI/2.0 @@ -50,14 +50,14 @@ interactions: uri: https://fake_resource.servicebus.windows.net/$schemagroups/fakegroup/schemas/test-schema-update-async24591503?api-version=2020-09-01-preview response: body: - string: '{"id":"680ba41f9439473d9efb9b8c044635cc"}' + string: '{"id":"575bde2d54e74039b6a5166f07b580c2"}' headers: content-type: application/json - date: Fri, 03 Sep 2021 21:37:57 GMT - location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/fakegroup/schemas/test-schema-update-async24591503/versions/4?api-version=2020-09-01-preview - schema-id: 680ba41f9439473d9efb9b8c044635cc - schema-id-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/680ba41f9439473d9efb9b8c044635cc?api-version=2020-09-01-preview - schema-version: '4' + date: Mon, 20 Sep 2021 20:08:39 GMT + location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/fakegroup/schemas/test-schema-update-async24591503/versions/2?api-version=2020-09-01-preview + schema-id: 575bde2d54e74039b6a5166f07b580c2 + schema-id-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/575bde2d54e74039b6a5166f07b580c2?api-version=2020-09-01-preview + schema-version: '2' schema-versions-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/swathip-test-schema/schemas/test-schema-update-async24591503/versions?api-version=2020-09-01-preview serialization-type: Avro server: Microsoft-HTTPAPI/2.0 @@ -75,17 +75,17 @@ interactions: User-Agent: - azsdk-python-azureschemaregistry/1.0.0b3 Python/3.9.0 (Windows-10-10.0.19041-SP0) method: GET - uri: https://fake_resource.servicebus.windows.net/$schemagroups/getSchemaById/680ba41f9439473d9efb9b8c044635cc?api-version=2020-09-01-preview + uri: https://fake_resource.servicebus.windows.net/$schemagroups/getSchemaById/575bde2d54e74039b6a5166f07b580c2?api-version=2020-09-01-preview response: body: string: '{"namespace":"example.avro","type":"record","name":"User","fields":[{"name":"name","type":"string"},{"name":"favorite_number","type":["int","null"]},{"name":"favorite_food","type":["string","null"]}]}' headers: content-type: application/json - date: Fri, 03 Sep 2021 21:37:57 GMT - location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/fakegroup/schemas/test-schema-update-async24591503/versions/4?api-version=2020-09-01-preview - schema-id: 680ba41f9439473d9efb9b8c044635cc - schema-id-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/680ba41f9439473d9efb9b8c044635cc?api-version=2020-09-01-preview - schema-version: '4' + date: Mon, 20 Sep 2021 20:08:40 GMT + location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/fakegroup/schemas/test-schema-update-async24591503/versions/2?api-version=2020-09-01-preview + schema-id: 575bde2d54e74039b6a5166f07b580c2 + schema-id-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/575bde2d54e74039b6a5166f07b580c2?api-version=2020-09-01-preview + schema-version: '2' schema-versions-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/swathip-test-schema/schemas/test-schema-update-async24591503/versions?api-version=2020-09-01-preview serialization-type: Avro server: Microsoft-HTTPAPI/2.0 @@ -94,67 +94,5 @@ interactions: status: code: 200 message: OK - url: https://swathip-test-eventhubs.servicebus.windows.net/$schemagroups/getSchemaById/680ba41f9439473d9efb9b8c044635cc?api-version=2020-09-01-preview -- request: - body: null - headers: - Accept: - - text/plain; charset=utf-8 - User-Agent: - - azsdk-python-azureschemaregistry/1.0.0b3 Python/3.9.0 (Windows-10-10.0.19041-SP0) - method: GET - uri: https://fake_resource.servicebus.windows.net/$schemagroups/getSchemaById/680ba41f9439473d9efb9b8c044635cc?api-version=2020-09-01-preview - response: - body: - string: '{"namespace":"example.avro","type":"record","name":"User","fields":[{"name":"name","type":"string"},{"name":"favorite_number","type":["int","null"]},{"name":"favorite_food","type":["string","null"]}]}' - headers: - content-type: application/json - date: Fri, 03 Sep 2021 21:37:57 GMT - location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/fakegroup/schemas/test-schema-update-async24591503/versions/4?api-version=2020-09-01-preview - schema-id: 680ba41f9439473d9efb9b8c044635cc - schema-id-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/680ba41f9439473d9efb9b8c044635cc?api-version=2020-09-01-preview - schema-version: '4' - schema-versions-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/swathip-test-schema/schemas/test-schema-update-async24591503/versions?api-version=2020-09-01-preview - serialization-type: Avro - server: Microsoft-HTTPAPI/2.0 - strict-transport-security: max-age=31536000 - transfer-encoding: chunked - status: - code: 200 - message: OK - url: https://swathip-test-eventhubs.servicebus.windows.net/$schemagroups/getSchemaById/680ba41f9439473d9efb9b8c044635cc?api-version=2020-09-01-preview -- request: - body: '{"namespace":"example.avro","type":"record","name":"User","fields":[{"name":"name","type":"string"},{"name":"favorite_number","type":["int","null"]},{"name":"favorite_food","type":["string","null"]}]}' - headers: - Accept: - - application/json - Content-Length: - - '200' - Content-Type: - - application/json - Serialization-Type: - - Avro - User-Agent: - - azsdk-python-azureschemaregistry/1.0.0b3 Python/3.9.0 (Windows-10-10.0.19041-SP0) - method: POST - uri: https://fake_resource.servicebus.windows.net/$schemagroups/fakegroup/schemas/test-schema-update-async24591503?api-version=2020-09-01-preview - response: - body: - string: '{"id":"680ba41f9439473d9efb9b8c044635cc"}' - headers: - content-type: application/json - date: Fri, 03 Sep 2021 21:37:58 GMT - location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/fakegroup/schemas/test-schema-update-async24591503/versions/4?api-version=2020-09-01-preview - schema-id: 680ba41f9439473d9efb9b8c044635cc - schema-id-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/680ba41f9439473d9efb9b8c044635cc?api-version=2020-09-01-preview - schema-version: '4' - schema-versions-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/swathip-test-schema/schemas/test-schema-update-async24591503/versions?api-version=2020-09-01-preview - serialization-type: Avro - server: Microsoft-HTTPAPI/2.0 - strict-transport-security: max-age=31536000 - transfer-encoding: chunked - status: - code: 200 - message: OK - url: https://swathip-test-eventhubs.servicebus.windows.net/$schemagroups/swathip-test-schema/schemas/test-schema-update-async24591503?api-version=2020-09-01-preview + url: https://swathip-test-eventhubs.servicebus.windows.net/$schemagroups/getSchemaById/575bde2d54e74039b6a5166f07b580c2?api-version=2020-09-01-preview version: 1 diff --git a/sdk/schemaregistry/azure-schemaregistry/tests/async_tests/test_schema_registry_async.py b/sdk/schemaregistry/azure-schemaregistry/tests/async_tests/test_schema_registry_async.py index 093bb43e085e..e9a737ca043a 100644 --- a/sdk/schemaregistry/azure-schemaregistry/tests/async_tests/test_schema_registry_async.py +++ b/sdk/schemaregistry/azure-schemaregistry/tests/async_tests/test_schema_registry_async.py @@ -47,11 +47,7 @@ async def test_schema_basic_async(self, schemaregistry_endpoint, schemaregistry_ schema_name = self.get_resource_name('test-schema-basic-async') schema_str = """{"namespace":"example.avro","type":"record","name":"User","fields":[{"name":"name","type":"string"},{"name":"favorite_number","type":["int","null"]},{"name":"favorite_color","type":["string","null"]}]}""" serialization_type = "Avro" - assert len(client._id_to_schema) == 0 - assert len(client._description_to_properties) == 0 schema_properties = await client.register_schema(schemaregistry_group, schema_name, schema_str, serialization_type) - assert len(client._id_to_schema) == 1 - assert len(client._description_to_properties) == 1 assert schema_properties.id is not None assert schema_properties.location is not None @@ -66,28 +62,13 @@ async def test_schema_basic_async(self, schemaregistry_endpoint, schemaregistry_ assert returned_schema.properties.serialization_type == "Avro" assert returned_schema.content == schema_str - # check that same cached properties object is returned by get_schema_properties - cached_properties = await client.get_schema_properties(schemaregistry_group, schema_name, schema_str, serialization_type) - same_cached_properties = await client.get_schema_properties(schemaregistry_group, schema_name, schema_str, serialization_type) - assert same_cached_properties == cached_properties - - # check if schema is added to cache when it does not exist in the cache - cached_properties = client._description_to_properties[ - (schemaregistry_group, schema_name, schema_str, serialization_type) - ] - properties_cache_length = len(client._description_to_properties) - del client._description_to_properties[ - (schemaregistry_group, schema_name, schema_str, serialization_type) - ] - assert len(client._description_to_properties) == properties_cache_length - 1 - returned_schema_properties = await client.get_schema_properties(schemaregistry_group, schema_name, schema_str, serialization_type) - assert len(client._description_to_properties) == properties_cache_length assert returned_schema_properties.id == schema_properties.id assert returned_schema_properties.location is not None assert returned_schema_properties.version == 1 assert returned_schema_properties.serialization_type == "Avro" + await client._generated_client._config.credential.close() @SchemaRegistryPowerShellPreparer() @@ -112,19 +93,7 @@ async def test_schema_update_async(self, schemaregistry_endpoint, schemaregistry assert new_schema_properties.version == schema_properties.version + 1 assert new_schema_properties.serialization_type == "Avro" - # check that same cached schema object is returned by get_schema - cached_schema = await client.get_schema(id=new_schema_properties.id) - same_cached_schema = await client.get_schema(id=new_schema_properties.id) - assert same_cached_schema == cached_schema - - # check if schema is added to cache when it does not exist in the cache - cached_schema = client._id_to_schema[new_schema_properties.id] - schema_cache_length = len(client._id_to_schema) - del client._id_to_schema[new_schema_properties.id] - assert len(client._id_to_schema) == schema_cache_length - 1 - new_schema = await client.get_schema(id=new_schema_properties.id) - assert len(client._id_to_schema) == schema_cache_length assert new_schema.properties.id != schema_properties.id assert new_schema.properties.id == new_schema_properties.id @@ -133,12 +102,6 @@ async def test_schema_update_async(self, schemaregistry_endpoint, schemaregistry assert new_schema.properties.version == schema_properties.version + 1 assert new_schema.properties.serialization_type == "Avro" - # check that properties object is the same in caches - client._id_to_schema = {} - client._description_to_properties = {} - new_schema = await client.get_schema(id=new_schema_properties.id) - new_schema_properties = await client.get_schema_properties(schemaregistry_group, schema_name, schema_str_new, serialization_type) - assert new_schema.properties == new_schema_properties await client._generated_client._config.credential.close() @SchemaRegistryPowerShellPreparer() @@ -149,14 +112,8 @@ async def test_schema_same_twice_async(self, schemaregistry_endpoint, schemaregi serialization_type = "Avro" async with client: schema_properties = await client.register_schema(schemaregistry_group, schema_name, schema_str, serialization_type) - schema_cache_length = len(client._id_to_schema) - desc_cache_length = len(client._description_to_properties) schema_properties_second = await client.register_schema(schemaregistry_group, schema_name, schema_str, serialization_type) - schema_cache_second_length = len(client._id_to_schema) - desc_cache_second_length = len(client._description_to_properties) assert schema_properties.id == schema_properties_second.id - assert schema_cache_length == schema_cache_second_length - assert desc_cache_length == desc_cache_second_length await client._generated_client._config.credential.close() @SchemaRegistryPowerShellPreparer() diff --git a/sdk/schemaregistry/azure-schemaregistry/tests/recordings/test_schema_registry.test_schema_basic.yaml b/sdk/schemaregistry/azure-schemaregistry/tests/recordings/test_schema_registry.test_schema_basic.yaml index c49c7d65f97b..4c737cf75275 100644 --- a/sdk/schemaregistry/azure-schemaregistry/tests/recordings/test_schema_registry.test_schema_basic.yaml +++ b/sdk/schemaregistry/azure-schemaregistry/tests/recordings/test_schema_registry.test_schema_basic.yaml @@ -20,18 +20,60 @@ interactions: uri: https://fake_resource.servicebus.windows.net/$schemagroups/fakegroup/schemas/test-schema-basic31c70f88?api-version=2020-09-01-preview response: body: - string: '{"id":"4e0f965608ea4e92b166bc3ef266cada"}' + string: '{"id":"0469b7e356874374a31df6a027213625"}' headers: content-type: - application/json date: - - Fri, 03 Sep 2021 21:37:31 GMT + - Mon, 20 Sep 2021 20:08:15 GMT location: - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/fakegroup/schemas/test-schema-basic31c70f88/versions/1?api-version=2020-09-01-preview schema-id: - - 4e0f965608ea4e92b166bc3ef266cada + - 0469b7e356874374a31df6a027213625 schema-id-location: - - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/4e0f965608ea4e92b166bc3ef266cada?api-version=2020-09-01-preview + - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/0469b7e356874374a31df6a027213625?api-version=2020-09-01-preview + schema-version: + - '1' + schema-versions-location: + - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/swathip-test-schema/schemas/test-schema-basic31c70f88/versions?api-version=2020-09-01-preview + serialization-type: + - Avro + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000 + transfer-encoding: + - chunked + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - text/plain; charset=utf-8 + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - azsdk-python-azureschemaregistry/1.0.0b3 Python/3.9.0 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://fake_resource.servicebus.windows.net/$schemagroups/getSchemaById/0469b7e356874374a31df6a027213625?api-version=2020-09-01-preview + response: + body: + string: '{"namespace":"example.avro","type":"record","name":"User","fields":[{"name":"name","type":"string"},{"name":"favorite_number","type":["int","null"]},{"name":"favorite_color","type":["string","null"]}]}' + headers: + content-type: + - application/json + date: + - Mon, 20 Sep 2021 20:08:15 GMT + location: + - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/fakegroup/schemas/test-schema-basic31c70f88/versions/1?api-version=2020-09-01-preview + schema-id: + - 0469b7e356874374a31df6a027213625 + schema-id-location: + - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/0469b7e356874374a31df6a027213625?api-version=2020-09-01-preview schema-version: - '1' schema-versions-location: @@ -68,18 +110,18 @@ interactions: uri: https://fake_resource.servicebus.windows.net/$schemagroups/fakegroup/schemas/test-schema-basic31c70f88?api-version=2020-09-01-preview response: body: - string: '{"id":"4e0f965608ea4e92b166bc3ef266cada"}' + string: '{"id":"0469b7e356874374a31df6a027213625"}' headers: content-type: - application/json date: - - Fri, 03 Sep 2021 21:37:31 GMT + - Mon, 20 Sep 2021 20:08:16 GMT location: - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/fakegroup/schemas/test-schema-basic31c70f88/versions/1?api-version=2020-09-01-preview schema-id: - - 4e0f965608ea4e92b166bc3ef266cada + - 0469b7e356874374a31df6a027213625 schema-id-location: - - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/4e0f965608ea4e92b166bc3ef266cada?api-version=2020-09-01-preview + - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/0469b7e356874374a31df6a027213625?api-version=2020-09-01-preview schema-version: - '1' schema-versions-location: diff --git a/sdk/schemaregistry/azure-schemaregistry/tests/recordings/test_schema_registry.test_schema_negative_no_schema.yaml b/sdk/schemaregistry/azure-schemaregistry/tests/recordings/test_schema_registry.test_schema_negative_no_schema.yaml index 0c94e9dcedfe..7e8724dc8084 100644 --- a/sdk/schemaregistry/azure-schemaregistry/tests/recordings/test_schema_registry.test_schema_negative_no_schema.yaml +++ b/sdk/schemaregistry/azure-schemaregistry/tests/recordings/test_schema_registry.test_schema_negative_no_schema.yaml @@ -15,14 +15,14 @@ interactions: response: body: string: '{"Code":400,"Detail":"SubCode=40000, UnknownType:The request is invalid. - [MGResponseHttpError=BadRequest]. TrackingId:a563e2f1-335c-4828-9b2f-da273d9ccd8c_G28, + [MGResponseHttpError=BadRequest]. TrackingId:0f167d85-f54f-4afe-aae9-949d2b894663_G28, SystemTracker:swathip-test-eventhubs.servicebus.windows.net:$schemagroups\/getSchemaById\/a, - Timestamp:2021-09-03T21:37:33"}' + Timestamp:2021-09-20T20:08:17"}' headers: content-type: - application/json date: - - Fri, 03 Sep 2021 21:37:32 GMT + - Mon, 20 Sep 2021 20:08:17 GMT server: - Microsoft-HTTPAPI/2.0 strict-transport-security: @@ -48,13 +48,13 @@ interactions: response: body: string: '{"Code":404,"Detail":"Schema id aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa does - not exist. TrackingId:68ff2f6e-e922-4c97-9673-4b96c50bd517_G28, SystemTracker:swathip-test-eventhubs.servicebus.windows.net:$schemagroups\/getSchemaById\/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, - Timestamp:2021-09-03T21:37:33"}' + not exist. TrackingId:8c8699e7-a6dc-437f-88fc-f6fddd2d64ef_G28, SystemTracker:swathip-test-eventhubs.servicebus.windows.net:$schemagroups\/getSchemaById\/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, + Timestamp:2021-09-20T20:08:17"}' headers: content-type: - application/json date: - - Fri, 03 Sep 2021 21:37:33 GMT + - Mon, 20 Sep 2021 20:08:17 GMT server: - Microsoft-HTTPAPI/2.0 strict-transport-security: diff --git a/sdk/schemaregistry/azure-schemaregistry/tests/recordings/test_schema_registry.test_schema_same_twice.yaml b/sdk/schemaregistry/azure-schemaregistry/tests/recordings/test_schema_registry.test_schema_same_twice.yaml index 1b38f3f9a0f5..6e445c1c3ea9 100644 --- a/sdk/schemaregistry/azure-schemaregistry/tests/recordings/test_schema_registry.test_schema_same_twice.yaml +++ b/sdk/schemaregistry/azure-schemaregistry/tests/recordings/test_schema_registry.test_schema_same_twice.yaml @@ -20,18 +20,18 @@ interactions: uri: https://fake_resource.servicebus.windows.net/$schemagroups/fakegroup/schemas/test-schema-twice863b11a7?api-version=2020-09-01-preview response: body: - string: '{"id":"d2fc67eed39142ddb6a93bb1c71a965d"}' + string: '{"id":"286ba485f55e4c06aac7f5c33d762000"}' headers: content-type: - application/json date: - - Fri, 03 Sep 2021 21:37:41 GMT + - Mon, 20 Sep 2021 20:08:24 GMT location: - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/fakegroup/schemas/test-schema-twice863b11a7/versions/1?api-version=2020-09-01-preview schema-id: - - d2fc67eed39142ddb6a93bb1c71a965d + - 286ba485f55e4c06aac7f5c33d762000 schema-id-location: - - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/d2fc67eed39142ddb6a93bb1c71a965d?api-version=2020-09-01-preview + - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/286ba485f55e4c06aac7f5c33d762000?api-version=2020-09-01-preview schema-version: - '1' schema-versions-location: @@ -68,18 +68,18 @@ interactions: uri: https://fake_resource.servicebus.windows.net/$schemagroups/fakegroup/schemas/test-schema-twice863b11a7?api-version=2020-09-01-preview response: body: - string: '{"id":"d2fc67eed39142ddb6a93bb1c71a965d"}' + string: '{"id":"286ba485f55e4c06aac7f5c33d762000"}' headers: content-type: - application/json date: - - Fri, 03 Sep 2021 21:37:41 GMT + - Mon, 20 Sep 2021 20:08:25 GMT location: - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/fakegroup/schemas/test-schema-twice863b11a7/versions/1?api-version=2020-09-01-preview schema-id: - - d2fc67eed39142ddb6a93bb1c71a965d + - 286ba485f55e4c06aac7f5c33d762000 schema-id-location: - - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/d2fc67eed39142ddb6a93bb1c71a965d?api-version=2020-09-01-preview + - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/286ba485f55e4c06aac7f5c33d762000?api-version=2020-09-01-preview schema-version: - '1' schema-versions-location: diff --git a/sdk/schemaregistry/azure-schemaregistry/tests/recordings/test_schema_registry.test_schema_update.yaml b/sdk/schemaregistry/azure-schemaregistry/tests/recordings/test_schema_registry.test_schema_update.yaml index 2d2c8798614a..f74ee88cd64b 100644 --- a/sdk/schemaregistry/azure-schemaregistry/tests/recordings/test_schema_registry.test_schema_update.yaml +++ b/sdk/schemaregistry/azure-schemaregistry/tests/recordings/test_schema_registry.test_schema_update.yaml @@ -20,20 +20,20 @@ interactions: uri: https://fake_resource.servicebus.windows.net/$schemagroups/fakegroup/schemas/test-schema-update423f1009?api-version=2020-09-01-preview response: body: - string: '{"id":"45dc034a90014105b91fab6d837f57f4"}' + string: '{"id":"320a8369b8454479bce5f9eb26dc3d5a"}' headers: content-type: - application/json date: - - Fri, 03 Sep 2021 21:37:42 GMT + - Mon, 20 Sep 2021 20:08:26 GMT location: - - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/fakegroup/schemas/test-schema-update423f1009/versions/3?api-version=2020-09-01-preview + - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/fakegroup/schemas/test-schema-update423f1009/versions/1?api-version=2020-09-01-preview schema-id: - - 45dc034a90014105b91fab6d837f57f4 + - 320a8369b8454479bce5f9eb26dc3d5a schema-id-location: - - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/45dc034a90014105b91fab6d837f57f4?api-version=2020-09-01-preview + - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/320a8369b8454479bce5f9eb26dc3d5a?api-version=2020-09-01-preview schema-version: - - '3' + - '1' schema-versions-location: - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/swathip-test-schema/schemas/test-schema-update423f1009/versions?api-version=2020-09-01-preview serialization-type: @@ -68,20 +68,20 @@ interactions: uri: https://fake_resource.servicebus.windows.net/$schemagroups/fakegroup/schemas/test-schema-update423f1009?api-version=2020-09-01-preview response: body: - string: '{"id":"d5f23b7f77434922bb8d503188609973"}' + string: '{"id":"003d87aaf24648aabf4255d7292f73e9"}' headers: content-type: - application/json date: - - Fri, 03 Sep 2021 21:37:43 GMT + - Mon, 20 Sep 2021 20:08:26 GMT location: - - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/fakegroup/schemas/test-schema-update423f1009/versions/4?api-version=2020-09-01-preview + - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/fakegroup/schemas/test-schema-update423f1009/versions/2?api-version=2020-09-01-preview schema-id: - - d5f23b7f77434922bb8d503188609973 + - 003d87aaf24648aabf4255d7292f73e9 schema-id-location: - - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/d5f23b7f77434922bb8d503188609973?api-version=2020-09-01-preview + - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/003d87aaf24648aabf4255d7292f73e9?api-version=2020-09-01-preview schema-version: - - '4' + - '2' schema-versions-location: - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/swathip-test-schema/schemas/test-schema-update423f1009/versions?api-version=2020-09-01-preview serialization-type: @@ -107,7 +107,7 @@ interactions: User-Agent: - azsdk-python-azureschemaregistry/1.0.0b3 Python/3.9.0 (Windows-10-10.0.19041-SP0) method: GET - uri: https://fake_resource.servicebus.windows.net/$schemagroups/getSchemaById/d5f23b7f77434922bb8d503188609973?api-version=2020-09-01-preview + uri: https://fake_resource.servicebus.windows.net/$schemagroups/getSchemaById/003d87aaf24648aabf4255d7292f73e9?api-version=2020-09-01-preview response: body: string: '{"namespace":"example.avro","type":"record","name":"User","fields":[{"name":"name","type":"string"},{"name":"favorite_number","type":["int","null"]},{"name":"favorite_food","type":["string","null"]}]}' @@ -115,105 +115,15 @@ interactions: content-type: - application/json date: - - Fri, 03 Sep 2021 21:37:43 GMT + - Mon, 20 Sep 2021 20:08:27 GMT location: - - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/fakegroup/schemas/test-schema-update423f1009/versions/4?api-version=2020-09-01-preview + - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/fakegroup/schemas/test-schema-update423f1009/versions/2?api-version=2020-09-01-preview schema-id: - - d5f23b7f77434922bb8d503188609973 + - 003d87aaf24648aabf4255d7292f73e9 schema-id-location: - - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/d5f23b7f77434922bb8d503188609973?api-version=2020-09-01-preview + - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/003d87aaf24648aabf4255d7292f73e9?api-version=2020-09-01-preview schema-version: - - '4' - schema-versions-location: - - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/swathip-test-schema/schemas/test-schema-update423f1009/versions?api-version=2020-09-01-preview - serialization-type: - - Avro - server: - - Microsoft-HTTPAPI/2.0 - strict-transport-security: - - max-age=31536000 - transfer-encoding: - - chunked - status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - text/plain; charset=utf-8 - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - User-Agent: - - azsdk-python-azureschemaregistry/1.0.0b3 Python/3.9.0 (Windows-10-10.0.19041-SP0) - method: GET - uri: https://fake_resource.servicebus.windows.net/$schemagroups/getSchemaById/d5f23b7f77434922bb8d503188609973?api-version=2020-09-01-preview - response: - body: - string: '{"namespace":"example.avro","type":"record","name":"User","fields":[{"name":"name","type":"string"},{"name":"favorite_number","type":["int","null"]},{"name":"favorite_food","type":["string","null"]}]}' - headers: - content-type: - - application/json - date: - - Fri, 03 Sep 2021 21:37:44 GMT - location: - - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/fakegroup/schemas/test-schema-update423f1009/versions/4?api-version=2020-09-01-preview - schema-id: - - d5f23b7f77434922bb8d503188609973 - schema-id-location: - - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/d5f23b7f77434922bb8d503188609973?api-version=2020-09-01-preview - schema-version: - - '4' - schema-versions-location: - - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/swathip-test-schema/schemas/test-schema-update423f1009/versions?api-version=2020-09-01-preview - serialization-type: - - Avro - server: - - Microsoft-HTTPAPI/2.0 - strict-transport-security: - - max-age=31536000 - transfer-encoding: - - chunked - status: - code: 200 - message: OK -- request: - body: '{"namespace":"example.avro","type":"record","name":"User","fields":[{"name":"name","type":"string"},{"name":"favorite_number","type":["int","null"]},{"name":"favorite_food","type":["string","null"]}]}' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '200' - Content-Type: - - application/json - Serialization-Type: - - Avro - User-Agent: - - azsdk-python-azureschemaregistry/1.0.0b3 Python/3.9.0 (Windows-10-10.0.19041-SP0) - method: POST - uri: https://fake_resource.servicebus.windows.net/$schemagroups/fakegroup/schemas/test-schema-update423f1009?api-version=2020-09-01-preview - response: - body: - string: '{"id":"d5f23b7f77434922bb8d503188609973"}' - headers: - content-type: - - application/json - date: - - Fri, 03 Sep 2021 21:37:44 GMT - location: - - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/fakegroup/schemas/test-schema-update423f1009/versions/4?api-version=2020-09-01-preview - schema-id: - - d5f23b7f77434922bb8d503188609973 - schema-id-location: - - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/d5f23b7f77434922bb8d503188609973?api-version=2020-09-01-preview - schema-version: - - '4' + - '2' schema-versions-location: - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/swathip-test-schema/schemas/test-schema-update423f1009/versions?api-version=2020-09-01-preview serialization-type: diff --git a/sdk/schemaregistry/azure-schemaregistry/tests/test_schema_registry.py b/sdk/schemaregistry/azure-schemaregistry/tests/test_schema_registry.py index 4966f5713feb..9e9c4692e97b 100644 --- a/sdk/schemaregistry/azure-schemaregistry/tests/test_schema_registry.py +++ b/sdk/schemaregistry/azure-schemaregistry/tests/test_schema_registry.py @@ -42,11 +42,7 @@ def test_schema_basic(self, schemaregistry_endpoint, schemaregistry_group, **kwa schema_name = self.get_resource_name('test-schema-basic') schema_str = """{"namespace":"example.avro","type":"record","name":"User","fields":[{"name":"name","type":"string"},{"name":"favorite_number","type":["int","null"]},{"name":"favorite_color","type":["string","null"]}]}""" serialization_type = "Avro" - assert len(client._id_to_schema) == 0 - assert len(client._description_to_properties) == 0 schema_properties = client.register_schema(schemaregistry_group, schema_name, schema_str, serialization_type) - assert len(client._id_to_schema) == 1 - assert len(client._description_to_properties) == 1 assert schema_properties.id is not None assert schema_properties.location is not None @@ -61,22 +57,7 @@ def test_schema_basic(self, schemaregistry_endpoint, schemaregistry_group, **kwa assert returned_schema.properties.serialization_type == "Avro" assert returned_schema.content == schema_str - # check that same cached properties object is returned by get_schema_properties - cached_properties = client.get_schema_properties(schemaregistry_group, schema_name, schema_str, serialization_type) - assert client.get_schema_properties(schemaregistry_group, schema_name, schema_str, serialization_type) == cached_properties - - # check if schema is added to cache when it does not exist in the cache - cached_properties = client._description_to_properties[ - (schemaregistry_group, schema_name, schema_str, serialization_type) - ] - properties_cache_length = len(client._description_to_properties) - del client._description_to_properties[ - (schemaregistry_group, schema_name, schema_str, serialization_type) - ] - assert len(client._description_to_properties) == properties_cache_length - 1 - returned_schema_properties = client.get_schema_properties(schemaregistry_group, schema_name, schema_str, serialization_type) - assert len(client._description_to_properties) == properties_cache_length assert returned_schema_properties.id == schema_properties.id assert returned_schema_properties.location is not None @@ -104,19 +85,7 @@ def test_schema_update(self, schemaregistry_endpoint, schemaregistry_group, **kw assert new_schema_properties.version == schema_properties.version + 1 assert new_schema_properties.serialization_type == "Avro" - # check that same cached schema object is returned by get_schema - cached_schema = client.get_schema(id=new_schema_properties.id) - assert client.get_schema(id=new_schema_properties.id) == cached_schema - - # check if schema is added to cache when it does not exist in the cache - cached_schema = client._id_to_schema[new_schema_properties.id] - schema_cache_length = len(client._id_to_schema) - del client._id_to_schema[new_schema_properties.id] - assert len(client._id_to_schema) == schema_cache_length - 1 - new_schema = client.get_schema(id=new_schema_properties.id) - assert len(client._id_to_schema) == schema_cache_length - assert cached_schema != new_schema # assert not same object after deletion from cache assert new_schema.properties.id != schema_properties.id assert new_schema.properties.id == new_schema_properties.id @@ -125,13 +94,6 @@ def test_schema_update(self, schemaregistry_endpoint, schemaregistry_group, **kw assert new_schema.properties.version == schema_properties.version + 1 assert new_schema.properties.serialization_type == "Avro" - # check that properties object is the same in caches - client._id_to_schema = {} - client._description_to_properties = {} - new_schema = client.get_schema(id=new_schema_properties.id) - new_schema_properties = client.get_schema_properties(schemaregistry_group, schema_name, schema_str_new, serialization_type) - assert new_schema.properties == new_schema_properties - @SchemaRegistryPowerShellPreparer() def test_schema_same_twice(self, schemaregistry_endpoint, schemaregistry_group, **kwargs): client = self.create_client(schemaregistry_endpoint) @@ -139,14 +101,8 @@ def test_schema_same_twice(self, schemaregistry_endpoint, schemaregistry_group, schema_str = """{"namespace":"example.avro","type":"record","name":"User","fields":[{"name":"name","type":"string"},{"name":"age","type":["int","null"]},{"name":"city","type":["string","null"]}]}""" serialization_type = "Avro" schema_properties = client.register_schema(schemaregistry_group, schema_name, schema_str, serialization_type) - schema_cache_length = len(client._id_to_schema) - desc_cache_length = len(client._description_to_properties) schema_properties_second = client.register_schema(schemaregistry_group, schema_name, schema_str, serialization_type) - schema_cache_second_length = len(client._id_to_schema) - desc_cache_second_length = len(client._description_to_properties) assert schema_properties.id == schema_properties_second.id - assert schema_cache_length == schema_cache_second_length - assert desc_cache_length == desc_cache_second_length @SchemaRegistryPowerShellPreparer() def test_schema_negative_wrong_credential(self, schemaregistry_endpoint, schemaregistry_group, **kwargs):