Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
fb24b240
Commit
fb24b240
authored
2 months ago
by
catch
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3513618
by mstrelan, mondrake: [random test failure] ConnectionUnitTest::testOpenQueryClose
parent
c0490079
Branches
Branches containing commit
Tags
Tags containing commit
3 merge requests
!5423
Draft: Resolve #3329907 "Test2"
,
!3478
Issue #3337882: Deleted menus are not removed from content type config
,
!579
Issue #2230909: Simple decimals fail to pass validation
Pipeline
#472788
passed with warnings
2 months ago
Stage: 🪄 Lint
Stage: 🗜️ Test
Pipeline: drupal
#472819
Pipeline: drupal
#472815
Pipeline: drupal
#472810
+4
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/tests/Drupal/KernelTests/Core/Database/DriverSpecificConnectionUnitTestBase.php
+33
-9
33 additions, 9 deletions
...ts/Core/Database/DriverSpecificConnectionUnitTestBase.php
with
33 additions
and
9 deletions
core/tests/Drupal/KernelTests/Core/Database/DriverSpecificConnectionUnitTestBase.php
+
33
−
9
View file @
fb24b240
...
...
@@ -95,7 +95,39 @@ protected function assertConnection(int $id): void {
* @internal
*/
protected
function
assertNoConnection
(
int
$id
):
void
{
$this
->
assertArrayNotHasKey
(
$id
,
$this
->
monitor
->
query
(
$this
->
getQuery
()[
'processlist'
])
->
fetchAllKeyed
(
0
,
0
));
// Wait up to 100ms to give the database engine sufficient time to react.
$this
->
assertTrue
(
$this
->
waitFor
(
0.1
,
function
()
use
(
$id
)
{
$key
=
$this
->
monitor
->
query
(
$this
->
getQuery
()[
'processlist'
])
->
fetchAllKeyed
(
0
,
0
);
return
!
array_key_exists
(
$id
,
$key
);
}));
}
/**
* Wait for a callback to return a truthy value.
*
* @param int|float $timeout
* Number of seconds to wait for.
* @param callable $callback
* The callback to call.
*
* @return mixed
* The result of the callback.
*/
protected
function
waitFor
(
int
|
float
$timeout
,
callable
$callback
):
mixed
{
$start
=
microtime
(
TRUE
);
$end
=
$start
+
$timeout
;
do
{
$result
=
call_user_func
(
$callback
,
$this
);
if
(
$result
)
{
break
;
}
usleep
(
10000
);
}
while
(
microtime
(
TRUE
)
<
$end
);
return
$result
;
}
/**
...
...
@@ -106,8 +138,6 @@ protected function assertNoConnection(int $id): void {
public
function
testOpenClose
():
void
{
// Close the connection.
Database
::
closeConnection
(
static
::
TEST_TARGET_CONNECTION
);
// Wait 20ms to give the database engine sufficient time to react.
usleep
(
20000
);
// Verify that we are back to the original connection count.
$this
->
assertNoConnection
(
$this
->
id
);
...
...
@@ -122,8 +152,6 @@ public function testOpenQueryClose(): void {
// Close the connection.
Database
::
closeConnection
(
static
::
TEST_TARGET_CONNECTION
);
// Wait 20ms to give the database engine sufficient time to react.
usleep
(
20000
);
// Verify that we are back to the original connection count.
$this
->
assertNoConnection
(
$this
->
id
);
...
...
@@ -138,8 +166,6 @@ public function testOpenQueryPrefetchClose(): void {
// Close the connection.
Database
::
closeConnection
(
static
::
TEST_TARGET_CONNECTION
);
// Wait 20ms to give the database engine sufficient time to react.
usleep
(
20000
);
// Verify that we are back to the original connection count.
$this
->
assertNoConnection
(
$this
->
id
);
...
...
@@ -171,8 +197,6 @@ public function testOpenSelectQueryClose(): void {
// Close the connection.
Database
::
closeConnection
(
static
::
TEST_TARGET_CONNECTION
);
// Wait 20ms to give the database engine sufficient time to react.
usleep
(
20000
);
// Verify that we are back to the original connection count.
$this
->
assertNoConnection
(
$this
->
id
);
...
...
This diff is collapsed.
Click to expand it.
catch
@catch
mentioned in commit
0f068a5d
·
2 months ago
mentioned in commit
0f068a5d
mentioned in commit 0f068a5d41aaf7f7a42fee4ab5c7402ef1e03919
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment