Skip to content

Commit

Permalink
Modify the logical for getting schema compatibility strategy (apache#…
Browse files Browse the repository at this point in the history
…5785)

### Motivation
Modify the logical for getting schema compatibility strategy, if schemaCompatibilityStrategy = SchemaCompatibilityStrategy.UNDEFINED return the SchemaAutoUpdateCompatibilityStrategy. 

### Verifying this change
Add the tests for it
  • Loading branch information
congbobo184 authored and sijie committed Dec 3, 2019
1 parent 387e290 commit c952b6b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2044,7 +2044,13 @@ protected SchemaAutoUpdateCompatibilityStrategy internalGetSchemaAutoUpdateCompa

protected SchemaCompatibilityStrategy internalGetSchemaCompatibilityStrategy() {
validateAdminAccessForTenant(namespaceName.getTenant());
return getNamespacePolicies(namespaceName).schema_compatibility_strategy;
Policies policies = getNamespacePolicies(namespaceName);
SchemaCompatibilityStrategy schemaCompatibilityStrategy = policies.schema_compatibility_strategy;
if (schemaCompatibilityStrategy == SchemaCompatibilityStrategy.UNDEFINED){
schemaCompatibilityStrategy = SchemaCompatibilityStrategy
.fromAutoUpdatePolicy(policies.schema_auto_update_compatibility_strategy);
}
return schemaCompatibilityStrategy;
}

@Deprecated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@

import static org.apache.pulsar.common.naming.TopicName.PUBLIC_TENANT;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;


@Slf4j
Expand Down Expand Up @@ -233,6 +234,9 @@ public void testIsAutoUpdateSchema(SchemaCompatibilityStrategy schemaCompatibili
Sets.newHashSet(CLUSTER_NAME)
);

assertEquals(admin.namespaces().getSchemaCompatibilityStrategy(namespaceName.toString()),
SchemaCompatibilityStrategy.FULL);

admin.namespaces().setSchemaCompatibilityStrategy(namespaceName.toString(), schemaCompatibilityStrategy);
admin.schemas().createSchema(fqtn, Schema.AVRO(Schemas.PersonOne.class).getSchemaInfo());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,7 @@ void run() throws PulsarAdminException {
}
}

@Parameters(commandDescription = "Get the schema auto-update strategy for a namespace")
@Parameters(commandDescription = "Get the schema auto-update strategy for a namespace", hidden = true)
private class GetSchemaAutoUpdateStrategy extends CliCommand {
@Parameter(description = "tenant/namespace", required = true)
private java.util.List<String> params;
Expand All @@ -1095,7 +1095,7 @@ void run() throws PulsarAdminException {
}
}

@Parameters(commandDescription = "Set the schema auto-update strategy for a namespace")
@Parameters(commandDescription = "Set the schema auto-update strategy for a namespace", hidden = true)
private class SetSchemaAutoUpdateStrategy extends CliCommand {
@Parameter(description = "tenant/namespace", required = true)
private java.util.List<String> params;
Expand Down

0 comments on commit c952b6b

Please sign in to comment.