@Test(expectedExceptions = IllegalStateException.class, expectedExceptionsMessageRegExp = "node\\(id\\) didn't achieve the status running; aborting after 0 seconds with final status: PENDING") public void testIllegalStateExceptionWhenNodeStillPending() { final NodeMetadata pendingNode = new NodeMetadataBuilder().ids("id").status(Status.PENDING).build(); // node always stays pending Predicate<AtomicReference<NodeMetadata>> nodeRunning = new Predicate<AtomicReference<NodeMetadata>>() { @Override public boolean apply(AtomicReference<NodeMetadata> input) { assertEquals(input.get(), pendingNode); return false; } }; AtomicReference<NodeMetadata> atomicNode = Atomics.newReference(pendingNode); try { new PollNodeRunning(nodeRunning).apply(atomicNode); } finally { assertEquals(atomicNode.get(), pendingNode); } }
@Test(expectedExceptions = IllegalStateException.class, expectedExceptionsMessageRegExp = "node\\(id\\) didn't achieve the status running; aborting after 0 seconds with final status: PENDING") public void testIllegalStateExceptionWhenNodeStillPending() { final NodeMetadata pendingNode = new NodeMetadataBuilder().ids("id").status(Status.PENDING).build(); // node always stays pending Predicate<AtomicReference<NodeMetadata>> nodeRunning = new Predicate<AtomicReference<NodeMetadata>>() { @Override public boolean apply(AtomicReference<NodeMetadata> input) { assertEquals(input.get(), pendingNode); return false; } }; AtomicReference<NodeMetadata> atomicNode = Atomics.newReference(pendingNode); try { new PollNodeRunning(nodeRunning).apply(atomicNode); } finally { assertEquals(atomicNode.get(), pendingNode); } }
@Test(expectedExceptions = IllegalStateException.class, expectedExceptionsMessageRegExp = "api response for node\\(id\\) was null") public void testIllegalStateExceptionAndNodeResetWhenRefSetToNull() { final NodeMetadata pendingNode = new NodeMetadataBuilder().ids("id").status(Status.PENDING).build(); Predicate<AtomicReference<NodeMetadata>> nodeRunning = new Predicate<AtomicReference<NodeMetadata>>() { @Override public boolean apply(AtomicReference<NodeMetadata> input) { assertEquals(input.get(), pendingNode); input.set(null); return false; } }; AtomicReference<NodeMetadata> atomicNode = Atomics.newReference(pendingNode); try { new PollNodeRunning(nodeRunning).apply(atomicNode); } finally { assertEquals(atomicNode.get(), pendingNode); } }
@Test(expectedExceptions = IllegalStateException.class, expectedExceptionsMessageRegExp = "api response for node\\(id\\) was null") public void testIllegalStateExceptionAndNodeResetWhenRefSetToNull() { final NodeMetadata pendingNode = new NodeMetadataBuilder().ids("id").status(Status.PENDING).build(); Predicate<AtomicReference<NodeMetadata>> nodeRunning = new Predicate<AtomicReference<NodeMetadata>>() { @Override public boolean apply(AtomicReference<NodeMetadata> input) { assertEquals(input.get(), pendingNode); input.set(null); return false; } }; AtomicReference<NodeMetadata> atomicNode = Atomics.newReference(pendingNode); try { new PollNodeRunning(nodeRunning).apply(atomicNode); } finally { assertEquals(atomicNode.get(), pendingNode); } }
@Test(expectedExceptions = IllegalStateException.class, expectedExceptionsMessageRegExp = "node\\(id\\) terminated") public void testIllegalStateExceptionWhenNodeDied() { final NodeMetadata pendingNode = new NodeMetadataBuilder().ids("id").status(Status.PENDING).build(); final NodeMetadata deadNode = new NodeMetadataBuilder().ids("id").status(Status.TERMINATED).build(); Predicate<AtomicReference<NodeMetadata>> nodeRunning = new Predicate<AtomicReference<NodeMetadata>>() { @Override public boolean apply(AtomicReference<NodeMetadata> input) { assertEquals(input.get(), pendingNode); input.set(deadNode); return false; } }; AtomicReference<NodeMetadata> atomicNode = Atomics.newReference(pendingNode); try { new PollNodeRunning(nodeRunning).apply(atomicNode); } finally { assertEquals(atomicNode.get(), deadNode); } }
@Test(expectedExceptions = IllegalStateException.class, expectedExceptionsMessageRegExp = "node\\(id\\) terminated") public void testIllegalStateExceptionWhenNodeDied() { final NodeMetadata pendingNode = new NodeMetadataBuilder().ids("id").status(Status.PENDING).build(); final NodeMetadata deadNode = new NodeMetadataBuilder().ids("id").status(Status.TERMINATED).build(); Predicate<AtomicReference<NodeMetadata>> nodeRunning = new Predicate<AtomicReference<NodeMetadata>>() { @Override public boolean apply(AtomicReference<NodeMetadata> input) { assertEquals(input.get(), pendingNode); input.set(deadNode); return false; } }; AtomicReference<NodeMetadata> atomicNode = Atomics.newReference(pendingNode); try { new PollNodeRunning(nodeRunning).apply(atomicNode); } finally { assertEquals(atomicNode.get(), deadNode); } }
new PollNodeRunning(retryableNodeRunning).apply(atomicNode);
new PollNodeRunning(retryableNodeRunning).apply(atomicNode);