Background job class#507
Conversation
|
As of now, there is no |
modules/images/regenerate-existing-images/background-process/class-perflab-background-job.php
Outdated
Show resolved
Hide resolved
modules/images/regenerate-existing-images/background-process/class-perflab-background-job.php
Outdated
Show resolved
Hide resolved
modules/images/regenerate-existing-images/background-process/class-perflab-background-job.php
Outdated
Show resolved
Hide resolved
|
@eugene-manuilov Thanks for review. Addressed the feedback, requesting re-review. |
mukeshpanchal27
left a comment
There was a problem hiding this comment.
@ankitrox Left some reviews with suggestions.
Is a unit test remaining for these changes?
modules/images/regenerate-existing-images/background-process/class-perflab-background-job.php
Outdated
Show resolved
Hide resolved
modules/images/regenerate-existing-images/background-process/class-perflab-background-job.php
Outdated
Show resolved
Hide resolved
modules/images/regenerate-existing-images/background-process/class-perflab-background-job.php
Outdated
Show resolved
Hide resolved
modules/images/regenerate-existing-images/background-process/class-perflab-background-job.php
Outdated
Show resolved
Hide resolved
|
@mukeshpanchal27 Added unit tests and addressed the feedback. Re-requesting review. |
...modules/images/regenerate-existing-images/background-process/perflab-background-job-test.php
Outdated
Show resolved
Hide resolved
...modules/images/regenerate-existing-images/background-process/perflab-background-job-test.php
Outdated
Show resolved
Hide resolved
|
@ankitrox Left replies to the open comments. Once those iterations have been made, the PR should be good. |
jjgrainger
left a comment
There was a problem hiding this comment.
Thanks @ankitrox we're almost there, just followed up on some comments from @felixarntz I think still need to be addressed.
| $this->assertEquals( 'perflab_job_action', constant( $job_class . '::META_KEY_JOB_ACTION' ) ); | ||
| $this->assertEquals( 'perflab_job_data', constant( $job_class . '::META_KEY_JOB_DATA' ) ); | ||
| $this->assertEquals( 'perflab_job_attempts', constant( $job_class . '::META_KEY_JOB_ATTEMPTS' ) ); | ||
| $this->assertEquals( 'perflab_job_lock', constant( $job_class . '::META_KEY_JOB_LOCK' ) ); | ||
| $this->assertEquals( 'perflab_job_errors', constant( $job_class . '::META_KEY_JOB_ERRORS' ) ); | ||
| $this->assertEquals( 'perflab_job_status', constant( $job_class . '::META_KEY_JOB_STATUS' ) ); | ||
| $this->assertEquals( 'perflab_job_completed_at', constant( $job_class . '::META_KEY_JOB_COMPLETED_AT' ) ); | ||
| $this->assertEquals( 'queued', constant( $job_class . '::JOB_STATUS_QUEUED' ) ); | ||
| $this->assertEquals( 'running', constant( $job_class . '::JOB_STATUS_RUNNING' ) ); | ||
| $this->assertEquals( 'partial', constant( $job_class . '::JOB_STATUS_PARTIAL' ) ); | ||
| $this->assertEquals( 'completed', constant( $job_class . '::JOB_STATUS_COMPLETE' ) ); | ||
| $this->assertEquals( 'failed', constant( $job_class . '::JOB_STATUS_FAILED' ) ); |
There was a problem hiding this comment.
@ankitrox I agree with @felixarntz here, lets keep it simple and reference the class name directly.
| * | ||
| * @var Perflab_Background_Job | ||
| */ | ||
| private $job; |
...modules/images/regenerate-existing-images/background-process/perflab-background-job-test.php
Outdated
Show resolved
Hide resolved
felixarntz
left a comment
There was a problem hiding this comment.
@ankitrox A few last fixes needed here. Please make sure to address the open comments from previous reviews as well.
modules/images/regenerate-existing-images/background-process/class-perflab-background-job.php
Outdated
Show resolved
Hide resolved
modules/images/regenerate-existing-images/background-process/class-perflab-background-job.php
Outdated
Show resolved
Hide resolved
modules/images/regenerate-existing-images/background-process/class-perflab-background-job.php
Outdated
Show resolved
Hide resolved
| $this->assertEquals( 'perflab_job_action', constant( $job_class . '::META_KEY_JOB_ACTION' ) ); | ||
| $this->assertEquals( 'perflab_job_data', constant( $job_class . '::META_KEY_JOB_DATA' ) ); | ||
| $this->assertEquals( 'perflab_job_attempts', constant( $job_class . '::META_KEY_JOB_ATTEMPTS' ) ); | ||
| $this->assertEquals( 'perflab_job_lock', constant( $job_class . '::META_KEY_JOB_LOCK' ) ); | ||
| $this->assertEquals( 'perflab_job_errors', constant( $job_class . '::META_KEY_JOB_ERRORS' ) ); | ||
| $this->assertEquals( 'perflab_job_status', constant( $job_class . '::META_KEY_JOB_STATUS' ) ); | ||
| $this->assertEquals( 'perflab_job_completed_at', constant( $job_class . '::META_KEY_JOB_COMPLETED_AT' ) ); | ||
| $this->assertEquals( 'queued', constant( $job_class . '::JOB_STATUS_QUEUED' ) ); | ||
| $this->assertEquals( 'running', constant( $job_class . '::JOB_STATUS_RUNNING' ) ); | ||
| $this->assertEquals( 'partial', constant( $job_class . '::JOB_STATUS_PARTIAL' ) ); | ||
| $this->assertEquals( 'completed', constant( $job_class . '::JOB_STATUS_COMPLETE' ) ); | ||
| $this->assertEquals( 'failed', constant( $job_class . '::JOB_STATUS_FAILED' ) ); |
There was a problem hiding this comment.
This still needs to be addressed.
...modules/images/regenerate-existing-images/background-process/perflab-background-job-test.php
Outdated
Show resolved
Hide resolved
...modules/images/regenerate-existing-images/background-process/perflab-background-job-test.php
Show resolved
Hide resolved
| public function test_create_job() { | ||
| $this->assertInstanceOf( Perflab_Background_Job::class, $this->job ); | ||
| } |
There was a problem hiding this comment.
This should be removed as it's not testing any part of the class, but rather the perflab_create_background_job() function, which is already covered by the other test class's test_perflab_create_background_job() method.
Co-authored-by: Felix Arntz <felixarntz@users.noreply.github.com>
…WordPress/performance into experiment/background-job-class
jjgrainger
left a comment
There was a problem hiding this comment.
Thanks @ankitrox I've requested a couple of changes here, can you take a look?
| * | ||
| * @var Perflab_Background_Job | ||
| */ | ||
| private $job; |
There was a problem hiding this comment.
@ankitrox please can you address or respond to this comment from Felix
No need to have a class property for jobs created in tests. WordPress cleans up pretty much any changes to the database after each tests. So you don't need this property, simply use a local variable per test method - and then you can also remove the unnecessary
tear_down()method implementation.
Co-authored-by: Joe Grainger <904708+jjgrainger@users.noreply.github.com>
@jjgrainger Please refer this comment, according to this comment we will be using |
felixarntz
left a comment
There was a problem hiding this comment.
Thanks @ankitrox! LGTM, just one tiny nit-pick.
@jjgrainger Could you please re-review as well?
...modules/images/regenerate-existing-images/background-process/perflab-background-job-test.php
Outdated
Show resolved
Hide resolved
mukeshpanchal27
left a comment
There was a problem hiding this comment.
Thanks @ankitrox Left some minor update, not blocker.
...modules/images/regenerate-existing-images/background-process/perflab-background-job-test.php
Show resolved
Hide resolved
...modules/images/regenerate-existing-images/background-process/perflab-background-job-test.php
Outdated
Show resolved
Hide resolved
Co-authored-by: Mukesh Panchal <mukeshpanchal27@users.noreply.github.com>
Co-authored-by: Mukesh Panchal <mukeshpanchal27@users.noreply.github.com>
Co-authored-by: Felix Arntz <felixarntz@users.noreply.github.com>
jjgrainger
left a comment
There was a problem hiding this comment.
Thanks @ankitrox great work here, approved!
Summary
Background job class to manage the life cycle of a background job.
This class is responsible for:
Fixes #503 #479
Relevant technical choices
Checklist
[Focus]orInfrastructurelabel.[Type]label.no milestonelabel.