DetachCommand extends TopologyCommand { public void setSourceIdentifier(Identifier sourceIdentifier) { this.sourceIdentifier = sourceIdentifier; }  void setStopWaitTime(Measure<TimeUnit> stopWaitTime); void setStopDelay(Measure<TimeUnit> stopDelay); void setSourceIdentifier(Identifier sourceIdentifier); @Override void validate();  }
@Test public void test_validate_failures() { DetachCommand command = newCommand(); command.setSourceIdentifier(Identifier.valueOf("localhost:9410")); command.setOperationType(NODE); command.setDestinationAddress(InetSocketAddress.createUnresolved("localhost", 9410)); assertThat( command::run, is(throwing(instanceOf(IllegalArgumentException.class)).andMessage(is(equalTo("The destination and the source nodes must not be the same"))))); }
@Test public void testDetachNode_success_srcPartOfDestStripe_by_addr() throws IOException { DetachCommand command = newCommand(); command.setSourceIdentifier(Identifier.valueOf(node1_2.getInternalAddress().toString())); command.setOperationType(NODE); command.setDestinationAddress(node1_1.getInternalAddress()); assertDetachNodeSucess(command); }
@Test public void testDetachNode_success_srcPartOfDestStripe_by_uid() throws IOException { DetachCommand command = newCommand(); command.setSourceIdentifier(Identifier.valueOf(node1_2.getUID().toString())); command.setOperationType(NODE); command.setDestinationAddress(node1_1.getInternalAddress()); assertDetachNodeSucess(command); }
@Test public void testDetachNode_success_srcPartOfDestStripe_by_name() throws IOException { DetachCommand command = newCommand(); command.setSourceIdentifier(Identifier.valueOf(node1_2.getName())); command.setOperationType(NODE); command.setDestinationAddress(node1_1.getInternalAddress()); assertDetachNodeSucess(command); }
@Test public void testDetachNode_fail_srcNotPartOfDestStripe() { DetachCommand command = newCommand(); command.setSourceIdentifier(Identifier.valueOf(node1_1.getInternalAddress().toString())); command.setOperationType(NODE); command.setDestinationAddress(node2_1.getInternalAddress()); assertThat( command::run, is(throwing(instanceOf(IllegalStateException.class)).andMessage(containsString("not present in the same stripe")))); }
@Test public void testDetachNode_fail_randomSource() { DetachCommand command = newCommand(); command.setSourceIdentifier(Identifier.valueOf(strayNode.getInternalAddress().toString())); command.setOperationType(NODE); command.setDestinationAddress(cluster.getNode(Testing.N_UIDS[1]).get().getInternalAddress()); assertThat( command::run, is(throwing(instanceOf(IllegalStateException.class)).andMessage(containsString("not part of cluster")))); }
@Test public void testDetachStripe_success_srcPartOfCluster_with_addr() throws IOException { DetachCommand command = newCommand(); command.setSourceIdentifier(Identifier.valueOf(node2_1.getInternalAddress().toString())); command.setOperationType(STRIPE); command.setDestinationAddress(node1_1.getInternalAddress()); assertDetachStripeSuccess(command); }
@Test public void testDetachStripe_success_srcPartOfCluster_with_node_uid() throws IOException { DetachCommand command = newCommand(); command.setSourceIdentifier(Identifier.valueOf(node2_1.getUID().toString())); command.setOperationType(STRIPE); command.setDestinationAddress(node1_1.getInternalAddress()); assertDetachStripeSuccess(command); }
@Test public void testDetachStripe_success_srcPartOfCluster_with_node_name() throws IOException { DetachCommand command = newCommand(); command.setSourceIdentifier(Identifier.valueOf(node2_1.getName())); command.setOperationType(STRIPE); command.setDestinationAddress(node1_1.getInternalAddress()); assertDetachStripeSuccess(command); }
@Test public void testDetachStripe_success_srcPartOfCluster_with_stripe_uid() throws IOException { DetachCommand command = newCommand(); command.setSourceIdentifier(Identifier.valueOf(Testing.S_UIDS[2].toString())); command.setOperationType(STRIPE); command.setDestinationAddress(node1_1.getInternalAddress()); assertDetachStripeSuccess(command); }
@Test public void testDetachStripe_success_srcPartOfCluster_with_stripe_name() throws IOException { DetachCommand command = newCommand(); command.setSourceIdentifier(Identifier.valueOf("stripe2")); command.setOperationType(STRIPE); command.setDestinationAddress(node1_1.getInternalAddress()); assertDetachStripeSuccess(command); }
@Test public void testDetachStripe_fail_srcNotPartOfCluster() { DetachCommand command = newCommand(); command.setSourceIdentifier(Identifier.valueOf(strayNode.getInternalAddress().toString())); command.setOperationType(STRIPE); command.setDestinationAddress(node2_1.getInternalAddress()); assertThat( command::run, is(throwing(instanceOf(IllegalStateException.class)).andMessage(containsString("not part of cluster")))); }
@Test public void testDetachStripe_fail_srcAndDestSameStripe() { DetachCommand command = newCommand(); command.setSourceIdentifier(Identifier.valueOf(node1_1.getInternalAddress().toString())); command.setOperationType(STRIPE); command.setDestinationAddress(node1_2.getInternalAddress()); assertThat( command::run, is(throwing(instanceOf(IllegalStateException.class)).andMessage(containsString("are part of the same stripe")))); }