public void TestFilterMinInSync() { var node = new NodeMock(); var routes = new Dictionary <string, Partition[]> { { "test1p", new[] { new Partition { Id = 0, Leader = node } } }, { "test2p", new[] { new Partition { Id = 1, Leader = new NodeMock(), NbIsr = 1 }, new Partition { Id = 2, Leader = node }, new Partition { Id = 3, Leader = new NodeMock() } } }, }; var routingTable = new RoutingTable(routes); Assert.AreEqual(1, routingTable.GetPartitions("test1p").Length); Assert.AreEqual(3, routingTable.GetPartitions("test2p").Length); routingTable = new RoutingTable(routingTable, 1); Assert.AreEqual(0, routingTable.GetPartitions("test1p").Length); Assert.AreEqual(1, routingTable.GetPartitions("test2p").Length); }
public void TestSignalDeadNode() { var node = new NodeMock(); var routes = new Dictionary <string, Partition[]> { { "test1p", new[] { new Partition { Id = 0, Leader = node } } }, { "test2p", new[] { new Partition { Id = 1, Leader = new NodeMock() }, new Partition { Id = 2, Leader = node }, new Partition { Id = 3, Leader = new NodeMock() } } }, }; var routingTable = new RoutingTable(routes); Assert.AreEqual(1, routingTable.GetPartitions("test1p").Length); Assert.AreEqual(3, routingTable.GetPartitions("test2p").Length); routingTable = new RoutingTable(routingTable, node); Assert.AreEqual(0, routingTable.GetPartitions("test1p").Length); Assert.AreEqual(2, routingTable.GetPartitions("test2p").Length); }
public void TestRoutingTableReturnsEmptyForAbsentTopic() { var node = new NodeMock(); var routes = new Dictionary <string, Partition[]> { { "test1p", new[] { new Partition { Id = 0, Leader = node } } }, }; var routingTable = new RoutingTable(routes); Assert.Less(0, routingTable.GetPartitions("test1p").Length); Assert.AreEqual(0, routingTable.GetPartitions("tortemoque").Length); }
void AssertRoutingTablesAreEqual(RoutingTable expectedRoutingTable, RoutingTable routingTable, IEnumerable <string> topics) { foreach (var topic in topics) { var expectedPartitions = expectedRoutingTable.GetPartitions(topic); var partitions = routingTable.GetPartitions(topic); Assert.AreEqual(expectedPartitions.Length, partitions.Length); for (int i = 0; i < expectedPartitions.Length; i++) { Assert.AreEqual(expectedPartitions[i].Id, partitions[i].Id); Assert.AreEqual(expectedPartitions[i].Leader.Name, partitions[i].Leader.Name); } } }
public void TestRoutingTableReturnsPartitions() { var node = new NodeMock(); var routes = new Dictionary <string, Partition[]> { { "test1p", new[] { new Partition { Id = 0, Leader = node } } }, }; var routingTable = new RoutingTable(routes); var partitions = routingTable.GetPartitions("test1p"); Assert.AreEqual(1, partitions.Length); Assert.AreEqual(0, partitions[0].Id); Assert.AreSame(node, partitions[0].Leader); }