Skip to content

Commit

Permalink
Default schema compatability to full_transitive (#408)
Browse files Browse the repository at this point in the history
Why?

To enforce data product owners contract with data consumers, we require FULL_TRANSITIVE checks to ensure the new schema version is fully compatible, i.e. both backwards and forwards compatible, with all previous versions of the schema.

Forwards compatibility allows consumers with older schemas to read data produced with a newer schema, (forwards compatibility: old schema reads new data).  This is required to allow data product owners to make changes to their schema without breaking existing clients.

Backwards compatibility allows consumers on a newer schema to read data produced with an older schema, (backwards compatibility: new schema reads only data). This is required to allow consumers to read the history of a topic, which can contain data produced using older schema versions.

Co-authored-by: Andy Coates <[email protected]>
  • Loading branch information
big-andy-coates and Andy Coates authored Oct 21, 2024
1 parent b8be16d commit ed2cc11
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
/** Mutators for mutating Schemas */
public final class SchemaMutators {

public static final String DEFAULT_EVOLUTION = "FORWARD_TRANSITIVE";
public static final String DEFAULT_EVOLUTION = "FULL_TRANSITIVE";

/** defensive */
private SchemaMutators() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,13 @@
import io.confluent.kafka.schemaregistry.ParsedSchema;
import io.confluent.kafka.schemaregistry.avro.AvroSchema;
import io.confluent.kafka.schemaregistry.client.SchemaRegistryClient;
import io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException;
import io.specmesh.kafka.DockerKafkaEnvironment;
import io.specmesh.kafka.KafkaApiSpec;
import io.specmesh.kafka.KafkaEnvironment;
import io.specmesh.kafka.provision.Status.STATE;
import io.specmesh.kafka.provision.schema.SchemaProvisioner;
import io.specmesh.kafka.provision.schema.SchemaProvisioner.Schema;
import io.specmesh.test.TestSpecLoader;
import java.io.IOException;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -176,7 +174,7 @@ void shouldPublishUpdatedSchemas() throws Exception {

@Test
@Order(3)
void shouldRemoveUnspecdSchemas() throws RestClientException, IOException {
void shouldRemoveUnspecdSchemas() throws Exception {

final var subject = "simple.provision_demo._public.NOT_user_signed_up-value";
final var schemaContent =
Expand Down Expand Up @@ -204,7 +202,7 @@ void shouldRemoveUnspecdSchemas() throws RestClientException, IOException {
testCleanUnSpecSchemas();
}

private void testCleanUnSpecSchemas() throws IOException, RestClientException {
private void testCleanUnSpecSchemas() throws Exception {
final var cleanerSet2 =
SchemaProvisioner.provision(
false, true, API_UPDATE_SPEC, "./src/test/resources", srClient);
Expand All @@ -221,7 +219,7 @@ private void testCleanUnSpecSchemas() throws IOException, RestClientException {
"simple.provision_demo._protected.user_info-value"));
}

private void testDryRun(final String subject) throws IOException, RestClientException {
private void testDryRun(final String subject) throws Exception {
// test dry run
final var cleanerSet =
SchemaProvisioner.provision(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
{"name": "fullName", "type": "string"},
{"name": "email", "type": "string"},
{"name": "address", "type": "string"},
{"name": "age", "type": "int"}
{"name": "age", "type": "int"},
{"name": "newThing", "type": [ "null", "string" ], "default": null}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"fields": [
{"name": "fullName", "type": "string"},
{"name": "email", "type": "string"},
{"name": "age", "type": "int"}
{"name": "address", "type": "string"},
{"name": "age", "type": "int"},
{"name": "oldThing", "type": [ "null", "string" ], "default": null}
]
}

0 comments on commit ed2cc11

Please sign in to comment.