public void testJoin() throws Exception {
System.err.println(CommandSupport.executeCommand("fabric:create --force --clean -n"));
ModuleContext moduleContext = RuntimeLocator.getRequiredRuntime().getModuleContext();;
ServiceProxy<FabricService> fabricProxy = ServiceProxy.createServiceProxy(moduleContext, FabricService.class);
try {
FabricService fabricService = fabricProxy.getService();
AdminService adminService = ServiceLocator.awaitService(moduleContext, AdminService.class);
String version = System.getProperty("fabric.version");
System.err.println(CommandSupport.executeCommand("admin:create --featureURL mvn:io.fabric8/fabric8-karaf/" + version + "/xml/features --feature fabric-git --feature fabric-agent --feature fabric-boot-commands smoke.childD"));
try {
System.err.println(CommandSupport.executeCommand("admin:start smoke.childD"));
ProvisionSupport.instanceStarted(Arrays.asList("smoke.childD"), ProvisionSupport.PROVISION_TIMEOUT);
System.err.println(CommandSupport.executeCommand("admin:list"));
String joinCommand = "fabric:join -f --zookeeper-password "+ fabricService.getZookeeperPassword() +" " + fabricService.getZookeeperUrl();
String response = "";
for (int i = 0; i < 10 && !response.contains("true"); i++) {
response = CommandSupport.executeCommand("ssh:ssh -l karaf -P karaf -p " + adminService.getInstance("smoke.childD").getSshPort() + " localhost " + WAIT_FOR_JOIN_SERVICE);
Thread.sleep(1000);
}
System.err.println(CommandSupport.executeCommand("ssh:ssh -l karaf -P karaf -p " + adminService.getInstance("smoke.childD").getSshPort() + " localhost " + joinCommand));
ProvisionSupport.containersExist(Arrays.asList("smoke.childD"), ProvisionSupport.PROVISION_TIMEOUT);
Container childD = fabricService.getContainer("smoke.childD");
System.err.println(CommandSupport.executeCommand("fabric:container-list"));
ProvisionSupport.containerStatus(Arrays.asList(childD), "success", ProvisionSupport.PROVISION_TIMEOUT);
System.err.println(CommandSupport.executeCommand("fabric:container-list"));
} finally {
System.err.println(CommandSupport.executeCommand("admin:stop smoke.childD"));