Support from Acquia helps fund testing for Drupal Acquia logo

Comments

larowlan created an issue. See original summary.

larowlan’s picture

Status: Active » Needs review
FileSize
36.16 KB

wip

one gnarly issue seems that submitting the admin/modules page kicks the session in the test

larowlan’s picture

Still to do - fix uninstall test (logs out user)
Finish ForumTest (only one method done so far)
More tomorrow

Status: Needs review » Needs work

The last submitted patch, 2: 2737805-forum-btb.1.patch, failed testing.

dawehner’s picture

  1. +++ b/core/modules/forum/tests/src/Functional/ForumBlockTest.php
    @@ -51,29 +64,32 @@ public function testNewForumTopicsBlock() {
    -    $this->assertLink(t('More'), 0, 'New forum topics block has a "more"-link.');
    -    $this->assertLinkByHref('forum', 0, 'New forum topics block has a "more"-link.');
    +    $this->assertNotEmpty($page->findLink(t('More')), 'New forum topics block has a "more"-link.');
    +    $this->assertNotEmpty($page->find('xpath', '//a[contains(@href, forum)]'), 'New forum topics block has a "more"-link.');
    ...
    -      $this->assertLink($topic, 0, format_string('Forum topic @topic found in the "New forum topics" block.', array('@topic' => $topic)));
    +      $this->assertNotEmpty($page->findLink($topic), sprintf('Forum topic %s found in the "New forum topics" block.', $topic));
    

    Note: the other issue adds assertLink or something similar

  2. +++ b/core/modules/forum/tests/src/Functional/ForumBlockTest.php
    @@ -88,12 +104,13 @@ public function testActiveForumTopicsBlock() {
    +    /** @var \DateTime|\Drupal\Core\Datetime\DrupalDateTime $date */
         $date = new DrupalDateTime();
    

    This is confusing, can't phpstorm figure that out on its own?

  3. +++ b/core/modules/forum/tests/src/Functional/ForumBlockTest.php
    @@ -101,42 +118,47 @@ public function testActiveForumTopicsBlock() {
    -    $block->getPlugin()->setConfigurationValue('block_count', 2);
    -    $block->save();
    +    $this->drupalGet($block->toUrl());
    +    $this->submitForm([
    +      'settings[block_count]' => 2,
    +    ], t('Save block'));
    

    I'm wondering the reason to change that. I agree that using APIs in tests is potentially problematic, so is that the reason to change it?

  4. +++ b/core/tests/Drupal/Tests/BrowserTestBase.php
    @@ -1529,4 +1534,42 @@ protected function cssSelectToXpath($selector, $html = TRUE, $prefix = 'descenda
     
    +  /**
    +   * Asserts whether an expected cache tag was present in the last response.
    +   *
    +   * @param string $expected_cache_tag
    +   *   The expected cache tag.
    +   */
    +  protected function assertCacheTag($expected_cache_tag) {
    +    $cache_tags = explode(' ', $this->getSession()->getResponseHeader('X-Drupal-Cache-Tags'));
    +    $this->assertTrue(in_array($expected_cache_tag, $cache_tags), "'" . $expected_cache_tag . "' is present in the X-Drupal-Cache-Tags header.");
    +  }
    

    Let's ensure to add this to the webassert

klausi’s picture

Status: Needs work » Needs review
FileSize
26.88 KB
5.51 KB

@larowlan: I can't reproduce the problems with the module install page in ForumUninstallTest. Attached is a conversion that works for me, based on #2735045: Convert StandardTest to BrowserTestBase by introducing a AssertLegacyTrait and new assertions on the WebAssert.

larowlan’s picture

Status: Needs review » Reviewed & tested by the community

Thanks @klausi - looks good to me

larowlan’s picture

fwiw I couldn't reproduce the uninstall test issues either (nor did my patch above)

klausi’s picture

Status: Reviewed & tested by the community » Needs work

My patch is incomplete because it converts only the uninstall test.

larowlan’s picture

Oh, I thought you added on top of mine, will continue with this in the morning

klausi’s picture

Assigned: larowlan » klausi
klausi’s picture

Assigned: klausi » Unassigned
Status: Needs work » Needs review
FileSize
12.28 KB
8.35 KB

Borrowed some helper methods from #2750941: Additional BC assertions from WebTestBase to BrowserTestBase.

Converted 2 more forum tests, currently failing at asserting cache tags in HTTP headers.

Status: Needs review » Needs work

The last submitted patch, 12: browsertest-forum-2737805-13.patch, failed testing.

klausi’s picture

Status: Needs work » Needs review
FileSize
16.29 KB
4.24 KB

Cacheability headers for debugging were not set in BrowserTestBase.

Still a couple of old simpletests to go.

klausi’s picture

Converted all but one test - the Views test, which depends on #2747167: Convert first part of web tests of views_ui.

dawehner’s picture

+++ b/core/tests/Drupal/Tests/BrowserTestBase.php
@@ -1076,11 +1078,14 @@ public function installDrupal() {
+
     $settings_services_file = DRUPAL_ROOT . '/' . $this->originalSiteDirectory . '/testing.services.yml';
-    if (file_exists($settings_services_file)) {
-      // Copy the testing-specific service overrides in place.
-      copy($settings_services_file, $directory . '/services.yml');
+    if (!file_exists($settings_services_file)) {
+      // Otherwise, use the default services as a starting point for overrides.
+      $settings_services_file = DRUPAL_ROOT . '/sites/default/default.services.yml';
     }
+    // Copy the testing-specific service overrides in place.
+    copy($settings_services_file, $directory . '/services.yml');

Just checked, this is synching code from WebTestBase with BrowserTestBase. Perfect.

  1. +++ b/core/tests/Drupal/Tests/WebAssert.php
    @@ -215,6 +215,52 @@ public function linkExists($label, $index = 0, $message = '') {
    +    // Cast MarkupInterface objects to string.
    +    $label = (string) $label;
    

    So let's skip using the casting?

  2. +++ b/core/tests/Drupal/Tests/WebAssert.php
    @@ -215,6 +215,52 @@ public function linkExists($label, $index = 0, $message = '') {
    +    $this->assert(null === $node, sprintf('A link "%s" appears on this page, but it should not.', $label));
    

    Nitick: NULL :)

klausi’s picture

We should probably spin out the BrowserTestBase fix into its own issue: #2751875: BrowserTestBase must enable cache tags in responses

klausi’s picture

Rerolled, merged in #2750941: Additional BC assertions from WebTestBase to BrowserTestBase (see that issue for interdiff).

larowlan’s picture

+++ b/core/modules/forum/tests/src/Functional/ForumTest.php
@@ -193,21 +193,19 @@ function testForum() {
+    $this->assertEquals('6 6 new posts in forum ' . $this->forum['name'], $topics, 'Number of topics found.');

is the 6 6 right here?

Other than that, looks great - we just need the other issues to go in now

klausi’s picture

Yes, the "6 6" is right here, added a comment.

The Forum Views test is still missing, but we can skip that until #2747167: Convert first part of web tests of views_ui is done.

dawehner’s picture

+++ b/core/modules/forum/tests/src/Functional/ForumTest.php
@@ -322,8 +322,8 @@ private function doAdminTests($user) {
+    $this->assertSession()->buttonExists('Save');

Should we in general try to reuse existing instances of the assertSession objects?

klausi’s picture

I think that is up to the taste of the patch author. I'm using $this->assertSession() always in this patch to have a better diff what lines have been replaced with what.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

I think that is up to the taste of the patch author. I'm using $this->assertSession() always in this patch to have a better diff what lines have been replaced with what.

Fair point!

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed 57432ad42187bfce6e2f82709ee6a7e979e626fb to 8.2.x and 3e86a03 to 8.1.x. Thanks!

  • alexpott committed 57432ad on 8.2.x
    Issue #2737805 by klausi, larowlan: Convert web tests to browser tests...

  • alexpott committed 3e86a03 on 8.1.x
    Issue #2737805 by klausi, larowlan: Convert web tests to browser tests...
klausi’s picture

Status: Fixed » Postponed

Thanks for this first step, this is now postponed on #2747167: Convert first part of web tests of views_ui for the remaining Views integration test.

alexpott’s picture

Status: Postponed » Fixed

@klausi we don't reuse issues because that messes up credit and reporting etc. We just can have another issue.

  • xjm committed 6615efa on 8.1.x
    Revert "Issue #2737805 by klausi, larowlan: Convert web tests to browser...

  • xjm committed 408330a on 8.2.x
    Revert "Issue #2737805 by klausi, larowlan: Convert web tests to browser...
xjm’s picture

Status: Fixed » Needs work

Unfortunately I've had to revert this conversion. It introduced a high rate of random failures for this test group on Postgres, especially on 8.2.x and PHP 7 (although the fails also occur with Postgres on 8.1.x and on PHP 5.5 at a lower rate). See #2776269: High random fail rate in BTB forum tests on Postgres (especially, but not only, with PHP7).

The fails do not seem to occur when the test group is run by itself, only when the full test suite is run together. This suggests that the bug may not actually be introduced by these tests themselves, but that they are exposing an existing bug in the BTB test runner and/or with DrupalCI. However, the very high random fail rate will make it virtually impossible to catch any actual Postgres regression from another patch. Since this patch is not fixing any bug, we'll unfortunately need to block or postpone this conversion on resolving the underlying issue.

The test results on #2776269: High random fail rate in BTB forum tests on Postgres (especially, but not only, with PHP7) can be a starting point. Hopefully someone with more experience with BTB, Postgres, or DrupalCI can debug further to narrow down what the actual bug is.

xjm’s picture

Status: Needs work » Postponed

Postponing explicitly on that, although we should see if we can move this into larger, conceptually scoped conversions.

  • alexpott committed 57432ad on 8.3.x
    Issue #2737805 by klausi, larowlan: Convert web tests to browser tests...
  • xjm committed 408330a on 8.3.x
    Revert "Issue #2737805 by klausi, larowlan: Convert web tests to browser...

  • alexpott committed 57432ad on 8.3.x
    Issue #2737805 by klausi, larowlan: Convert web tests to browser tests...
  • xjm committed 408330a on 8.3.x
    Revert "Issue #2737805 by klausi, larowlan: Convert web tests to browser...

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

dawehner’s picture

Status: Postponed » Needs review
dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Back to RTBC

klausi’s picture

Status: Reviewed & tested by the community » Needs review

We need to wait for #2771547: In Browser and FunctionalJavascript tests SIMPLETEST_USER_AGENT cookie needs to be set every 5 seconds, otherwise we will get random fails on Postgres again.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

That one got committed

alexpott’s picture

Status: Reviewed & tested by the community » Postponed
klausi’s picture

Status: Needs review » Needs work

The last submitted patch, 20: browsertest-forum-2737805-20.patch, failed testing.

klausi’s picture

Status: Needs work » Needs review

Random test fail, back to needs review.

dawehner’s picture

This issue should try to leverage the forward compatibility layer #2809181: Provide forward compatibility layer for BrowserTestBase::xpath

  • alexpott committed 57432ad on 8.4.x
    Issue #2737805 by klausi, larowlan: Convert web tests to browser tests...
  • xjm committed 408330a on 8.4.x
    Revert "Issue #2737805 by klausi, larowlan: Convert web tests to browser...

  • alexpott committed 57432ad on 8.4.x
    Issue #2737805 by klausi, larowlan: Convert web tests to browser tests...
  • xjm committed 408330a on 8.4.x
    Revert "Issue #2737805 by klausi, larowlan: Convert web tests to browser...

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

klausi’s picture

Status: Needs review » Needs work

This needs a reroll.

naveenvalecha’s picture

Issue tags: +Needs reroll
jofitz’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
6.92 KB

Re-roll.

klausi’s picture

Status: Needs review » Needs work

It looks like you forgot to move the files to the tests directory.

jofitz’s picture

Status: Needs work » Needs review
FileSize
7.43 KB

Sorry, I'm obviously not concentrating enough today!

Here's the re-roll with the files moved.

klausi’s picture

Status: Needs review » Needs work
+++ b/core/modules/forum/tests/src/Functional/ForumNodeAccessTest.php
@@ -2,8 +2,8 @@
-use Drupal\Tests\BrowserTestBase;
 use Drupal\node\Entity\NodeType;
+use Drupal\Tests\BrowserTestBase;

unrelated change that is not needed. This file has already been moved.

Otherwise looks good to me. The only remaining old test in forum module is for Views, which is blocked on #2747167: Convert first part of web tests of views_ui and we decided to convert that one later.

tameeshb’s picture

Status: Needs work » Needs review
FileSize
6.9 KB
375 bytes

Change mentioned in #53 reverted.

claudiu.cristea’s picture

Status: Needs review » Reviewed & tested by the community

Reviewed, this looks good now.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed 7c5c3fd to 8.4.x and 9d97196 to 8.3.x. Thanks!

Let's hope we truly have fixed the random errors that this original conversion caused. Committed to 8.3.x too to keep tests inline.

  • alexpott committed 7c5c3fd on 8.4.x
    Issue #2737805 by klausi, Jo Fitzgerald, tameeshb, larowlan, dawehner:...

  • alexpott committed 9d97196 on 8.3.x
    Issue #2737805 by klausi, Jo Fitzgerald, tameeshb, larowlan, dawehner:...

Status: Fixed » Closed (fixed)

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