Closed (fixed)
Project:
Monitoring
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
24 Aug 2015 at 15:22 UTC
Updated:
1 Oct 2015 at 06:53 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
giancarlosotelo commentedComment #3
berdirSounds like that's my fault. I wasn't aware that the watchdog sensor is addable.
This was broken by #2543886: Allow database sensor plugins to control which configuration elements are shown. We need what we discussed there, the concept of default configuration so that when you add a new one of a given type, it starts with that set of settings. We will need to discuss this.
Comment #4
giancarlosotelo commentedHere is a patch adding a default configuration. I am wondering if we need to create test for this issue.
Comment #5
miro_dietiker;-)
No reason to wonder. It's a bug and it has no test coverage. It definitively needs test coverage by our definition of done.
In cases of a bug, i recommend you to once start with writing the (failing) test first and then start writing code to fix the test.
Comment #6
miro_dietikerDon't call this twice.
Wrong indentation.
Mind the core ConfigurablePluginInterface. Should we reuse it here?
Comment #7
berdir3. No, we can't. That assumes configuration is an array, but we use the sensor config entity directly. Would be weird to mix that.
Comment #8
giancarlosotelo commentedTestonly patch and patch with comments on #6 and test
Comment #9
giancarlosotelo commentedComment #10
juanse254 commentedEmpty line here, and the SafeMarkup::format is no needed here, guess that t() should be enough. have a look at
Comment #11
juanse254 commentedhttps://api.drupal.org/api/drupal/core%21lib%21Drupal%21Component%21Util...
Comment #12
giancarlosotelo commentedDone and removed @label, it probably is not worth it.
Comment #13
miro_dietikerUse the same structure in default configuration as in the settings. Just set the entity settings and it should work.
Plz mention that we are testing default configuration here.
Comment #14
giancarlosotelo commentedDone, much better now.
Comment #15
miro_dietikerMuch better. Almost. ;-)
This should not be in validateForm().
Default config is about default values, before the form is displayed. So the form should represent the default values.
Set the entity settings on the entity in form() around:
Comment #16
giancarlosotelo commentedOk I change the location of the default config and it has to be after .
Because a selected plugin is needed and the settings have to be set in that way.
Comment #17
giancarlosotelo commentedComment #18
miro_dietikerExactly. Now one last thing more to make test coverage happy.
Here you should check that the default values are filled out in the form. :-)
Comment #19
berdirSorry, but miro is wrong :)
Your code *overwrites* existing settings every time the form is displayed.
As discussed, the correct place to set this is submitSelectPlugin(), which is where the plugin *changes*. Then we need to reset the settings back to the defaults of that plugin type. Always, even if they are empty.
Also, you can't test this in the UI since those settings aren't visible. You need to actually run the sensor to test it.
Comment #20
giancarlosotelo commentedWell now it is in the right place and also small fix with the timestamp to be displayed in the right way (was wrong).
Comment #21
giancarlosotelo commentedAdded an assert after the sensor is created in test and a better approach to set default configuration.
Comment #22
giancarlosotelo commentedAn extra space removed.
Comment #23
juanse254 commentedThe code seems fine, still waiting for the test to pass.
Comment #24
miro_dietikerMuch nice now. Monitoring HEAD is broken, so we can wait forever until this is green... ;-)
Comment #26
miro_dietikerAwesome, working default configuration with nice test coverage!
Fails unrelated, the UI test passes.
Comment #46
giancarlosotelo commented