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

Added rule rest endpoint and backend operation for rule execution simulation #2125

Merged
merged 18 commits into from
Apr 11, 2021

Conversation

soenkekueper
Copy link
Contributor

@soenkekueper soenkekueper commented Jan 17, 2021

Fixes #2044
Fixes #2266

UI PR is openhab/openhab-webui#815

@soenkekueper soenkekueper requested a review from a team as a code owner January 17, 2021 13:30
@soenkekueper soenkekueper changed the title 2044 schedule with conditions 2044 Added rule rest endpoint and backend operation for rule execution simulation Jan 17, 2021
@soenkekueper soenkekueper changed the title 2044 Added rule rest endpoint and backend operation for rule execution simulation Added rule rest endpoint and backend operation for rule execution simulation Jan 17, 2021
Base automatically changed from master to main January 18, 2021 20:04
@wborn wborn added rebuild Triggers the Jenkins PR build and removed rebuild Triggers the Jenkins PR build labels Jan 18, 2021
@soenkekueper
Copy link
Contributor Author

soenkekueper commented Jan 20, 2021

Hey,

i need your help here :(

The jenkins build fails with the following error messages:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  02:58 min (Wall Clock)
[INFO] Finished at: 2021-01-19T01:41:36Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project org.openhab.core.automation.integration.tests: Compilation failure: Compilation failure: 
[ERROR] /home/jenkins/jenkins-agent1/workspace/PR-openHAB-Core/itests/org.openhab.core.automation.integration.tests/src/main/java/org/openhab/core/automation/integration/test/RuleSimulationTest.java:[41,8] The import org.openhab.core.automation.RuleExecution cannot be resolved
[ERROR] /home/jenkins/jenkins-agent1/workspace/PR-openHAB-Core/itests/org.openhab.core.automation.integration.tests/src/main/java/org/openhab/core/automation/integration/test/RuleSimulationTest.java:[135,14] RuleExecution cannot be resolved to a type
[ERROR] /home/jenkins/jenkins-agent1/workspace/PR-openHAB-Core/itests/org.openhab.core.automation.integration.tests/src/main/java/org/openhab/core/automation/integration/test/RuleSimulationTest.java:[135,53] The method simulateRuleExecutions(java.time.ZonedDateTime, java.time.ZonedDateTime) is undefined for the type org.openhab.core.automation.RuleManager
[ERROR] /home/jenkins/jenkins-agent1/workspace/PR-openHAB-Core/itests/org.openhab.core.automation.integration.tests/src/main/java/org/openhab/core/automation/integration/test/RuleSimulationTest.java:[141,18] RuleExecution cannot be resolved to a type
[ERROR] /home/jenkins/jenkins-agent1/workspace/PR-openHAB-Core/itests/org.openhab.core.automation.integration.tests/src/main/java/org/openhab/core/automation/integration/test/RuleSimulationTest.java:[162,40] RuleExecution cannot be resolved to a type
[ERROR] /home/jenkins/jenkins-agent1/workspace/PR-openHAB-Core/itests/org.openhab.core.automation.integration.tests/src/main/java/org/openhab/core/automation/integration/test/RuleSimulationTest.java:[191,47] CFG_START_TIME cannot be resolved or is not a field
[ERROR] /home/jenkins/jenkins-agent1/workspace/PR-openHAB-Core/itests/org.openhab.core.automation.integration.tests/src/main/java/org/openhab/core/automation/integration/test/RuleSimulationTest.java:[192,47] CFG_END_TIME cannot be resolved or is not a field
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <args> -rf :org.openhab.core.automation.integration.tests
Build step 'Execute shell' marked build as failure
[htmlpublisher] Archiving HTML reports...
[htmlpublisher] Archiving at BUILD level /home/jenkins/jenkins-agent1/workspace/PR-openHAB-Core/target to /var/jenkins_home/jobs/PR-openHAB-Core/builds/3049/htmlreports/Static_20Code_20Analysis_20Report
Finished: FAILURE

So this seems that my changes within the bundle org.openhab.core.automation are not available when building the org.openhab.core.automation.integration.tests bundle. It seems to me if an wrong version of the previous build bundle has been resolved?!

Confusing is also that the jenkins status page https://ci.openhab.org/job/PR-openHAB-Core/3049/ shows up green for all the given modules but the build is failed...

What can i do?

Of course this compiles and runs on my machine :D

Thanks!

@cweitkamp cweitkamp added rebuild Triggers the Jenkins PR build automation REST/SSE and removed rebuild Triggers the Jenkins PR build labels Jan 21, 2021
@soenkekueper soenkekueper force-pushed the 2044-ScheduleWithConditions branch from ee94c04 to 3ba1dc3 Compare February 6, 2021 16:09
…e based and thus can be used to simulate execution times.

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>
…time based and thus can be checked during rule execution for a certain time.

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>
Signed-off-by: Sönke Küper <soenkekueper@gmx.de>
Signed-off-by: Sönke Küper <soenkekueper@gmx.de>
Signed-off-by: Sönke Küper <soenkekueper@gmx.de>
Signed-off-by: Sönke Küper <soenkekueper@gmx.de>
Signed-off-by: Sönke Küper <soenkekueper@gmx.de>
Signed-off-by: Sönke Küper <soenkekueper@gmx.de>
Signed-off-by: Sönke Küper <soenkekueper@gmx.de>
Signed-off-by: Sönke Küper <soenkekueper@gmx.de>
Signed-off-by: Sönke Küper <soenkekueper@gmx.de>
…xpression. This better hides the internals of the TriggerHandler (i.e. the cron expression) and is more clear and flexible for other handlers to implement

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>
Signed-off-by: Sönke Küper <soenkekueper@gmx.de>
@soenkekueper soenkekueper force-pushed the 2044-ScheduleWithConditions branch from 3da3d6b to aabee1d Compare April 2, 2021 15:05
@ghys
Copy link
Member

ghys commented Apr 3, 2021

@openhab/core-maintainers maybe you'd want to have a look at this PR?
Overall it looks good, and despite being API breaking, along with openhab/openhab-webui#815, I think it would be a good addition to have a more accurate "Schedule" page in the UI (it would take Ephemeris into account etc.)

Copy link
Contributor

@cweitkamp cweitkamp left a comment

Choose a reason for hiding this comment

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

Thanks for your work. I looked into your PR and left some thoughts.

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>
Signed-off-by: Sönke Küper <soenkekueper@gmx.de>
Signed-off-by: Sönke Küper <soenkekueper@gmx.de>
Signed-off-by: Sönke Küper <soenkekueper@gmx.de>
Signed-off-by: Sönke Küper <soenkekueper@gmx.de>
@openhab-bot
Copy link
Collaborator

This pull request has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/solved-oh3-schedule-rules/120518/8

Copy link
Contributor

@cweitkamp cweitkamp left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you.

@cweitkamp cweitkamp merged commit db488d8 into openhab:main Apr 11, 2021
@cweitkamp cweitkamp added this to the 3.1 milestone Apr 11, 2021
@cweitkamp cweitkamp added the enhancement An enhancement or new feature of the Core label May 2, 2021
fwolter pushed a commit to fwolter/openhab-core that referenced this pull request May 24, 2021
…execution simulation (openhab#2125)

* Added marker interface for TriggerHandler to indicate if they are time based and thus can be used to simulate execution times.
* Added marker interface for ConditionHandler to indicate, if they are time based and thus can be checked during rule execution for a certain time.
* Moved CronAdjuster to common, so it can be used for the rule simulation
* Created RuleExecutionSimulator that allows simulation of rules
* Added method in RuleManger to create simulation
* Added rest endpoint for rule simulation.
* Changed marker interface to return TemporalAdjuster instead of cron expression. This better hides the internals of the TriggerHandler (i.e. the cron expression) and is more clear and flexible for other handlers to implement

Fixes openhab#2044
Fixes openhab#2266

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>
@openhab-bot
Copy link
Collaborator

This pull request has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/ephemeris-condition-with-offset-not-working-in-rules-in-oh-3-1-0m5/123088/4

splatch pushed a commit to ConnectorIO/copybara-hab-core that referenced this pull request Jul 11, 2023
…execution simulation (openhab#2125)

* Added marker interface for TriggerHandler to indicate if they are time based and thus can be used to simulate execution times.
* Added marker interface for ConditionHandler to indicate, if they are time based and thus can be checked during rule execution for a certain time.
* Moved CronAdjuster to common, so it can be used for the rule simulation
* Created RuleExecutionSimulator that allows simulation of rules
* Added method in RuleManger to create simulation
* Added rest endpoint for rule simulation.
* Changed marker interface to return TemporalAdjuster instead of cron expression. This better hides the internals of the TriggerHandler (i.e. the cron expression) and is more clear and flexible for other handlers to implement

Fixes openhab#2044
Fixes openhab#2266

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>
GitOrigin-RevId: db488d8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automation enhancement An enhancement or new feature of the Core REST/SSE
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[automation] Schedule shows disabled rules Ephemeris conditions not evaluated for schedule
5 participants