Search in sources :

Example 21 with Pipeline

use of org.guvnor.ala.pipeline.Pipeline in project kie-wb-common by kiegroup.

the class BuildPipelineTest method testIncrementalBuildResourceChangesExecution.

@Test
public void testIncrementalBuildResourceChangesExecution() {
    when(buildHelper.applyBatchResourceChanges(eq(module), any(Map.class))).thenReturn(incrementalBuildResults);
    // prepare the pipeline input.
    Input input = createBatchChangesInput(ROOT_PATH_URI, LocalBuildConfig.BuildType.INCREMENTAL_BATCH_CHANGES.name(), changes);
    // execute the pipeline and verify the result.
    pipelineInitializer.getExecutor().execute(input, pipe, (Consumer<LocalBinaryConfig>) localBinaryConfig -> {
        assertEquals(incrementalBuildResults, localBinaryConfig.getIncrementalBuildResults());
    }, pipelineEventListener);
    // verify that all stages were properly invoked.
    verifyLocalSourceConfigWasInvoked();
    verifyLocalProjectConfigWasInvoked();
    verifyLocalBuildConfigExecutorWasInvoked(module, changes);
    verifyLocalBuildExecConfigExecutorWasInvoked(module, changes);
    // verify the pipeline events where properly raised.
    verifyPipelineEvents();
}
Also used : Builder(org.kie.workbench.common.services.backend.builder.core.Builder) IncrementalBuildResults(org.guvnor.common.services.project.builder.model.IncrementalBuildResults) Stage(org.guvnor.ala.pipeline.Stage) Mock(org.mockito.Mock) ConfigExecutor(org.guvnor.ala.pipeline.ConfigExecutor) RunWith(org.junit.runner.RunWith) InMemoryPipelineRegistry(org.guvnor.ala.registry.inmemory.InMemoryPipelineRegistry) ArrayList(java.util.ArrayList) BeforePipelineExecutionEvent(org.guvnor.ala.pipeline.events.BeforePipelineExecutionEvent) Paths(org.uberfire.backend.server.util.Paths) Pipeline(org.guvnor.ala.pipeline.Pipeline) ArgumentCaptor(org.mockito.ArgumentCaptor) KieModuleService(org.kie.workbench.common.services.shared.project.KieModuleService) Map(java.util.Map) AfterPipelineExecutionEvent(org.guvnor.ala.pipeline.events.AfterPipelineExecutionEvent) ResourceChange(org.uberfire.workbench.events.ResourceChange) Source(org.guvnor.ala.source.Source) AfterStageExecutionEvent(org.guvnor.ala.pipeline.events.AfterStageExecutionEvent) Path(org.uberfire.backend.vfs.Path) Before(org.junit.Before) BuildResults(org.guvnor.common.services.project.builder.model.BuildResults) PipelineRegistry(org.guvnor.ala.registry.PipelineRegistry) Input(org.guvnor.ala.pipeline.Input) Collection(java.util.Collection) Test(org.junit.Test) BuildHelper(org.kie.workbench.common.services.backend.builder.core.BuildHelper) KieModule(org.kie.workbench.common.services.shared.project.KieModule) PipelineEventListener(org.guvnor.ala.pipeline.events.PipelineEventListener) Consumer(java.util.function.Consumer) BeforeStageExecutionEvent(org.guvnor.ala.pipeline.events.BeforeStageExecutionEvent) Mockito(org.mockito.Mockito) List(java.util.List) DeploymentMode(org.guvnor.common.services.project.service.DeploymentMode) MockitoJUnitRunner(org.mockito.runners.MockitoJUnitRunner) Assert(org.junit.Assert) Input(org.guvnor.ala.pipeline.Input) Map(java.util.Map) Test(org.junit.Test)

Example 22 with Pipeline

use of org.guvnor.ala.pipeline.Pipeline 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)

Example 23 with Pipeline

use of org.guvnor.ala.pipeline.Pipeline in project kie-wb-common by kiegroup.

the class WildflyExecutorTest method testAPI.

@Test
@InSequence(1)
public void testAPI() {
    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("create-repo", "true");
            put("branch", "master");
            put("out-dir", tempPath.getAbsolutePath());
            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)

Example 24 with Pipeline

use of org.guvnor.ala.pipeline.Pipeline in project kie-wb-common by kiegroup.

the class PipelineExecutorTraceImplMarshallerTest method getValue.

@Override
public PipelineExecutorTraceImpl getValue() {
    // only the stage names are used by the taskDef, so the pipeline can be mocked.
    List<Stage> stages = mockStages(STAGE_COUNT);
    Pipeline pipeline = new BasePipeline(PIPELINE_NAME, stages) {
    };
    Input input = mockInput(PIPELINE_INPUT_SIZE);
    PipelineExecutorTaskDefImpl taskDef = new PipelineExecutorTaskDefImpl(pipeline, input);
    PipelineExecutorTaskImpl taskImpl = new PipelineExecutorTaskImpl(taskDef, PIPELINE_EXECUTION_ID);
    taskImpl.setPipelineStatus(PipelineExecutorTask.Status.SCHEDULED);
    taskImpl.setPipelineError(mockError(PIPELINE_ERROR, PIPELINE_ERROR_DETAIL));
    taskImpl.getTaskDef().getStages().forEach(stage -> taskImpl.setStageError(stage, mockStageError(stage)));
    taskImpl.setOutput(new MockPipelineOutput(PIPELINE_OUTPUT));
    return new PipelineExecutorTraceImpl(taskImpl);
}
Also used : PipelineExecutorTaskDefImpl(org.guvnor.ala.pipeline.execution.impl.PipelineExecutorTaskDefImpl) Input(org.guvnor.ala.pipeline.Input) PipelineExecutorTaskImpl(org.guvnor.ala.pipeline.execution.impl.PipelineExecutorTaskImpl) PipelineExecutorTraceImpl(org.guvnor.ala.pipeline.execution.impl.PipelineExecutorTraceImpl) Stage(org.guvnor.ala.pipeline.Stage) BasePipeline(org.guvnor.ala.pipeline.impl.BasePipeline) BasePipeline(org.guvnor.ala.pipeline.impl.BasePipeline) Pipeline(org.guvnor.ala.pipeline.Pipeline)

Example 25 with Pipeline

use of org.guvnor.ala.pipeline.Pipeline in project kie-wb-common by kiegroup.

the class InMemoryPipelineRegistryTest method getPipelinesForProvider.

@Test
public void getPipelinesForProvider() {
    ProviderType providerType1 = mockProviderTypeSPI("providerType1");
    ProviderType providerType2 = mockProviderTypeSPI("providerType2");
    List<Pipeline> result = pipelineRegistry.getPipelines(0, 1000, PipelineRegistry.PIPELINE_NAME_SORT, true);
    assertTrue(result.isEmpty());
    // register pipelines for providerType, providerType1, and providerType2
    List<Pipeline> pipelines = mockPipelineList("providerType", ELEMENTS_COUNT);
    registerPipelinesForProviderType(pipelines, providerType);
    registerPipelinesForProviderType(mockPipelineList("providerType1", ELEMENTS_COUNT), providerType1);
    registerPipelinesForProviderType(mockPipelineList("providerType2", ELEMENTS_COUNT), providerType2);
    result = pipelineRegistry.getPipelines(0, 1000, PipelineRegistry.PIPELINE_NAME_SORT, true);
    assertEquals(3 * ELEMENTS_COUNT, result.size());
    result = pipelineRegistry.getPipelines(providerType.getProviderTypeName(), providerType.getVersion(), 0, 1000, PipelineRegistry.PIPELINE_NAME_SORT, true);
    assertEquals(pipelines.size(), result.size());
    for (Pipeline pipeline : result) {
        assertTrue(result.contains(pipeline));
    }
}
Also used : ProviderType(org.guvnor.ala.runtime.providers.ProviderType) Pipeline(org.guvnor.ala.pipeline.Pipeline) Test(org.junit.Test)

Aggregations

Pipeline (org.guvnor.ala.pipeline.Pipeline)27 Test (org.junit.Test)15 Input (org.guvnor.ala.pipeline.Input)12 PipelineExecutor (org.guvnor.ala.pipeline.execution.PipelineExecutor)8 ArrayList (java.util.ArrayList)6 BuildRegistry (org.guvnor.ala.registry.BuildRegistry)6 InMemoryBuildRegistry (org.guvnor.ala.registry.inmemory.InMemoryBuildRegistry)6 InMemoryRuntimeRegistry (org.guvnor.ala.registry.inmemory.InMemoryRuntimeRegistry)5 Runtime (org.guvnor.ala.runtime.Runtime)5 Stage (org.guvnor.ala.pipeline.Stage)4 SourceRegistry (org.guvnor.ala.registry.SourceRegistry)4 InMemorySourceRegistry (org.guvnor.ala.registry.inmemory.InMemorySourceRegistry)4 GitConfigExecutor (org.guvnor.ala.source.git.executor.GitConfigExecutor)4 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 MavenBuildConfigImpl (org.guvnor.ala.build.maven.config.impl.MavenBuildConfigImpl)3 MavenBuildExecConfigImpl (org.guvnor.ala.build.maven.config.impl.MavenBuildExecConfigImpl)3 MavenProjectConfigImpl (org.guvnor.ala.build.maven.config.impl.MavenProjectConfigImpl)3 MavenBuildConfigExecutor (org.guvnor.ala.build.maven.executor.MavenBuildConfigExecutor)3