Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Broker] Fix read schema compatibility strategy priority
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
- Loading branch information
Showing
9 changed files
with
145 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
...java/org/apache/pulsar/broker/admin/AdminApiNamespaceSchemaCompatibilityStrategyTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.apache.pulsar.broker.admin; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNull; | ||
import com.google.common.collect.Sets; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.apache.pulsar.broker.auth.MockedPulsarServiceBaseTest; | ||
import org.apache.pulsar.client.admin.PulsarAdminException; | ||
import org.apache.pulsar.common.policies.data.ClusterData; | ||
import org.apache.pulsar.common.policies.data.SchemaAutoUpdateCompatibilityStrategy; | ||
import org.apache.pulsar.common.policies.data.SchemaCompatibilityStrategy; | ||
import org.apache.pulsar.common.policies.data.TenantInfoImpl; | ||
import org.awaitility.Awaitility; | ||
import org.testng.annotations.AfterMethod; | ||
import org.testng.annotations.BeforeMethod; | ||
import org.testng.annotations.Test; | ||
|
||
@Slf4j | ||
@Test(groups = "broker-admin") | ||
public class AdminApiNamespaceSchemaCompatibilityStrategyTest extends MockedPulsarServiceBaseTest { | ||
private final String tenant = "test-tenant"; | ||
private final String namespace = tenant + "/" + "test-ns"; | ||
|
||
@BeforeMethod | ||
@Override | ||
public void setup() throws Exception { | ||
super.internalSetup(); | ||
|
||
// Setup namespaces | ||
admin.clusters() | ||
.createCluster("test", ClusterData.builder().serviceUrl(pulsar.getWebServiceAddress()).build()); | ||
TenantInfoImpl tenantInfo = new TenantInfoImpl(Sets.newHashSet("role1", "role2"), Sets.newHashSet("test")); | ||
admin.tenants().createTenant(tenant, tenantInfo); | ||
admin.namespaces().createNamespace(namespace, Sets.newHashSet("test")); | ||
} | ||
|
||
@AfterMethod(alwaysRun = true) | ||
@Override | ||
public void cleanup() throws Exception { | ||
super.internalCleanup(); | ||
} | ||
|
||
@Test | ||
public void testGetSchemaCompatibilityStrategy() throws PulsarAdminException { | ||
assertEquals(admin.namespaces().getSchemaCompatibilityStrategy(namespace), SchemaCompatibilityStrategy.UNDEFINED); | ||
} | ||
|
||
@Test | ||
public void testGetSchemaAutoUpdateCompatibilityStrategy() throws PulsarAdminException { | ||
assertNull(admin.namespaces().getSchemaAutoUpdateCompatibilityStrategy(namespace)); | ||
} | ||
|
||
@Test | ||
public void testGetSchemaCompatibilityStrategyWithBackwardSchemaAutoUpdateCompatibilityStrategy() | ||
throws PulsarAdminException { | ||
assertEquals(admin.namespaces().getSchemaCompatibilityStrategy(namespace), SchemaCompatibilityStrategy.UNDEFINED); | ||
|
||
admin.namespaces() | ||
.setSchemaAutoUpdateCompatibilityStrategy(namespace, SchemaAutoUpdateCompatibilityStrategy.Forward); | ||
Awaitility.await().untilAsserted( | ||
() -> assertEquals(admin.namespaces().getSchemaAutoUpdateCompatibilityStrategy(namespace), | ||
SchemaAutoUpdateCompatibilityStrategy.Forward)); | ||
|
||
admin.namespaces().setSchemaCompatibilityStrategy(namespace, SchemaCompatibilityStrategy.BACKWARD); | ||
Awaitility.await().untilAsserted( | ||
() -> assertEquals(admin.namespaces().getSchemaCompatibilityStrategy(namespace), | ||
SchemaCompatibilityStrategy.BACKWARD)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters