-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Functional api test unable to load install-config-mysql database credentials #33696
Comments
Hi @baatractive. Thank you for your report.
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:
For more details, please, review the Magento Contributor Assistant documentation. Please, add a comment to assign the issue:
🕙 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 |
@magento give me 2.4-develop instance |
Hi @baatractive. Thank you for your request. I'm working on Magento instance for you. |
Hi @baatractive, here is your Magento Instance: https://b6af6eaf68e0b9d60502403379a6271e-2-4-develop.instances.magento-community.engineering |
The API functional test uses |
@gwharton Yes that seems a similar issue and why is it closed? Was it resolved? |
Lack of interest from Magento team. |
I'll take a look at this later today as I almost had a fix working when I last looked at this. |
@gwharton That would be great help, thanks. |
as i remembered you need create seperate db tmp-mysql for test |
elasticsearch seem required too |
OK, ive had a look at the API Functional test code and how it works and it exposes a fundamental issue with the way the API Functional tests work. Lets consider the integration tests first. When they are run, they use the install-mysql-config.php and the test framework installs a bastardised runtime of magento into dev/tests/integration/tmp/sandbox---------- and creates a separate database as defined in install-mysql-config.php. The tests are all run in the context of this sandbox test environment so as to not affect any data in the main development database. This works fine and is well understood. Now, the API Functional tests. Well, these seem to follow the same approach, as there is a install-mysql-config.php file detailing a separate database however the bootstrap functions in the api functional tests operate differently to the integration tests. The test framework seems to have been implemented by a mixture of people who don't understand the difference between api functional and integration tests, and people that have hacked it to appear to work. Let me explain. So, the difference between the two test types : whereas the integration tests run in their own sandbox, you cannot do this for the api functional tests so easily. The API Functional tests are essentially very simple REST/SOAP/GRAPHQL clients which makes a call to a Magento HTTP(s) endpoint. Had the test framework been configured to work in the same way as the integration tests with its own sandbox using details in install-mysql-config.php, then it would be ONLY the REST/SOAP/GRAPHQL clients that run in this sandbox. You would have a sandboxed database in existence for the test client, which then makes a call to a HTTP(s) endpoint somewhere else. but where??? There is only one HTTP(s) based Magento endpoint and that is the one configured in app/etc/env.php. We do not have a separate webserver setup that could serve the sandboxed version of the api-functional test installation. I believe at this point the Magento team may well have just thrown their hands in the air and decided that the API functional tests should not run in a sandbox environment, and adjusted the test framework bootstrap code to operate on the main database. They did leave in a couple of nasty features though
So, what do we do. The current API functional tests intentionally ignore the install-mysql-config.php data and use the app/etc/env.php details instead. The tests operate on the HTTP(s) endpoint configured in app/etc/env.php with the result being the tests are performed on the main development database and not a sandboxed version. People assume it uses a sandbox database but it doesn't, it uses whichever database is configured behind the HTTP(s) endpoint. Their development database will be being polluted with data from the API Functional tests, if not cleaned up properly by the test. It is fairly straight forward to adjust the test framework to use the install-mysql-config.php settings and generate a sandbox for the REST/SOAP/GRAPHQL client to run in, but we would also need to either adjust the main app/etc/env.php to temporarily use the sandbox details from install-mysql-config.php for the duration of the test, or create a separate web server config that points at the sandbox installation. |
@gwharton I see, I investigated this issue too but thought I might be wrong because they already provide I am fairly new to Magento so not quite sure for any alternative approcah especially as you suggested: create a web server config that points at the sandbox installation. Could you give me any hint for this as how to achieve it? |
@mrtuvn There's already a database for the integration which is working properly but the current issue is with the Functional Api tests. |
A little bit more research that confirms the fundamental broken'ness of the API Functional tests. If the following settings are set in phpunit.xml
Then running the API-Functional tests will run them against the Magento HTTP(s) endpoint as defined in the setting if either of the TESTS_CLEANUP (ununstalls magento) or TESTS_MAGENTO_INSTALLATION (installs magento) are set to enabled, then because of this bug, then the database defined in app/etc/env.php is DROPPED and then the database defined in install-config-mysql.php is installed. This is probably not what you want and will most likely mess up your development node database. So, two ways to run API Functional tests...... Run the API Functional Tests against Magento configured to use your development database.
Run the API Functional Tests against Magento configured to use a sandbox database.
|
Hi, @ihor-sviziev I wondered if you were aware of the issues with the API-Functional test framework as detailed in my post above. Can you copy anyone in, in the test team that may need to be aware of this. Its been in this broken/working only by chance state for a while now, and I am sure because of the bug, regularly wipes peoples development databases when they first try to run the intergration tests, and pollutes their development database with test data as the test framework uses the wrong database. I raised #27213 on it a while ago but got no traction. |
@gwharton I see, thanks for the explanation. However, I did update |
you could have two env.php files and use a symbolic link to switch between them. It could be triggered automatically by a test runner script. Lets see if Magento core comes back with any comments. I agree its not ideal. |
Hi @engcom-Delta. Thank you for working on this issue.
|
Hi @engcom-Echo. Thank you for working on this issue.
|
Hi @engcom-Lima. Thank you for working on this issue.
|
Hi @baatractive, Thank you for reporting the issue. I have gone through the issue description and related comments with @gwharton. I tried to replicate this issue on 2.4-develop instance with the provided steps but I was not able to reproduce it. So for further analysis, can you please update on the below queries:
It would be helpful if you guys can provide some more info so that I can try again to reproduce this. |
Hi @baatractive, We have noticed that this issue has not been updated for some time. Since we were not able to reproduce this so we are closing it. Please raise a fresh ticket or reopen this ticket if you need more assistance on this with answer to queries asked in #33696 (comment) Regards |
Preconditions (*)
Steps to reproduce (*)
../../../vendor/bin/phpunit --config phpunit_rest.xml
Expected result (*)
install-config-mysql.php
file for database connection but it rather tries to connect with the default connection settings. For some reason the default connection is also throwing an error with this command. However, I could successfully run integration tests and also my default is fully functional when try to upgrade or clear any cache.Actual result (*)
Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.
The text was updated successfully, but these errors were encountered: