-
Notifications
You must be signed in to change notification settings - Fork 3
Implement Retry into Queue Lib #17
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
77f2272
Finish Initial Retry Implementation
PineappleIOnic 99ea60d
Run Linter
PineappleIOnic 19d58a7
Use rightPop instead of loading stuff into memory
PineappleIOnic 406eee3
Refactor Tests
PineappleIOnic 7d5d9ff
Run Linter
PineappleIOnic 97c77da
Update Base.php
PineappleIOnic 7dba0c8
Address Eldad's Comments
PineappleIOnic af0b8c2
Run Linter
PineappleIOnic 4c0397b
Git Gymnastics
PineappleIOnic 9930184
Update phpunit.xml
PineappleIOnic cd6d836
Update Client.php
PineappleIOnic 49194d0
Update Client.php
PineappleIOnic 07f9ce9
Update sum methods to count methods
PineappleIOnic 88f2b40
Update tests and docblock
PineappleIOnic f42207a
Update tests/Queue/E2E/Adapter/Base.php
christyjacob4 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,155 @@ | ||
| <?php | ||
|
|
||
| namespace Tests\E2E\Adapter; | ||
|
|
||
| use PHPUnit\Framework\TestCase; | ||
| use Utopia\Queue\Client; | ||
|
|
||
| use function Co\run; | ||
|
|
||
| abstract class Base extends TestCase | ||
| { | ||
| protected array $payloads; | ||
|
|
||
| public function setUp(): void | ||
| { | ||
| $this->payloads = []; | ||
| $this->payloads[] = [ | ||
| 'type' => 'test_string', | ||
| 'value' => 'lorem ipsum' | ||
| ]; | ||
| $this->payloads[] = [ | ||
| 'type' => 'test_number', | ||
| 'value' => 123 | ||
| ]; | ||
| $this->payloads[] = [ | ||
| 'type' => 'test_number', | ||
| 'value' => 123.456 | ||
| ]; | ||
| $this->payloads[] = [ | ||
| 'type' => 'test_bool', | ||
| 'value' => true | ||
| ]; | ||
| $this->payloads[] = [ | ||
| 'type' => 'test_null', | ||
| 'value' => null | ||
| ]; | ||
| $this->payloads[] = [ | ||
| 'type' => 'test_array', | ||
| 'value' => [ | ||
| 1, | ||
| 2, | ||
| 3 | ||
| ] | ||
| ]; | ||
| $this->payloads[] = [ | ||
| 'type' => 'test_assoc', | ||
| 'value' => [ | ||
| 'string' => 'ipsum', | ||
| 'number' => 123, | ||
| 'bool' => true, | ||
| 'null' => null | ||
| ] | ||
| ]; | ||
| } | ||
|
|
||
| /** | ||
| * @return Client | ||
| */ | ||
| abstract protected function getClient(): Client; | ||
|
|
||
| public function testEvents(): void | ||
| { | ||
| $client = $this->getClient(); | ||
| $client->resetStats(); | ||
|
|
||
| foreach ($this->payloads as $payload) { | ||
| $this->assertTrue($client->enqueue($payload)); | ||
| } | ||
|
|
||
| sleep(1); | ||
|
|
||
| $this->assertEquals(7, $client->countTotalJobs()); | ||
| $this->assertEquals(0, $client->getQueueSize()); | ||
| $this->assertEquals(0, $client->countProcessingJobs()); | ||
| $this->assertEquals(0, $client->countFailedJobs()); | ||
| $this->assertEquals(7, $client->countSuccessfulJobs()); | ||
| } | ||
|
|
||
| protected function testConcurrency(): void | ||
| { | ||
| run(function () { | ||
| $client = $this->getClient(); | ||
| go(function () use ($client) { | ||
| $client->resetStats(); | ||
|
|
||
| foreach ($this->payloads as $payload) { | ||
| $this->assertTrue($client->enqueue($payload)); | ||
| } | ||
|
|
||
| sleep(1); | ||
|
|
||
| $this->assertEquals(7, $client->countTotalJobs()); | ||
| $this->assertEquals(0, $client->countProcessingJobs()); | ||
| $this->assertEquals(0, $client->countFailedJobs()); | ||
| $this->assertEquals(7, $client->countSuccessfulJobs()); | ||
| }); | ||
| }); | ||
| } | ||
|
|
||
| /** | ||
| * @depends testEvents | ||
| */ | ||
| public function testRetry(): void | ||
| { | ||
| $client = $this->getClient(); | ||
| $client->resetStats(); | ||
|
|
||
| $client->enqueue([ | ||
| 'type' => 'test_exception', | ||
| 'id' => 1 | ||
| ]); | ||
| $client->enqueue([ | ||
| 'type' => 'test_exception', | ||
| 'id' => 2 | ||
| ]); | ||
| $client->enqueue([ | ||
| 'type' => 'test_exception', | ||
| 'id' => 3 | ||
| ]); | ||
| $client->enqueue([ | ||
| 'type' => 'test_exception', | ||
| 'id' => 4 | ||
| ]); | ||
|
|
||
| sleep(1); | ||
|
|
||
| $this->assertEquals(4, $client->countTotalJobs()); | ||
| $this->assertEquals(0, $client->countProcessingJobs()); | ||
| $this->assertEquals(4, $client->countFailedJobs()); | ||
| $this->assertEquals(0, $client->countSuccessfulJobs()); | ||
|
|
||
| $client->resetStats(); | ||
|
|
||
| $client->retry(); | ||
|
|
||
| sleep(1); | ||
|
|
||
| // Retry will retry ALL failed jobs regardless of if they are still tracked in stats | ||
| $this->assertEquals(4, $client->countTotalJobs()); | ||
| $this->assertEquals(0, $client->countProcessingJobs()); | ||
| $this->assertEquals(4, $client->countFailedJobs()); | ||
| $this->assertEquals(0, $client->countSuccessfulJobs()); | ||
|
|
||
| $client->resetStats(); | ||
|
|
||
| $client->retry(2); | ||
|
|
||
| sleep(1); | ||
|
|
||
| $this->assertEquals(2, $client->countTotalJobs()); | ||
| $this->assertEquals(0, $client->countProcessingJobs()); | ||
| $this->assertEquals(2, $client->countFailedJobs()); | ||
| $this->assertEquals(0, $client->countSuccessfulJobs()); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| <?php | ||
|
|
||
| namespace Tests\E2E\Adapter; | ||
|
|
||
| use Utopia\Queue\Client; | ||
| use Utopia\Queue\Connection\Redis; | ||
|
|
||
| class SwooleTest extends Base | ||
| { | ||
| protected function getClient(): Client | ||
| { | ||
| $connection = new Redis('redis', 6379); | ||
| $client = new Client('swoole', $connection); | ||
|
|
||
| return $client; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| <?php | ||
|
|
||
| namespace Tests\E2E\Adapter; | ||
|
|
||
| use Utopia\Queue\Client; | ||
| use Utopia\Queue\Connection\Redis; | ||
|
|
||
| class WorkermanTest extends Base | ||
| { | ||
| protected function getClient(): Client | ||
| { | ||
| $connection = new Redis('redis', 6379); | ||
| $client = new Client('workerman', $connection); | ||
|
|
||
| return $client; | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.