use of org.kie.workbench.common.services.backend.compiler.impl.kie.KieCompilationResponse in project kie-wb-common by kiegroup.
the class KieAfterDecoratorTest method compileTest.
@Test
@Ignore("https://issues.redhat.com/browse/AF-2892")
public void compileTest() {
CompilationRequest req = new DefaultCompilationRequest(mavenRepoPath, info, new String[] { MavenCLIArgs.COMPILE, MavenCLIArgs.ALTERNATE_USER_SETTINGS + alternateSettingsAbsPath }, Boolean.FALSE);
KieAfterDecorator decorator = new KieAfterDecorator(new BaseMavenCompiler(false, false));
KieCompilationResponse kieRes = (KieCompilationResponse) decorator.compile(req);
SoftAssertions.assertSoftly(softly -> {
softly.assertThat(kieRes.isSuccessful()).isTrue();
softly.assertThat(kieRes.getMavenOutput()).isEmpty();
softly.assertThat(kieRes.getKieModule()).isNotNull();
softly.assertThat(kieRes.getKieModuleMetaInfo()).isNotNull();
});
}
use of org.kie.workbench.common.services.backend.compiler.impl.kie.KieCompilationResponse in project kie-wb-common by kiegroup.
the class KieMetadataTest method compileAndLoadKieJarMetadataAllResourcesPackagedJar.
@Ignore("https://issues.redhat.com/browse/AF-2741\n" + "https://issues.redhat.com/browse/AF-2892")
// AF-1459 it tooks 30% of the time of the time spent by all module's test (108), alone it took 30 sec
@Test
public void compileAndLoadKieJarMetadataAllResourcesPackagedJar() throws Exception {
/**
* If the test fail check if the Drools core classes used, KieModuleMetaInfo and TypeMetaInfo implements Serializable
*/
Path temp = TestUtil.createAndCopyToDirectory(tmpRoot, "dummy", ResourcesConstants.KJAR_2_ALL_RESOURCES);
final AFCompiler compiler = KieMavenCompilerFactory.getCompiler(EnumSet.of(KieDecorator.ENABLE_LOGGING, KieDecorator.STORE_KIE_OBJECTS, KieDecorator.STORE_BUILD_CLASSPATH, KieDecorator.ENABLE_INCREMENTAL_BUILD));
WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(temp);
CompilationRequest req = new DefaultCompilationRequest(mavenRepoPath, info, new String[] { MavenCLIArgs.COMPILE, MavenCLIArgs.ALTERNATE_USER_SETTINGS + alternateSettingsAbsPath }, Boolean.FALSE);
KieCompilationResponse res = (KieCompilationResponse) compiler.compile(req);
TestUtil.saveMavenLogIfCompilationResponseNotSuccessfull(temp, res, this.getClass(), testName);
if (!res.isSuccessful()) {
List<String> msgs = res.getMavenOutput();
for (String msg : msgs) {
logger.info(msg);
}
}
assertThat(res.isSuccessful()).isTrue();
Optional<KieModuleMetaInfo> metaDataOptional = res.getKieModuleMetaInfo();
assertThat(metaDataOptional).isPresent();
KieModuleMetaInfo kieModuleMetaInfo = metaDataOptional.get();
assertThat(kieModuleMetaInfo).isNotNull();
Map<String, Set<String>> rulesBP = kieModuleMetaInfo.getRulesByPackage();
assertThat(rulesBP).hasSize(6);
Map<String, TypeMetaInfo> typesMI = kieModuleMetaInfo.getTypeMetaInfos();
// This is a "magic number" test and may or may not be valid since changes
// to the mechanism for generating classes, especially in PMML processing,
// may cause this value to change.
assertThat(typesMI).hasSize(22);
Optional<KieModule> kieModuleOptional = res.getKieModule();
assertThat(kieModuleOptional).isPresent();
assertThat(res.getDependenciesAsURI()).hasSize(4);
KieModule kModule = kieModuleOptional.get();
KieModuleMetaData kieModuleMetaData = new KieModuleMetaDataImpl((InternalKieModule) kModule, res.getDependenciesAsURI());
assertThat(kieModuleMetaData).isNotNull();
}
use of org.kie.workbench.common.services.backend.compiler.impl.kie.KieCompilationResponse in project kie-wb-common by kiegroup.
the class ConcurrentBuildTest method compileAndLoadKieJarMetadataAllResourcesPackagedJar.
private KieCompilationResponse compileAndLoadKieJarMetadataAllResourcesPackagedJar() {
String alternateSettingsAbsPath = TestUtilMaven.getSettingsFile();
Path tmpRoot = Files.createTempDirectory("repo_" + UUID.randomUUID().toString());
Path tmp = Files.createDirectories(Paths.get(tmpRoot.toString(), "dummy"));
try {
TestUtil.copyTree(Paths.get(ResourcesConstants.KJAR_2_ALL_RESOURCES), tmp);
} catch (Exception e) {
logger.error(e.getMessage());
}
final AFCompiler compiler = KieMavenCompilerFactory.getCompiler(EnumSet.of(KieDecorator.STORE_KIE_OBJECTS, KieDecorator.ENABLE_LOGGING));
final KieCompilationResponse res;
try {
final WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(tmp);
final CompilationRequest req = new DefaultCompilationRequest(mavenRepoPath, info, new String[] { MavenCLIArgs.COMPILE, MavenCLIArgs.ALTERNATE_USER_SETTINGS + alternateSettingsAbsPath }, Boolean.FALSE);
res = (KieCompilationResponse) compiler.compile(req);
logger.info("\nFinished, successful:{} , all Metadata tmp:{} UUID:{} res.getMavenOutput().isEmpty():{}", res.isSuccessful(), tmp, req.getRequestUUID(), res.getMavenOutput().isEmpty());
if (!res.isSuccessful()) {
try {
logger.error("writing output on target folder:{}", tmp);
TestUtil.writeMavenOutputIntoTargetFolder(tmp, res.getMavenOutput(), "ConcurrentBuildTest.compileAndLoadKieJarMetadataAllResourcesPackagedJar_" + req.getRequestUUID());
} catch (Exception e) {
logger.error(e.getMessage());
}
}
} finally {
latch.countDown();
}
return res;
}
use of org.kie.workbench.common.services.backend.compiler.impl.kie.KieCompilationResponse in project kie-wb-common by kiegroup.
the class ConcurrentBuildTest method buildFourProjectsInFourThreadCompletableFuture.
// https://issues.redhat.com/browse/AF-2744
@Ignore
@Test
public void buildFourProjectsInFourThreadCompletableFuture() throws Exception {
latch = new CountDownLatch(4);
ExecutorService executor = Executors.newFixedThreadPool(4);
final CompletableFuture<KieCompilationResponse> resOne = supplyAsync(this::compileAndloadKieJarSingleMetadataWithPackagedJar, executor);
final CompletableFuture<KieCompilationResponse> resTwo = supplyAsync(this::compileAndLoadKieJarMetadataAllResourcesPackagedJar, executor);
final CompletableFuture<KieCompilationResponse> resThree = supplyAsync(this::compileAndloadKieJarSingleMetadataWithPackagedJar, executor);
final CompletableFuture<KieCompilationResponse> resFour = supplyAsync(this::compileAndLoadKieJarMetadataAllResourcesPackagedJar, executor);
latch.await();
System.err.println(resOne.get());
System.err.println(resTwo.get());
System.err.println(resThree.get());
System.err.println(resFour.get());
assertThat(resOne.get().isSuccessful()).isTrue();
assertThat(resTwo.get().isSuccessful()).isTrue();
assertThat(resThree.get().isSuccessful()).isTrue();
assertThat(resFour.get().isSuccessful()).isTrue();
}
use of org.kie.workbench.common.services.backend.compiler.impl.kie.KieCompilationResponse in project kie-wb-common by kiegroup.
the class ConcurrentBuildTest method buildFourProjectsInFourThread.
// https://issues.redhat.com/browse/AF-2743
@Ignore
@Test
public void buildFourProjectsInFourThread() {
latch = new CountDownLatch(4);
ExecutorService executor = Executors.newFixedThreadPool(4);
try {
List<Callable<KieCompilationResponse>> tasks = Arrays.asList(this::compileAndloadKieJarSingleMetadataWithPackagedJar, this::compileAndloadKieJarSingleMetadataWithPackagedJar, this::compileAndLoadKieJarMetadataAllResourcesPackagedJar, this::compileAndLoadKieJarMetadataAllResourcesPackagedJar);
final List<Future<KieCompilationResponse>> results = executor.invokeAll(tasks);
latch.await();
logger.info("\nFinished all threads ");
assertThat(results).hasSize(4);
for (Future<KieCompilationResponse> result : results) {
logger.info("Working dir:{} success:{}", result.get().getWorkingDir().get(), result.get().isSuccessful());
}
for (Future<KieCompilationResponse> result : results) {
assertThat(result.get().isSuccessful()).isTrue();
}
} catch (ExecutionException ee) {
logger.error(ee.getMessage());
} catch (InterruptedException e) {
logger.error("tasks interrupted");
} finally {
if (!executor.isTerminated()) {
logger.error("cancel non-finished tasks");
}
executor.shutdownNow();
logger.info("shutdown finished");
}
}
Aggregations