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

Test failure: MysqliConnectionTest::testRestoresErrorHandlerOnException on appveyor #2924

Closed
photodude opened this issue Nov 24, 2017 · 11 comments
Labels

Comments

@photodude
Copy link
Contributor

photodude commented Nov 24, 2017

The following failure occurred on recent appveyor testing with
db=mariadb, driver=pdo_mysql
db=mssql, driver=sqlsrv, db_version=sql2008r2sp2
db=mssql, driver=pdo_sqlsrv, db_version=sql2008r2sp2

There was 1 failure:
1) Doctrine\Tests\DBAL\Driver\Mysqli\MysqliConnectionTest::testRestoresErrorHandlerOnException
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'Network is unreachable'
+'The requested address is not valid in its context.
+'

C:\projects\dbal\tests\Doctrine\Tests\DBAL\Driver\Mysqli\MysqliConnectionTest.php:45

https://ci.appveyor.com/project/photodude/dbal/build/1.0.256/job/b74yrv4i6h3i0b1y
https://ci.appveyor.com/project/photodude/dbal/build/1.0.256/job/iakaekt0evwh68lr
https://ci.appveyor.com/project/photodude/dbal/build/1.0.257/job/th66xvantxwway5t

@Majkl578
Copy link
Contributor

Majkl578 commented Dec 9, 2017

Assertion was added in #2704.

@photodude
Copy link
Contributor Author

@Majkl578 looking at #2704 it seems some platforms have different strings in this test.
Network is unreachable is a valid error in some platforms,
The requested address is not valid in its context is a valid error in others.

@Majkl578
Copy link
Contributor

@photodude The simplest way seems to be to remove the assert for message and only assert that exception was thrown. Maybe it could be replaced by asserting exception code, if there is any.

@photodude
Copy link
Contributor Author

photodude commented Dec 27, 2017

@Ocramius Would @Majkl578's proposal^ to "only assert that an exception was thrown" be an acceptable solution?

@morozov
Copy link
Member

morozov commented Dec 27, 2017

FWIW, dropping the verification of the exception message is acceptable since it belongs to the current TCP/IP stack implementation, not to the DBAL or even the DB platform.

Unless there's something else which we can use to identify the nature of the error (like the error code mentioned above), we can just verify the fact of the exception thrown.

@photodude
Copy link
Contributor Author

photodude commented Dec 28, 2017

I did a quick test switching $e->getMessage() with $e->getCode() in the test. Unfortunetly I got 0 as the error code. 0 does not seem like a valid code to me.

https://travis-ci.org/photodude/dbal/jobs/322699909

seems like just checking that an exception was thrown might be the primary option.

@morozov
Copy link
Member

morozov commented Dec 28, 2017

@photodude #2704 seems to be about a generic error, not necessarily the "Network is unreachable" one. Looks like not the best way to trigger a generic error was chosen.

The test checks the error message to prove that this is the error triggered by mysqli::real_connect(), not another accidental one. We probably could find some other circumstances under which it will trigger a predictable error and use it instead. For instance, trying to connect with a knowingly wrong password. In this case, the error message will be defined by MySQL, not by the underlying network layer.

@photodude
Copy link
Contributor Author

Also note this is an issue specifically with testing on windows as it's coming from the WIP appveyor CI PR

@morozov
Copy link
Member

morozov commented Dec 29, 2017

@photodude I understand. That's why I'm suggesting instead of triggering the error whose message depends on the OS to trigger another one which doesn't.

@photodude
Copy link
Contributor Author

photodude commented Apr 1, 2018

Closing as addressed with the completion of and scope changes in the initial AppVeyor project

@github-actions
Copy link

github-actions bot commented Aug 2, 2022

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants