-
Notifications
You must be signed in to change notification settings - Fork 133
Background job class #507
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
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ankitrox I agree with @felixarntz here, lets keep it simple and reference the class name directly.
* | ||
* @var Perflab_Background_Job | ||
*/ | ||
private $job; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ankitrox have you addressed this?
...modules/images/regenerate-existing-images/background-process/perflab-background-job-test.php
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
Outdated
Show resolved
Hide resolved
public function test_create_job() { | ||
$this->assertInstanceOf( Perflab_Background_Job::class, $this->job ); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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]
orInfrastructure
label.[Type]
label.no milestone
label.