I've just moved the code back from the sandbox, and when running the D8 tests on the d.o test bot for the first time I got a lot of errors. Running locally, everything is fine, and the last Travis builds also didn't show these errors (they only had an issue with the very long-running processor integration test).

So, I guess we should soon investigate what could be behind this, what differences there are in d.o's testbot environment, etc., and fix those incompatibilities so we can have proper testing integration in the D8 issue queue as well.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

drunken monkey’s picture

Tried the solution Berdir mentions in #2386309-1: Views query plugin does not check for aborted in build() method. Cross your fingers …

Berdir’s picture

drunken monkey’s picture

Hm, no, it seems that didn't help at all … :-/

drunken monkey’s picture

Ah, OK, great! So that causes all our test failures? (OK, all except the new ProcessorIntegrationTest failures I just saw locally …)
However, I don't really understand the issue. Is the fix of moving the test modules to the root directory of the module still necessary, or can I revert that?

Berdir’s picture

Not sure, moving it worked for us, if it doesn't for you then you can probably move it back. Hard to test.

Berdir’s picture

The mentioned core issue was committed today.

I think there are valid test fails now as well, e.g. related to config schema validation. That is now strict by default.

Berdir’s picture

Yep, looking at https://qa.drupal.org/pifr/test/577238, all I can see there right now are schema validation failures.

Nick_vh’s picture

FileSize
9.61 KB

Started fixing the schema errors and some other annoying errors that I came across when trying to fix the tests.

Berdir’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 9: 2386357-9.patch, failed testing.

Nick_vh’s picture

FileSize
9.61 KB

Reversed patch...

Nick_vh’s picture

no needs review needed yet. Tests won't pass yet.

drunken monkey’s picture

Are you currently working on this, or is there a newer version? Otherwise I'd now have the time to work on this myself. (It's probably a good idea to first fix all of this before tackling other issues.)

Nick_vh’s picture

If you want to work on this, please take the patch and improve and post back. That way we can iteratively fix the test failures. Mostly they are schema inconsistencies.

Nick_vh’s picture

Status: Needs work » Needs review
drunken monkey’s picture

Sorry, won't have the time after all, just got a pretty time-intensive project for the next weeks.
I'll see what I can do, but probably I won't have time to work on D8 again until March. :-/ (I'll try to commit any patches you come up with, though – otherwise please ping me via mail!)

Berdir’s picture

FileSize
13.49 KB
4.79 KB

Worked a bit on this.

Status: Needs review » Needs work

The last submitted patch, 18: 2386357-18.patch, failed testing.

Berdir’s picture

Status: Needs work » Needs review
FileSize
20.34 KB
9.32 KB

This should be close. Can't reproduce the local task test fails locally, but I've seen them elsewhere too.

The test failures in IntegrationTest were annoying. It was all the bundles schema. It was integer, but that was wishful thinking, what we actually store are strings, because checkboxes. Casting that to integer resulted in them being stored as 0. I also tried boolean, which I think we would be correct, but *that* broke change tracking in the setConfiguration() method, maybe we could fix that too, but I gave up and just went with string for now.

Will comment a bit on my changes in a self-review.

Berdir’s picture

  1. +++ b/config/schema/search_api.datasource.schema.yml
    @@ -1,14 +1,13 @@
    -# @todo Update the key when https://www.drupal.org/node/2291073 is fixed.
    -search_api.datasource.plugin.entity:
    +"search_api.datasource.plugin.entity:*":
       type: mapping
       label: 'Entity datasource configuration'
    

    This works now :)

  2. +++ b/config/schema/search_api.datasource.schema.yml
    @@ -1,14 +1,13 @@
           label: 'The selected bundles'
           sequence:
             - type: string
    -          label: 'An entity bundle'
    +          label: 'Value to define if the bundle was selected or not'
    

    Did not even notice that it was in fact string before, should probably revert the label too?

  3. +++ b/config/schema/search_api.tracker.schema.yml
    @@ -0,0 +1,7 @@
    +# @todo Update the key when https://www.drupal.org/node/2291073 is fixed.
    +search_api.tracker.plugin.default:
    

    I think those @todo additions and removals were added by Nick, didn't track them down, not sure why we remove some and add others.

  4. +++ b/src/Entity/Index.php
    @@ -258,6 +258,8 @@ class Index extends ConfigEntityBase implements IndexInterface {
     
    +
    +
       /**
    
    @@ -464,8 +466,10 @@ class Index extends ConfigEntityBase implements IndexInterface {
               /** @var $processor \Drupal\search_api\Processor\ProcessorInterface */
               $processor = $processorPluginManager->createInstance($name, $settings);
    +
               if ($processor->supportsIndex($this)) {
                 $this->processors[$name] = $processor;
    +
               }
    

    Unneeded changes.

  5. +++ b/src/Entity/Index.php
    @@ -1127,6 +1131,7 @@ class Index extends ConfigEntityBase implements IndexInterface {
         $this->options['processors']['language']['status'] = TRUE;
         $this->options['processors']['language']['weight'] = -50;
    +    $this->options['processors']['language']['processorPluginId'] = 'language';
    

    The fact that we have to add the key inside is a bit annoying, also the fact that this behavior is currently only in the form (and now here).

  6. +++ b/src/Form/IndexFiltersForm.php
    @@ -182,7 +182,12 @@ class IndexFiltersForm extends EntityForm {
    -        $processor->validateConfigurationForm($form['settings'][$name], $processor_form_state);
    +        // @todo: $processor sometimes (?) is a plugin_id here, instead of an
    +        //   object as expected. submitForm() has the same check but this does
    +        //   not seem correct.
    +        if (is_object($processor)) {
    +          $processor->validateConfigurationForm($form['settings'][$name], $processor_form_state);
    

    What the todo says, I followed the lead of submitForm() here, but I don't think it is correct.

  7. +++ b/src/Form/IndexForm.php
    @@ -505,14 +506,18 @@ class IndexForm extends EntityForm {
    +    $datasource_configuration = array();
         foreach ($form_state->get('datasource_plugins') as $datasource_id => $datasource) {
           $datasource->submitConfigurationForm($datasource_forms[$datasource_id], $datasource_form_states[$datasource_id]);
    +      $datasource_configuration[$datasource_id] = $datasource->getConfiguration();
         }
    +    $index->set('datasource_configs', $datasource_configuration);
     
         /** @var \Drupal\search_api\Tracker\TrackerInterface $tracker */
         $tracker = $form_state->get('tracker_plugin');
         $tracker_form_state = $form_state->get('tracker_form_state');
         $tracker->submitConfigurationForm($form['tracker_config'], $tracker_form_state);
    +    $index->set('tracker_config', $tracker->getConfiguration());
    

    This was one of the many wrong leads that I followed with IntegrationTest. The weird part about the index edit form is that we call the submit methods on the plugins, let them update their configuration, but then don't core about that. The reason it worked is because we got the values mapped into datasource_configs directly from the form values. So if a plugin wants to convert something (e.g., checkbox values to bool), we would never see that.

    This means that we set it twice now. Core has similar weird behavior with block settings, they are also set through the default entity form behavior and through the plugins. There it works automatically through plugin collections, maybe we should use that in search api too, but those changes are not trivial and it wouldn't really change something.

  8. +++ b/src/Form/IndexForm.php
    @@ -534,7 +539,7 @@ class IndexForm extends EntityForm {
    -      catch (\Exception $ex) {
    +      catch (SearchApiException $ex) {
    

    I changed this because it eat the config schema exceptions. I'm not sure why exactly we are catching all exceptions here and are displaying only a generic error message, and what exception we should catch, but I left it for now.

  9. +++ b/src/Plugin/search_api/processor/RoleFilter.php
    @@ -96,8 +96,6 @@ class RoleFilter extends ProcessorPluginBase {
    -    // Annoyingly, this doc comment is needed for PHPStorm. See
    -    // http://youtrack.jetbrains.com/issue/WI-23586
         /** @var \Drupal\search_api\Item\ItemInterface $item */
         foreach ($items as $item_id => $item) {
    

    No idea why this is removed?

  10. +++ b/src/Plugin/search_api/processor/Stopwords.php
    @@ -61,14 +61,24 @@ class Stopwords extends FieldsProcessorPluginBase {
        */
    +
       public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
    

    More unneeded changes.

  11. +++ b/src/Plugin/search_api/processor/Stopwords.php
    @@ -61,14 +61,24 @@ class Stopwords extends FieldsProcessorPluginBase {
    +    $stopwords = $this->getConfiguration()['stopwords'];
    +    if (is_array($stopwords)) {
    +      $default_value = implode("\n", $stopwords);
    +    }
    

    I only fixed the condition here, was if (!array($stopwords), no idea what that was supposed to do :)

    Also not sure why this is even necessary, when is it not an array?

Status: Needs review » Needs work

The last submitted patch, 20: 2386357-20.patch, failed testing.

Berdir’s picture

Status: Needs work » Needs review
FileSize
15.62 KB
10.88 KB

Uff, that was real scary. Something super weird happend when serializing and unseralizing the $processors array in $form_state. So I refactored it to only keep it that between validate and submit, and also some more changes there to avoid saving settings for disabled sensors, because they have not been validate/processed.

Still no idea about LocalTasksTest, I've seen that fail before, but it is working fine for me now, in UI, run-test.sh, phpunit, locally and on the server that is running http://d8ms.worldempire.ch/, as visible there, and I saw it failing there as well some days ago. So wth?

Berdir’s picture

FileSize
21.92 KB
5.98 KB

Wrong patches.

Status: Needs review » Needs work

The last submitted patch, 24: 2386357-23.patch, failed testing.

Berdir’s picture

Status: Needs work » Needs review
FileSize
22.91 KB
6.97 KB

The new test fail is easy to fix. But I'm officially giving up on LocalTasksTest. I suggest to disable/drop that and open an issue to figure out what is going on and enable it again.

Berdir’s picture

FileSize
1009 bytes

interdiff was wrong.

Status: Needs review » Needs work

The last submitted patch, 26: 2386357-25.patch, failed testing.

Berdir’s picture

Status: Needs work » Needs review
FileSize
25.93 KB
3.43 KB

More core changes...

Berdir’s picture

FileSize
26.36 KB
446 bytes

And here is a patch that disables that test. not sure if that will actually work with testbot. Otherwise we have to drop the class.

The last submitted patch, 29: 2386357-29.patch, failed testing.

drunken monkey’s picture

Status: Needs review » Fixed

Uff, that was real scary. Something super weird happend when serializing and unseralizing the $processors array in $form_state. So I refactored it to only keep it that between validate and submit, and also some more changes there to avoid saving settings for disabled sensors, because they have not been validate/processed.

See #2383093-8: Fix saving of "Fields" settings on processors: I already discovered and fixed that.
And with #2349435-27: Seperate filters/processors by stage still awaiting reviews, we now have two monster patches, partially fixing the same things and, pretty surely, often touching the same code. Also really scary.
But since this fixes all the tests and makes the test bot happy again, I guess comitting this right away makes the most sense. I'll just have to find the time to do a merge with the other branch again – probably not before the week after next, though. (If someone else feels strong enough, that would of course be a great help! But, in any case, better not work on something large other than that merge for now – don't want to create another big patch needing to be merged.) At that point I'll also review this patch properly – I sadly don't have the time right now.

Anyways, thanks a lot for your help, must have been quite some work!
Committed.
Thanks again!
Also thanks to Nick for providing the initial patches!

The last submitted patch, 12: 2386357-11.patch, failed testing.

The last submitted patch, 23: 2406103.15.patch, failed testing.

Berdir’s picture

Yay! :)

Seeing all those old issues being re-opened by the testbot, looks like we have a green search_api 8.x-1.x branch in the main project for the first time :)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.