Skip to content

Commit

Permalink
revert un-needed change in test helper
Browse files Browse the repository at this point in the history
  • Loading branch information
bohhyang committed May 16, 2024
1 parent df81fe0 commit 3cbd628
Showing 1 changed file with 5 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.mockito.Mockito;

import static org.mockito.Matchers.anyInt;
Expand Down Expand Up @@ -78,19 +77,6 @@ public static List<TrackerClient> mockTrackerClients(int numTrackerClients,
return mockTrackerClients(numTrackerClients, callCountList, outstandingCallCountList, latencyList, outstandingLatencyList, errorCountList, false, doNotLoadBalance);
}

public static List<TrackerClient> mockTrackerClients(int numTrackerClients, List<Integer> callCountList,
List<Integer> outstandingCallCountList, List<Long> latencyList, List<Long> outstandingLatencyList,
List<Integer> errorCountList, boolean doNotSlowStart, List<Boolean> doNotLoadBalance)
{
List<Map<ErrorType, Integer>> errorTypeCountsList = errorCountList.stream().map(count -> {
Map<ErrorType, Integer> errorTypeCounts = new HashMap<>();
errorTypeCounts.put(ErrorType.SERVER_ERROR, count);
return errorTypeCounts;
}).collect(Collectors.toList());
return mockTrackerClients(numTrackerClients, callCountList, outstandingCallCountList, latencyList,
outstandingLatencyList, errorCountList, doNotSlowStart, doNotLoadBalance, errorTypeCountsList);
}

/**
* Mock a list of {@link TrackerClient} for testing
*
Expand All @@ -100,13 +86,11 @@ public static List<TrackerClient> mockTrackerClients(int numTrackerClients, List
* @param latencyList The latency of each host
* @param outstandingLatencyList The outstanding latency of each host
* @param errorCountList The error count of each host
* @param errorTypeCounts The error count by type of each host
* @return A list of mocked {@link TrackerClient}
*/
public static List<TrackerClient> mockTrackerClients(int numTrackerClients, List<Integer> callCountList,
List<Integer> outstandingCallCountList, List<Long> latencyList, List<Long> outstandingLatencyList,
List<Integer> errorCountList, boolean doNotSlowStart, List<Boolean> doNotLoadBalance,
List<Map<ErrorType, Integer>> errorTypeCounts)
List<Integer> errorCountList, boolean doNotSlowStart, List<Boolean> doNotLoadBalance)
{
List<TrackerClient> trackerClients = new ArrayList<>();
for (int index = 0; index < numTrackerClients; index ++)
Expand All @@ -115,6 +99,8 @@ public static List<TrackerClient> mockTrackerClients(int numTrackerClients, List
TrackerClient trackerClient = Mockito.mock(TrackerClient.class);
CallTracker callTracker = Mockito.mock(CallTracker.class);
LongStats longStats = new LongStats(callCountList.get(index), latencyList.get(index), 0, 0, 0, 0, 0, 0, 0);
Map<ErrorType, Integer> errorTypeCounts = new HashMap<>();
errorTypeCounts.put(ErrorType.SERVER_ERROR, errorCountList.get(index));

CallTrackerImpl.CallTrackerStats callStats = new CallTrackerImpl.CallTrackerStats(
RelativeLoadBalancerStrategyFactory.DEFAULT_UPDATE_INTERVAL_MS,
Expand All @@ -129,8 +115,8 @@ public static List<TrackerClient> mockTrackerClients(int numTrackerClients, List
RelativeLoadBalancerStrategyFactory.DEFAULT_UPDATE_INTERVAL_MS - outstandingLatencyList.get(index),
outstandingCallCountList.get(index),
longStats,
errorTypeCounts.get(index),
errorTypeCounts.get(index));
errorTypeCounts,
errorTypeCounts);

Mockito.when(trackerClient.getCallTracker()).thenReturn(callTracker);
Mockito.when(callTracker.getCallStats()).thenReturn(callStats);
Expand Down

0 comments on commit 3cbd628

Please sign in to comment.