See: https://www.drupal.org/pift-ci-job/606884

All tests are passing on DrupalCI except for Functional and FunctionalJavascript tests involving the checkout. The key difference is that DrupalCI uses the run-tests.sh runner and executes in parallel.

1) Drupal\Tests\commerce_checkout\Functional\CheckoutOrderTest::testOrderAccess
Behat\Mink\Exception\ExpectationException: Current response status code is 404, but 403 expected.

2) Drupal\Tests\commerce_checkout\Functional\CheckoutOrderTest::testGuestOrderCheckout
Behat\Mink\Exception\ElementNotFoundException: Button with id|name|label|value "Continue as Guest" not found.

3) Drupal\Tests\commerce_checkout\Functional\CheckoutOrderTest::testRegisterOrderCheckout
Behat\Mink\Exception\ResponseTextException: The text "New Customer" was not found anywhere in the text of the current page.

4) Drupal\Tests\commerce_checkout\Functional\CheckoutOrderTest::testOrderSummary
Behat\Mink\Exception\ElementNotFoundException: Element matching css ".view-id-commerce_checkout_order_summary" not found.

5) Drupal\Tests\commerce_checkout\Functional\CheckoutOrderTest::testCheckoutFlowOnCartUpdate
Behat\Mink\Exception\ElementHtmlException: The string "Order information" was not found in the HTML of the element matching css "h1.page-title".

1) Drupal\Tests\commerce_payment\Functional\PaymentCheckoutTest::testCheckoutWithPayment
Behat\Mink\Exception\ResponseTextException: The text "Order Summary" was not found anywhere in the text of the current page.

2) Drupal\Tests\commerce_payment\Functional\PaymentCheckoutTest::testDeclineStopsCheckout
Behat\Mink\Exception\ResponseTextException: The text "Order Summary" was not found anywhere in the text of the current page.

3) Drupal\Tests\commerce_payment\Functional\PaymentCheckoutTest::testTransactionModeAuthorizeOnly
Behat\Mink\Exception\ResponseTextException: The text "Order Summary" was not found anywhere in the text of the current page.

1) Drupal\Tests\commerce_payment\Functional\PaymentCheckoutOffsiteRedirectTest::testCheckoutWithOffsiteRedirectPost
Behat\Mink\Exception\ResponseTextException: The text "Order Summary" was not found anywhere in the text of the current page.

2) Drupal\Tests\commerce_payment\Functional\PaymentCheckoutOffsiteRedirectTest::testCheckoutWithOffsiteRedirectGet
Behat\Mink\Exception\ResponseTextException: The text "Order Summary" was not found anywhere in the text of the current page.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mglaman created an issue. See original summary.

mglaman’s picture

It is also reproduceable locally

------------

Drupal\Tests\commerce_checkout\Kernel\ChainCheckoutFlowResol   1 passes                                      
Drupal\Tests\commerce_checkout\Functional\CheckoutFlowTest     4 passes                                      
Drupal\Tests\commerce_checkout\Functional\CheckoutOrderTest    0 passes             1 exceptions             
FATAL Drupal\Tests\commerce_checkout\Functional\CheckoutOrderTest: test runner returned a non-zero error code (2).
Drupal\Tests\commerce_checkout\Functional\CheckoutOrderTest    0 passes   1 fails                            

Test run duration: 3 min 58 sec

That's no good.

drugan’s picture

Seems that on some environments the relative url path passed to BrowserTestBase->drupalGet() does not become resolved to a proper absolute url.

For example, on my local server the url to the product normally looks like this:

http://mysites/acommerce/web/product/1

But if it is passed as a relative path ($this->product->toUrl()->toString() === /product/1) then it is resolved to this:

http://mysites/acommerce/web/acommerce/product/1

Obviously, there is no such a page, therefore any test will fail.

The method can take as the first argument either relative path or absolute path or Url object. My suggestion is whenever possible to use the Url object:

BrowserTestBase->drupalGet($my_test_entity->toUrl());

If you don't have toUrl() method on your test entity then try this:

$url = BrowserTestBase->getAbsoluteUrl('/relative/url/path/to/my/test/entity');
BrowserTestBase->drupalGet($url);

The PR: https://github.com/drupalcommerce/commerce/pull/652

The patch: https://patch-diff.githubusercontent.com/raw/drupalcommerce/commerce/pul...

Note: the PR is red for now because of this:

The job exceeded the maximum time limit for jobs, and has been terminated.

No errors, no warnings or something indicating a trouble. It happens only on the PHP 7 version.

Does anybody know what is it?

mglaman’s picture

Status: Active » Needs review
FileSize
10.97 KB

Based on drugan's findings, the issue is how we're passing paths in tests. And, as a highlighted, getting DrupalCI to work is critical since we're hitting Travis's build limit of 50 minutes granted to open source projects. Here's a patch based on drugan's initial work with some tweaks.

drugan’s picture

Great work!

The only notice is that Url object parameter is not documented in BrowsertestBase->drupalGet() and if ever they'll decide to not use buildUrl() for parsing passed $path then we could have a problem.

Still, I hope they will not do this otherwise our own CommerceBrowsertestBase->drupalGet() should be defined.

Just to keep in mind before applying the patch.

Sorry for that I can't test a patch because local server on my notebook is so sloooooooow. It'll take a day for me to run all the tests in the patch :). Even through CLI. But I'm sure they all should pass.

mglaman’s picture

Status: Needs review » Needs work

That patch still failed: https://dispatcher.drupalci.org/job/drupal_contrib/12490/console

So it isn't just the absolute URLs.

mglaman’s picture

drugan, so the issue is definitely when running the tests within run-tests.sh and having concurrency. TravisCI directly invokes PHPUnit. There's something about how either the tests are written or our checkout access has a weird flaw.

drugan’s picture

mglaman, thanks for sharing Drupal CI output but it didn't help a lot.

I've tried to run CheckoutOrderTest with run-tests.sh once more on my local server and it's passed.

It is pretty difficult to find the reason for test fail if you can't reproduce it locally. Obviously that on Drupal CI you also can't do any print_r() or similar variable dump just to see what we have at the moment of the test run.

Not sure if that could be related with the issue but somehow I've found that on any of my drupalcommerce clones checkout and payment dot module files have executable bits for all user and group and others. Actually they should not. No any other of drupalcommerce files has it except travis-before-script.sh.

When committing git does not respect any user permissions by default beyond a simple executable bit. Useful info on git administering permissions:

http://stackoverflow.com/questions/10516201/updating-file-permissions-on...

On the latest commit I've already removed executable bits from the dot modules files but if you are not ready to commit this PR yet then try to do the same bits removing and running Drupal CI test again.

mglaman credited Mixologic.

mglaman’s picture

Status: Needs work » Fixed
FileSize
48.93 KB

This was due to a core bug where having Drupal in a subdirectory which matches the beginning of a route wreaked havoc. This is why our checkout tests broke. DrupalCI would place Drupal inside the checkout directory. The core bug is reproducible by putting Drupal in coreand trying to install.

The fix can be found here: http://cgit.drupalcode.org/drupalci_testbot/commit/?id=35e96d7

Status: Fixed » Closed (fixed)

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