Support from Acquia helps fund testing for Drupal Acquia logo

Comments

gabesullice created an issue. See original summary.

gabesullice’s picture

gabesullice’s picture

Status: Active » Needs review
Wim Leers’s picture

CI error because

java.lang.NullPointerException

Retesting.


+++ b/src/Normalizer/RelationshipItemNormalizer.php
@@ -52,16 +52,6 @@ class RelationshipItemNormalizer extends FieldItemNormalizer {
-  public function setSerializer(SerializerInterface $serializer) {

Why this change? Seems unrelated.

gabesullice’s picture

Why this change? Seems unrelated.

Its only purpose is to set the serializer on JsonApiDocumentTopLevelNormalizer, which isn't necessary anymore because the DI container should already be doing this for us, which is the point of this issue ;)

Wim Leers’s picture

I've been ignoring this because it's filed against 8.x-2.x. Any reason to not just get this in right now?

gabesullice’s picture

Version: 8.x-2.x-dev » 8.x-1.x-dev

Nope, go for it!

gabesullice’s picture

Status: Needs review » Active
Wim Leers’s picture

Rebased #2. No changes at all.

Wim Leers’s picture

00:01:22.569 ------------
00:01:22.569 
00:01:54.209 Drupal\Tests\jsonapi\Functional\RestJsonApiUnsupported         0 passes             1 exceptions             
00:01:54.210 FATAL Drupal\Tests\jsonapi\Functional\RestJsonApiUnsupported: test runner returned a non-zero error code (2).
00:01:54.211 Drupal\Tests\jsonapi\Functional\RestJsonApiUnsupported         0 passes   1 fails                            
00:04:26.770 Drupal\Tests\jsonapi\Functional\JsonApiFunctionalMultilingua   0 passes             1 exceptions             
00:04:26.931 FATAL Drupal\Tests\jsonapi\Functional\JsonApiFunctionalMultilingualTest: test runner returned a non-zero error code (2).
00:04:26.932 Drupal\Tests\jsonapi\Functional\JsonApiFunctionalMultilingua   0 passes   1 fails                            
00:23:48.286 Drupal\Tests\jsonapi\Functional\TestCoverageTest               1 passes   

It looks like this patch horribly breaks things :P

Status: Needs review » Needs work

The last submitted patch, 9: 2962461-9.patch, failed testing. View results

Wim Leers’s picture

Status: Needs work » Needs review

I can't reproduce those failures locally. I thought it might've been a 8.5 vs 8.6 thing. But no, passes on both locally…

So the only thing I can think of to do is to retest, and hope it was a DrupalCI glitch.

Status: Needs review » Needs work

The last submitted patch, 9: 2962461-9.patch, failed testing. View results

Wim Leers’s picture

Two times this:

00:04:31.674 
01:50:00.719 Build timed out (after 110 minutes). Marking the build as aborted.
01:50:00.721 Build was aborted
01:50:00.722 ERROR: Step ?Archive the artifacts? failed: no workspace for drupal8_contrib_patches #30611
01:50:00.722 Checking console output

How is this even possible?! I have no idea.

Mixologic’s picture

I kicked off another one of these tests, and whatever this patch is doing is causing the testbots to get themselves into an infinite loop somehow. Im trying to ssh into the machine and its utterly crippled. The bots are completely out of memory (64GB) and swap.

This leads me to believe its not bot related, but patch related.

Mixologic’s picture

I was able to get onto one of the dying bots and get this:

<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
  <testsuite name="Drupal\Tests\jsonapi\Functional\ExternalNormalizersTest" file="/var/www/html/modules/contrib/jsonapi/tests/src/Functional/ExternalNormalizersTest.php" tests="2" assertions="0" failures="0" errors="2" time="0.000000">
    <testsuite name="Drupal\Tests\jsonapi\Functional\ExternalNormalizersTest::testFormatAgnosticNormalizers" tests="2" assertions="0" failures="0" errors="2" time="0.000000">
      <testcase name="testFormatAgnosticNormalizers with data set &quot;Format-agnostic @FieldType-level normalizers SHOULD NOT be able to affect the JSON API normalization&quot;" assertions="0" time="0.000000">
        <error type="PHPUnit_Framework_Exception">Drupal\Tests\jsonapi\Functional\ExternalNormalizersTest::testFormatAgnosticNormalizers with data set "Format-agnostic @FieldType-level normalizers SHOULD NOT be able to affect the JSON API normalization" ('jsonapi_test_field_type', 'Llamas are super awesome!')
PHPUnit_Framework_Exception: Killed

</error>
      </testcase>
      <testcase name="testFormatAgnosticNormalizers with data set &quot;Format-agnostic @DataType-level normalizers SHOULD be able to affect the JSON API normalization&quot;" assertions="0" time="0.000000">
        <error type="PHPUnit_Framework_Exception">Drupal\Tests\jsonapi\Functional\ExternalNormalizersTest::testFormatAgnosticNormalizers with data set "Format-agnostic @DataType-level normalizers SHOULD be able to affect the JSON API normalization" ('jsonapi_test_data_type', 'Llamas are NOT awesome!')
PHPUnit_Framework_Exception: Killed

</error>
      </testcase>
    </testsuite>
  </testsuite>
</testsuites>

Not much help, but perhaps if you ran this patch against just one test?

Wim Leers’s picture

I ran this test using both test runners:

  1. /usr/local/bin/php /private/var/folders/f6/g_q2g6w545z_q3h4cx7kv2qm0000gn/T/ide-phpunit.php --configuration /Users/wim.leers/Work/d8/core/phpunit.xml Drupal\Tests\jsonapi\Functional\ExternalNormalizersTest /Users/wim.leers/Work/d8/modules/jsonapi/tests/src/Functional/ExternalNormalizersTest.php
    Testing started at 19:06 ...
    #!/usr/bin/env php
    PHPUnit 6.5.8 by Sebastian Bergmann and contributors.
    
    Testing Drupal\Tests\jsonapi\Functional\ExternalNormalizersTest
    ..                                                                  2 / 2 (100%)
    
    Time: 16.34 seconds, Memory: 6.00MB
    
    OK (2 tests, 0 assertions)
    
    Process finished with exit code 0
    
    
  2. $ php core/scripts/run-tests.sh --url http://d8 --class "\Drupal\Tests\jsonapi\Functional\ExternalNormalizersTest"
    
    Drupal test run
    ---------------
    
    Tests to be run:
      - \Drupal\Tests\jsonapi\Functional\ExternalNormalizersTest
    
    Test run started:
      Thursday, May 31, 2018 - 17:07
    
    Test summary
    ------------
    
    Drupal\Tests\jsonapi\Functional\ExternalNormalizersTest        2 passes                                      
    
    Test run duration: 15 sec
    
    
    wim.leers at acquia in ~/Work/d8 on 8.6.x [!?]
    

IDK what else to do.

Wim Leers’s picture

Oh wait:

OK (2 tests, 0 assertions)

ZERO assertions! So this code is somehow breaking PHPUnit. But how!?!

Wim Leers’s picture

Status: Needs work » Needs review
FileSize
5.26 KB
5.92 KB
+++ b/jsonapi.services.yml
@@ -75,6 +75,8 @@ services:
   serializer.normalizer.jsonapi_document_toplevel.jsonapi:
     class: Drupal\jsonapi\Normalizer\JsonApiDocumentTopLevelNormalizer
     arguments: ['@jsonapi.link_manager', '@entity_type.manager', '@jsonapi.resource_type.repository']
+    calls:
+      - [setSerializer, ['@jsonapi.serializer_do_not_use_removal_imminent']]
     tags:

Gabe and I think this must be triggering an endless loop.

Rather than fixing this particular problem, I dug deeper, and removed the need for JsonApiDocumentTopLevelNormalizer to get injected into RelationshipItemNormalizer … which is what made

+++ b/src/Normalizer/RelationshipItemNormalizer.php
@@ -54,16 +54,6 @@ class RelationshipItemNormalizer extends FieldItemNormalizer {
-  public function setSerializer(SerializerInterface $serializer) {
-    parent::setSerializer($serializer);
-    $this->jsonapiDocumentToplevelNormalizer->setSerializer($serializer);
-  }

necessary in the first place. And in doing so, I resolved two @todos!

Status: Needs review » Needs work

The last submitted patch, 19: 2962461-19.patch, failed testing. View results

Wim Leers’s picture

Assigned: Unassigned » Wim Leers

Much better! Actual test failures instead of breaking testbot :D 🎉

All failures are in \Drupal\Tests\jsonapi\Kernel\Normalizer\JsonApiDocumentTopLevelNormalizerTest, but all integration/functional tests are passing. The only possible conclusion is that the kernel test is mocking something incorrectly. Will determine what that is.

Wim Leers’s picture

Assigned: Wim Leers » Unassigned
Status: Needs work » Needs review
FileSize
1.12 KB
6.59 KB
gabesullice’s picture

Status: Needs review » Reviewed & tested by the community

Fantastic! What a terribly esoteric bug. I like where we ended up though.

  • Wim Leers committed 242be8b on 8.x-1.x
    Issue #2962461 by Wim Leers, gabesullice:...
  • Wim Leers committed f3572c8 on 8.x-2.x
    Issue #2962461 by Wim Leers, gabesullice:...
Wim Leers’s picture

Status: Reviewed & tested by the community » Fixed

Committed!

This also enables a simplification in #2948666, see #2948666-32: Remove JSON API's use of $context['cacheable_metadata'].2.

Status: Fixed » Closed (fixed)

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