mirror of
https://github.com/apache/druid.git
synced 2025-02-20 00:47:40 +00:00
Moar unit tests
This commit is contained in:
parent
8768406069
commit
74ff07ba3e
@ -73,13 +73,13 @@ public class AnnouncerTest extends CuratorTestBase
|
|||||||
|
|
||||||
announcer.start();
|
announcer.start();
|
||||||
|
|
||||||
Assert.assertArrayEquals(billy, curator.getData().forPath(testPath1));
|
Assert.assertArrayEquals(billy, curator.getData().decompressed().forPath(testPath1));
|
||||||
Assert.assertNull(curator.checkExists().forPath(testPath2));
|
Assert.assertNull(curator.checkExists().forPath(testPath2));
|
||||||
|
|
||||||
announcer.announce(testPath2, billy);
|
announcer.announce(testPath2, billy);
|
||||||
|
|
||||||
Assert.assertArrayEquals(billy, curator.getData().forPath(testPath1));
|
Assert.assertArrayEquals(billy, curator.getData().decompressed().forPath(testPath1));
|
||||||
Assert.assertArrayEquals(billy, curator.getData().forPath(testPath2));
|
Assert.assertArrayEquals(billy, curator.getData().decompressed().forPath(testPath2));
|
||||||
|
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
curator.getCuratorListenable().addListener(
|
curator.getCuratorListenable().addListener(
|
||||||
@ -88,21 +88,21 @@ public class AnnouncerTest extends CuratorTestBase
|
|||||||
@Override
|
@Override
|
||||||
public void eventReceived(CuratorFramework client, CuratorEvent event) throws Exception
|
public void eventReceived(CuratorFramework client, CuratorEvent event) throws Exception
|
||||||
{
|
{
|
||||||
if (event.getType() == CuratorEventType.DELETE && event.getPath().equals(testPath1)) {
|
if (event.getType() == CuratorEventType.CREATE && event.getPath().equals(testPath1)) {
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
curator.delete().forPath(testPath1);
|
curator.delete().forPath(testPath1);
|
||||||
timing.awaitLatch(latch);
|
Assert.assertTrue(timing.awaitLatch(latch));
|
||||||
|
|
||||||
Assert.assertArrayEquals(billy, curator.getData().forPath(testPath1));
|
Assert.assertArrayEquals(billy, curator.getData().decompressed().forPath(testPath1));
|
||||||
Assert.assertArrayEquals(billy, curator.getData().forPath(testPath2));
|
Assert.assertArrayEquals(billy, curator.getData().decompressed().forPath(testPath2));
|
||||||
|
|
||||||
announcer.unannounce(testPath1);
|
announcer.unannounce(testPath1);
|
||||||
Assert.assertNull(curator.checkExists().forPath(testPath1));
|
Assert.assertNull(curator.checkExists().forPath(testPath1));
|
||||||
Assert.assertArrayEquals(billy, curator.getData().forPath(testPath2));
|
Assert.assertArrayEquals(billy, curator.getData().decompressed().forPath(testPath2));
|
||||||
|
|
||||||
announcer.stop();
|
announcer.stop();
|
||||||
|
|
||||||
@ -128,8 +128,8 @@ public class AnnouncerTest extends CuratorTestBase
|
|||||||
announcer.announce(testPath1, billy);
|
announcer.announce(testPath1, billy);
|
||||||
announcer.announce(testPath2, billy);
|
announcer.announce(testPath2, billy);
|
||||||
|
|
||||||
Assert.assertArrayEquals(billy, curator.getData().forPath(testPath1));
|
Assert.assertArrayEquals(billy, curator.getData().decompressed().forPath(testPath1));
|
||||||
Assert.assertArrayEquals(billy, curator.getData().forPath(testPath2));
|
Assert.assertArrayEquals(billy, curator.getData().decompressed().forPath(testPath2));
|
||||||
|
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
curator.getCuratorListenable().addListener(
|
curator.getCuratorListenable().addListener(
|
||||||
@ -149,10 +149,10 @@ public class AnnouncerTest extends CuratorTestBase
|
|||||||
);
|
);
|
||||||
KillSession.kill(curator.getZookeeperClient().getZooKeeper(), server.getConnectString());
|
KillSession.kill(curator.getZookeeperClient().getZooKeeper(), server.getConnectString());
|
||||||
|
|
||||||
timing.awaitLatch(latch);
|
Assert.assertTrue(timing.awaitLatch(latch));
|
||||||
|
|
||||||
Assert.assertArrayEquals(billy, curator.getData().forPath(testPath1));
|
Assert.assertArrayEquals(billy, curator.getData().decompressed().forPath(testPath1));
|
||||||
Assert.assertArrayEquals(billy, curator.getData().forPath(testPath2));
|
Assert.assertArrayEquals(billy, curator.getData().decompressed().forPath(testPath2));
|
||||||
|
|
||||||
announcer.stop();
|
announcer.stop();
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ public class CuratorInventoryManagerTest extends CuratorTestBase
|
|||||||
strategy.setNewContainerLatch(containerLatch);
|
strategy.setNewContainerLatch(containerLatch);
|
||||||
curator.create().withMode(CreateMode.EPHEMERAL).forPath("/container/billy", new byte[]{});
|
curator.create().withMode(CreateMode.EPHEMERAL).forPath("/container/billy", new byte[]{});
|
||||||
|
|
||||||
timing.awaitLatch(containerLatch);
|
Assert.assertTrue(timing.awaitLatch(containerLatch));
|
||||||
strategy.setNewContainerLatch(null);
|
strategy.setNewContainerLatch(null);
|
||||||
|
|
||||||
final Iterable<Map<String, Integer>> inventory = manager.getInventory();
|
final Iterable<Map<String, Integer>> inventory = manager.getInventory();
|
||||||
@ -63,7 +63,7 @@ public class CuratorInventoryManagerTest extends CuratorTestBase
|
|||||||
curator.create().withMode(CreateMode.EPHEMERAL).forPath("/inventory/billy/1", Ints.toByteArray(100));
|
curator.create().withMode(CreateMode.EPHEMERAL).forPath("/inventory/billy/1", Ints.toByteArray(100));
|
||||||
curator.create().withMode(CreateMode.EPHEMERAL).forPath("/inventory/billy/bob", Ints.toByteArray(2287));
|
curator.create().withMode(CreateMode.EPHEMERAL).forPath("/inventory/billy/bob", Ints.toByteArray(2287));
|
||||||
|
|
||||||
timing.awaitLatch(inventoryLatch);
|
Assert.assertTrue(timing.awaitLatch(inventoryLatch));
|
||||||
strategy.setNewInventoryLatch(null);
|
strategy.setNewInventoryLatch(null);
|
||||||
|
|
||||||
verifyInventory(manager);
|
verifyInventory(manager);
|
||||||
@ -72,7 +72,7 @@ public class CuratorInventoryManagerTest extends CuratorTestBase
|
|||||||
strategy.setDeadInventoryLatch(deleteLatch);
|
strategy.setDeadInventoryLatch(deleteLatch);
|
||||||
curator.delete().forPath("/inventory/billy/1");
|
curator.delete().forPath("/inventory/billy/1");
|
||||||
|
|
||||||
timing.awaitLatch(deleteLatch);
|
Assert.assertTrue(timing.awaitLatch(deleteLatch));
|
||||||
strategy.setDeadInventoryLatch(null);
|
strategy.setDeadInventoryLatch(null);
|
||||||
|
|
||||||
Assert.assertEquals(1, manager.getInventoryValue("billy").size());
|
Assert.assertEquals(1, manager.getInventoryValue("billy").size());
|
||||||
@ -82,7 +82,7 @@ public class CuratorInventoryManagerTest extends CuratorTestBase
|
|||||||
strategy.setNewInventoryLatch(inventoryLatch);
|
strategy.setNewInventoryLatch(inventoryLatch);
|
||||||
curator.create().withMode(CreateMode.EPHEMERAL).forPath("/inventory/billy/1", Ints.toByteArray(100));
|
curator.create().withMode(CreateMode.EPHEMERAL).forPath("/inventory/billy/1", Ints.toByteArray(100));
|
||||||
|
|
||||||
timing.awaitLatch(inventoryLatch);
|
Assert.assertTrue(timing.awaitLatch(inventoryLatch));
|
||||||
strategy.setNewInventoryLatch(null);
|
strategy.setNewInventoryLatch(null);
|
||||||
|
|
||||||
verifyInventory(manager);
|
verifyInventory(manager);
|
||||||
@ -104,7 +104,7 @@ public class CuratorInventoryManagerTest extends CuratorTestBase
|
|||||||
);
|
);
|
||||||
|
|
||||||
server.stop();
|
server.stop();
|
||||||
timing.awaitLatch(latch);
|
Assert.assertTrue(timing.awaitLatch(latch));
|
||||||
|
|
||||||
verifyInventory(manager);
|
verifyInventory(manager);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user