Nodetool paxos-only repair is no longer incremental

Patch by Ningzi Zhan; reviewed by brandonwilliams, jlewandowski, and
Maxwell Guo for CASSANDRA-18466
This commit is contained in:
Brandon Williams 2023-09-08 09:02:55 -05:00
parent 9ce86e0ff8
commit 4093be5295
3 changed files with 87 additions and 1 deletions

View File

@ -2,6 +2,7 @@
* Fix SAI's SegmentMetadata min and max primary keys (CASSANDRA-18734)
* Remove commons-codec dependency (CASSANDRA-18772)
Merged from 4.1:
* Nodetool paxos-only repair is no longer incremental (CASSANDRA-18466)
Merged from 4.0:
Merged from 3.11:
Merged from 3.0:

View File

@ -149,7 +149,7 @@ public class Repair extends NodeToolCmd
parallelismDegree = RepairParallelism.DATACENTER_AWARE;
options.put(RepairOption.PARALLELISM_KEY, parallelismDegree.getName());
options.put(RepairOption.PRIMARY_RANGE_KEY, Boolean.toString(primaryRange));
options.put(RepairOption.INCREMENTAL_KEY, Boolean.toString(!fullRepair));
options.put(RepairOption.INCREMENTAL_KEY, Boolean.toString(!fullRepair && !(paxosOnly && getPreviewKind() == PreviewKind.NONE)));
options.put(RepairOption.JOB_THREADS_KEY, Integer.toString(numJobThreads));
options.put(RepairOption.TRACE_KEY, Boolean.toString(trace));
options.put(RepairOption.COLUMNFAMILIES_KEY, StringUtils.join(cfnames, ","));

View File

@ -0,0 +1,85 @@
/*
* 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.cassandra.tools;
import java.io.IOException;
import java.util.Arrays;
import java.util.Map;
import org.apache.commons.lang3.ArrayUtils;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.apache.cassandra.repair.messages.RepairOption;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
public class NodeToolCommandTest
{
final NodeProbe nodeProbe = Mockito.mock(NodeProbe.class);
final Output output = Output.CONSOLE;
final NodeProbeFactory repairNodeFactory = new NodeProbeFactory()
{
@Override
public NodeProbe create(String host, int port) throws IOException
{
return nodeProbe;
}
@Override
public NodeProbe create(String host, int port, String username, String password) throws IOException
{
return nodeProbe;
}
};
@Before
public void beforeTest()
{
Mockito.reset(nodeProbe);
when(nodeProbe.getKeyspaces()).thenReturn(Arrays.asList("ks"));
when(nodeProbe.getNonSystemKeyspaces()).thenReturn(Arrays.asList("ks"));
when(nodeProbe.output()).thenReturn(output);
}
private Map<String, String> testRepairCommand(int expectedExitCode, String ...args) throws IOException
{
int result = new NodeTool(repairNodeFactory, output).execute(ArrayUtils.addFirst(args, "repair"));
Assert.assertEquals(result, expectedExitCode);
ArgumentCaptor<Map<String, String>> optCaptor = ArgumentCaptor.forClass(Map.class);
verify(nodeProbe).repairAsync(any(), any(), optCaptor.capture());
return optCaptor.getValue();
}
@Test
public void repairCommandTest() throws IOException
{
Map<String, String> options = testRepairCommand(0, "--paxos-only", "ks");
Assert.assertEquals(options.get(RepairOption.PAXOS_ONLY_KEY), Boolean.toString(true));
Assert.assertEquals(options.get(RepairOption.INCREMENTAL_KEY), Boolean.toString(false));
}
}