Github user krummas commented on a diff in the pull request:

    https://github.com/apache/cassandra/pull/276#discussion_r222566547
  
    --- Diff: test/unit/org/apache/cassandra/repair/RepairJobTest.java ---
    @@ -0,0 +1,569 @@
    +/*
    + * 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.repair;
    +
    +import java.net.UnknownHostException;
    +import java.util.Arrays;
    +import java.util.Collection;
    +import java.util.HashMap;
    +import java.util.HashSet;
    +import java.util.List;
    +import java.util.Map;
    +import java.util.Set;
    +import java.util.UUID;
    +import java.util.function.Predicate;
    +
    +import com.google.common.collect.Sets;
    +import org.junit.AfterClass;
    +import org.junit.Assert;
    +import org.junit.Test;
    +
    +import org.apache.cassandra.config.DatabaseDescriptor;
    +import org.apache.cassandra.dht.ByteOrderedPartitioner;
    +import org.apache.cassandra.dht.IPartitioner;
    +import org.apache.cassandra.dht.Range;
    +import org.apache.cassandra.dht.Token;
    +import org.apache.cassandra.locator.InetAddressAndPort;
    +import org.apache.cassandra.streaming.PreviewKind;
    +import org.apache.cassandra.utils.ByteBufferUtil;
    +import org.apache.cassandra.utils.FBUtilities;
    +import org.apache.cassandra.utils.MerkleTree;
    +import org.apache.cassandra.utils.MerkleTrees;
    +
    +import static org.junit.Assert.assertEquals;
    +import static org.junit.Assert.assertFalse;
    +import static org.junit.Assert.assertNull;
    +import static org.junit.Assert.assertTrue;
    +
    +public class RepairJobTest
    +{
    +    private static final IPartitioner PARTITIONER = 
ByteOrderedPartitioner.instance;
    +
    +    static InetAddressAndPort addr1;
    +    static InetAddressAndPort addr2;
    +    static InetAddressAndPort addr3;
    +    static InetAddressAndPort addr4;
    +    static InetAddressAndPort addr5;
    +
    +    static Range<Token> range1 = range(0, 1);
    +    static Range<Token> range2 = range(2, 3);
    +    static Range<Token> range3 = range(4, 5);
    +    static RepairJobDesc desc = new RepairJobDesc(UUID.randomUUID(), 
UUID.randomUUID(), "ks", "cf", Arrays.asList());
    +
    +    @AfterClass
    +    public static void reset()
    +    {
    +        FBUtilities.reset();
    +    }
    +
    +    static
    +    {
    +        try
    +        {
    +            addr1 = InetAddressAndPort.getByName("127.0.0.1");
    +            addr2 = InetAddressAndPort.getByName("127.0.0.2");
    +            addr3 = InetAddressAndPort.getByName("127.0.0.3");
    +            addr4 = InetAddressAndPort.getByName("127.0.0.4");
    +            addr5 = InetAddressAndPort.getByName("127.0.0.5");
    +            DatabaseDescriptor.setBroadcastAddress(addr1.address);
    +        }
    +        catch (UnknownHostException e)
    +        {
    +            e.printStackTrace();
    +        }
    +    }
    +
    +    @Test
    +    public void testCreateStandardSyncTasks()
    +    {
    +        testCreateStandardSyncTasks(false);
    +    }
    +
    +    @Test
    +    public void testCreateStandardSyncTasksPullRepair()
    +    {
    +        testCreateStandardSyncTasks(true);
    +    }
    +
    +    public static void testCreateStandardSyncTasks(boolean pullRepair)
    +    {
    +        List<TreeResponse> treeResponses = 
Arrays.asList(treeResponse(addr1, range1, "same",      range2, "same", range3, 
"same"),
    +                                                         
treeResponse(addr2, range1, "different", range2, "same", range3, "different"),
    +                                                         
treeResponse(addr3, range1, "same",      range2, "same", range3, "same"));
    +
    +        Map<SyncNodePair, SyncTask> tasks = 
toMap(RepairJob.createStandardSyncTasks(desc,
    +                                                                           
         treeResponses,
    +                                                                           
         addr1, // local
    +                                                                           
         noTransient(), // transient
    +                                                                           
         false,
    +                                                                           
         pullRepair,
    +                                                                           
         PreviewKind.ALL));
    +
    +        Assert.assertEquals(2, tasks.size());
    +
    +        SyncTask task = tasks.get(pair(addr1, addr2));
    +        Assert.assertTrue(task.isLocal());
    +        Assert.assertTrue(((LocalSyncTask) task).requestRanges);
    +        Assert.assertEquals(!pullRepair, ((LocalSyncTask) 
task).transferRanges);
    +        Assert.assertEquals(Arrays.asList(range1, range3), 
task.rangesToSync);
    +
    +        task = tasks.get(pair(addr2, addr3));
    +        Assert.assertFalse(task.isLocal());
    +        Assert.assertTrue(task instanceof SymmetricRemoteSyncTask);
    +        Assert.assertEquals(Arrays.asList(range1, range3), 
task.rangesToSync);
    +
    +        Assert.assertNull(tasks.get(pair(addr1, addr3)));
    +    }
    +
    +    @Test
    +    public void testStanardSyncTransient()
    --- End diff --
    
    s/Stanard/Standard/ (in the whole file)


---

---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org
For additional commands, e-mail: pr-h...@cassandra.apache.org

Reply via email to