-
Notifications
You must be signed in to change notification settings - Fork 546
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix dualread monitoring log * add retries to some tests for stability
- Loading branch information
Showing
6 changed files
with
85 additions
and
14 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
57 changes: 57 additions & 0 deletions
57
d2/src/test/java/com/linkedin/d2/balancer/dualread/DualReadLoadBalancerMonitorTest.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,57 @@ | ||
package com.linkedin.d2.balancer.dualread; | ||
|
||
import com.linkedin.d2.balancer.properties.UriProperties; | ||
import com.linkedin.d2.util.TestDataHelper; | ||
import org.testng.Assert; | ||
import org.testng.annotations.DataProvider; | ||
import org.testng.annotations.Test; | ||
|
||
import static com.linkedin.d2.util.TestDataHelper.*; | ||
|
||
|
||
public class DualReadLoadBalancerMonitorTest { | ||
|
||
@DataProvider | ||
public Object[][] getEntriesMessageDataProvider() | ||
{ | ||
return new Object[][] { | ||
{ | ||
true, new DualReadLoadBalancerMonitor.CacheEntry<>("", "", PROPERTIES_1), | ||
new DualReadLoadBalancerMonitor.CacheEntry<>("", "", PROPERTIES_2), | ||
"\nOld LB: CacheEntry{_version=, _timeStamp='', _data=UriProperties [_clusterName=TestCluster," | ||
+ " _urisBySchemeAndPartition={http={0=[http://google.com:1], 1=[http://google.com:1]}}," | ||
+ " _partitions={http://google.com:1={0=[ weight =1.0 ], 1=[ weight =2.0 ]}}," | ||
+ " _uriSpecificProperties={}]}\n" | ||
+ "New LB: CacheEntry{_version=, _timeStamp='', " | ||
+ "_data=UriProperties [_clusterName=TestCluster, " | ||
+ "_urisBySchemeAndPartition={http={1=[http://linkedin.com:2]}}, " | ||
+ "_partitions={http://linkedin.com:2={1=[ weight =0.5 ]}}, _uriSpecificProperties={}]}" | ||
}, | ||
{ | ||
false, new DualReadLoadBalancerMonitor.CacheEntry<>("", "", PROPERTIES_1), | ||
new DualReadLoadBalancerMonitor.CacheEntry<>("", "", PROPERTIES_2), | ||
"\nOld LB: CacheEntry{_version=, _timeStamp='', _data=UriProperties [_clusterName=TestCluster," | ||
+ " _urisBySchemeAndPartition={http={1=[http://linkedin.com:2]}}, " | ||
+ "_partitions={http://linkedin.com:2={1=[ weight =0.5 ]}}, _uriSpecificProperties={}]}\n" | ||
+ "New LB: CacheEntry{_version=, _timeStamp='', _data=UriProperties [_clusterName=TestCluster," | ||
+ " _urisBySchemeAndPartition={http={0=[http://google.com:1], 1=[http://google.com:1]}}," | ||
+ " _partitions={http://google.com:1={0=[ weight =1.0 ], 1=[ weight =2.0 ]}}," | ||
+ " _uriSpecificProperties={}]}" | ||
} | ||
}; | ||
} | ||
@Test(dataProvider = "getEntriesMessageDataProvider") | ||
public void testGetEntriesMessage(Boolean isFromNewLb, | ||
DualReadLoadBalancerMonitor.CacheEntry<UriProperties> oldE, | ||
DualReadLoadBalancerMonitor.CacheEntry<UriProperties> newE, | ||
String expected) | ||
{ | ||
DualReadLoadBalancerMonitor.UriPropertiesDualReadMonitor monitor = | ||
new DualReadLoadBalancerMonitor.UriPropertiesDualReadMonitor( | ||
new DualReadLoadBalancerJmx(), TestDataHelper.getClock()); | ||
|
||
Assert.assertEquals(monitor.getEntriesMessage(isFromNewLb, oldE, newE), | ||
expected, | ||
"entry message is not the same"); | ||
} | ||
} |
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