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-drools#5709] [new-parser] Some rules do not fire in Mu… #5794

Merged
merged 1 commit into from
Mar 21, 2024

Conversation

tkobayas
Copy link
Contributor

…ltiKieBaseTest

Issue:

How to replicate CI configuration locally?

Build Chain tool does "simple" maven build(s), the builds are just Maven commands, but because the repositories relates and depends on each other and any change in API or class method could affect several of those repositories there is a need to use build-chain tool to handle cross repository builds and be sure that we always use latest version of the code for each repository.

build-chain tool is a build tool which can be used on command line locally or in Github Actions workflow(s), in case you need to change multiple repositories and send multiple dependent pull requests related with a change you can easily reproduce the same build by executing it on Github hosted environment or locally in your development environment. See local execution details to get more information about it.

How to retest this PR or trigger a specific build:
  • for pull request and downstream checks

    • Push a new commit to the PR. An empty commit would be enough.
  • for a full downstream build

    • for github actions job: add the label run_fdb
  • for Jenkins PR check only

@tkobayas
Copy link
Contributor Author

tkobayas commented Mar 19, 2024

Fixed org.drools.model.codegen.execmodel.MultiKieBaseTest#testHelloWorldWithPackagesAnd2KieBases. Now all tests in MultiKieBaseTest are successful.

Before PR
drools-model-codegen

[ERROR] Tests run: 2433, Failures: 336, Errors: 0, Skipped: 9

After PR
drools-model-codegen

[ERROR] Tests run: 2433, Failures: 335, Errors: 0, Skipped: 9

@@ -268,6 +268,7 @@ public RuleDescr visitRuledef(DRLParser.RuledefContext ctx) {
ruleDescr.setConsequence(trimThen(getTokenTextPreservingWhitespace(ctx.rhs(), tokenStream))); // RHS is just a text
}

populateStartEnd(ruleDescr, ctx);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The root cause was that RuleDescr.getStartCharacter() returned -1 (missed in DRLVisitorImpl), so the kbase was not updated (the error was logged). So fixed.

https://github.com/apache/incubator-kie-drools/blob/dev-new-parser/drools-compiler/src/main/java/org/drools/compiler/kie/util/ChangeSetBuilder.java#L247

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @tkobayas , thanks for the PR!
IIUC the comment, it means that a piece of code does not populate correctly a given object (ruleDescr), and your modification somehow "workaround" that.
I read the method, and TBH is somehow "brittle" by itself (I may give detailed explanation of this remark, if you want): would not be better to fix the root problem itself ? Eventually, I would be glad to help there

@tkobayas
Copy link
Contributor Author

@yurloc @mariofusco @gitgabrio Please review, thanks!

Copy link
Contributor

@gitgabrio gitgabrio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @tkobayas
but IIUC, the problem is elsewhere (please correct me if I'm wrong)

@@ -268,6 +268,7 @@ public RuleDescr visitRuledef(DRLParser.RuledefContext ctx) {
ruleDescr.setConsequence(trimThen(getTokenTextPreservingWhitespace(ctx.rhs(), tokenStream))); // RHS is just a text
}

populateStartEnd(ruleDescr, ctx);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @tkobayas , thanks for the PR!
IIUC the comment, it means that a piece of code does not populate correctly a given object (ruleDescr), and your modification somehow "workaround" that.
I read the method, and TBH is somehow "brittle" by itself (I may give detailed explanation of this remark, if you want): would not be better to fix the root problem itself ? Eventually, I would be glad to help there

@gitgabrio
Copy link
Contributor

@mariofusco @baldimir @yesamer
Hi folks. This PR, accidentally, uncover two kinds of issues we are currently ignoring:

  1. technical debt, that instead of being addressed is workarounded
  2. increase of technical debt, polluting the code of such "workarounds"

IMO we have to to change the approach and the mindset, striving to improve the code whenever we have the chance: wdyt ?

@tkobayas
Copy link
Contributor Author

@gitgabrio Thank you for the suggestion.

startCharacter and endCharacter are Descr's properties, so populating them is not a workaround, rather a right thing to do from the parser point of view.

Having said that,

  • This PR is okay as-is

and

  • It's great to refactor/improve the ChangeSetBuilder.diffDescrs method, so could you file it as a separate issue?

Does it make sense?

Thanks!

@gitgabrio
Copy link
Contributor

gitgabrio commented Mar 19, 2024

@tkobayas
if

startCharacter and endCharacter are Descr's properties

why they are not already populated at that specific point, and the proposed modification has to populate them ?

populating them is not a workaround, rather a right thing to do from the parser point of view.

Yes, I understand that "from the parser point of view" this could be the right fix, but IIUC the problem is somewhere else (please correct me if I'm wrong, I'm simply inferring from your own comment) and we, as communtiy, have to manage all the codebase as a whole.
As usual, I may be wrong on all my remarks, and I can't wait to talk directly with you, to get to a better understanding.

@tkobayas
Copy link
Contributor Author

if

startCharacter and endCharacter are Descr's properties

why they are not already populated at that specific point, and the proposed modification has to populate them ?

startCharacter and endCharacter should be populated when the RuleDescr is created, and the PR fix does it --- in the same method DRLVisitorImpl.visitRuledef.

Talking about the root cause "why we had this bug", I think of

  • We can improve the way to create Descr objects not to miss populating the properties in DRLVisitorImpl
  • Add more test cases

In this regard, I filed #5798

but IIUC the problem is somewhere else (please correct me if I'm wrong, I'm simply inferring from your own comment)

My comment:

The root cause was that RuleDescr.getStartCharacter() returned -1 (missed in DRLVisitorImpl), so the kbase was not updated (the error was logged). So fixed.

meant that the RuleDescr.startCharacter was -1 at the point. It had to be populated by DRLVisitorImpl beforehand. So I wanted to explain that the root cause was DRLVisitorImpl, not ChangeSetBuilder.diffDescrs.

I can't wait to talk directly with you, to get to a better understanding.

Sure, we can talk on meet or zoom.

Copy link
Contributor

@gitgabrio gitgabrio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tkobayas
Many thanks for the chat and the explanation: it clarifies things a lot!
With that in place, I see this PR is good to merge.
Thanks again!

@tkobayas
Copy link
Contributor Author

@gitgabrio Thanks!

@tkobayas tkobayas merged commit 8bf5075 into apache:dev-new-parser Mar 21, 2024
0 of 3 checks passed
@gitgabrio
Copy link
Contributor

@mariofusco @tkobayas @baldimir @yesamer
Follow up ticket

@yurloc
Copy link
Contributor

yurloc commented Mar 21, 2024

Overall fixing progress: There were 407 failed tests.

tkobayas added a commit to tkobayas/drools that referenced this pull request Jun 11, 2024
tkobayas added a commit to tkobayas/drools that referenced this pull request Oct 2, 2024
tkobayas added a commit to tkobayas/drools that referenced this pull request Oct 11, 2024
tkobayas added a commit that referenced this pull request Oct 11, 2024
rgdoliveira pushed a commit to rgdoliveira/drools that referenced this pull request Oct 24, 2024
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.

4 participants