예제 #1
0
 private void AssertSameReplicas(IEnumerable <KeyspaceMetadata> keyspaces, IReadOnlyTokenMap expectedTokenMap, IReadOnlyTokenMap actualTokenMap)
 {
     foreach (var k in keyspaces)
     {
         var actual = actualTokenMap.GetByKeyspace(k.Name);
         try
         {
             var expected = expectedTokenMap.GetByKeyspace(k.Name);
             CollectionAssert.AreEqual(expected.Keys, actual.Keys);
             foreach (var kvp in expected)
             {
                 Assert.IsTrue(
                     expected[kvp.Key].SetEquals(actual[kvp.Key]),
                     $"mismatch in keyspace '{k}' and token '{kvp.Key}': " +
                     $"'{string.Join(",", expected[kvp.Key].Select(h => h.Address.ToString()))}' vs " +
                     $"'{string.Join(",", actual[kvp.Key].Select(h => h.Address.ToString()))}'");
             }
         }
         catch (KeyNotFoundException)
         {
             var rf = k.Replication["replication_factor"];
             Assert.AreEqual(10 * 256, actual.Count);
             foreach (var kvp in actual)
             {
                 Assert.AreEqual(rf, kvp.Value.Count);
             }
         }
     }
 }
예제 #2
0
 private void AssertSameReplicas(IEnumerable <KeyspaceMetadata> keyspaces, IReadOnlyTokenMap expectedTokenMap, IReadOnlyTokenMap actualTokenMap)
 {
     foreach (var k in keyspaces)
     {
         var actual   = actualTokenMap.GetByKeyspace(k.Name);
         var expected = expectedTokenMap.GetByKeyspace(k.Name);
         if (expected != null)
         {
             CollectionAssert.AreEqual(expected.Keys, actual.Keys);
             foreach (var kvp in expected)
             {
                 Assert.IsTrue(
                     expected[kvp.Key].SetEquals(actual[kvp.Key]),
                     $"mismatch in keyspace '{k}' and token '{kvp.Key}': " +
                     $"'{string.Join(",", expected[kvp.Key].Select(h => h.Address.ToString()))}' vs " +
                     $"'{string.Join(",", actual[kvp.Key].Select(h => h.Address.ToString()))}'");
             }
         }
         else
         {
             // keyspace is one of the keyspaces that were inserted by the tasks and wasn't removed
             var rf = k.Replication["replication_factor"];
             Assert.AreEqual(10 * 256, actual.Count);
             foreach (var kvp in actual)
             {
                 Assert.AreEqual(rf, kvp.Value.Count);
             }
         }
     }
 }