Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions tests/Ackintosh/Ganesha/Storage/Adapter/MemcachedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,9 @@ public function outdatedCountsShouldBeEvictedInCaseOfRateStrategy(): void
->intervalToHalfOpen(10)
->build();

// Ensure memcache is cleared
sleep(1);

// Record successes.
// Since Memcached adapter implements `TumblingTimeWindow`, the count is recorded into a key which based on timestamp.
$serviceName = 'outdatedCountsShouldBeEvicted';
Expand Down Expand Up @@ -441,8 +444,8 @@ public function outdatedCountsShouldBeEvictedInCaseOfRateStrategy(): void
(int)$this->memcached->get($failureKeyForTheTumblingTimeWindow)
);

// Since sleeping 15 seconds as below, the `TumblingTimeWindow` contains the success count recorded above is outdated.
sleep(15);
// Since sleeping 10 seconds as below, the `TumblingTimeWindow` contains the success count recorded above is outdated.
sleep(10);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this is enough, so we save 5 seconds here, but add 1 above, essentially we are still faster 4 seconds 😂


// The count should be got cleared as the `TumblingTimeWindow` is outdated at this point.
self::assertFalse($this->memcached->get($successKeyForTheTumblingTimeWindow));
Expand Down