Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Impossible to run graphql functional tests #32252

Closed
5 tasks
delyriand opened this issue Feb 23, 2021 · 18 comments
Closed
5 tasks

Impossible to run graphql functional tests #32252

delyriand opened this issue Feb 23, 2021 · 18 comments
Labels
Area: Framework Component: GraphQL GraphQL Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: done Reported on 2.4.x Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Severity: S4 Affects aesthetics, professional look and feel, “quality” or “usability”. Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it

Comments

@delyriand
Copy link

Summary (*)

When we follow the documentation to run GraphQL functional tests, we get an error: Could not use "Magento\TestFramework\ApiSuiteLoader" as loader

Examples (*)

  • Configure your instance, copy the phpunit_graphql.xml.dist file to phpunit_graphql.xml and set environment values
  • Run the single test vendor/bin/phpunit -c dev/tests/api-functional/phpunit_graphql.xml dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/GenerateCustomerTokenTest.php

We get the error:
image

Proposed solution

For me, it fails with the error because the bootstrap instantiates a WebApiApplication, by inheritance, it executes the following code and we are in the wrong folder:

if (getcwd() != BP . '/dev/tests/integration') {
      chdir(BP . '/dev/tests/integration');
}

Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

  • Severity: S0 - Affects critical data or functionality and leaves users with no workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
@delyriand delyriand added the Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it label Feb 23, 2021
@m2-assistant
Copy link

m2-assistant bot commented Feb 23, 2021

Hi @delyriand. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, please, review the Magento Contributor Assistant documentation.

Please, add a comment to assign the issue: @magento I am working on this


⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.

🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@t-heuser
Copy link

Can confirm in magento 2.4.2

@bgorski bgorski added Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch labels Mar 23, 2021
@m2-community-project m2-community-project bot moved this from Ready for Confirmation to Confirmed in Issue Confirmation and Triage Board Mar 23, 2021
@magento-engcom-team
Copy link
Contributor

✅ Confirmed by @bgorski
Thank you for verifying the issue. Based on the provided information internal tickets MC-41522 were created

Issue Available: @bgorski, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

@gabrieldagama gabrieldagama added the Priority: P2 A defect with this priority could have functionality issues which are not to expectations. label Apr 27, 2021
@m2-community-project m2-community-project bot added this to Ready for Development in High Priority Backlog Apr 27, 2021
@bgorski
Copy link
Contributor

bgorski commented Aug 14, 2021

@magento I'm working on this

@m2-community-project m2-community-project bot moved this from Ready for Development to Dev In Progress in High Priority Backlog Aug 14, 2021
@bgorski
Copy link
Contributor

bgorski commented Aug 15, 2021

I'm unassigning myself from this after all as it requires a bit more effort to fix it the right way than I can currently commit to.

The part of the functionality that's failing here - the custom test suite loader PHPUnit functionality is actually deprecated (sebastianbergmann/phpunit#4039) and marked with a @internal This class is not covered by the backward compatibility promise for PHPUnit comment so it can stop working any moment.

From what I see in Magento it's used to provide wrappers for tests to make it possible to skip them, so a right approach here would be to provide the same functionality in a different way. I don't think a simple workaround fixing the directory issue is enough.

Maybe @mykhailomatiola would have some ideas on how to deal with this as from what I see in the commits history he's the author of this feature that later on got deprecated on the PHPUnit side. Mykhailo, any hints? :)

And if someone does require a simple workaround - the initial comment in the task is correct, that piece of code changing the directory makes API Functional tests fail to find the test suite loader file.

Workaround 1:
Modify the dev/tests/integration/framework/Magento/TestFramework/Application.php file and change

if (getcwd() != BP . '/dev/tests/integration') {
    // phpcs:ignore Magento2.Functions.DiscouragedFunction
    chdir(BP . '/dev/tests/integration');
}

to

if (getcwd() != $this->getExecutionDir()) {
    // phpcs:ignore Magento2.Functions.DiscouragedFunction
    chdir($this->getExecutionDir());
}

and introduce the getExecutionDir() method:

    protected function getExecutionDir(): string
    {
        return BP . '/dev/tests/integration';
    }

Then modify the dev/tests/api-functional/framework/Magento/TestFramework/WebApiApplication.php file by adding the same method with a different dir:

    protected function getExecutionDir(): string
    {
        return BP;
    }

Workaround 2:
Include full path to the testSuiteLoaderFile in your phpunit_graphql.xml config file, instead of:

testSuiteLoaderFile="framework/Magento/TestFramework/ApiSuiteLoader.php"

use something like:

testSuiteLoaderFile="/shared/httpd/github-magento2-ce/htdocs/dev/tests/api-functional/framework/Magento/TestFramework/ApiSuiteLoader.php"

Of course replace with the actual path on your system, the one above is just an example.

@m2-community-project m2-community-project bot moved this from Pull Request In Progress to Ready for Development in High Priority Backlog Oct 25, 2021
@andrewbess
Copy link
Contributor

Hello there.
Try to run tests from directory dev/tests/integration.
It works for me.

cc @delyriand @bgorski

@sprankhub
Copy link
Member

The workaround suggested by @andrewbess also works for me. Another option is to run the tests with an absolute path to the configuration file:

vendor/bin/phpunit -c $(pwd)/dev/tests/api-functional/phpunit_graphql.xml dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/GenerateCustomerTokenTest.php

@cpartica
Copy link
Contributor

cpartica commented Feb 8, 2022

I think this option works fine and we can document it in devdocs. Since I am using PHPStorm I did not even have this problem as it uses full URLs all the time

@cpartica
Copy link
Contributor

cpartica commented Feb 8, 2022

Thank you @keharper for adding this to the docs!

@cpartica
Copy link
Contributor

cpartica commented Feb 8, 2022

Thank you @sprankhub, @andrewbess, @bgorski @delyriand for exposing your workarounds

If you experienced things that have a workaround that we need to document, please open a PR to the docs.
We can get far faster to those PRs than these ones
The Severity 4 of this ticket makes this ticket to linger like this for a while until we get to it. It also has no PR which will just prolongue its existence. Docs brings more value meanwhile.

@sprankhub
Copy link
Member

Thanks for caring @cpartica! I agree that having a documented workaround is better than having nothing. However, we probably agree that this should still be fixed in the core as it is awful developer experience.

Please mind that this also affects integration tests.

@engcom-November
Copy link
Contributor

Verified the issue on Magento 2.4-develop branch and the issue is still reproducible.
Configured the instance as per devdocs but unable to run the functional tests from CLI. Hence confirming the issue.
image

@engcom-November engcom-November added Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reported on 2.4.x Indicates original Magento version for the Issue report. labels Nov 19, 2022
@github-jira-sync-bot
Copy link

Unfortunately, not enough information was provided to create a Jira ticket. Please make sure you added the following label(s): Reproduced on 2.4.x, ^Area:.*

Once all required labels are present, please add Issue: Confirmed label again.

@github-jira-sync-bot github-jira-sync-bot removed the Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed label Nov 19, 2022
@engcom-November engcom-November added Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch and removed Fixed in 2.4.x The issue has been fixed in 2.4-develop branch labels Nov 21, 2022
@github-jira-sync-bot
Copy link

❌ Cannot export the issue. This GitHub issue is already linked to Jira issue(s): https://jira.corp.adobe.com/browse/AC-831

@github-jira-sync-bot github-jira-sync-bot added Progress: PR Created Indicates that Pull Request has been created to fix issue and removed Progress: ready for grooming labels Jun 26, 2023
@m2-community-project m2-community-project bot moved this from Ready for Development to Done in High Priority Backlog Jul 11, 2023
@m2-community-project m2-community-project bot removed the Progress: PR Created Indicates that Pull Request has been created to fix issue label Jul 11, 2023
@hostep
Copy link
Contributor

hostep commented Jul 11, 2023

@engcom-November, @sdzhepa, @sidolov: any idea why this got closed? There is no explanation telling us why it got closed? (please stop doing that...)

@engcom-Hotel
Copy link
Contributor

Hello @hostep,

We have gone through with its related JIRA and as per the comment there, the issue is not reproducible for them.

As per their conclusion on this issue, they have commented below in the JIRA:

The tests are run through the CLI according to the command given in [devdocs](https://developer.adobe.com/commerce/webapi/get-started/web-api-functional-testing/).). In the devdocs, they have specifically mentioned that the command has to be provided with the full path of an XML configuration file.

As per the screenshot below, if tests are run according to the devdocs there is no issue.
![image](https://github.com/magento/magento2/assets/51681618/8be3a3ea-de8f-4a64-b9a5-1b75d801c9a4)

So due to a change in the status of its JIRA, the status of this issue is also been changed to Closed.

We apologize for not making a proper communication here, we will definitely take care of the same in future.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Framework Component: GraphQL GraphQL Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: done Reported on 2.4.x Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Severity: S4 Affects aesthetics, professional look and feel, “quality” or “usability”. Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it
Projects
Development

No branches or pull requests