-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix][admin] Report earliest msg in partitioned backlog (#19465)
Co-authored-by: tison <wander4096@gmail.com>
- Loading branch information
1 parent
e5e853b
commit d2300e4
Showing
6 changed files
with
204 additions
and
1 deletion.
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
82 changes: 82 additions & 0 deletions
82
...src/test/java/org/apache/pulsar/common/policies/data/stats/SubscriptionStatsImplTest.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,82 @@ | ||
/* | ||
* 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.common.policies.data.stats; | ||
|
||
import static org.testng.Assert.assertEquals; | ||
import org.testng.annotations.Test; | ||
|
||
public class SubscriptionStatsImplTest { | ||
|
||
@Test | ||
public void testReset() { | ||
SubscriptionStatsImpl stats = new SubscriptionStatsImpl(); | ||
stats.earliestMsgPublishTimeInBacklog = 1L; | ||
stats.reset(); | ||
assertEquals(stats.earliestMsgPublishTimeInBacklog, 0L); | ||
|
||
} | ||
|
||
@Test | ||
public void testAdd_EarliestMsgPublishTimeInBacklogs_Earliest() { | ||
SubscriptionStatsImpl stats1 = new SubscriptionStatsImpl(); | ||
stats1.earliestMsgPublishTimeInBacklog = 10L; | ||
|
||
SubscriptionStatsImpl stats2 = new SubscriptionStatsImpl(); | ||
stats2.earliestMsgPublishTimeInBacklog = 20L; | ||
|
||
SubscriptionStatsImpl aggregate = stats1.add(stats2); | ||
assertEquals(aggregate.earliestMsgPublishTimeInBacklog, 10L); | ||
} | ||
|
||
@Test | ||
public void testAdd_EarliestMsgPublishTimeInBacklogs_First0() { | ||
SubscriptionStatsImpl stats1 = new SubscriptionStatsImpl(); | ||
stats1.earliestMsgPublishTimeInBacklog = 0L; | ||
|
||
SubscriptionStatsImpl stats2 = new SubscriptionStatsImpl(); | ||
stats2.earliestMsgPublishTimeInBacklog = 20L; | ||
|
||
SubscriptionStatsImpl aggregate = stats1.add(stats2); | ||
assertEquals(aggregate.earliestMsgPublishTimeInBacklog, 20L); | ||
} | ||
|
||
@Test | ||
public void testAdd_EarliestMsgPublishTimeInBacklogs_Second0() { | ||
SubscriptionStatsImpl stats1 = new SubscriptionStatsImpl(); | ||
stats1.earliestMsgPublishTimeInBacklog = 10L; | ||
|
||
SubscriptionStatsImpl stats2 = new SubscriptionStatsImpl(); | ||
stats2.earliestMsgPublishTimeInBacklog = 0L; | ||
|
||
SubscriptionStatsImpl aggregate = stats1.add(stats2); | ||
assertEquals(aggregate.earliestMsgPublishTimeInBacklog, 10L); | ||
} | ||
|
||
@Test | ||
public void testAdd_EarliestMsgPublishTimeInBacklogs_Zero() { | ||
SubscriptionStatsImpl stats1 = new SubscriptionStatsImpl(); | ||
stats1.earliestMsgPublishTimeInBacklog = 0L; | ||
|
||
SubscriptionStatsImpl stats2 = new SubscriptionStatsImpl(); | ||
stats2.earliestMsgPublishTimeInBacklog = 0L; | ||
|
||
SubscriptionStatsImpl aggregate = stats1.add(stats2); | ||
assertEquals(aggregate.earliestMsgPublishTimeInBacklog, 0L); | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
...common/src/test/java/org/apache/pulsar/common/policies/data/stats/TopicStatsImplTest.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,81 @@ | ||
/* | ||
* 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.common.policies.data.stats; | ||
|
||
import static org.testng.Assert.assertEquals; | ||
import org.testng.annotations.Test; | ||
|
||
public class TopicStatsImplTest { | ||
|
||
@Test | ||
public void testReset() { | ||
TopicStatsImpl stats = new TopicStatsImpl(); | ||
stats.earliestMsgPublishTimeInBacklogs = 1L; | ||
stats.reset(); | ||
assertEquals(stats.earliestMsgPublishTimeInBacklogs, 0L); | ||
} | ||
|
||
@Test | ||
public void testAdd_EarliestMsgPublishTimeInBacklogs_Earliest() { | ||
TopicStatsImpl stats1 = new TopicStatsImpl(); | ||
stats1.earliestMsgPublishTimeInBacklogs = 10L; | ||
|
||
TopicStatsImpl stats2 = new TopicStatsImpl(); | ||
stats2.earliestMsgPublishTimeInBacklogs = 20L; | ||
|
||
TopicStatsImpl aggregate = stats1.add(stats2); | ||
assertEquals(aggregate.earliestMsgPublishTimeInBacklogs, 10L); | ||
} | ||
|
||
@Test | ||
public void testAdd_EarliestMsgPublishTimeInBacklogs_First0() { | ||
TopicStatsImpl stats1 = new TopicStatsImpl(); | ||
stats1.earliestMsgPublishTimeInBacklogs = 0L; | ||
|
||
TopicStatsImpl stats2 = new TopicStatsImpl(); | ||
stats2.earliestMsgPublishTimeInBacklogs = 20L; | ||
|
||
TopicStatsImpl aggregate = stats1.add(stats2); | ||
assertEquals(aggregate.earliestMsgPublishTimeInBacklogs, 20L); | ||
} | ||
|
||
@Test | ||
public void testAdd_EarliestMsgPublishTimeInBacklogs_Second0() { | ||
TopicStatsImpl stats1 = new TopicStatsImpl(); | ||
stats1.earliestMsgPublishTimeInBacklogs = 10L; | ||
|
||
TopicStatsImpl stats2 = new TopicStatsImpl(); | ||
stats2.earliestMsgPublishTimeInBacklogs = 0L; | ||
|
||
TopicStatsImpl aggregate = stats1.add(stats2); | ||
assertEquals(aggregate.earliestMsgPublishTimeInBacklogs, 10L); | ||
} | ||
|
||
@Test | ||
public void testAdd_EarliestMsgPublishTimeInBacklogs_Zero() { | ||
TopicStatsImpl stats1 = new TopicStatsImpl(); | ||
stats1.earliestMsgPublishTimeInBacklogs = 0L; | ||
|
||
TopicStatsImpl stats2 = new TopicStatsImpl(); | ||
stats2.earliestMsgPublishTimeInBacklogs = 0L; | ||
|
||
TopicStatsImpl aggregate = stats1.add(stats2); | ||
assertEquals(aggregate.earliestMsgPublishTimeInBacklogs, 0L); | ||
} | ||
} |