Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[SchemaRegistry] Fix broken test recordings #14935

Merged
merged 6 commits into from
Sep 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions sdk/schemaregistry/Azure.Data.SchemaRegistry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,14 @@ Response<SchemaProperties> schemaProperties = client.GetSchema(schemaId);
string schemaContent = schemaProperties.Value.Content;
```

## Troubleshooting

Information on troubleshooting steps will be added as problems are discovered.

## Next steps

Additional information will be available as documents related to Azure Schema Registry are published.

## Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit [cla.microsoft.com][cla].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,85 +22,59 @@ private SchemaRegistryClient CreateClient() =>
Recording.InstrumentClientOptions(new SchemaRegistryClientOptions())
));

private const string SchemaContent = "{\"type\" : \"record\",\"namespace\" : \"TestSchema\",\"name\" : \"Employee\",\"fields\" : [{ \"name\" : \"Name\" , \"type\" : \"string\" },{ \"name\" : \"Age\", \"type\" : \"int\" }]}";

[Ignore("The recording keeping the entire schema content string literally (including surround quotes and backslashes) causing playback to fail.")]
[Test]
public async Task CanRegisterSchema()
{
var client = CreateClient();
var schemaName = "test1";
var groupName = "miyanni_srgroup";
var schemaType = SerializationType.Avro;
var schema = @"
{
""type"" : ""record"",
""namespace"" : ""TestSchema"",
""name"" : ""Employee"",
""fields"" : [
{ ""name"" : ""Name"" , ""type"" : ""string"" },
{ ""name"" : ""Age"", ""type"" : ""int"" }
]
}";

var schemaProperties = await client.RegisterSchemaAsync(groupName, schemaName, schemaType, schema);
var schemaProperties = await client.RegisterSchemaAsync(groupName, schemaName, schemaType, SchemaContent);
Assert.IsNotNull(schemaProperties.Value);
Assert.IsNotNull(schemaProperties.Value.Id);
Assert.IsTrue(Guid.TryParse(schemaProperties.Value.Id, out Guid _));
Assert.AreEqual(schema, schemaProperties.Value.Content);
Assert.AreEqual(SchemaContent, schemaProperties.Value.Content);
}


[Ignore("The recording keeping the entire schema content string literally (including surround quotes and backslashes) causing playback to fail.")]
[Test]
public async Task CanGetSchemaId()
{
var client = CreateClient();
var schemaName = "test1";
var groupName = "miyanni_srgroup";
var schemaType = SerializationType.Avro;
var schema = @"
{
""type"" : ""record"",
""namespace"" : ""TestSchema"",
""name"" : ""Employee"",
""fields"" : [
{ ""name"" : ""Name"" , ""type"" : ""string"" },
{ ""name"" : ""Age"", ""type"" : ""int"" }
]
}";

await client.RegisterSchemaAsync(groupName, schemaName, schemaType, schema);
var schemaProperties = await client.GetSchemaIdAsync(groupName, schemaName, schemaType, schema);
await client.RegisterSchemaAsync(groupName, schemaName, schemaType, SchemaContent);
var schemaProperties = await client.GetSchemaIdAsync(groupName, schemaName, schemaType, SchemaContent);
Assert.IsNotNull(schemaProperties.Value);
Assert.IsNotNull(schemaProperties.Value.Id);
Assert.IsTrue(Guid.TryParse(schemaProperties.Value.Id, out Guid _));
Assert.AreEqual(schema, schemaProperties.Value.Content);
Assert.AreEqual(SchemaContent, schemaProperties.Value.Content);
}

[Ignore("The recording keeping the entire schema content string literally (including surround quotes and backslashes) causing playback to fail.")]
[Test]
public async Task CanGetSchema()
{
var client = CreateClient();
var schemaName = "test1";
var groupName = "miyanni_srgroup";
var schemaType = SerializationType.Avro;
var schema = @"
{
""type"" : ""record"",
""namespace"" : ""TestSchema"",
""name"" : ""Employee"",
""fields"" : [
{ ""name"" : ""Name"" , ""type"" : ""string"" },
{ ""name"" : ""Age"", ""type"" : ""int"" }
]
}";

var registerProperties = await client.RegisterSchemaAsync(groupName, schemaName, schemaType, schema);
var registerProperties = await client.RegisterSchemaAsync(groupName, schemaName, schemaType, SchemaContent);
Assert.IsNotNull(registerProperties.Value.Id);
Assert.IsTrue(Guid.TryParse(registerProperties.Value.Id, out Guid _));

var schemaProperties = await client.GetSchemaAsync(registerProperties.Value.Id);
Assert.IsNotNull(schemaProperties.Value);
Assert.IsNotNull(schemaProperties.Value.Id);
Assert.IsTrue(Guid.TryParse(schemaProperties.Value.Id, out Guid _));
Assert.AreEqual(schema, schemaProperties.Value.Content);
Assert.AreEqual(SchemaContent, schemaProperties.Value.Content);
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading