Search in sources :

Example 1 with ContextAwareWildflyRuntimeExecConfig

use of org.guvnor.ala.wildfly.config.impl.ContextAwareWildflyRuntimeExecConfig in project kie-wb-common by kiegroup.

the class ProvisioningPipelinesProducer method getWildflyPipeline.

/**
 * Produces a pipeline for provisioning building an provisioning war applications into an Wildlfy server.
 */
@Produces
public SystemPipelineDescriptor getWildflyPipeline() {
    return new SystemPipelineDescriptor() {

        @Override
        public Optional<ProviderType> getProviderType() {
            return Optional.of(WildflyProviderType.instance());
        }

        @Override
        public Pipeline getPipeline() {
            // Create Wildfly Pipeline Configuration
            final GitConfig gitConfig = new GitConfig() {
            };
            final MavenProjectConfig projectConfig = new MavenProjectConfig() {
            };
            final MavenBuildConfig mavenBuildConfig = new MavenBuildConfig() {

                @Override
                public List<String> getGoals() {
                    final List<String> result = new ArrayList<>();
                    result.add("clean");
                    result.add("package");
                    return result;
                }

                @Override
                public Properties getProperties() {
                    final Properties result = new Properties();
                    result.setProperty("failIfNoTests", "false");
                    return result;
                }
            };
            final MavenBuildExecConfig mavenBuildExecConfig = new MavenBuildExecConfig() {
            };
            final WildflyProviderConfig wildflyProviderConfig = new WildflyProviderConfig() {
            };
            final ContextAwareWildflyRuntimeExecConfig wildflyRuntimeExecConfig = new ContextAwareWildflyRuntimeExecConfig() {
            };
            final Pipeline pipeline = PipelineFactory.newBuilder().addConfigStage("Git Source", gitConfig).addConfigStage("Maven Project", projectConfig).addConfigStage("Maven Build Config", mavenBuildConfig).addConfigStage("Maven Build", mavenBuildExecConfig).addConfigStage("Wildfly Provider Config", wildflyProviderConfig).addConfigStage("Wildfly Runtime Exec", wildflyRuntimeExecConfig).buildAs("source-to-wildlfy-provisioning");
            return pipeline;
        }
    };
}
Also used : WildflyProviderConfig(org.guvnor.ala.wildfly.config.WildflyProviderConfig) ArrayList(java.util.ArrayList) MavenBuildConfig(org.guvnor.ala.build.maven.config.MavenBuildConfig) Properties(java.util.Properties) Pipeline(org.guvnor.ala.pipeline.Pipeline) MavenBuildExecConfig(org.guvnor.ala.build.maven.config.MavenBuildExecConfig) SystemPipelineDescriptor(org.guvnor.ala.pipeline.SystemPipelineDescriptor) MavenProjectConfig(org.guvnor.ala.build.maven.config.MavenProjectConfig) ContextAwareWildflyRuntimeExecConfig(org.guvnor.ala.wildfly.config.impl.ContextAwareWildflyRuntimeExecConfig) GitConfig(org.guvnor.ala.source.git.config.GitConfig) ProviderType(org.guvnor.ala.runtime.providers.ProviderType) WildflyProviderType(org.guvnor.ala.wildfly.model.WildflyProviderType) Produces(javax.enterprise.inject.Produces)

Example 2 with ContextAwareWildflyRuntimeExecConfig

use of org.guvnor.ala.wildfly.config.impl.ContextAwareWildflyRuntimeExecConfig in project kie-wb-common by kiegroup.

the class ContextAwareWildflyRuntimeExecConfigTest method testContextUsingPath.

@Test
public void testContextUsingPath() {
    final ContextAwareWildflyRuntimeExecConfig config = new ContextAwareWildflyRuntimeExecConfig();
    final WildflyProvider provider = mock(WildflyProvider.class);
    final Map<String, Object> context = singletonMap("wildfly-provider", provider);
    config.setContext(context);
    assertEquals(provider, config.getProviderId());
    assertEquals(WAR_PATH_DEFAULT_EXPRESSION, config.getWarPath());
    final WildflyRuntimeExecConfig configClone = config.asNewClone(config);
    assertEquals(provider, configClone.getProviderId());
    assertEquals(WAR_PATH_DEFAULT_EXPRESSION, configClone.getWarPath());
}
Also used : ContextAwareWildflyRuntimeExecConfig(org.guvnor.ala.wildfly.config.impl.ContextAwareWildflyRuntimeExecConfig) WildflyRuntimeExecConfig(org.guvnor.ala.wildfly.config.WildflyRuntimeExecConfig) ContextAwareWildflyRuntimeExecConfig(org.guvnor.ala.wildfly.config.impl.ContextAwareWildflyRuntimeExecConfig) WildflyProvider(org.guvnor.ala.wildfly.model.WildflyProvider) Test(org.junit.Test)

Example 3 with ContextAwareWildflyRuntimeExecConfig

use of org.guvnor.ala.wildfly.config.impl.ContextAwareWildflyRuntimeExecConfig in project kie-wb-common by kiegroup.

the class ContextAwareWildflyRuntimeExecConfigTest method testVariablesResolution.

@Test
public void testVariablesResolution() {
    Map<String, String> values = new HashMap<>();
    values.put(ContextAwareWildflyRuntimeExecConfig.WAR_PATH, FILE_PATH);
    values.put(ContextAwareWildflyRuntimeExecConfig.REDEPLOY_STRATEGY, REDEPLOY_OPTION);
    values.put(ContextAwareWildflyRuntimeExecConfig.RUNTIME_NAME, RUNTIME_NAME);
    final ContextAwareWildflyRuntimeExecConfig config = new ContextAwareWildflyRuntimeExecConfig();
    final ContextAwareWildflyRuntimeExecConfig varConfig = interpolate(singletonMap("input", values), config);
    assertEquals(FILE_PATH, varConfig.getWarPath());
    assertEquals(REDEPLOY_OPTION, varConfig.getRedeployStrategy());
    assertEquals(RUNTIME_NAME, varConfig.getRuntimeName());
}
Also used : HashMap(java.util.HashMap) ContextAwareWildflyRuntimeExecConfig(org.guvnor.ala.wildfly.config.impl.ContextAwareWildflyRuntimeExecConfig) Test(org.junit.Test)

Example 4 with ContextAwareWildflyRuntimeExecConfig

use of org.guvnor.ala.wildfly.config.impl.ContextAwareWildflyRuntimeExecConfig in project kie-wb-common by kiegroup.

the class ContextAwareWildflyRuntimeExecConfigTest method testContextUsingMavenBinary.

@Test
public void testContextUsingMavenBinary() {
    final ContextAwareWildflyRuntimeExecConfig config = new ContextAwareWildflyRuntimeExecConfig();
    final Map<String, Object> context = new HashMap<>();
    final WildflyProvider provider = mock(WildflyProvider.class);
    context.put("wildfly-provider", provider);
    final MavenBinary binary = mock(MavenBinary.class);
    final Path path = mock(Path.class);
    when(binary.getPath()).thenReturn(path);
    when(path.toString()).thenReturn(FILE_PATH);
    context.put("binary", binary);
    config.setContext(context);
    assertEquals(provider, config.getProviderId());
    assertEquals(FILE_PATH, config.getWarPath());
    final WildflyRuntimeExecConfig configClone = config.asNewClone(config);
    assertEquals(provider, configClone.getProviderId());
    assertEquals(FILE_PATH, configClone.getWarPath());
}
Also used : Path(org.uberfire.java.nio.file.Path) HashMap(java.util.HashMap) ContextAwareWildflyRuntimeExecConfig(org.guvnor.ala.wildfly.config.impl.ContextAwareWildflyRuntimeExecConfig) WildflyRuntimeExecConfig(org.guvnor.ala.wildfly.config.WildflyRuntimeExecConfig) ContextAwareWildflyRuntimeExecConfig(org.guvnor.ala.wildfly.config.impl.ContextAwareWildflyRuntimeExecConfig) MavenBinary(org.guvnor.ala.build.maven.model.MavenBinary) WildflyProvider(org.guvnor.ala.wildfly.model.WildflyProvider) Test(org.junit.Test)

Example 5 with ContextAwareWildflyRuntimeExecConfig

use of org.guvnor.ala.wildfly.config.impl.ContextAwareWildflyRuntimeExecConfig in project kie-wb-common by kiegroup.

the class WildflyExecutorTest method testRedeploy.

@Test
@InSequence(2)
public void testRedeploy() {
    final SourceRegistry sourceRegistry = new InMemorySourceRegistry();
    final BuildRegistry buildRegistry = new InMemoryBuildRegistry();
    final InMemoryRuntimeRegistry runtimeRegistry = new InMemoryRuntimeRegistry();
    final WildflyAccessInterface wildflyAccessInterface = new WildflyAccessInterfaceImpl();
    final Pipeline pipe = PipelineFactory.newBuilder().addConfigStage("Git Source", new GitConfig() {
    }).addConfigStage("Maven Project", new MavenProjectConfig() {
    }).addConfigStage("Maven Build Config", new MavenBuildConfig() {
    }).addConfigStage("Maven Build", new MavenBuildExecConfig() {
    }).addConfigStage("Wildfly Provider Config", new WildflyProviderConfig() {
    }).addConfigStage("Wildfly Runtime Exec", new ContextAwareWildflyRuntimeExecConfig()).buildAs("my pipe");
    WildflyRuntimeExecExecutor wildflyRuntimeExecExecutor = new WildflyRuntimeExecExecutor(runtimeRegistry, wildflyAccessInterface);
    final PipelineExecutor executor = new PipelineExecutor(asList(new GitConfigExecutor(sourceRegistry), new MavenProjectConfigExecutor(sourceRegistry), new MavenBuildConfigExecutor(), new MavenBuildExecConfigExecutor(buildRegistry), new WildflyProviderConfigExecutor(runtimeRegistry), wildflyRuntimeExecExecutor));
    executor.execute(new Input() {

        {
            put("repo-name", "drools-workshop");
            put("branch", "master");
            put("origin", gitUrl);
            put("provider-name", "wildlfy-test");
            put("wildfly-user", "admin");
            put("wildfly-password", "Admin#70365");
            put("host", ip);
            put("port", "8080");
            put("management-port", "9990");
        }
    }, pipe, System.out::println);
    List<Runtime> allRuntimes = runtimeRegistry.getRuntimes(0, 10, "", true);
    assertEquals(1, allRuntimes.size());
    Runtime runtime = allRuntimes.get(0);
    assertTrue(runtime instanceof WildflyRuntime);
    WildflyRuntime wildflyRuntime = (WildflyRuntime) runtime;
    WildflyRuntimeManager runtimeManager = new WildflyRuntimeManager(runtimeRegistry, wildflyAccessInterface);
    runtimeManager.start(wildflyRuntime);
    allRuntimes = runtimeRegistry.getRuntimes(0, 10, "", true);
    assertEquals(1, allRuntimes.size());
    runtime = allRuntimes.get(0);
    assertTrue(runtime instanceof WildflyRuntime);
    wildflyRuntime = (WildflyRuntime) runtime;
    assertEquals(RUNNING, wildflyRuntime.getState().getState());
    runtimeManager.stop(wildflyRuntime);
    allRuntimes = runtimeRegistry.getRuntimes(0, 10, "", true);
    assertEquals(1, allRuntimes.size());
    runtime = allRuntimes.get(0);
    assertTrue(runtime instanceof WildflyRuntime);
    wildflyRuntime = (WildflyRuntime) runtime;
    assertEquals(STOPPED, wildflyRuntime.getState().getState());
    wildflyRuntimeExecExecutor.destroy(wildflyRuntime);
    wildflyAccessInterface.dispose();
}
Also used : InMemoryBuildRegistry(org.guvnor.ala.registry.inmemory.InMemoryBuildRegistry) MavenProjectConfigExecutor(org.guvnor.ala.build.maven.executor.MavenProjectConfigExecutor) InMemorySourceRegistry(org.guvnor.ala.registry.inmemory.InMemorySourceRegistry) SourceRegistry(org.guvnor.ala.registry.SourceRegistry) MavenBuildConfig(org.guvnor.ala.build.maven.config.MavenBuildConfig) PipelineExecutor(org.guvnor.ala.pipeline.execution.PipelineExecutor) WildflyRuntime(org.guvnor.ala.wildfly.model.WildflyRuntime) MavenBuildExecConfig(org.guvnor.ala.build.maven.config.MavenBuildExecConfig) Input(org.guvnor.ala.pipeline.Input) WildflyRuntime(org.guvnor.ala.wildfly.model.WildflyRuntime) Runtime(org.guvnor.ala.runtime.Runtime) MavenProjectConfig(org.guvnor.ala.build.maven.config.MavenProjectConfig) WildflyAccessInterfaceImpl(org.guvnor.ala.wildfly.access.impl.WildflyAccessInterfaceImpl) WildflyProviderConfigExecutor(org.guvnor.ala.wildfly.executor.WildflyProviderConfigExecutor) BuildRegistry(org.guvnor.ala.registry.BuildRegistry) InMemoryBuildRegistry(org.guvnor.ala.registry.inmemory.InMemoryBuildRegistry) GitConfig(org.guvnor.ala.source.git.config.GitConfig) WildflyProviderConfig(org.guvnor.ala.wildfly.config.WildflyProviderConfig) Pipeline(org.guvnor.ala.pipeline.Pipeline) WildflyRuntimeExecExecutor(org.guvnor.ala.wildfly.executor.WildflyRuntimeExecExecutor) MavenBuildExecConfigExecutor(org.guvnor.ala.build.maven.executor.MavenBuildExecConfigExecutor) WildflyAccessInterface(org.guvnor.ala.wildfly.access.WildflyAccessInterface) GitConfigExecutor(org.guvnor.ala.source.git.executor.GitConfigExecutor) InMemorySourceRegistry(org.guvnor.ala.registry.inmemory.InMemorySourceRegistry) ContextAwareWildflyRuntimeExecConfig(org.guvnor.ala.wildfly.config.impl.ContextAwareWildflyRuntimeExecConfig) WildflyRuntimeManager(org.guvnor.ala.wildfly.service.WildflyRuntimeManager) InMemoryRuntimeRegistry(org.guvnor.ala.registry.inmemory.InMemoryRuntimeRegistry) MavenBuildConfigExecutor(org.guvnor.ala.build.maven.executor.MavenBuildConfigExecutor) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Aggregations

