Problem/Motivation

Test for HAL module are scattered around in other modules. We need to consolidate the

Steps to reproduce

n.a.

Proposed resolution

Move all tests to HAL module.

Remaining tasks

Move all tests to HAL module.

User interface changes

none

API changes

none

Data model changes

none

Release notes snippet

n.a.

Issue fork drupal-3263654

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

bbrala created an issue. See original summary.

bbrala’s picture

That failure is expected since it checks for coverage and the tests have now moved. Will fix later.

bbrala’s picture

StatusFileSize
new14.88 KB

All the scoped tests are moved. These are a few tests left that have some test methods that test hal, or parts of the test methods test HAL. So this part will require a bit more attention :)

Spokje made their first commit to this issue’s fork.

bbrala’s picture

There is a few challenges left. There is quite a few places where the rest module uses hal to test functionality, I'm not entirely sure how to handle that. The same goes for some other places where I'm not sure what the best way is to handle the test changes.

spokje’s picture

Now that's annoying, locally the test passes when ran as a single test:

$ ../vendor/bin/phpunit --stop-on-failure modules/hal/tests/src/Kernel/EntityResource/EntityResourceHalTestCoverageTest.php
PHPUnit 9.5.13 by Sebastian Bergmann and contributors.

Warning:       Your XML configuration validates against a deprecated schema.
Suggestion:    Migrate your XML configuration using "--migrate-configuration"!

Testing Drupal\Tests\hal\Kernel\EntityResource\EntityResourceHalTestCoverageTest
.                                                                   1 / 1 (100%)

Time: 01:19.712, Memory: 10.00 MB

OK (1 test, 1 assertion)

spokje’s picture

Assigned: Unassigned » spokje
spokje’s picture

Assigned: spokje » Unassigned
bbrala’s picture

StatusFileSize
new44.06 KB
new47.95 KB

Hmm, i tried moving the rest export part of comment_test_views test module. But i cant get it to work with only the rest view in the hal module. Kinda annoying but perhaps you could have a look spokje?

(asked this in slack)

Also attached the current search results for hal and hal_json.

Search for 'hal'

Search for hal_json

spokje’s picture

Assigned: Unassigned » spokje
spokje’s picture

Assigned: spokje » Unassigned
Status: Active » Needs review

I think we're there. All HAL related tests should now be in the hal namespace and /core/modules/hal/tests directory.

bbrala’s picture

You rock spokje:)

spokje’s picture

To make sure we indeed moved everything:

  • I've applied the changes in this MR on D10.0.x-dev
  • Then deleted the whole core/modules/hal
  • Altered the drupal-9.3.0.filled.standard.php.gz fixture to _not_ have the HAL module installed

Then ran it through TestBot here: https://www.drupal.org/project/drupal/issues/3191612#comment-14408424, that came back green, so I think we indeed caught them all.

larowlan’s picture

Amazing work

kristen pol’s picture

Title: Move all HAL tests to the module in preperation of removal in d10 » Move all HAL tests to the module in preparation of removal in D10
Issue summary: View changes

Thanks for the updates. I've updated the title and issue summary with typo fixes and minor wording and formatting changes.

spokje’s picture

Thanks @daffie for the review, all threads resolved.

bbrala credited daffie.

bbrala’s picture

Adding Daffie to credit for his (partial?) review.

daffie’s picture

Issue summary: View changes
Status: Needs review » Needs work
diff --git a/core/modules/rest/config/optional/rest.resource.entity.node.yml b/core/modules/hal/config/optional/rest.resource.entity.node.yml
similarity index 100%
rename from core/modules/rest/config/optional/rest.resource.entity.node.yml
rename to core/modules/hal/config/optional/rest.resource.entity.node.yml

Are we sure that we want to do this? The config is be used in core/modules/layout_builder/tests/src/Functional/Rest/OverrideSectionsTest.php. Also we are linking core/core.api.php to this to be removed from core config.

spokje’s picture

Are we sure that we want to do this? The config is be used in core/modules/layout_builder/tests/src/Functional/Rest/OverrideSectionsTest.php. Also we are linking core/core.api.php to this to be removed from core config.

Thus spoketh @daffie in #20

The rationale here is that even when moved as-is to Contrib, HAL needs to work out-of-the-box.. Which means there should be (as before) a working example of a REST endpoint config file. Hence the moving-to-HAL of this config YAML.
The mention in core/core.api.php is altered from a currently already non-existing path to the one in this change.

In the actual removal in D10.0.0 issue for HAL #3049857: Remove HAL module from core and create a contrib project for it we restore the REST endpoint config in /core/modules/rest/config/optional/rest.resource.entity.node.yml but as json instead of hal_json. (As mentioned in the @todo in core/modules/system/tests/src/Functional/System/ResponseGeneratorTest.php). Also we change core/core.api.php once more to link to the config in the REST module.

(And thanks for reviewing these MegaMR)

daffie’s picture

Status: Needs work » Reviewed & tested by the community

I get why the config item has been moved.
All changes look good to me.
All my points are resolved.
For me it is RTBC.

longwave’s picture

Read through the whole patch, the changes almost all look good to me. Added a couple of minor questions but nothing that should block the RTBC.

spokje’s picture

Status: Reviewed & tested by the community » Needs review

To make sure we've met "gotta catch them all" for the moved test, I've applied the changes in this MR to the latest 10.0.x-dev, applied the changes from #3049857: Remove HAL module from core and create a contrib project for it on top of it (which is in essence some small changes, a changed 9.3-filled fixture which has hal module _not_ installed, and deletion of the core/modules/hal directory) here: https://www.drupal.org/project/drupal/issues/3191612#comment-14411302

FWIW: That just came back green.

I've looked at the remarks made by @longwave (tips hat for doing the review), they make sense (per usual) but are indeed more nice to haves IMHO.
I'll try to tackle them later today, if $dayjob allows it. (I'm pretty sure by then this issue won't be committed yet.)

spokje’s picture

Status: Needs review » Reviewed & tested by the community

Hang on, didn't want a status change...

spokje’s picture

Status: Reviewed & tested by the community » Needs review

Thanks @daffie for the review and suggestions. I've tried to incorporate them all.

TestBot returned green, also the "Gotta catch em all" test (Apply the changes in this MR on top of 10.0.x-dev, apply the changes of the removal MR #3049857: Remove HAL module from core and create a contrib project for it on top of that, delete the whole core/modules/hal) came back green here: https://www.drupal.org/project/drupal/issues/3191612#comment-14412677

Since code changed I think another round of review is needed => Back to NR

All open threads are (in my mind at least) resolved, but since I didn't create the MR I can't actually resolve them. @bbrala will come along at some point and do so.

daffie’s picture

Status: Needs review » Reviewed & tested by the community

All code changes look good to me.
All threads on the MR are addressed.
For me it is RTBC.

catch’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll

OK this is a huge diff but it's only really doing a couple of things:

1. 1-1 moves for Hal tests
2. Stops using HAL as a random format in a couple of tests, switching to something else.
3. Duplicating/splitting some generic REST tests that cover both json and hal into hal module to only test hal.

All of this seems fine. However, the MR diff only applies to 9.4.x, and I think (?) this should go into 10.0.x first and be backported (then contrib hal can be a subtree split following this change), so we need a separate 10.x patch/MR to commit there first.

spokje’s picture

Version: 9.4.x-dev » 10.0.x-dev
Assigned: Unassigned » spokje

Thanks @catch for speaking words of wisdom (let it be, let it be, let it be-e, let it be...), aiming for 10.0.x first is indeed inline with the normal proceedings now 10.0.0-alpha-something is out, I'll create a new MR for that.

spokje’s picture

  • MR!1802 is against 9.4.x-dev
  • MR!1848 is against 10.0.x-dev

spokje’s picture

Title: Move all HAL tests to the module in preparation of removal in D10 » [PP-1] Move all HAL tests to the module in preparation of removal in D10
Status: Needs work » Postponed
Related issues: +#3265356: Deprecate Symfony 4 RequestStack BC shim for removal in D11
00:02:55.711 Running PHPStan on *all* files.

00:04:07.005  ------ -------------------------------------------------------------------- 
00:04:07.005   Line   core/lib/Drupal/Core/Http/RequestStack.php                          
00:04:07.005  ------ -------------------------------------------------------------------- 
00:04:07.005   26     Call to an undefined static method                                  
00:04:07.005          Symfony\Component\HttpFoundation\RequestStack::getMasterRequest().  
00:04:07.005  ------ -------------------------------------------------------------------- 
00:04:07.005 
00:04:07.005 
00:04:07.005  [ERROR] Found 1 error                                                          
00:04:07.005 
00:04:07.046 
00:04:07.046 PHPStan: failed

Another victim of #3265356: Deprecate Symfony 4 RequestStack BC shim for removal in D11, postponing on that issue.

spokje’s picture

Assigned: spokje » Unassigned
Issue tags: -Needs reroll
spokje’s picture

Title: [PP-1] Move all HAL tests to the module in preparation of removal in D10 » Move all HAL tests to the module in preparation of removal in D10
Status: Postponed » Active
catch’s picture

Status: Active » Reviewed & tested by the community

Give this is just a re-roll since the last RTBC, moving it back there.

spokje’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new11.73 KB

Even the tiny help_topic snippet for the hal module should probably also be moved.

Also attached a raw diff between both MRs.

daffie’s picture

Status: Needs review » Reviewed & tested by the community

Back to RTBC

  • catch committed 0cec486 on 10.0.x
    Issue #3263654 by Spokje, bbrala, daffie, Kristen Pol, longwave: Move...
catch’s picture

Version: 10.0.x-dev » 9.4.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/pushed the respective patches to 10.0.x and 9.4.x respectively, thanks!

spokje’s picture

Committed/pushed the respective patches to 10.0.x and 9.4.x respectively, thanks!

@catch Looks like the 9.4.x part of the above sentence never made it into Git, forgotten push perhaps?

  • catch committed 493149e on 9.4.x
    Issue #3263654 by Spokje, bbrala, daffie, Kristen Pol, longwave: Move...

Status: Fixed » Closed (fixed)

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

tr’s picture

At least one of the tests in this issue should not have been removed from core. See #3268078: DBLogResource is no longer being tested

catch’s picture

kristen pol’s picture

Issue tags: +Drupal 10

Tagging for posterity.