Search in sources :

Example 41 with Resolver

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);
}
Also used : PlaceholderResolver(io.fabric8.api.PlaceholderResolver) Test(org.junit.Test)

Example 42 with Resolver

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);
}
Also used : PlaceholderResolver(io.fabric8.api.PlaceholderResolver) Test(org.junit.Test)

Example 43 with Resolver

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();
    }
}
Also used : CuratorFramework(org.apache.curator.framework.CuratorFramework) Container(io.fabric8.api.Container) FabricService(io.fabric8.api.FabricService) BundleContext(org.osgi.framework.BundleContext) Test(org.junit.Test)

Example 44 with Resolver

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();
    }
}
Also used : Container(io.fabric8.api.Container) FabricService(io.fabric8.api.FabricService) BundleContext(org.osgi.framework.BundleContext) Test(org.junit.Test)

Example 45 with Resolver

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();
    }
}
Also used : CuratorFramework(org.apache.curator.framework.CuratorFramework) Container(io.fabric8.api.Container) FabricService(io.fabric8.api.FabricService) BundleContext(org.osgi.framework.BundleContext) Test(org.junit.Test)

Aggregations

File (java.io.File)23 MavenResolver (io.fabric8.maven.MavenResolver)22 Test (org.junit.Test)21 IOException (java.io.IOException)20 FabricService (io.fabric8.api.FabricService)10 Container (io.fabric8.api.Container)9 RuntimeProperties (io.fabric8.api.RuntimeProperties)7 HashMap (java.util.HashMap)7 PlaceholderResolver (io.fabric8.api.PlaceholderResolver)6 HashSet (java.util.HashSet)6 Hashtable (java.util.Hashtable)6 Metadata (org.apache.maven.artifact.repository.metadata.Metadata)6 Map (java.util.Map)5 DownloadManager (io.fabric8.agent.download.DownloadManager)4 AbstractRuntimeProperties (io.fabric8.api.scr.AbstractRuntimeProperties)4 MavenConfigurationImpl (io.fabric8.maven.util.MavenConfigurationImpl)4 FileInputStream (java.io.FileInputStream)4 URI (java.net.URI)4 HttpServletRequest (javax.servlet.http.HttpServletRequest)4 HttpServletResponse (javax.servlet.http.HttpServletResponse)4