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
6f8e9603
Commit
6f8e9603
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
b5ca7607
No related branches found
No related tags found
1 merge request
!74
Issue #3470139: Update the cache tests to verify there are no conflicts with the lock keys
Pipeline
#267395
passed
5 months ago
Stage: build
Stage: validate
Stage: test
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
apc.install
+0
-1
0 additions, 1 deletion
apc.install
apc.test
+27
-3
27 additions, 3 deletions
apc.test
with
27 additions
and
4 deletions
apc.install
+
0
−
1
View file @
6f8e9603
...
...
@@ -142,7 +142,6 @@ function apc_update_7201() {
registry_rebuild
();
}
/**
* Implements hook_uninstall().
*/
...
...
This diff is collapsed.
Click to expand it.
apc.test
+
27
−
3
View file @
6f8e9603
...
...
@@ -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
();
...
...
@@ -1009,7 +1031,7 @@ class ApcCachePreserveExistingApcuKeysTestCase extends ApcCacheBaseTestCase {
if
(
$this
->
assertApcuEmpty
()
&&
$this
->
assertCacheBinsOnApcu
())
{
foreach
(
$this
->
getCacheBins
(
TRUE
)
as
$bin
)
{
foreach
(
$this
->
storageData
()
as
$id
=>
$data
)
{
$key
=
"
$bin
$id
"
;
$key
=
$this
->
getLockKey
(
$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
();
...
...
@@ -1066,7 +1090,7 @@ class ApcCachePreserveExistingApcuKeysTestCase extends ApcCacheBaseTestCase {
if
(
$this
->
assertTrue
(
!
empty
(
$stored
),
$message
))
{
foreach
(
$this
->
getCacheBins
(
TRUE
)
as
$bin
)
{
foreach
(
$this
->
storageData
()
as
$id
=>
$data
)
{
$key
=
"
$bin
$id
"
;
$key
=
$this
->
getLockKey
(
$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