@Test
	public void testIncompleteState() throws Exception {
		for (int i = 0; i < 2; i++) {
			startContainer();
		}

		SpringXDTemplate template = ensureTemplate();
		logger.info("Waiting for containers...");
		Map<Long, String> mapPidUuid = waitForContainers();
		logger.info("Containers running");

		String streamName = testName.getMethodName() + "-ticktock";

		template.streamOperations().createStream(streamName, "time|log", false);
		verifyStreamCreated(streamName);

		template.streamOperations().deploy(streamName, DeploymentPropertiesFormat.parseDeploymentProperties("module.log.count=2"));
		verifyStreamDeployed(streamName);

		ModuleRuntimeContainers moduleContainers = retrieveModuleRuntimeContainers(streamName);
		Set<String> sinks = new HashSet<String>(moduleContainers.getSinkContainers());
		sinks.removeAll(moduleContainers.getSourceContainers());

		long pidToKill = 0;
		for (Map.Entry<Long, String> entry : mapPidUuid.entrySet()) {
			if (sinks.contains(entry.getValue())) {
				pidToKill = entry.getKey();
				break;
			}
		}
		assertFalse(pidToKill == 0);

		logger.info("Killing container with pid {}", pidToKill);
		shutdownContainer(pidToKill);
		verifyStreamState(streamName, DeploymentUnitStatus.State.incomplete);

		shutdownContainers();
		verifyStreamState(streamName, DeploymentUnitStatus.State.failed);

		startContainer();
		verifyStreamState(streamName, DeploymentUnitStatus.State.incomplete);

		startContainer();
		verifyStreamDeployed(streamName);
	}
For a stream with a sink that requires two containers,
assert the following state transitions:
<ul>
    <li>Initial state: deployed</li>
    <li>Shut down one container (not the one hosting
        the source): incomplete</li>
    <li>Shut down the remaining container: failed</li>
    <li>Start one container: incomplete</li>
    <li>Start another container: deployed</li>
</ul>

@throws Exception
spring-xd-distributed-test/src/test/java/org/springframework/xd/distributed/test/StreamStateTests.java