protected void waitAndAssertUntilAgentAttachedTo(SingleConsole console, int expected, int retryCount) {
		int size = 0;
		retryCount++;
		for (int i = 0; i < retryCount; i++) {
			size = console.getAllAttachedAgents().size();
			if (size == expected) {
				return;
			}
			sleep(2000);
		}
		assertThat(size, equalTo(expected));
	}
Returns a free port number on localhost, or -1 if unable to find a free port.

@return a free port number on localhost, or -1 if unable to find a free port
ngrinder-core/src/test/java/org/ngrinder/AbstractMultiGrinderTestBase.java