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;
}
};
}
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());
}
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());
}
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());
}
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();
}
Aggregations