Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed

Conversation

Abhitocode
Copy link
Contributor

@Abhitocode Abhitocode commented Jul 17, 2024

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 apache/incubator-kie-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
Copy link
Contributor

kie-ci3 commented Jul 17, 2024

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 #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:

  • PASSED: 3263
  • FAILED: 2

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
Copy link
Contributor

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
Copy link
Contributor Author

Abhitocode commented Jul 22, 2024

@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<org.jbpm.bpmn2.subprocess.ErrorsBetweenSubProcessModel>' . 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
Copy link
Contributor

elguardian commented Jul 23, 2024

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
Copy link
Contributor Author

Hi @elguardian Can you guide me on how to obtain the org.kie.kogito.process.ProcessInstance<org.jbpm.bpmn2.subprocess.ErrorsBetweenSubProcessModel> 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<org.jbpm.bpmn2.subprocess.ErrorsBetweenSubProcessModel> object using that id or is there any other alternative to get the sub-process instance?

@elguardian
Copy link
Contributor

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

@Abhitocode
Copy link
Contributor Author

Abhitocode commented Jul 24, 2024

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
Copy link
Contributor

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

@elguardian elguardian marked this pull request as ready for review August 8, 2024 06:39
@elguardian
Copy link
Contributor

ActivityTest.testErrorBetweenProcessesProcess failures related. please fix

@Abhitocode
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate process test migration from v7 legacy runtime to code generation
4 participants