ContextAwareWildflyRuntimeExecConfig (org.guvnor.ala.wildfly.config.impl.ContextAwareWildflyRuntimeExecConfig)6 Test (org.junit.Test)5 MavenBuildConfig (org.guvnor.ala.build.maven.config.MavenBuildConfig)3 MavenBuildExecConfig (org.guvnor.ala.build.maven.config.MavenBuildExecConfig)3 MavenProjectConfig (org.guvnor.ala.build.maven.config.MavenProjectConfig)3 Pipeline (org.guvnor.ala.pipeline.Pipeline)3 GitConfig (org.guvnor.ala.source.git.config.GitConfig)3 WildflyProviderConfig (org.guvnor.ala.wildfly.config.WildflyProviderConfig)3 HashMap (java.util.HashMap)2 MavenBuildConfigExecutor (org.guvnor.ala.build.maven.executor.MavenBuildConfigExecutor)2 MavenBuildExecConfigExecutor (org.guvnor.ala.build.maven.executor.MavenBuildExecConfigExecutor)2 MavenProjectConfigExecutor (org.guvnor.ala.build.maven.executor.MavenProjectConfigExecutor)2 Input (org.guvnor.ala.pipeline.Input)2 PipelineExecutor (org.guvnor.ala.pipeline.execution.PipelineExecutor)2 BuildRegistry (org.guvnor.ala.registry.BuildRegistry)2 SourceRegistry (org.guvnor.ala.registry.SourceRegistry)2 InMemoryBuildRegistry (org.guvnor.ala.registry.inmemory.InMemoryBuildRegistry)2 InMemoryRuntimeRegistry (org.guvnor.ala.registry.inmemory.InMemoryRuntimeRegistry)2 InMemorySourceRegistry (org.guvnor.ala.registry.inmemory.InMemorySourceRegistry)2 Runtime (org.guvnor.ala.runtime.Runtime)2