Skip to content

Commit

Permalink
[fix][test] Fix test testThreadSwitchOfZkMetadataStore
Browse files Browse the repository at this point in the history
  • Loading branch information
liangyepianzhou committed Jul 7, 2023
1 parent 1dbc723 commit e6d4f09
Showing 1 changed file with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -396,33 +396,29 @@ public void testDeleteUnusedDirectories(String provider, Supplier<String> urlSup
@DataProvider(name = "conditionOfSwitchThread")
public Object[][] conditionOfSwitchThread(){
return new Object[][]{
{false, false},
{false, true},
{true, false},
{true, true}
{false},
{true},
{false},
{true}
};
}

@Test(dataProvider = "conditionOfSwitchThread")
public void testThreadSwitchOfZkMetadataStore(boolean hasSynchronizer, boolean enabledBatch) throws Exception {
public void testThreadSwitchOfZkMetadataStore(boolean enabledBatch) throws Exception {
final String prefix = newKey();
final String metadataStoreName = UUID.randomUUID().toString().replaceAll("-", "");
final String metadataStoreNamePrefix = "metadata-store";
MetadataStoreConfig.MetadataStoreConfigBuilder builder =
MetadataStoreConfig.builder().metadataStoreName(metadataStoreName);
builder.fsyncEnable(false);
MetadataStoreConfig.builder();
builder.batchingEnabled(enabledBatch);
if (!hasSynchronizer) {
builder.synchronizer(null);
}
MetadataStoreConfig config = builder.build();
@Cleanup
ZKMetadataStore store = (ZKMetadataStore) MetadataStoreFactory.create(zks.getConnectionString(), config);

final Runnable verify = () -> {
String currentThreadName = Thread.currentThread().getName();
String errorMessage = String.format("Expect to switch to thread %s, but currently it is thread %s",
metadataStoreName, currentThreadName);
assertTrue(Thread.currentThread().getName().startsWith(metadataStoreName), errorMessage);
metadataStoreNamePrefix, currentThreadName);
assertTrue(Thread.currentThread().getName().startsWith(metadataStoreNamePrefix), errorMessage);
};

// put with node which has parent(but the parent node is not exists).
Expand Down

1 comment on commit e6d4f09

@dave2wave
Copy link
Member

@dave2wave dave2wave commented on e6d4f09 Jul 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make sure that PRs pass checkstyle

18:05:08  [INFO] --- maven-checkstyle-plugin:3.1.2:check (checkstyle) @ pulsar-metadata ---
18:05:08  [INFO] There is 1 error reported by Checkstyle 8.37 with /home/ubuntu/workspace/_Apache_Pulsar_Build_branch-2.10/buildtools/src/main/resources/pulsar/checkstyle.xml ruleset.
18:05:08  [ERROR] src/test/java/org/apache/pulsar/metadata/MetadataStoreTest.java:[33,8] (imports) UnusedImports: Unused import: java.util.UUID.

Please sign in to comment.