Problem/Motivation
Splitting task from #2791619: Test Monitoring Mail with real examples, this issue is created to fix the bug for the status race condition:
a result is/is not logged based on status change, but to send a mail we always checked with the second last sensor result which could be/not be outdated (as we store the current result as the "last sensor result" if the status changes).
Added a setter/getter to set the previous result when we want to log the current one, so we don't get the wrong result and don't need to fancy store the previous status to check if a mail needs to be sent.
And write a test.
Proposed resolution
- fix the bug implementing a setter/getter for SensorResult
- write a test to check if the previous sensor result is what we expect.
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#10 | get_the_correct_previous_result-2800055-10.patch | 8.37 KB | Ginovski |
#10 | interdiff-2800055-6-10.txt | 4.05 KB | Ginovski |
#6 | get_the_correct_previous_result-2800055-6.patch | 8.82 KB | Ginovski |
#2 | get_the_correct_previous_result-2800055-2.patch | 10.96 KB | tduong |
Comments
Comment #2
tduong CreditAttribution: tduong at MD Systems GmbH commentedHere is a first patch. Still needs work for the test, left a @todo in the assert helper method.
Comment #4
tduong CreditAttribution: tduong at MD Systems GmbH commentedRaise priority because the parent issue is waiting for this to be committed.
Comment #5
Ginovski CreditAttribution: Ginovski at MD Systems GmbH commentedHere there are 2 results asserted, but one is a SensorResultEntity and the other is SensorResult. So the function assertSameResultHelper would take an entity and a result object and try to compare them (right now it takes 2 entities instead). But I don't think this is necessary, because we are comparing 2 different objects and we only need to compare some properties between the entity and the result. I suggest we can do a regular assertion in this test only for the statuses?
Comment #6
Ginovski CreditAttribution: Ginovski at MD Systems GmbH commentedHere is a patch with the solution suggested in #5, along with some minor changes:
1. Changed the test comments and some result comparison.
2. Removed monitoring_sensor_result_second_last() since it is not used anymore.
Comment #7
Berdirmonitoring is now stable and this is a method in a non-experimental module.
I suppose nobody uses it yet, but we can't just remove this now.
So, keep it but add a @deprecated method like they exist on deprecated core methods. Schedule removel for 8.x-2.0 or something like that.
use the interface
what happens with cached sensors? are we now serializing the injected object when caching? We should avoid that and set it again or so.
Comment #8
miro_dietikerWe could drop setPreviousResult() and simply use call getPreviousResult() here that internally uses monitoring_sensor_result_last().
Then internally set the property and simply drop it on serialisation.
Comment #9
Berdir3. We checked that and the current logic is fine, so you can ignore that part.
Comment #10
Ginovski CreditAttribution: Ginovski at MD Systems GmbH commented1. Added the second_last function again.
2. Using the DataInterface for the previous result. (this makes it easier to assert results with Tramy's method - assertSameResult() ).
Comment #12
miro_dietikerIn general looks fine to me. :-)
However, lots of small unrelated changes... Reverted them.
And please don't touch things such as removing file headers. If you want to do this, submit a separate issue that does this for ALL files.
Otherwise, patches conflict with those clean-ups being present here and there.