-
Notifications
You must be signed in to change notification settings - Fork 7.8k
ext/mysqli: Work on making tests parallizable #11814
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
Conversation
Can you merge the first 4 commits onto master? They look fine and they don't seem related to this PR much. These changes should have been made on their own. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will finish reviewing it tomorrow, but one thing stands out to me. I can't see $driver->report_mode = MYSQLI_REPORT_OFF;
anywhere in your new file. Is it an omission? You can improve it by keeping only one connection-function, and in there first, enable error reporting and at the end, before returning, switch it off. This way you ensure that the connection will fail, but all other tests will still be responsible for their own error handling.
As an aside, the file renames are making the diff a little difficult to understand. Maybe apply file renames on master first?
function default_mysqli_connect_ex(): \mysqli|false { | ||
return my_mysqli_connect( | ||
get_default_host(), | ||
get_default_user(), | ||
get_default_password(), | ||
get_default_database(), | ||
get_default_port(), | ||
null, | ||
); | ||
} | ||
function default_mysqli_connect(): \mysqli{ | ||
$link = default_mysqli_connect_ex(); | ||
if (!$link) { | ||
throw new Error("Cannot connect to default connection"); | ||
} | ||
return $link; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What exactly is the purpose of these two functions? Why not merge it all into my_mysqli_connect()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Part of the idea was to be able to "just" replace the current set of test files which this include instead of the mix of includes currently in place.
But for the ones I've touched I just kinda rewrote them on the way... so for the moment they are very pointless.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also this was copied from the current connect.inc
file which specifies both versions (the non real and real versions).
As far as I could see from a glance, none of the tests actually specify custom args for the standard connection params so in the end I would probably just have everything use the default_mysqli_connect()
function
$flags = $flags | get_environment_connection_flags(); | ||
} | ||
|
||
return mysqli_real_connect($link, $host, $user, $password, $db, $port, $socket, $flags); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This already exists in my_mysqli_connect()
so this is duplicated code.
I didn't understand the purpose of this call initially. But I wonder if while at it it doesn't make sense to rewrite the tests to not need to deal with error handling and just fail with an exception. As I can imagine these tests being written prior to exception usage really being a thing.
I'm not sure, how I would be able to do that frankly, as I figure out what the test is about while reading it for the refactor and then move it and rename it. |
mysqli_select_db($link, get_default_database()); | ||
mysqli_query($link, "SET sql_mode=''"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kamil-tekiela are those two lines actually necessary? As we are pretty inconsistent about using them and wonder if we could just simplify the tests by removing these lines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mysqli_select_db($link, $db);
is unnecessary because it's already done in line above it: $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
mysqli_query($link, "SET sql_mode=''");
is needed because of the test assumption: %s(19) "0000-00-00 00:00:00"
. Without we would be getting inconsistent test results depending on the DB version/setup. But it's only needed in this test.
c2 smallint unsigned, | ||
c3 smallint, | ||
c4 smallint, | ||
c5 smallint, | ||
c6 smallint unsigned, | ||
c7 smallint) ENGINE=" . $engine); | ||
c7 smallint) ENGINE=" . get_default_db_engine()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the engine need to be actually specified? Because again we are not very consistent in that regards...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea. To my knowledge, the engine doesn't matter here. I am not entirely sure what this test actually tests.
That is true, but we need to test both modes. Therefore, best if each test would control this setting on its own. But you are right that the majority of tests were written before exception use was common. We could rewrite many of the tests, but it is menial work that doesn't seem that necessary. |
Do we currently test the exception mode? A lot of the current failures checks seem to just bail (by calling |
Okay @kamil-tekiela I think the tests are now cleaned-up and ready. I will just see if CI is finally green and then clean-up the DB link retrieval functions. |
Well... we don't. Some tests do switch on exception mode and test both, but many do not. This is also why there were a number of bugs with missing exceptions. I might try to do some cleanup to these tests now. |
While reviewing this PR I noticed a lot of issues with these tests. While I really love your PR and I hope we can merge it soon, can I ask you to put this aside for a week while I review these tests in more detail? I will try not to do too many conflicts. The current ones can be ignored when you rebase, as your changes will overwrite them. |
Sure, that's not a problem for me :) |
--EXPECTF-- | ||
string(%d) "%s" | ||
--EXPECT-- | ||
string(6) "utf8mb" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't do this. We don't actually know what the charset will be until we set it. We don't set the charset anywhere, so it could be anything. I also do not understand why on earth are we using substr
here.
I'd suggest to rewrite this test and call set_charset
twice with different values. After each call check if the charset actually changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I delete this as we have ext/mysqli/tests/functions/mysqli_set_charset.phpt
already?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also have ext\mysqli\tests\mysqli_character_set_name.phpt
so I think it's safe to remove this one.
--CLEAN-- | ||
<?php | ||
// Re-enable exceptions | ||
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); | ||
?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct me if I am wrong, but I thought CLEAN sections are sandboxed, so this is unnecessary. This setting lasts only per execution of the script.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually don't know if they are sandboxed, so you might be correct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just been told they do, I will remove this
Currently away from my main desktop for a month so this PR might be on hold for that long. But I will go throughthe review comments |
0212de9
to
f17942f
Compare
@kamil-tekiela finally got round to this again, rebased and took all of my changes. Then started applying some of the review comments. The only one I haven't applied just yet is the helper file one. |
Add a way to set up a table with some data in the table helpers
Also reformat some querries and add comment for the SET sql_mode='' query
Ubuntu does this but not Fedora
Co-authored-by: Kamil Tekiela <[email protected]>
Co-authored-by: Kamil Tekiela <[email protected]>
9bcbfa1
to
225a2f7
Compare
ext/mysqli/tests/fetch/mysqli_fetch_all_data_types_variation.phpt
Outdated
Show resolved
Hide resolved
Are you able to fix the failing tests? I think we should merge this in and then continue fixing in next PRs. This is too big PR and I am having really hard time reviewing it properly. The more I look at them the more I don't like these tests. |
6d54b0a
to
cbdbab5
Compare
I'll merge if the build is green |
Bunch of cleanup in the first commits.
Beginning of moving tests with a new test_helper which are able to run in parallel. Will need to do this in multiple stages as I'm going to go insane trying to go through 400+ tests in one go.