apache / incubator-kie-kogito-runtimes

Kogito Runtimes - Kogito is a cloud-native business automation technology for building cloud-ready business applications.
http://kogito.kie.org
Apache License 2.0
542 stars 209 forks source link

[incubator-kie-issues-1131] test migration from V7 to code generation-7 #3583

Closed Abhitocode closed 2 months ago

Abhitocode commented 4 months ago

In addition to previous changes associated, Migrated test case testErrorBetweenProcessesProcess but the test seems to have issue where expected state of sub process should be aborted but we are getting state pending

The test can be identified by referring to Activitytest.java: https://github.com/apache/incubator-kie-kogito-runtimes/blob/main/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/ActivityTest.java

Closes https://github.com/apache/incubator-kie-issues/issues/1131.

NOTE : This pr contains test which is yet to be resolved, commented the issues for particular tests, will update and push once resolved.

kie-ci3 commented 4 months ago

PR job #1 was: UNSTABLE Possible explanation: This should be test failures

Reproducer build-chain build full_downstream -f 'https://raw.githubusercontent.com/${AUTHOR:apache}/incubator-kie-kogito-pipelines/${BRANCH:main}/.ci/buildchain-config-pr-cdb.yaml' -o 'bc' -p apache/incubator-kie-kogito-runtimes -u https://github.com/apache/incubator-kie-kogito-runtimes/pull/3583 --skipParallelCheckout NOTE: To install the build-chain tool, please refer to https://github.com/kiegroup/github-action-build-chain#local-execution

Please look here: https://ci-builds.apache.org/job/KIE/job/kogito/job/main/job/pullrequest_jobs/job/kogito-runtimes-pr/job/PR-3583/1/display/redirect

Test results:

Those are the test failures:

org.jbpm.bpmn2.ActivityTest.testErrorBetweenProcessesProcess
expected: 3
but was: 0
io.quarkus.it.kogito.devmode.DevMojoIT.testDRLHotReload Condition with io.quarkus.it.kogito.devmode.DevMojoIT was not fulfilled within 2 minutes.
elguardian commented 4 months ago

Hi the test is not correct. You need to access the process instance created by the engine, not your process instance like you are doing in here. For doing so, you need to create a listener and check the event start process (at that moment you can fetch the new process instance created and matched against the the subprocess id.

Abhitocode commented 4 months ago

@elguardian I have implemented the listener and registered, that allows me to get the sub-process instance of type 'org.kie.api.runtime.process.ProcessInstance', however in order to check the status in migrated test I need sub-process instance of type 'org.kie.kogito.process.ProcessInstance' . An alternative solution might be to get the process instance by the id (which we can obtain from listener event) if there is any way to do so. But however I'm not sure how to retrieve the process instance by id.

This is how I implemented and registered the listener :

DefaultKogitoProcessEventListener listener = new DefaultKogitoProcessEventListener() { @Override public void afterProcessStarted(ProcessStartedEvent event) { subProcessInstanceList.add((ProcessInstance<ErrorsBetweenSubProcessModel>) event.getProcessInstance()); } }; ProcessTestHelper.registerProcessEventListener(app, listener);

elguardian commented 3 months ago

event.getProcessInstance().getId()

btw... the ProcessInstance kogito api is not the same as the ProcessInstance kie api (engine). it will throw you a class cast

Abhitocode commented 3 months ago

Hi @elguardian Can you guide me on how to obtain the org.kie.kogito.process.ProcessInstance object from the event object using a listener? Additionally, is the process instance id the same in both kie api and kogito api? If so, how can we retrieve the org.kie.kogito.process.ProcessInstance object using that id or is there any other alternative to get the sub-process instance?

elguardian commented 3 months ago

@Abhitocode yes the id is the same. you can access the ProcessInstances from the definition to get the process instance

Abhitocode commented 3 months ago

Hi @elguardian , I've implemented a ProcessEventListener to capture the process instance created by the engine, but I'm facing an issue. The beforeProcessStarted and afterProcessStarted methods of the listener are not being executed. Can you please help me understand if I'm missing something in the configuration or implementation?

Application app = ProcessTestHelper.newApplication(); org.kie.kogito.process.Process errorsBetweenSubProcessProcess = ErrorsBetweenSubProcessProcess.newProcess(app); org.kie.kogito.process.Process process = ErrorsBetweenProcessProcess.newProcess(app); final Set processInstanceIdSet = new HashSet<>(); DefaultKogitoProcessEventListener listener = new DefaultKogitoProcessEventListener() { @Override public void beforeProcessStarted(ProcessStartedEvent event) { logger.info("sub process id: {}, process id: {}", errorsBetweenSubProcessProcess.id(), process.id()); logger.info("Process Instance process id: {}, instance id: {}", event.getProcessInstance().getProcessId(), event.getProcessInstance().getId()); if (event.getProcessInstance().getProcessId().equals(errorsBetweenSubProcessProcess.id())) { processInstanceIdSet.add(event.getProcessInstance().getId()); } } }; ProcessTestHelper.registerProcessEventListener(app, listener);

elguardian commented 3 months ago

you are registering the listener after registering the process... listener should be register before.

elguardian commented 2 months ago

ActivityTest.testErrorBetweenProcessesProcess failures related. please fix

Abhitocode commented 2 months ago

Il be submitting this particular test testErrorBetweenProcessesProcess in the upcoming pr related to DataTest.java. Removing it from this as of now.