boc-tothefuture / openhab-jruby

JRuby Libraries for Openhab
Eclipse Public License 2.0
6 stars 9 forks source link

Cucumber test runs twice #595

Closed jimtng closed 2 years ago

jimtng commented 2 years ago

I have noticed this when I ran one particular scenario while tailing the log, it seems that the same scenario is executed twice.

I would see two instances of these

11:23:38.672 [INFO ] [.rulesupport.loader.ScriptFileWatcher] - Loading script '/home/jimmy/Projects/openhab-jruby/tmp/openhab/conf/automation/jsr223/ruby/personal/cucumber_test20220427-1395833-1sl7br4.rb'
11:23:41.697 [INFO ] [cucumber_test20220427-1395833-1sl7br4] - Processing Started for 41f62734-4da0-4694-a182-26e9030469fe
11:23:41.741 [INFO ] [cucumber_test20220427-1395833-1sl7br4] - Processing Complete for 41f62734-4da0-4694-a182-26e9030469fe

11:23:42.771 [INFO ] [.rulesupport.loader.ScriptFileWatcher] - Loading script '/home/jimmy/Projects/openhab-jruby/tmp/openhab/conf/automation/jsr223/ruby/personal/cucumber_test20220427-1395833-1sl7br4.rb'
11:23:45.022 [INFO ] [cucumber_test20220427-1395833-1sl7br4] - Processing Started for 41f62734-4da0-4694-a182-26e9030469fe
11:23:45.049 [INFO ] [cucumber_test20220427-1395833-1sl7br4] - Processing Complete for 41f62734-4da0-4694-a182-26e9030469fe

So it's the same file name. Just that Loading script happens twice, and therefore openhab processed it twice.

But only one of:

11:23:43.764 [INFO ] [openhab.event.ItemCommandEvent       ] - Item 'Alarm_Mode' received command 7

So perhaps the test didn't run twice, but somehow openhab loads the script twice.

I tried manually moving the script file out of conf/automation/jsr223/ruby/personal then move it back in, and this time openhab only processed the script once.

jimtng commented 2 years ago

I discovered what caused this problem.

atomic_rule_write creates the Temp file in /tmp and then calls FileUtils.rename. Normally when /tmp and the main conf/automation/jsr223 are in the same partition, this results in the intended atomic move operation.

However, when /tmp is on a separate partition, rename cannot move the file, so it needs to copy. For some reason, this caused OpenHAB file watcher to load the target file twice.

github-actions[bot] commented 2 years ago

:tada: This issue has been resolved in version 4.43.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: