Skip to content

Commit

Permalink
Merge branch '5.5.x' into 6.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
rayokota committed Oct 11, 2021
2 parents 794f955 + 6f9129b commit f74b3a5
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,8 @@ public int register(String subject,
}
}
for (SchemaValue schemaValue : deletedVersions) {
if (schemaValue.getId().equals(schema.getId())) {
if (schemaValue.getId().equals(schema.getId())
&& schemaValue.getVersion().compareTo(schema.getVersion()) < 0) {
// Tombstone previous version with the same ID
SchemaKey key = new SchemaKey(schemaValue.getSubject(), schemaValue.getVersion());
kafkaStore.delete(key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,49 @@ public void testRegisterSchemaWithDifferentIdAfterImport() throws Exception {
expectedIdSchema1,
restApp.restClient.registerSchema(SCHEMA_STRING, subject, 1, expectedIdSchema1));
}

@Test
public void testRegisterSchemaWithSameIdAfterImport() throws Exception {
String subject = "testSubject";
String mode = "READWRITE";

// set mode to read write
assertEquals(
mode,
restApp.restClient.setMode(mode).getMode());

int expectedIdSchema1 = 1;
assertEquals("Registering without id should succeed",
expectedIdSchema1,
restApp.restClient.registerSchema(SCHEMA_STRING, subject));

// delete subject so we can switch to import mode
restApp.restClient.deleteSubject(Collections.emptyMap(), subject);

mode = "IMPORT";

// set mode to import
assertEquals(
mode,
restApp.restClient.setMode(mode).getMode());

// register same schema with same id
expectedIdSchema1 = 1;
assertEquals("Registering with id should succeed",
expectedIdSchema1,
restApp.restClient.registerSchema(SCHEMA_STRING, subject, 1, expectedIdSchema1));

// delete subject again
restApp.restClient.deleteSubject(Collections.emptyMap(), subject);

// register same schema with same id
expectedIdSchema1 = 1;
assertEquals("Registering with id should succeed",
expectedIdSchema1,
restApp.restClient.registerSchema(SCHEMA_STRING, subject, 1, expectedIdSchema1));

assertEquals("Getting schema by id should succeed",
SCHEMA_STRING,
restApp.restClient.getVersion(subject, 1).getSchema());
}
}

0 comments on commit f74b3a5

Please sign in to comment.