Skip to content

Commit

Permalink
Fix up testDontFailRepairAfterTopologyChangeIncrementalRepair so th…
Browse files Browse the repository at this point in the history
…at the coordinator is the node that gets swapped out.
  • Loading branch information
Miles-Garnsey committed Nov 10, 2022
1 parent 16f0052 commit c186b9a
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ public void testHangingRepair() throws InterruptedException, ReaperException, JM
context.config = new ReaperApplicationConfiguration();
final Semaphore mutex = new Semaphore(0);
final JmxProxy jmx = JmxProxyTest.mockJmxProxyImpl();
Map<String, String> endpointToHostIDMap = endpointToHostIDMap();
when(jmx.getEndpointToHostId()).thenReturn(endpointToHostIDMap);
when(jmx.getClusterName()).thenReturn(cluster.getName());
when(jmx.isConnectionAlive()).thenReturn(true);
when(jmx.getRangeToEndpointMap(anyString())).thenReturn(RepairRunnerTest.sixNodeCluster());
Expand Down Expand Up @@ -247,6 +249,7 @@ public void run() {
when(clusterFacade.connect(any(Cluster.class), any())).thenReturn(jmx);
when(clusterFacade.nodeIsAccessibleThroughJmx(any(), any())).thenReturn(true);
when(clusterFacade.tokenRangeToEndpoint(any(), anyString(), any())).thenReturn(Lists.newArrayList(nodeSet));
when(clusterFacade.getEndpointToHostId(any())).thenReturn(endpointToHostIDMap);
when(clusterFacade.listActiveCompactions(any())).thenReturn(CompactionStats.builder().withActiveCompactions(
Collections.emptyList()).withPendingCompactions(Optional.of(0)).build());
when(clusterFacade.getRangeToEndpointMap(any(), anyString()))
Expand Down Expand Up @@ -493,6 +496,7 @@ public void testResumeRepair() throws InterruptedException, ReaperException, Mal
Lists.newArrayList("100", "200"), Lists.newArrayList(nodeSet)));
when(clusterFacade.listActiveCompactions(any())).thenReturn(CompactionStats.builder().withActiveCompactions(
Collections.emptyList()).withPendingCompactions(Optional.of(0)).build());
when(clusterFacade.getEndpointToHostId(any())).thenReturn(nodeMap);

context.repairManager = RepairManager.create(
context,
Expand Down Expand Up @@ -1018,10 +1022,10 @@ public void testDontFailRepairAfterTopologyChangeIncrementalRepair() throws Inte
final Set<String> cfNames = Sets.newHashSet("reaper");
final boolean incrementalRepair = true;
final Set<String> nodeSet = Sets.newHashSet("127.0.0.1", "127.0.0.2", "127.0.0.3");
final List<String> nodeSetAfterTopologyChange = Lists.newArrayList("127.0.0.1", "127.0.0.2", "127.0.0.4");
final List<String> nodeSetAfterTopologyChange = Lists.newArrayList("127.0.0.3", "127.0.0.2", "127.0.0.4");
final Map<String, String> nodeMap = ImmutableMap.of("127.0.0.1", "dc1", "127.0.0.2", "dc1", "127.0.0.3", "dc1");
final Map<String, String> nodeMapAfterTopologyChange = ImmutableMap.of(
"127.0.0.1", "dc1", "127.0.0.2", "dc1", "127.0.0.4", "dc1");
"127.0.0.3", "dc1", "127.0.0.2", "dc1", "127.0.0.4", "dc1");
final Set<String> datacenters = Collections.emptySet();
final Set<String> blacklistedTables = Collections.emptySet();
final double intensity = 0.5f;
Expand Down Expand Up @@ -1140,10 +1144,10 @@ protected JmxProxy connectImpl(Node host) throws ReaperException {
.thenReturn((Map) ImmutableMap.of(
Lists.newArrayList("0", "100"), Lists.newArrayList(nodeSetAfterTopologyChange),
Lists.newArrayList("100", "200"), Lists.newArrayList(nodeSetAfterTopologyChange)));
String hostIdToChange = endpointToHostIDMap.get("127.0.0.3");
endpointToHostIDMap.remove("127.0.0.3");
String hostIdToChange = endpointToHostIDMap.get("127.0.0.1");
endpointToHostIDMap.remove("127.0.0.1");
endpointToHostIDMap.put("127.0.0.4", hostIdToChange);
when(clusterFacade.getEndpointToHostId(any())).thenReturn(nodeMapAfterTopologyChange);
when(clusterFacade.getEndpointToHostId(any())).thenReturn(endpointToHostIDMap);
when(clusterFacade.tokenRangeToEndpoint(any(), anyString(), any()))
.thenReturn(Lists.newArrayList(nodeSetAfterTopologyChange));
context.repairManager.resumeRunningRepairRuns();
Expand Down

0 comments on commit c186b9a

Please sign in to comment.