Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
apc
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
apc
Commits
47fb1408
Verified
Commit
47fb1408
authored
5 months ago
by
Alberto Paderno
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3470139
: Update the cache tests to verify there are no conflicts with the lock keys
parent
e4f80c43
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!75
Issue #3470139: Update the cache tests to verify there are no conflicts with the lock keys
Pipeline
#267476
passed
5 months ago
Stage: build
Stage: validate
Stage: test
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
apc.test
+30
-6
30 additions, 6 deletions
apc.test
with
30 additions
and
6 deletions
apc.test
+
30
−
6
View file @
47fb1408
...
...
@@ -977,6 +977,26 @@ class ApcCacheConflictingKeysTestCase extends ApcCacheBaseTestCase {
*/
class
ApcCachePreserveExistingApcuKeysTestCase
extends
ApcCacheBaseTestCase
{
/**
* Returns the key name used for locks.
*
* This method uses code similar to the code in
* ApcCacheTestTrait::getLockKey(). It is duplicated here because including
* the drupal_apc_lock.inc file would cause an error about functions already
* defined.
*/
protected
function
getLockKey
(
$name
)
{
static
$unique_id
;
if
(
empty
(
$unique_id
))
{
$unique_id
=
drupal_random_bytes
(
32
);
}
$hash
=
hash
(
'sha256'
,
$unique_id
.
$name
,
TRUE
);
return
'apc_lock::'
.
drupal_base64_encode
(
$hash
);
}
/**
* {@inheritdoc}
*/
...
...
@@ -992,12 +1012,14 @@ class ApcCachePreserveExistingApcuKeysTestCase extends ApcCacheBaseTestCase {
* {@inheritdoc}
*/
protected
function
setUp
()
{
$this
->
setCacheBins
(
'apc_cache::'
,
'apc_cache::default_prefix::'
);
$this
->
setCacheBins
(
'apc_cache'
,
'apc_cache::'
,
'apc_cache::default_prefix::'
,
'apc_lock'
,
'apc_lock::'
);
parent
::
setUp
();
}
/**
* Tests that writing cache items does not change other APCu values.
*
* This test also verifies that locks stored in APCu are preserved.
*/
public
function
testWriteFirstApcuValues
()
{
$stored
=
array
();
...
...
@@ -1007,9 +1029,9 @@ class ApcCachePreserveExistingApcuKeysTestCase extends ApcCacheBaseTestCase {
}
if
(
$this
->
assertApcuEmpty
()
&&
$this
->
assertCacheBinsOnApcu
())
{
foreach
(
$this
->
getCacheBins
(
TRUE
)
as
$bin
)
{
foreach
(
$this
->
getCacheBins
()
as
$bin
)
{
foreach
(
$this
->
storageData
()
as
$id
=>
$data
)
{
$key
=
"
$bin$id
"
;
$key
=
$this
->
getLockKey
(
"
$bin$id
"
)
;
if
(
$this
->
assertApcuKeySaved
(
$key
,
$data
[
'value'
]))
{
$stored
[
$key
]
=
$data
;
...
...
@@ -1042,6 +1064,8 @@ class ApcCachePreserveExistingApcuKeysTestCase extends ApcCacheBaseTestCase {
/**
* Tests that writing APCu values does not change cache items.
*
* This test also verifies that locks stored in APCu are preserved.
*/
public
function
testWriteFirstCacheItems
()
{
$stored
=
array
();
...
...
@@ -1051,7 +1075,7 @@ class ApcCachePreserveExistingApcuKeysTestCase extends ApcCacheBaseTestCase {
}
if
(
$this
->
assertApcuEmpty
()
&&
$this
->
assertCacheBinsOnApcu
())
{
foreach
(
$this
->
getCacheBins
(
TRUE
)
as
$bin
)
{
foreach
(
$this
->
getCacheBins
()
as
$bin
)
{
foreach
(
$this
->
storageData
()
as
$id
=>
$data
)
{
if
(
$this
->
assertCacheItemSaved
(
$bin
,
$id
,
$data
[
'value'
]))
{
$data
[
'bin'
]
=
$bin
;
...
...
@@ -1064,9 +1088,9 @@ class ApcCachePreserveExistingApcuKeysTestCase extends ApcCacheBaseTestCase {
$message
=
'New items were stored in the cache.'
;
if
(
$this
->
assertTrue
(
!
empty
(
$stored
),
$message
))
{
foreach
(
$this
->
getCacheBins
(
TRUE
)
as
$bin
)
{
foreach
(
$this
->
getCacheBins
()
as
$bin
)
{
foreach
(
$this
->
storageData
()
as
$id
=>
$data
)
{
$key
=
"
$bin$id
"
;
$key
=
$this
->
getLockKey
(
"
$bin$id
"
)
;
if
(
$this
->
assertApcuKeySaved
(
$key
,
$data
[
'value'
]))
{
$count
++
;
...
...
This diff is collapsed.
Click to expand it.
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