diff --git a/sdk/schemaregistry/azure-schemaregistry-avroserializer/CHANGELOG.md b/sdk/schemaregistry/azure-schemaregistry-avroserializer/CHANGELOG.md index c0c620b6c1b5..a24aa8e035c3 100644 --- a/sdk/schemaregistry/azure-schemaregistry-avroserializer/CHANGELOG.md +++ b/sdk/schemaregistry/azure-schemaregistry-avroserializer/CHANGELOG.md @@ -5,6 +5,7 @@ ### Features Added - `auto_register_schemas` keyword argument has been added to `SchemaRegistryAvroSerializer`, which will allow for automatically registering schemas passed in to the `serialize`. +- `value` parameter in `serialize` on `SchemaRegistryAvroSerializer` takes type `Mapping` rather than `Dict`. ### Breaking Changes @@ -13,6 +14,9 @@ - `data` parameter in the `serialize` and `deserialize` methods on `SchemaRegistryAvroSerializer` has been renamed `value`. - `schema` parameter in the `serialize` method on `SchemaRegistryAvroSerializer` no longer accepts argument of type `bytes`. - `SchemaRegistryAvroSerializer` constructor no longer takes in the `codec` keyword argument. +- The following positional arguments are now required keyword arguments: + - `client` and `group_name` in `SchemaRegistryAvroSerializer` constructor + - `schema` in `serialize` on `SchemaRegistryAvroSerializer` ### Bugs Fixed diff --git a/sdk/schemaregistry/azure-schemaregistry-avroserializer/azure/schemaregistry/serializer/avroserializer/_schema_registry_avro_serializer.py b/sdk/schemaregistry/azure-schemaregistry-avroserializer/azure/schemaregistry/serializer/avroserializer/_schema_registry_avro_serializer.py index e385630a81e2..d322730bfd16 100644 --- a/sdk/schemaregistry/azure-schemaregistry-avroserializer/azure/schemaregistry/serializer/avroserializer/_schema_registry_avro_serializer.py +++ b/sdk/schemaregistry/azure-schemaregistry-avroserializer/azure/schemaregistry/serializer/avroserializer/_schema_registry_avro_serializer.py @@ -24,7 +24,7 @@ # # -------------------------------------------------------------------------- from io import BytesIO -from typing import Any, Dict, Union +from typing import Any, Dict, Mapping import avro from ._constants import SCHEMA_ID_START_INDEX, SCHEMA_ID_LENGTH, DATA_START_INDEX @@ -36,20 +36,23 @@ class SchemaRegistryAvroSerializer(object): SchemaRegistryAvroSerializer provides the ability to serialize and deserialize data according to the given avro schema. It would automatically register, get and cache the schema. - :param client: The schema registry client + :keyword client: Required. The schema registry client which is used to register schema and retrieve schema from the service. - :type client: ~azure.schemaregistry.SchemaRegistryClient - :param str group_name: Schema group under which schema should be registered. + :paramtype client: ~azure.schemaregistry.SchemaRegistryClient + :keyword str group_name: Required. Schema group under which schema should be registered. :keyword bool auto_register_schemas: When true, register new schemas passed to serialize. Otherwise, and by default, fail if it has not been pre-registered in the registry. """ - def __init__(self, client, group_name, **kwargs): - # type: ("SchemaRegistryClient", str, Any) -> None - self._schema_group = group_name + def __init__(self, **kwargs): + # type: (Any) -> None + try: + self._schema_group = kwargs.pop("group_name") + self._schema_registry_client = kwargs.pop("client") # type: "SchemaRegistryClient" + except KeyError as e: + raise TypeError("'{}' is a required keyword.".format(e.args[0])) self._avro_serializer = AvroObjectSerializer(codec=kwargs.get("codec")) - self._schema_registry_client = client # type: "SchemaRegistryClient" self._auto_register_schemas = kwargs.get("auto_register_schemas", False) self._auto_register_schema_func = ( self._schema_registry_client.register_schema @@ -119,20 +122,23 @@ def _get_schema(self, schema_id, **kwargs): self._schema_to_id[schema_str] = schema_id return schema_str - def serialize(self, value, schema, **kwargs): - # type: (Dict[str, Any], Union[str, bytes], Any) -> bytes + def serialize(self, value, **kwargs): + # type: (Mapping[str, Any], Any) -> bytes """ Encode data with the given schema. The returns bytes are consisted of: The first 4 bytes denoting record format identifier. The following 32 bytes denoting schema id returned by schema registry service. The remaining bytes are the real data payload. :param value: The data to be encoded. - :type value: Dict[str, Any] - :param schema: The schema used to encode the data. - :type schema: str + :type value: Mapping[str, Any] + :keyword schema: Required. The schema used to encode the data. + :paramtype schema: str :rtype: bytes """ - raw_input_schema = schema + try: + raw_input_schema = kwargs.pop("schema") + except KeyError as e: + raise TypeError("'{}' is a required keyword.".format(e.args[0])) try: cached_schema = self._user_input_schema_cache[raw_input_schema] except KeyError: diff --git a/sdk/schemaregistry/azure-schemaregistry-avroserializer/samples/avro_serializer.py b/sdk/schemaregistry/azure-schemaregistry-avroserializer/samples/avro_serializer.py index c7a40e56104e..592f1afa760f 100644 --- a/sdk/schemaregistry/azure-schemaregistry-avroserializer/samples/avro_serializer.py +++ b/sdk/schemaregistry/azure-schemaregistry-avroserializer/samples/avro_serializer.py @@ -33,7 +33,7 @@ CLIENT_ID=os.environ['SCHEMA_REGISTRY_AZURE_CLIENT_ID'] CLIENT_SECRET=os.environ['SCHEMA_REGISTRY_AZURE_CLIENT_SECRET'] -SCHEMA_REGISTRY_ENDPOINT=os.environ['SCHEMA_REGISTRY_ENDPOINT'] +SCHEMA_REGISTRY_FULLY_QUALIFIED_NAMESPACE=os.environ['SCHEMA_REGISTRY_FULLY_QUALIFIED_NAMESPACE'] GROUP_NAME=os.environ['SCHEMA_REGISTRY_GROUP'] SCHEMA_STRING = """ {"namespace": "example.avro", @@ -59,9 +59,9 @@ def serialize(serializer): dict_data_alice = {"name": u"Alice", "favorite_number": 15, "favorite_color": u"green"} # Schema would be automatically registered into Schema Registry and cached locally. - payload_ben = serializer.serialize(dict_data_ben, SCHEMA_STRING) + payload_ben = serializer.serialize(dict_data_ben, schema=SCHEMA_STRING) # The second call won't trigger a service call. - payload_alice = serializer.serialize(dict_data_alice, SCHEMA_STRING) + payload_alice = serializer.serialize(dict_data_alice, schema=SCHEMA_STRING) print('Encoded bytes are: ', payload_ben) print('Encoded bytes are: ', payload_alice) @@ -79,8 +79,8 @@ def deserialize(serializer, bytes_payload): if __name__ == '__main__': - schema_registry = SchemaRegistryClient(endpoint=SCHEMA_REGISTRY_ENDPOINT, credential=token_credential) - serializer = SchemaRegistryAvroSerializer(schema_registry, GROUP_NAME) + schema_registry = SchemaRegistryClient(endpoint=SCHEMA_REGISTRY_FULLY_QUALIFIED_NAMESPACE, credential=token_credential) + serializer = SchemaRegistryAvroSerializer(client=schema_registry, group_name=GROUP_NAME, auto_register_schemas=True) bytes_data_ben, bytes_data_alice = serialize(serializer) dict_data_ben = deserialize(serializer, bytes_data_ben) dict_data_alice = deserialize(serializer, bytes_data_alice) diff --git a/sdk/schemaregistry/azure-schemaregistry-avroserializer/samples/eventhub_receive_integration.py b/sdk/schemaregistry/azure-schemaregistry-avroserializer/samples/eventhub_receive_integration.py index 783fc7167603..2cf4d0095b28 100644 --- a/sdk/schemaregistry/azure-schemaregistry-avroserializer/samples/eventhub_receive_integration.py +++ b/sdk/schemaregistry/azure-schemaregistry-avroserializer/samples/eventhub_receive_integration.py @@ -19,7 +19,7 @@ EVENTHUB_CONNECTION_STR = os.environ['EVENT_HUB_CONN_STR'] EVENTHUB_NAME = os.environ['EVENT_HUB_NAME'] -SCHEMA_REGISTRY_ENDPOINT = os.environ['SCHEMA_REGISTRY_ENDPOINT'] +SCHEMA_REGISTRY_FULLY_QUALIFIED_NAMESPACE = os.environ['SCHEMA_REGISTRY_FULLY_QUALIFIED_NAMESPACE'] GROUP_NAME = os.environ['SCHEMA_REGISTRY_GROUP'] @@ -45,12 +45,14 @@ def on_event(partition_context, event): # create a SchemaRegistryAvroSerializer instance +# TODO: after 'azure-schemaregistry==1.0.0b3' is released, update 'endpoint' to 'fully_qualified_namespace' avro_serializer = SchemaRegistryAvroSerializer( client=SchemaRegistryClient( - endpoint=SCHEMA_REGISTRY_ENDPOINT, + endpoint=SCHEMA_REGISTRY_FULLY_QUALIFIED_NAMESPACE, credential=DefaultAzureCredential() ), - group_name=GROUP_NAME + group_name=GROUP_NAME, + auto_register_schemas=True ) diff --git a/sdk/schemaregistry/azure-schemaregistry-avroserializer/samples/eventhub_send_integration.py b/sdk/schemaregistry/azure-schemaregistry-avroserializer/samples/eventhub_send_integration.py index 8169e9ea2734..2638b849cf8d 100644 --- a/sdk/schemaregistry/azure-schemaregistry-avroserializer/samples/eventhub_send_integration.py +++ b/sdk/schemaregistry/azure-schemaregistry-avroserializer/samples/eventhub_send_integration.py @@ -20,7 +20,7 @@ EVENTHUB_CONNECTION_STR = os.environ['EVENT_HUB_CONN_STR'] EVENTHUB_NAME = os.environ['EVENT_HUB_NAME'] -SCHEMA_REGISTRY_ENDPOINT = os.environ['SCHEMA_REGISTRY_ENDPOINT'] +SCHEMA_REGISTRY_FULLY_QUALIFIED_NAMESPACE = os.environ['SCHEMA_REGISTRY_FULLY_QUALIFIED_NAMESPACE'] GROUP_NAME = os.environ['SCHEMA_REGISTRY_GROUP'] SCHEMA_STRING = """ @@ -59,12 +59,14 @@ def send_event_data_batch(producer, serializer): # create a SchemaRegistryAvroSerializer instance +# TODO: after 'azure-schemaregistry==1.0.0b3' is released, update 'endpoint' to 'fully_qualified_namespace' avro_serializer = SchemaRegistryAvroSerializer( client=SchemaRegistryClient( - endpoint=SCHEMA_REGISTRY_ENDPOINT, + endpoint=SCHEMA_REGISTRY_FULLY_QUALIFIED_NAMESPACE, credential=DefaultAzureCredential() ), - group_name=GROUP_NAME + group_name=GROUP_NAME, + auto_register_schemas=True ) diff --git a/sdk/schemaregistry/azure-schemaregistry-avroserializer/tests/recordings/test_avro_serializer.test_basic_sr_avro_serializer_with_auto_register_schemas.yaml b/sdk/schemaregistry/azure-schemaregistry-avroserializer/tests/recordings/test_avro_serializer.test_basic_sr_avro_serializer_with_auto_register_schemas.yaml index 2410144713ec..138b96d57d44 100644 --- a/sdk/schemaregistry/azure-schemaregistry-avroserializer/tests/recordings/test_avro_serializer.test_basic_sr_avro_serializer_with_auto_register_schemas.yaml +++ b/sdk/schemaregistry/azure-schemaregistry-avroserializer/tests/recordings/test_avro_serializer.test_basic_sr_avro_serializer_with_auto_register_schemas.yaml @@ -23,12 +23,12 @@ interactions: uri: https://fake_resource.servicebus.windows.net/$schemagroups/fakegroup/schemas/example.avro.User?api-version=2017-04 response: body: - string: '{"id":"041afcdb34a546faa3aa26a991567e32"}' + string: '{"id":"fc61e4d3e31b46f6a758fa1b67f35cc5"}' headers: content-type: - application/json date: - - Wed, 08 Sep 2021 22:17:05 GMT + - Fri, 24 Sep 2021 19:54:45 GMT location: - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/fakegroup/schemas/example.avro.User/versions/1?api-version=2017-04 server: @@ -38,9 +38,9 @@ interactions: transfer-encoding: - chunked x-schema-id: - - 041afcdb34a546faa3aa26a991567e32 + - fc61e4d3e31b46f6a758fa1b67f35cc5 x-schema-id-location: - - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/041afcdb34a546faa3aa26a991567e32?api-version=2017-04 + - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/fc61e4d3e31b46f6a758fa1b67f35cc5?api-version=2017-04 x-schema-type: - Avro x-schema-version: diff --git a/sdk/schemaregistry/azure-schemaregistry-avroserializer/tests/recordings/test_avro_serializer.test_basic_sr_avro_serializer_without_auto_register_schemas.yaml b/sdk/schemaregistry/azure-schemaregistry-avroserializer/tests/recordings/test_avro_serializer.test_basic_sr_avro_serializer_without_auto_register_schemas.yaml index bad3c1562982..2d3f07b5e19d 100644 --- a/sdk/schemaregistry/azure-schemaregistry-avroserializer/tests/recordings/test_avro_serializer.test_basic_sr_avro_serializer_without_auto_register_schemas.yaml +++ b/sdk/schemaregistry/azure-schemaregistry-avroserializer/tests/recordings/test_avro_serializer.test_basic_sr_avro_serializer_without_auto_register_schemas.yaml @@ -23,12 +23,12 @@ interactions: uri: https://fake_resource.servicebus.windows.net/$schemagroups/fakegroup/schemas/example.avro.User?api-version=2017-04 response: body: - string: '{"id":"041afcdb34a546faa3aa26a991567e32"}' + string: '{"id":"fc61e4d3e31b46f6a758fa1b67f35cc5"}' headers: content-type: - application/json date: - - Wed, 08 Sep 2021 22:17:06 GMT + - Fri, 24 Sep 2021 19:54:47 GMT location: - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/fakegroup/schemas/example.avro.User/versions/1?api-version=2017-04 server: @@ -38,9 +38,9 @@ interactions: transfer-encoding: - chunked x-schema-id: - - 041afcdb34a546faa3aa26a991567e32 + - fc61e4d3e31b46f6a758fa1b67f35cc5 x-schema-id-location: - - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/041afcdb34a546faa3aa26a991567e32?api-version=2017-04 + - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/fc61e4d3e31b46f6a758fa1b67f35cc5?api-version=2017-04 x-schema-type: - Avro x-schema-version: diff --git a/sdk/schemaregistry/azure-schemaregistry-avroserializer/tests/schemaregistry_preparer.py b/sdk/schemaregistry/azure-schemaregistry-avroserializer/tests/schemaregistry_preparer.py index f1f78608d0d0..bbf139cbac38 100644 --- a/sdk/schemaregistry/azure-schemaregistry-avroserializer/tests/schemaregistry_preparer.py +++ b/sdk/schemaregistry/azure-schemaregistry-avroserializer/tests/schemaregistry_preparer.py @@ -30,9 +30,9 @@ ) -SCHEMA_REGISTRY_ENDPOINT_PARAM = "schemaregistry_endpoint" +SCHEMA_REGISTRY_FULLY_QUALIFIED_NAMESPACE_PARAM = "schemaregistry_fully_qualified_namespace" SCHEMA_REGISTRY_GROUP_PARAM = "schemaregistry_group" -SCHEMA_REGISTRY_ENDPOINT_ENV_KEY_NAME = 'SCHEMA_REGISTRY_ENDPOINT' +SCHEMA_REGISTRY_FULLY_QUALIFIED_NAMESPACE_ENV_KEY_NAME = 'SCHEMA_REGISTRY_FULLY_QUALIFIED_NAMESPACE' SCHEMA_REGISTRY_GROUP_ENV_KEY_NAME = 'SCHEMA_REGISTRY_GROUP' @@ -59,13 +59,13 @@ def create_resource(self, name, **kwargs): # TODO: right now the endpoint/group is fixed, as there is no way to create/delete resources using api, in the future we should be able to dynamically create and remove resources if self.is_live: return { - SCHEMA_REGISTRY_ENDPOINT_PARAM: os.environ[SCHEMA_REGISTRY_ENDPOINT_ENV_KEY_NAME], + SCHEMA_REGISTRY_FULLY_QUALIFIED_NAMESPACE_PARAM: os.environ[SCHEMA_REGISTRY_FULLY_QUALIFIED_NAMESPACE_ENV_KEY_NAME], SCHEMA_REGISTRY_GROUP_PARAM: os.environ[SCHEMA_REGISTRY_GROUP_ENV_KEY_NAME] } else: return { - SCHEMA_REGISTRY_ENDPOINT_PARAM: "sr-playground.servicebus.windows.net", + SCHEMA_REGISTRY_FULLY_QUALIFIED_NAMESPACE_PARAM: "sr-playground.servicebus.windows.net", SCHEMA_REGISTRY_GROUP_PARAM: "azsdk_python_test_group" } diff --git a/sdk/schemaregistry/azure-schemaregistry-avroserializer/tests/test_avro_serializer.py b/sdk/schemaregistry/azure-schemaregistry-avroserializer/tests/test_avro_serializer.py index 9e8e6308c052..3d7b7f56608a 100644 --- a/sdk/schemaregistry/azure-schemaregistry-avroserializer/tests/test_avro_serializer.py +++ b/sdk/schemaregistry/azure-schemaregistry-avroserializer/tests/test_avro_serializer.py @@ -32,7 +32,7 @@ from devtools_testutils import AzureTestCase, PowerShellPreparer -SchemaRegistryPowerShellPreparer = functools.partial(PowerShellPreparer, "schemaregistry", schemaregistry_endpoint="fake_resource.servicebus.windows.net/", schemaregistry_group="fakegroup") +SchemaRegistryPowerShellPreparer = functools.partial(PowerShellPreparer, "schemaregistry", schemaregistry_fully_qualified_namespace="fake_resource.servicebus.windows.net/", schemaregistry_group="fakegroup") class SchemaRegistryAvroSerializerTests(AzureTestCase): @@ -75,15 +75,16 @@ def test_raw_avro_serializer_negative(self): raw_avro_object_serializer.serialize(dict_data_missing_required_field, schema) @SchemaRegistryPowerShellPreparer() - def test_basic_sr_avro_serializer_with_auto_register_schemas(self, schemaregistry_endpoint, schemaregistry_group, **kwargs): - sr_client = self.create_basic_client(SchemaRegistryClient, endpoint=schemaregistry_endpoint) - sr_avro_serializer = SchemaRegistryAvroSerializer(sr_client, schemaregistry_group, auto_register_schemas=True) + def test_basic_sr_avro_serializer_with_auto_register_schemas(self, schemaregistry_fully_qualified_namespace, schemaregistry_group, **kwargs): + # TODO: AFTER RELEASING azure-schemaregistry=1.0.0b3, UPDATE 'endpoint' to 'fully_qualified_namespace' + sr_client = self.create_basic_client(SchemaRegistryClient, endpoint=schemaregistry_fully_qualified_namespace) + sr_avro_serializer = SchemaRegistryAvroSerializer(client=sr_client, group_name=schemaregistry_group, auto_register_schemas=True) 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"]}]}""" schema = avro.schema.parse(schema_str) dict_data = {"name": u"Ben", "favorite_number": 7, "favorite_color": u"red"} - encoded_data = sr_avro_serializer.serialize(dict_data, schema_str) + encoded_data = sr_avro_serializer.serialize(dict_data, schema=schema_str) assert schema_str in sr_avro_serializer._user_input_schema_cache assert str(avro.schema.parse(schema_str)) in sr_avro_serializer._schema_to_id @@ -102,15 +103,16 @@ def test_basic_sr_avro_serializer_with_auto_register_schemas(self, schemaregistr sr_avro_serializer.close() @SchemaRegistryPowerShellPreparer() - def test_basic_sr_avro_serializer_without_auto_register_schemas(self, schemaregistry_endpoint, schemaregistry_group, **kwargs): - sr_client = self.create_basic_client(SchemaRegistryClient, endpoint=schemaregistry_endpoint) - sr_avro_serializer = SchemaRegistryAvroSerializer(sr_client, schemaregistry_group) + def test_basic_sr_avro_serializer_without_auto_register_schemas(self, schemaregistry_fully_qualified_namespace, schemaregistry_group, **kwargs): + # TODO: AFTER RELEASING azure-schemaregistry=1.0.0b3, UPDATE 'endpoint' to 'fully_qualified_namespace' + sr_client = self.create_basic_client(SchemaRegistryClient, endpoint=schemaregistry_fully_qualified_namespace) + sr_avro_serializer = SchemaRegistryAvroSerializer(client=sr_client, group_name=schemaregistry_group) 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"]}]}""" schema = avro.schema.parse(schema_str) dict_data = {"name": u"Ben", "favorite_number": 7, "favorite_color": u"red"} - encoded_data = sr_avro_serializer.serialize(dict_data, schema_str) + encoded_data = sr_avro_serializer.serialize(dict_data, schema=schema_str) assert schema_str in sr_avro_serializer._user_input_schema_cache assert str(avro.schema.parse(schema_str)) in sr_avro_serializer._schema_to_id diff --git a/sdk/schemaregistry/azure-schemaregistry/CHANGELOG.md b/sdk/schemaregistry/azure-schemaregistry/CHANGELOG.md index 91df0fb9ada9..178fe64b0b80 100644 --- a/sdk/schemaregistry/azure-schemaregistry/CHANGELOG.md +++ b/sdk/schemaregistry/azure-schemaregistry/CHANGELOG.md @@ -14,6 +14,8 @@ - `schema_definition`, which has been renamed from `schema_content` - `format`, which has been renamed from `serialization_type` - `endpoint` parameter in `SchemaRegistryClient` constructor has been renamed `fully_qualified_namespace` +- `location` instance variable in `SchemaProperties` has been removed. +- `Schema` and `SchemaProperties` no longer have positional parameters, as they will not be constructed by the user. ### Bugs Fixed diff --git a/sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/_common/_schema.py b/sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/_common/_schema.py index f7f32b18f4c6..cd706e3329e0 100644 --- a/sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/_common/_schema.py +++ b/sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/_common/_schema.py @@ -23,7 +23,7 @@ # IN THE SOFTWARE. # # -------------------------------------------------------------------------- -from typing import Any, Optional +from typing import Any class SchemaProperties(object): @@ -50,13 +50,12 @@ class SchemaProperties(object): def __init__( self, - id=None, # pylint:disable=redefined-builtin **kwargs ): - # type: (Optional[str], Any) -> None - self.id = id - self.format = kwargs.get('format') - self.version = kwargs.get('version') + # type: (Any) -> None + self.id = kwargs.pop('id') + self.format = kwargs.pop('format') + self.version = kwargs.pop('version') class Schema(object): @@ -81,9 +80,8 @@ class Schema(object): def __init__( self, - schema_definition, - properties, + **kwargs ): - # type: (str, SchemaProperties) -> None - self.schema_definition = schema_definition - self.properties = properties + # type: (Any) -> None + self.schema_definition = kwargs.pop("schema_definition") + self.properties = kwargs.pop("properties") 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 b447bcde69e7..f7adcf285361 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":"d919a8923e2446e69614c0220d967dd7"}' + string: '{"id":"ce01b38330914a5d92b88f534bafbfe9"}' headers: content-type: application/json - date: Wed, 22 Sep 2021 00:45:44 GMT + date: Fri, 24 Sep 2021 19:10: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: d919a8923e2446e69614c0220d967dd7 - schema-id-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/d919a8923e2446e69614c0220d967dd7?api-version=2020-09-01-preview + schema-id: ce01b38330914a5d92b88f534bafbfe9 + schema-id-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/ce01b38330914a5d92b88f534bafbfe9?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 @@ -41,16 +41,16 @@ 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/d919a8923e2446e69614c0220d967dd7?api-version=2020-09-01-preview + uri: https://fake_resource.servicebus.windows.net/$schemagroups/getSchemaById/ce01b38330914a5d92b88f534bafbfe9?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: Wed, 22 Sep 2021 00:45:44 GMT + date: Fri, 24 Sep 2021 19:10:31 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-id: ce01b38330914a5d92b88f534bafbfe9 + schema-id-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/ce01b38330914a5d92b88f534bafbfe9?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 @@ -60,7 +60,7 @@ interactions: status: code: 200 message: OK - url: https://swathip-test-eventhubs.servicebus.windows.net/$schemagroups/getSchemaById/d919a8923e2446e69614c0220d967dd7?api-version=2020-09-01-preview + url: https://swathip-test-eventhubs.servicebus.windows.net/$schemagroups/getSchemaById/ce01b38330914a5d92b88f534bafbfe9?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: @@ -78,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":"d919a8923e2446e69614c0220d967dd7"}' + string: '{"id":"ce01b38330914a5d92b88f534bafbfe9"}' headers: content-type: application/json - date: Wed, 22 Sep 2021 00:45:44 GMT + date: Fri, 24 Sep 2021 19:10:31 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-id: ce01b38330914a5d92b88f534bafbfe9 + schema-id-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/ce01b38330914a5d92b88f534bafbfe9?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 acd9965c636c..c8896c5d4452 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:f2315fcb-9423-493d-b69a-755243ae804f_G4, + [MGResponseHttpError=BadRequest]. TrackingId:c5b8cd47-1efe-41c2-964a-8cc46d7bafdb_G25, SystemTracker:swathip-test-eventhubs.servicebus.windows.net:$schemagroups\/getSchemaById\/a, - Timestamp:2021-09-22T00:45:46"}' + Timestamp:2021-09-24T19:10:33"}' headers: content-type: application/json - date: Wed, 22 Sep 2021 00:45:45 GMT + date: Fri, 24 Sep 2021 19:10:33 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:a7bda221-9b86-4e4f-b0b1-2e8db2e1d063_G4, SystemTracker:swathip-test-eventhubs.servicebus.windows.net:$schemagroups\/getSchemaById\/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, - Timestamp:2021-09-22T00:45:46"}' + not exist. TrackingId:6ad46706-814a-4973-9ec2-dc77945914b1_G25, SystemTracker:swathip-test-eventhubs.servicebus.windows.net:$schemagroups\/getSchemaById\/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, + Timestamp:2021-09-24T19:10:33"}' headers: content-type: application/json - date: Wed, 22 Sep 2021 00:45:46 GMT + date: Fri, 24 Sep 2021 19:10:33 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 90e06c4f36d3..c5ddf01cf2ae 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":"d6fb6739c94a45328ee36d163a7ee4de"}' + string: '{"id":"4eaa74dead3f4ee5b6f6ed66a4a2175a"}' headers: content-type: application/json - date: Mon, 20 Sep 2021 20:08:37 GMT + date: Fri, 24 Sep 2021 19:10:39 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: d6fb6739c94a45328ee36d163a7ee4de - schema-id-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/d6fb6739c94a45328ee36d163a7ee4de?api-version=2020-09-01-preview + schema-id: 4eaa74dead3f4ee5b6f6ed66a4a2175a + schema-id-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/4eaa74dead3f4ee5b6f6ed66a4a2175a?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":"d6fb6739c94a45328ee36d163a7ee4de"}' + string: '{"id":"4eaa74dead3f4ee5b6f6ed66a4a2175a"}' headers: content-type: application/json - date: Mon, 20 Sep 2021 20:08:38 GMT + date: Fri, 24 Sep 2021 19:10:40 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: d6fb6739c94a45328ee36d163a7ee4de - schema-id-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/d6fb6739c94a45328ee36d163a7ee4de?api-version=2020-09-01-preview + schema-id: 4eaa74dead3f4ee5b6f6ed66a4a2175a + schema-id-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/4eaa74dead3f4ee5b6f6ed66a4a2175a?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 f8d99055d4cc..1de1acbca093 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,13 +16,13 @@ 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":"9bc6877fc0a5427c9c1dd672d84ef8e4"}' + string: '{"id":"2b0e42eb865a491f8c60b139c93565ed"}' headers: content-type: application/json - date: Mon, 20 Sep 2021 20:08:39 GMT + date: Fri, 24 Sep 2021 19:10:40 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-id: 2b0e42eb865a491f8c60b139c93565ed + schema-id-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/2b0e42eb865a491f8c60b139c93565ed?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 @@ -50,13 +50,13 @@ 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":"575bde2d54e74039b6a5166f07b580c2"}' + string: '{"id":"75db6cf193ac46c7a7ee06b9fe37aced"}' headers: content-type: application/json - date: Mon, 20 Sep 2021 20:08:39 GMT + date: Fri, 24 Sep 2021 19:10:41 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-id: 75db6cf193ac46c7a7ee06b9fe37aced + schema-id-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/75db6cf193ac46c7a7ee06b9fe37aced?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 @@ -75,16 +75,16 @@ 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/575bde2d54e74039b6a5166f07b580c2?api-version=2020-09-01-preview + uri: https://fake_resource.servicebus.windows.net/$schemagroups/getSchemaById/75db6cf193ac46c7a7ee06b9fe37aced?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: Mon, 20 Sep 2021 20:08:40 GMT + date: Fri, 24 Sep 2021 19:10:41 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-id: 75db6cf193ac46c7a7ee06b9fe37aced + schema-id-location: https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/75db6cf193ac46c7a7ee06b9fe37aced?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 @@ -94,5 +94,5 @@ interactions: status: code: 200 message: OK - url: https://swathip-test-eventhubs.servicebus.windows.net/$schemagroups/getSchemaById/575bde2d54e74039b6a5166f07b580c2?api-version=2020-09-01-preview + url: https://swathip-test-eventhubs.servicebus.windows.net/$schemagroups/getSchemaById/75db6cf193ac46c7a7ee06b9fe37aced?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 8258fe3b39e1..01b08ff2b6e4 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 @@ -32,17 +32,17 @@ from azure.core.credentials import AccessToken -SchemaRegistryPowerShellPreparer = functools.partial(PowerShellPreparer, "schemaregistry", schemaregistry_endpoint="fake_resource.servicebus.windows.net/", schemaregistry_group="fakegroup") +SchemaRegistryPowerShellPreparer = functools.partial(PowerShellPreparer, "schemaregistry", schemaregistry_fully_qualified_namespace="fake_resource.servicebus.windows.net/", schemaregistry_group="fakegroup") class SchemaRegistryAsyncTests(AzureTestCase): - def create_client(self, endpoint): + def create_client(self, fully_qualified_namespace): credential = self.get_credential(SchemaRegistryClient, is_async=True) - return self.create_client_from_credential(SchemaRegistryClient, credential, fully_qualified_namespace=endpoint, is_async=True) + return self.create_client_from_credential(SchemaRegistryClient, credential, fully_qualified_namespace=fully_qualified_namespace, is_async=True) @SchemaRegistryPowerShellPreparer() - async def test_schema_basic_async(self, schemaregistry_endpoint, schemaregistry_group, **kwargs): - client = self.create_client(schemaregistry_endpoint) + async def test_schema_basic_async(self, schemaregistry_fully_qualified_namespace, schemaregistry_group, **kwargs): + client = self.create_client(schemaregistry_fully_qualified_namespace) async with client: 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"]}]}""" @@ -68,8 +68,8 @@ async def test_schema_basic_async(self, schemaregistry_endpoint, schemaregistry_ await client._generated_client._config.credential.close() @SchemaRegistryPowerShellPreparer() - async def test_schema_update_async(self, schemaregistry_endpoint, schemaregistry_group, **kwargs): - client = self.create_client(schemaregistry_endpoint) + async def test_schema_update_async(self, schemaregistry_fully_qualified_namespace, schemaregistry_group, **kwargs): + client = self.create_client(schemaregistry_fully_qualified_namespace) async with client: schema_name = self.get_resource_name('test-schema-update-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"]}]}""" @@ -98,8 +98,8 @@ async def test_schema_update_async(self, schemaregistry_endpoint, schemaregistry await client._generated_client._config.credential.close() @SchemaRegistryPowerShellPreparer() - async def test_schema_same_twice_async(self, schemaregistry_endpoint, schemaregistry_group, **kwargs): - client = self.create_client(schemaregistry_endpoint) + async def test_schema_same_twice_async(self, schemaregistry_fully_qualified_namespace, schemaregistry_group, **kwargs): + client = self.create_client(schemaregistry_fully_qualified_namespace) schema_name = self.get_resource_name('test-schema-twice-async') schema_str = """{"namespace":"example.avro","type":"record","name":"User","fields":[{"name":"name","type":"string"},{"name":"age","type":["int","null"]},{"name":"city","type":["string","null"]}]}""" format = "Avro" @@ -110,9 +110,9 @@ async def test_schema_same_twice_async(self, schemaregistry_endpoint, schemaregi await client._generated_client._config.credential.close() @SchemaRegistryPowerShellPreparer() - async def test_schema_negative_wrong_credential_async(self, schemaregistry_endpoint, schemaregistry_group, **kwargs): + async def test_schema_negative_wrong_credential_async(self, schemaregistry_fully_qualified_namespace, schemaregistry_group, **kwargs): credential = ClientSecretCredential(tenant_id="fake", client_id="fake", client_secret="fake") - client = SchemaRegistryClient(fully_qualified_namespace=schemaregistry_endpoint, credential=credential) + client = SchemaRegistryClient(fully_qualified_namespace=schemaregistry_fully_qualified_namespace, credential=credential) async with client, credential: schema_name = self.get_resource_name('test-schema-negative-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"]}]}""" @@ -121,7 +121,7 @@ async def test_schema_negative_wrong_credential_async(self, schemaregistry_endpo await client.register_schema(schemaregistry_group, schema_name, schema_str, format) @SchemaRegistryPowerShellPreparer() - async def test_schema_negative_wrong_endpoint_async(self, schemaregistry_endpoint, schemaregistry_group, **kwargs): + async def test_schema_negative_wrong_endpoint_async(self, schemaregistry_fully_qualified_namespace, schemaregistry_group, **kwargs): client = self.create_client("nonexist.servicebus.windows.net") async with client: schema_name = self.get_resource_name('test-schema-nonexist-async') @@ -132,8 +132,8 @@ async def test_schema_negative_wrong_endpoint_async(self, schemaregistry_endpoin await client._generated_client._config.credential.close() @SchemaRegistryPowerShellPreparer() - async def test_schema_negative_no_schema_async(self, schemaregistry_endpoint, schemaregistry_group, **kwargs): - client = self.create_client(schemaregistry_endpoint) + async def test_schema_negative_no_schema_async(self, schemaregistry_fully_qualified_namespace, schemaregistry_group, **kwargs): + client = self.create_client(schemaregistry_fully_qualified_namespace) async with client: with pytest.raises(HttpResponseError): await client.get_schema('a') 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 4630b204158a..01adea1ae411 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,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":"0469b7e356874374a31df6a027213625"}' + string: '{"id":"c9e4d79c4a06400aac374b9711bf98f8"}' headers: content-type: - application/json date: - - Wed, 22 Sep 2021 00:45:29 GMT + - Fri, 24 Sep 2021 23:46:00 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 + - c9e4d79c4a06400aac374b9711bf98f8 schema-id-location: - - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/0469b7e356874374a31df6a027213625?api-version=2020-09-01-preview + - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/c9e4d79c4a06400aac374b9711bf98f8?api-version=2020-09-01-preview schema-version: - '1' schema-versions-location: @@ -59,7 +59,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/0469b7e356874374a31df6a027213625?api-version=2020-09-01-preview + uri: https://fake_resource.servicebus.windows.net/$schemagroups/getSchemaById/c9e4d79c4a06400aac374b9711bf98f8?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"]}]}' @@ -67,13 +67,13 @@ interactions: content-type: - application/json date: - - Wed, 22 Sep 2021 00:45:30 GMT + - Fri, 24 Sep 2021 23:46:00 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 + - c9e4d79c4a06400aac374b9711bf98f8 schema-id-location: - - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/0469b7e356874374a31df6a027213625?api-version=2020-09-01-preview + - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/c9e4d79c4a06400aac374b9711bf98f8?api-version=2020-09-01-preview schema-version: - '1' schema-versions-location: @@ -110,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":"0469b7e356874374a31df6a027213625"}' + string: '{"id":"c9e4d79c4a06400aac374b9711bf98f8"}' headers: content-type: - application/json date: - - Wed, 22 Sep 2021 00:45:30 GMT + - Fri, 24 Sep 2021 23:46:01 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 + - c9e4d79c4a06400aac374b9711bf98f8 schema-id-location: - - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/0469b7e356874374a31df6a027213625?api-version=2020-09-01-preview + - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/c9e4d79c4a06400aac374b9711bf98f8?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 337f4d08bfb9..d3b4e6df3427 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:89eef0c1-0916-4518-aaa0-63459130469a_G15, + [MGResponseHttpError=BadRequest]. TrackingId:21ad828b-f18a-41e9-b6b2-a7999b16edf0_G16, SystemTracker:swathip-test-eventhubs.servicebus.windows.net:$schemagroups\/getSchemaById\/a, - Timestamp:2021-09-22T00:45:32"}' + Timestamp:2021-09-24T23:46:03"}' headers: content-type: - application/json date: - - Wed, 22 Sep 2021 00:45:31 GMT + - Fri, 24 Sep 2021 23:46:02 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:52b44c02-c087-449e-bd04-02c7fb57b43d_G15, SystemTracker:swathip-test-eventhubs.servicebus.windows.net:$schemagroups\/getSchemaById\/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, - Timestamp:2021-09-22T00:45:33"}' + not exist. TrackingId:84fba0d2-8892-49c4-83f7-a46bb0c51a72_G16, SystemTracker:swathip-test-eventhubs.servicebus.windows.net:$schemagroups\/getSchemaById\/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, + Timestamp:2021-09-24T23:46:03"}' headers: content-type: - application/json date: - - Wed, 22 Sep 2021 00:45:32 GMT + - Fri, 24 Sep 2021 23:46:03 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 c4d7a39fa68a..1314f6522692 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":"286ba485f55e4c06aac7f5c33d762000"}' + string: '{"id":"9d7f438550c74f65a54fbdf72c6fc2e5"}' headers: content-type: - application/json date: - - Wed, 22 Sep 2021 00:45:40 GMT + - Fri, 24 Sep 2021 19:10:27 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: - - 286ba485f55e4c06aac7f5c33d762000 + - 9d7f438550c74f65a54fbdf72c6fc2e5 schema-id-location: - - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/286ba485f55e4c06aac7f5c33d762000?api-version=2020-09-01-preview + - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/9d7f438550c74f65a54fbdf72c6fc2e5?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":"286ba485f55e4c06aac7f5c33d762000"}' + string: '{"id":"9d7f438550c74f65a54fbdf72c6fc2e5"}' headers: content-type: - application/json date: - - Wed, 22 Sep 2021 00:45:40 GMT + - Fri, 24 Sep 2021 19:10:27 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: - - 286ba485f55e4c06aac7f5c33d762000 + - 9d7f438550c74f65a54fbdf72c6fc2e5 schema-id-location: - - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/286ba485f55e4c06aac7f5c33d762000?api-version=2020-09-01-preview + - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/9d7f438550c74f65a54fbdf72c6fc2e5?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 3dc42f20085e..dd6609a3a1cf 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":"bbb495c5729844bbba2db5dd793b3243"}' + string: '{"id":"96623bcb8c1145ada80fcd5539e2bb38"}' headers: content-type: - application/json date: - - Wed, 22 Sep 2021 00:45:42 GMT + - Fri, 24 Sep 2021 19:10:29 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: - - bbb495c5729844bbba2db5dd793b3243 + - 96623bcb8c1145ada80fcd5539e2bb38 schema-id-location: - - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/bbb495c5729844bbba2db5dd793b3243?api-version=2020-09-01-preview + - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/96623bcb8c1145ada80fcd5539e2bb38?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":"a4a4e528cbd64dce8587e07d1aebc040"}' + string: '{"id":"06471c0b87b642b0b8db01fa7a03c788"}' headers: content-type: - application/json date: - - Wed, 22 Sep 2021 00:45:42 GMT + - Fri, 24 Sep 2021 19:10:29 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: - - a4a4e528cbd64dce8587e07d1aebc040 + - 06471c0b87b642b0b8db01fa7a03c788 schema-id-location: - - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/a4a4e528cbd64dce8587e07d1aebc040?api-version=2020-09-01-preview + - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/06471c0b87b642b0b8db01fa7a03c788?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/a4a4e528cbd64dce8587e07d1aebc040?api-version=2020-09-01-preview + uri: https://fake_resource.servicebus.windows.net/$schemagroups/getSchemaById/06471c0b87b642b0b8db01fa7a03c788?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,15 +115,15 @@ interactions: content-type: - application/json date: - - Wed, 22 Sep 2021 00:45:42 GMT + - Fri, 24 Sep 2021 19:10:30 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: - - a4a4e528cbd64dce8587e07d1aebc040 + - 06471c0b87b642b0b8db01fa7a03c788 schema-id-location: - - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/a4a4e528cbd64dce8587e07d1aebc040?api-version=2020-09-01-preview + - https://swathip-test-eventhubs.servicebus.windows.net:443/$schemagroups/getschemabyid/06471c0b87b642b0b8db01fa7a03c788?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/schemaregistry_preparer.py b/sdk/schemaregistry/azure-schemaregistry/tests/schemaregistry_preparer.py index 511e2b8c147c..9847fb47964a 100644 --- a/sdk/schemaregistry/azure-schemaregistry/tests/schemaregistry_preparer.py +++ b/sdk/schemaregistry/azure-schemaregistry/tests/schemaregistry_preparer.py @@ -30,9 +30,9 @@ ) -SCHEMA_REGISTRY_ENDPOINT_PARAM = "schemaregistry_endpoint" +SCHEMA_REGISTRY_FULLY_QUALIFIED_NAMESPACE_PARAM = "schemaregistry_fully_qualified_namespace" SCHEMA_REGISTRY_GROUP_PARAM = "schemaregistry_group" -SCHEMA_REGISTRY_ENDPOINT_ENV_KEY_NAME = 'SCHEMA_REGISTRY_ENDPOINT' +SCHEMA_REGISTRY_FULLY_QUALIFIED_NAMESPACE_ENV_KEY_NAME = 'SCHEMA_REGISTRY_FULLY_QUALIFIED_NAMESPACE' SCHEMA_REGISTRY_GROUP_ENV_KEY_NAME = 'SCHEMA_REGISTRY_GROUP' @@ -59,12 +59,12 @@ def create_resource(self, name, **kwargs): # TODO: right now the endpoint/group is fixed, as there is no way to create/delete resources using api, in the future we should be able to dynamically create and remove resources if self.is_live: return { - SCHEMA_REGISTRY_ENDPOINT_PARAM: os.environ[SCHEMA_REGISTRY_ENDPOINT_ENV_KEY_NAME], + SCHEMA_REGISTRY_FULLY_QUALIFIED_NAMESPACE_PARAM: os.environ[SCHEMA_REGISTRY_FULLY_QUALIFIED_NAMESPACE_ENV_KEY_NAME], SCHEMA_REGISTRY_GROUP_PARAM: os.environ[SCHEMA_REGISTRY_GROUP_ENV_KEY_NAME] } else: return { - SCHEMA_REGISTRY_ENDPOINT_PARAM: "sr-playground.servicebus.windows.net", + SCHEMA_REGISTRY_FULLY_QUALIFIED_NAMESPACE_PARAM: "sr-playground.servicebus.windows.net", SCHEMA_REGISTRY_GROUP_PARAM: "azsdk_python_test_group" } diff --git a/sdk/schemaregistry/azure-schemaregistry/tests/test_schema_registry.py b/sdk/schemaregistry/azure-schemaregistry/tests/test_schema_registry.py index 863e355ae840..907617a311bf 100644 --- a/sdk/schemaregistry/azure-schemaregistry/tests/test_schema_registry.py +++ b/sdk/schemaregistry/azure-schemaregistry/tests/test_schema_registry.py @@ -27,18 +27,18 @@ from devtools_testutils import AzureTestCase, PowerShellPreparer -SchemaRegistryPowerShellPreparer = functools.partial(PowerShellPreparer, "schemaregistry", schemaregistry_endpoint="fake_resource.servicebus.windows.net/", schemaregistry_group="fakegroup") +SchemaRegistryPowerShellPreparer = functools.partial(PowerShellPreparer, "schemaregistry", schemaregistry_fully_qualified_namespace="fake_resource.servicebus.windows.net/", schemaregistry_group="fakegroup") class SchemaRegistryTests(AzureTestCase): - def create_client(self, endpoint): + def create_client(self, fully_qualified_namespace): credential = self.get_credential(SchemaRegistryClient) - return self.create_client_from_credential(SchemaRegistryClient, credential, fully_qualified_namespace=endpoint) + return self.create_client_from_credential(SchemaRegistryClient, credential, fully_qualified_namespace=fully_qualified_namespace) @SchemaRegistryPowerShellPreparer() - def test_schema_basic(self, schemaregistry_endpoint, schemaregistry_group, **kwargs): - client = self.create_client(schemaregistry_endpoint) + def test_schema_basic(self, schemaregistry_fully_qualified_namespace, schemaregistry_group, **kwargs): + client = self.create_client(schemaregistry_fully_qualified_namespace) 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"]}]}""" format = "Avro" @@ -62,8 +62,8 @@ def test_schema_basic(self, schemaregistry_endpoint, schemaregistry_group, **kwa assert returned_schema_properties.format == "Avro" @SchemaRegistryPowerShellPreparer() - def test_schema_update(self, schemaregistry_endpoint, schemaregistry_group, **kwargs): - client = self.create_client(schemaregistry_endpoint) + def test_schema_update(self, schemaregistry_fully_qualified_namespace, schemaregistry_group, **kwargs): + client = self.create_client(schemaregistry_fully_qualified_namespace) schema_name = self.get_resource_name('test-schema-update') 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"]}]}""" format = "Avro" @@ -89,8 +89,8 @@ def test_schema_update(self, schemaregistry_endpoint, schemaregistry_group, **kw assert new_schema.properties.format == "Avro" @SchemaRegistryPowerShellPreparer() - def test_schema_same_twice(self, schemaregistry_endpoint, schemaregistry_group, **kwargs): - client = self.create_client(schemaregistry_endpoint) + def test_schema_same_twice(self, schemaregistry_fully_qualified_namespace, schemaregistry_group, **kwargs): + client = self.create_client(schemaregistry_fully_qualified_namespace) schema_name = self.get_resource_name('test-schema-twice') schema_str = """{"namespace":"example.avro","type":"record","name":"User","fields":[{"name":"name","type":"string"},{"name":"age","type":["int","null"]},{"name":"city","type":["string","null"]}]}""" format = "Avro" @@ -99,9 +99,9 @@ def test_schema_same_twice(self, schemaregistry_endpoint, schemaregistry_group, assert schema_properties.id == schema_properties_second.id @SchemaRegistryPowerShellPreparer() - def test_schema_negative_wrong_credential(self, schemaregistry_endpoint, schemaregistry_group, **kwargs): + def test_schema_negative_wrong_credential(self, schemaregistry_fully_qualified_namespace, schemaregistry_group, **kwargs): credential = ClientSecretCredential(tenant_id="fake", client_id="fake", client_secret="fake") - client = SchemaRegistryClient(fully_qualified_namespace=schemaregistry_endpoint, credential=credential) + client = SchemaRegistryClient(fully_qualified_namespace=schemaregistry_fully_qualified_namespace, credential=credential) schema_name = self.get_resource_name('test-schema-negative') 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"]}]}""" format = "Avro" @@ -109,7 +109,7 @@ def test_schema_negative_wrong_credential(self, schemaregistry_endpoint, schemar client.register_schema(schemaregistry_group, schema_name, schema_str, format) @SchemaRegistryPowerShellPreparer() - def test_schema_negative_wrong_endpoint(self, schemaregistry_endpoint, schemaregistry_group, **kwargs): + def test_schema_negative_wrong_endpoint(self, schemaregistry_fully_qualified_namespace, schemaregistry_group, **kwargs): client = self.create_client("nonexist.servicebus.windows.net") schema_name = self.get_resource_name('test-schema-nonexist') 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"]}]}""" @@ -118,8 +118,8 @@ def test_schema_negative_wrong_endpoint(self, schemaregistry_endpoint, schemareg client.register_schema(schemaregistry_group, schema_name, schema_str, format) @SchemaRegistryPowerShellPreparer() - def test_schema_negative_no_schema(self, schemaregistry_endpoint, schemaregistry_group, **kwargs): - client = self.create_client(schemaregistry_endpoint) + def test_schema_negative_no_schema(self, schemaregistry_fully_qualified_namespace, schemaregistry_group, **kwargs): + client = self.create_client(schemaregistry_fully_qualified_namespace) with pytest.raises(HttpResponseError): client.get_schema('a')