Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cleanup][broker] Fix ClusterDataImpl#clone and add test #19126

Merged

Conversation

michaeljmarshall
Copy link
Member

Motivation

In #17962, new configurations were added to the ClusterDataImpl without updating the clone method. In #17295, new configurations were incorrectly cloned. None of these "bugs" are in a released version of pulsar.

This PR fixes those issues and adds a test to verify the fixes. One gap on the test is that it won't easily test new fields unless the test is updated. I would guess we need smarter tests to make that work. I'm not aware of any solutions, but if someone has pointers, please let me know.

Modifications

  • Fix ClusterDataImpl#clone

Verifying this change

A new test is added to cover the changes.

Does this pull request potentially affect one of the following parts:

This is an internal change.

Documentation

  • doc-not-needed

Matching PR in forked repository

PR in forked repository: michaeljmarshall#10

@michaeljmarshall michaeljmarshall added type/cleanup Code or doc cleanups e.g. remove the outdated documentation or remove the code no longer in use area/broker labels Jan 3, 2023
@michaeljmarshall michaeljmarshall added this to the 2.12.0 milestone Jan 3, 2023
@michaeljmarshall michaeljmarshall self-assigned this Jan 3, 2023
@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Jan 3, 2023
.migrated(true)
.migratedClusterUrl(new ClusterData.ClusterUrl("pulsar://remote", "pulsar+ssl://remote"))
.build();

Copy link
Member

Choose a reason for hiding this comment

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

I think you should validate each field, so like:

assertEquals("JKS", originalData.getBrokerClientTlsTrustStoreType());

Copy link
Member Author

Choose a reason for hiding this comment

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

I will add a separate test to validate that we correctly implement equals.

Copy link
Member Author

@michaeljmarshall michaeljmarshall Jan 4, 2023

Choose a reason for hiding this comment

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

Actually, my suggested solution to test equals doesn't really make sense, especially because we use an annotation to generate the equals method.

Why do you think it is important to validate each field individually, @nodece?

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I didn't notice the method name. You are right.

public void verifyClone() {
ClusterDataImpl originalData = ClusterDataImpl.builder()
.serviceUrl("pulsar://test")
.serviceUrlTls("pulsar+ssl://test")
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we could use java reflection to test new added fields.

Copy link
Member

Choose a reason for hiding this comment

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

We shouldn't use the reflection. when the field changes, it's going to be a little difficult to maintain.

@nodece
Copy link
Member

nodece commented Jan 4, 2023

/pulsarbot rerun-failure-checks

@codecov-commenter
Copy link

codecov-commenter commented Jan 4, 2023

Codecov Report

Merging #19126 (90c9160) into master (9ec1d07) will decrease coverage by 0.20%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #19126      +/-   ##
============================================
- Coverage     47.43%   47.22%   -0.21%     
- Complexity     9535    10694    +1159     
============================================
  Files           632      712      +80     
  Lines         59839    69645    +9806     
  Branches       6234     7481    +1247     
============================================
+ Hits          28384    32890    +4506     
- Misses        28375    33053    +4678     
- Partials       3080     3702     +622     
Flag Coverage Δ
unittests 47.22% <ø> (-0.21%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
.../pulsar/broker/service/SharedConsumerAssignor.java 3.70% <0.00%> (-64.82%) ⬇️
...rvice/schema/KeyValueSchemaCompatibilityCheck.java 21.62% <0.00%> (-45.95%) ⬇️
...apache/pulsar/broker/service/EntryAndMetadata.java 0.00% <0.00%> (-40.75%) ⬇️
...lsar/broker/loadbalance/impl/ThresholdShedder.java 3.27% <0.00%> (-27.05%) ⬇️
...r/service/AbstractDispatcherMultipleConsumers.java 56.45% <0.00%> (-14.52%) ⬇️
...e/pulsar/broker/service/EntryBatchIndexesAcks.java 82.14% <0.00%> (-10.72%) ⬇️
...org/apache/pulsar/broker/loadbalance/LoadData.java 58.33% <0.00%> (-8.34%) ⬇️
...ersistentStickyKeyDispatcherMultipleConsumers.java 51.96% <0.00%> (-8.34%) ⬇️
...roker/service/persistent/MessageDeduplication.java 43.23% <0.00%> (-7.43%) ⬇️
...sistent/PersistentDispatcherMultipleConsumers.java 51.79% <0.00%> (-7.36%) ⬇️
... and 121 more

@nodece
Copy link
Member

nodece commented Jan 4, 2023

/pulsarbot rerun-failure-checks

@codelipenghui codelipenghui merged commit a2ec02d into apache:master Jan 4, 2023
@michaeljmarshall michaeljmarshall deleted the fix-clone-clusterdataimpl branch January 11, 2023 06:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/broker doc-not-needed Your PR changes do not impact docs type/cleanup Code or doc cleanups e.g. remove the outdated documentation or remove the code no longer in use
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants