HPT tests started failing on D10.1

Created on 8 August 2023, over 1 year ago
Updated 16 August 2023, about 1 year ago

Problem/Motivation

Following πŸ“Œ Allow upload of zipped hospital price file Fixed the tests fail on d.o.


Drupal\Tests\hospital_price_transparency\Functional\HospitalPriceTransparencyTest
exception: [Other] Line 0 of sites/default/files/simpletest/phpunit-3.xml:
PHPUnit Test failed to complete; Error: PHPUnit 9.6.8 by Sebastian Bergmann and contributors.

Testing Drupal\Tests\hospital_price_transparency\Functional\HospitalPriceTransparencyTest
E                                                                   1 / 1 (100%)

Time: 00:03.092, Memory: 4.00 MB

There was 1 error:

1) Drupal\Tests\hospital_price_transparency\Functional\HospitalPriceTransparencyTest::testHospitalPriceTransparency
Behat\Mink\Exception\ExpectationException: Current response status code is 500, but 200 expected.

/var/www/html/vendor/behat/mink/src/WebAssert.php:794
/var/www/html/vendor/behat/mink/src/WebAssert.php:130
/var/www/html/modules/contrib/hospital_price_transparency/tests/src/Functional/HospitalPriceTransparencyTest.php:139
/var/www/html/vendor/phpunit/phpunit/src/Framework/TestResult.php:728

I found the browser output from Jenkins and the error looks like this:

Called from GuzzleHttp\Promise\FulfilledPromise::GuzzleHttp\Promise\{closure}() line 48

GET request to: http://php-apache-jenkins-drupal-contrib-719294/subdirectory/hpt/3

The website encountered an unexpected error. Please try again later.

Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException: The file "public:/file.xml" does not exist in Symfony\Component\HttpFoundation\File\File->__construct() (line 36 of vendor/symfony/http-foundation/File/File.php).
Symfony\Component\HttpFoundation\BinaryFileResponse->setFile('public:/file.xml', NULL, , 1) (Line: 52)
Symfony\Component\HttpFoundation\BinaryFileResponse->__construct('public:/file.xml') (Line: 28)
Drupal\hospital_price_transparency\Controller\HospitalPriceTransparencyController->file(Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 592)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 166)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 74)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Original Report

See https://www.drupal.org/pift-ci-job/2719405 β†’

It started on 18 Jul 2023 at 21:29 CDT

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States danflanagan8 St. Louis, US

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @danflanagan8
  • πŸ‡ΊπŸ‡ΈUnited States danflanagan8 St. Louis, US

    I'm not reproducing this locally.

  • πŸ‡ΊπŸ‡ΈUnited States danflanagan8 St. Louis, US

    Oh, it's because of some changes that were made to the module and tests a few days earlier (July 14). See πŸ“Œ Allow upload of zipped hospital price file Fixed

    That's probably it. I couldn't run the new tests on d.o prior to committing since there were new binary files being added.

  • πŸ‡ΊπŸ‡ΈUnited States danflanagan8 St. Louis, US
  • πŸ‡ΊπŸ‡ΈUnited States danflanagan8 St. Louis, US
  • πŸ‡ΊπŸ‡ΈUnited States danflanagan8 St. Louis, US

    Is this a realpath thing?

  • Status changed to Needs review over 1 year ago
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.1.x + Environment: PHP 8.2 & MySQL 8
    last update over 1 year ago
    3 pass, 2 fail
  • πŸ‡ΊπŸ‡ΈUnited States danflanagan8 St. Louis, US
  • Status changed to Needs work over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States danflanagan8 St. Louis, US

    That didn't work. The error changed to this in the html output:

    Called from GuzzleHttp\Promise\FulfilledPromise::GuzzleHttp\Promise\{closure}() line 48
    GET request to: http://php-apache-jenkins-drupal8-contrib-patches-167737/subdirectory/hpt/3
    The website encountered an unexpected error. Please try again later.
    
    Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException: The file "" does not exist in Symfony\Component\HttpFoundation\File\File->__construct() (line 36 of vendor/symfony/http-foundation/File/File.php).
    Symfony\Component\HttpFoundation\BinaryFileResponse->setFile('', NULL, , 1) (Line: 52)
    Symfony\Component\HttpFoundation\BinaryFileResponse->__construct('') (Line: 28)
    Drupal\hospital_price_transparency\Controller\HospitalPriceTransparencyController->file(Object)
    call_user_func_array(Array, Array) (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 592)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 166)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 74)
    Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
    Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
    Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
    
  • πŸ‡ΊπŸ‡ΈUnited States danflanagan8 St. Louis, US

    Oh! There's a clue I missed. :)

    There's a missing slash:

    public:/file.xml

    That uri gets built here:

    $extract_to_dir = pathinfo($file->getFileUri(), PATHINFO_DIRNAME);
    $zip->extract($extract_to_dir, [$zipped_filename]);
    $unzipped_file_uri = $extract_to_dir . '/' . $zipped_filename;
    $new_file = File::create([
      'uri' => $unzipped_file_uri,
    ]);
    

    $file->getFileUri() gives public://xml_zip.zip and $extract_to_dir resolves as public:.

    So then $unzipped_file_uri gets built with one slash instead of a double slash. That's what needs to be fixed, but I'm not sure exactly the best way.

  • Status changed to Needs review over 1 year ago
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.1.x + Environment: PHP 8.2 & MySQL 8
    last update about 1 year ago
    4 pass
  • πŸ‡ΊπŸ‡ΈUnited States danflanagan8 St. Louis, US

    I think this does it.

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.1.x + Environment: PHP 8.2 & MySQL 8
    last update about 1 year ago
    4 pass
  • πŸ‡ΊπŸ‡ΈUnited States danflanagan8 St. Louis, US

    Yay!

    Here's a bit more test coverage though that focuses on the uri of the extracted zip files.

  • πŸ‡ΊπŸ‡ΈUnited States danflanagan8 St. Louis, US

    Phew! I guess some servers can deal with the malformed uri? Or some zip packages can do that? Regardless, this is better. My manual testing was positive as well. Let's commit it.

  • Status changed to Fixed about 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States danflanagan8 St. Louis, US
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024