use of io.fabric8.patch.management.conflicts.Resolver in project fabric8 by jboss-fuse.
the class ContainerPlaceholderResolverTest method testResolveNameContainerAttributes.
@Test
public void testResolveNameContainerAttributes() throws Exception {
PlaceholderResolver resolver = getContainerPlaceholderResolver();
assertEquals(ip, resolver.resolve(fabricService, null, null, null, "container:root/ip"));
assertEquals(localhostname, resolver.resolve(fabricService, null, null, null, "container:root/localhostname"));
assertEquals(bindaddress, resolver.resolve(fabricService, null, null, null, "container:root/bindaddress"));
assertEquals(containerResolver, resolver.resolve(fabricService, null, null, null, "container:root/resolver"));
verify(fabricService);
verify(dataStore);
}
use of io.fabric8.patch.management.conflicts.Resolver in project fabric8 by jboss-fuse.
the class ContainerPlaceholderResolverTest method testResolveCurrentAttributes.
@Test
public void testResolveCurrentAttributes() throws Exception {
PlaceholderResolver resolver = getContainerPlaceholderResolver();
assertEquals(ip, resolver.resolve(fabricService, null, null, null, "container:ip"));
assertEquals(localhostname, resolver.resolve(fabricService, null, null, null, "container:localhostname"));
assertEquals(bindaddress, resolver.resolve(fabricService, null, null, null, "container:bindaddress"));
assertEquals(containerResolver, resolver.resolve(fabricService, null, null, null, "container:resolver"));
verify(fabricService);
verify(dataStore);
}
use of io.fabric8.patch.management.conflicts.Resolver in project fabric8 by jboss-fuse.
the class ResolverTest method testChildContainerResolver.
@Test
public void testChildContainerResolver() throws Exception {
System.out.println(CommandSupport.executeCommand("fabric:create --force --clean -n --wait-for-provisioning"));
// System.out.println(executeCommand("shell:info"));
// System.out.println(executeCommand("fabric:info"));
// System.out.println(executeCommand("fabric:profile-list"));
BundleContext moduleContext = ServiceLocator.getSystemContext();
ServiceProxy<FabricService> fabricProxy = ServiceProxy.createServiceProxy(moduleContext, FabricService.class);
try {
FabricService fabricService = fabricProxy.getService();
CuratorFramework curator = fabricService.adapt(CuratorFramework.class);
Set<Container> containers = ContainerBuilder.create(1, 1).withName("basic.cntF").withProfiles("default").assertProvisioningResult().build(fabricService);
try {
Container cntF = containers.iterator().next();
Assert.assertEquals("localhostname", getSubstitutedPath(curator, ZkPath.CONTAINER_RESOLVER.getPath(cntF.getId())));
String sshUrlWithLocalhostResolver = cntF.getSshUrl();
CommandSupport.executeCommand("fabric:container-resolver-set --container " + cntF.getId() + " localip");
Assert.assertEquals("localip", getSubstitutedPath(curator, ZkPath.CONTAINER_RESOLVER.getPath(cntF.getId())));
String sshUrlWithLocalIpResolver = cntF.getSshUrl();
// Check that the SSH URL has been updated.
System.out.println("SSH URL with " + sshUrlWithLocalhostResolver + " resolver: localhostname");
System.out.println("SSH URL with " + sshUrlWithLocalIpResolver + " resolver: localip");
Assert.assertNotSame(sshUrlWithLocalhostResolver, sshUrlWithLocalIpResolver);
setData(curator, ZkPath.CONTAINER_PUBLIC_IP.getPath(cntF.getId()), "my.public.ip.address");
CommandSupport.executeCommand("fabric:container-resolver-set --container " + cntF.getId() + " publicip");
Assert.assertEquals("publicip", getSubstitutedPath(curator, ZkPath.CONTAINER_RESOLVER.getPath(cntF.getId())));
String sshUrlWithPublicIpResolver = cntF.getSshUrl();
System.out.println("SSH URL with " + sshUrlWithPublicIpResolver + " resolver: publicip");
Assert.assertNotNull(sshUrlWithPublicIpResolver);
Assert.assertTrue(sshUrlWithPublicIpResolver.startsWith("my.public.ip.address"));
setData(curator, ZkPath.CONTAINER_MANUAL_IP.getPath(cntF.getId()), "my.manual.ip.address");
CommandSupport.executeCommand("fabric:container-resolver-set --container " + cntF.getId() + " manualip");
Assert.assertEquals("manualip", getSubstitutedPath(curator, ZkPath.CONTAINER_RESOLVER.getPath(cntF.getId())));
String sshUrlWithManualIpResolver = cntF.getSshUrl();
System.out.println("SSH URL with " + sshUrlWithManualIpResolver + " resolver: manualip");
Assert.assertNotNull(sshUrlWithManualIpResolver);
Assert.assertTrue(sshUrlWithManualIpResolver.startsWith("my.manual.ip.address"));
} finally {
ContainerBuilder.destroy(fabricService, containers);
}
} finally {
fabricProxy.close();
}
}
use of io.fabric8.patch.management.conflicts.Resolver in project fabric8 by jboss-fuse.
the class ResolverTest method testRootContainerResolver.
@Test
public void testRootContainerResolver() throws Exception {
System.out.println(CommandSupport.executeCommand("fabric:create --force --clean -n --wait-for-provisioning"));
// System.out.println(executeCommand("shell:info"));
// System.out.println(executeCommand("fabric:info"));
// System.out.println(executeCommand("fabric:profile-list"));
BundleContext moduleContext = ServiceLocator.getSystemContext();
ServiceProxy<FabricService> fabricProxy = ServiceProxy.createServiceProxy(moduleContext, FabricService.class);
try {
FabricService fabricService = fabricProxy.getService();
Container current = fabricService.getCurrentContainer();
Assert.assertEquals("localhostname", current.getResolver());
String sshUrlWithLocalhostResolver = current.getSshUrl();
System.out.println(CommandSupport.executeCommand("fabric:container-resolver-set --container root localip"));
Assert.assertEquals("localip", current.getResolver());
String sshUrlWithLocalIpResolver = current.getSshUrl();
// Check that the SSH URL has been updated.
System.out.println("SSH URL with " + sshUrlWithLocalhostResolver + " resolver: localhostname");
System.out.println("SSH URL with " + sshUrlWithLocalIpResolver + " resolver: localip");
Assert.assertNotSame(sshUrlWithLocalhostResolver, sshUrlWithLocalIpResolver);
} finally {
fabricProxy.close();
}
}
use of io.fabric8.patch.management.conflicts.Resolver in project fabric8 by jboss-fuse.
the class ResolverTest method testResolverInheritanceOnChild.
@Test
public void testResolverInheritanceOnChild() throws Exception {
System.out.println(CommandSupport.executeCommand("fabric:create --force --clean -n --wait-for-provisioning -g localip -r manualip --manual-ip localhost -b localhost"));
// System.out.println(executeCommand("shell:info"));
// System.out.println(executeCommand("fabric:info"));
// System.out.println(executeCommand("fabric:profile-list"));
BundleContext moduleContext = ServiceLocator.getSystemContext();
ServiceProxy<FabricService> fabricProxy = ServiceProxy.createServiceProxy(moduleContext, FabricService.class);
try {
FabricService fabricService = fabricProxy.getService();
CuratorFramework curator = fabricService.adapt(CuratorFramework.class);
Set<Container> containers = ContainerBuilder.create(1, 1).withName("basic.cntG").withProfiles("default").assertProvisioningResult().build(fabricService);
try {
Container cntG = containers.iterator().next();
Assert.assertEquals("manualip", getSubstitutedPath(curator, ZkPath.CONTAINER_RESOLVER.getPath(cntG.getId())));
Assert.assertEquals("manualip", fabricService.getCurrentContainer().getResolver());
// We stop the config admin bridge, since the next step is going to hung the container if we do propagate the change to config admin.
// new BundleUtils(bundleContext).findAndStopBundle("io.fabric8.fabric-configadmin");
// We want to make sure that the child points to the parent, so we change the parent resolvers and assert.
System.out.println(CommandSupport.executeCommand("fabric:container-resolver-set --container root localip"));
Assert.assertEquals("localip", getSubstitutedPath(curator, ZkPath.CONTAINER_RESOLVER.getPath(cntG.getId())));
} finally {
ContainerBuilder.destroy(fabricService, containers);
}
} finally {
fabricProxy.close();
}
}
Aggregations