提交 c952b6b5 编写于 作者: C congbo 提交者: Sijie Guo

Modify the logical for getting schema compatibility strategy (#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
上级 387e2907
......@@ -2044,7 +2044,13 @@ public abstract class NamespacesBase extends AdminResource {
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
......
......@@ -45,6 +45,7 @@ import java.util.concurrent.ThreadLocalRandom;
import static org.apache.pulsar.common.naming.TopicName.PUBLIC_TENANT;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@Slf4j
......@@ -233,6 +234,9 @@ public class SchemaCompatibilityCheckTest extends MockedPulsarServiceBaseTest {
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());
......
......@@ -1082,7 +1082,7 @@ public class CmdNamespaces extends CmdBase {
}
}
@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;
......@@ -1095,7 +1095,7 @@ public class CmdNamespaces extends CmdBase {
}
}
@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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册