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

Add support for lock expiry. #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fabianfreyer
Copy link

Discussed-with: Nils Adermann <[email protected]>
@dvdcastro dvdcastro self-requested a review February 4, 2021 20:49
Copy link

@dvdcastro dvdcastro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unit tests are failing locally for me, please review them.

vendor/bin/phpunit local/redislock/tests/redis_lock_factory_test.php
Testing started at 3:49 PM ...
Moodle 3.9.3 (Build: 20201109), ab5949dbe283a074834710b28cf17a298c54a786
Php: 7.2.24.0.0.18.04.6, mysqli: 5.7.30-0ubuntu0.18.04.1, OS: Linux 4.15.0-101-generic x86_64
PHPUnit 7.5.20 by Sebastian Bergmann and contributors.


Failed asserting that 86400 matches expected -1.
Expected :-1
Actual   :86400
<Click to see difference>

 /vagrant/www/moodle/local/redislock/tests/redis_lock_factory_test.php:76
 /vagrant/www/moodle/lib/phpunit/classes/advanced_testcase.php:91
 

Failed asserting that a boolean is not empty.
 /vagrant/www/moodle/local/redislock/tests/redis_lock_factory_test.php:134
 /vagrant/www/moodle/lib/phpunit/classes/advanced_testcase.php:91
 

Failed asserting that a boolean is not empty.
 /vagrant/www/moodle/local/redislock/tests/redis_lock_factory_test.php:156
 /vagrant/www/moodle/lib/phpunit/classes/advanced_testcase.php:91
 

Expectation failed for method name is equal to 'setnx' when invoked at least once.
Expected invocation at least once but it never occurred.

 /vagrant/www/moodle/lib/phpunit/classes/advanced_testcase.php:91
 

Expectation failed for method name is equal to 'setnx' when invoked 1 time(s).
Method was expected to be called 1 times, actually called 0 times.

 /vagrant/www/moodle/lib/phpunit/classes/advanced_testcase.php:91
 


Time: 30.98 seconds, Memory: 128.50 MB


FAILURES!
Tests: 6, Assertions: 17, Failures: 5.

Fatal error: Uncaught coding_exception: Coding error detected, it must be fixed by a programmer: A lock was created but not released at:
/vagrant/www/moodle/local/redislock/tests/redis_lock_factory_test.php on line 74

 Code should look like:

 $factory = \core\lock\lock_config::get_lock_factory('type');
 $lock = $factory->get_lock(master372a_core_cron_test);
 $lock->release();  // Locks must ALWAYS be released like this.

 in /vagrant/www/moodle/lib/classes/lock/lock.php on line 117

Call Stack:
    0.0004     391544   1. {main}() /vagrant/www/moodle/vendor/phpunit/phpunit/phpunit:0
    0.0262    1159232   2. PHPUnit\TextUI\Command::main() /vagrant/www/moodle/vendor/phpunit/phpunit/phpunit:61
    0.0262    1159344   3. PHPUnit\TextUI\Command->run() /vagrant/www/moodle/vendor/phpunit/phpunit/src/TextUI/Command.php:162
    5.2651  130201720   4. PHPUnit\TextUI\TestRunner->doRun() /vagrant/www/moodle/vendor/phpunit/phpunit/src/TextUI/Command.php:206

coding_exception: Coding error detected, it must be fixed by a programmer: A lock was created but not released at:
/vagrant/www/moodle/local/redislock/tests/redis_lock_factory_test.php on line 74

 Code should look like:

 $factory = \core\lock\lock_config::get_lock_factory('type');
 $lock = $factory->get_lock(master372a_core_cron_test);
 $lock->release();  // Locks must ALWAYS be released like this.

 in /vagrant/www/moodle/lib/classes/lock/lock.php on line 117

Call Stack:
    0.0004     391544   1. {main}() /vagrant/www/moodle/vendor/phpunit/phpunit/phpunit:0
    0.0262    1159232   2. PHPUnit\TextUI\Command::main() /vagrant/www/moodle/vendor/phpunit/phpunit/phpunit:61
    0.0262    1159344   3. PHPUnit\TextUI\Command->run() /vagrant/www/moodle/vendor/phpunit/phpunit/src/TextUI/Command.php:162
    5.2651  130201720   4. PHPUnit\TextUI\TestRunner->doRun() /vagrant/www/moodle/vendor/phpunit/phpunit/src/TextUI/Command.php:206
   30.9895  132674296   5. core\lock\lock->__destruct() /vagrant/www/moodle/lib/classes/lock/lock.php:0

Process finished with exit code 1

@mr-www-admin mr-www-admin force-pushed the master branch 6 times, most recently from 44096df to d03db82 Compare May 9, 2022 15:58
@mr-www-admin mr-www-admin force-pushed the master branch 5 times, most recently from 80d70a2 to 101a6fa Compare August 11, 2022 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants