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 basic support for lower priority PR builds #6921
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c019df7
Add basic support for lower priority PR builds
ericholscher 0fd10e0
Be explicit with our priority steps
ericholscher e22a250
Only support 2 priorities for now and set a default
ericholscher 25ff993
Clean up celery logic around priority
ericholscher d4664f7
Merge branch 'master' of github.com:readthedocs/readthedocs.org into …
ericholscher fd359a4
Remove default priority which didn’t work.
ericholscher 739f6f8
Fix tests
ericholscher ecda0b7
Add medium priority for translations and tests for each
ericholscher File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
|
@@ -374,3 +374,9 @@ | |
# Git provider names | ||
GITHUB_BRAND = 'GitHub' | ||
GITLAB_BRAND = 'GitLab' | ||
|
||
# Set 3 priorities, [low, medium, high] -- default is medium | ||
# Leave some space on each side of the set to expand if needed | ||
CELERY_LOW = 3 | ||
CELERY_MEDIUM = 5 | ||
CELERY_HIGH = 7 | ||
Comment on lines
+378
to
+382
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: maybe these fit better in |
This file contains 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 |
---|---|---|
|
@@ -13,14 +13,15 @@ | |
from readthedocs.core.utils import slugify, trigger_build, prepare_build | ||
from readthedocs.core.utils.general import wipe_version_via_slugs | ||
from readthedocs.doc_builder.exceptions import BuildMaxConcurrencyError | ||
from readthedocs.projects.constants import CELERY_LOW, CELERY_MEDIUM, CELERY_HIGH | ||
from readthedocs.projects.models import Project, Feature | ||
from readthedocs.projects.tasks import remove_dirs | ||
|
||
|
||
class CoreUtilTests(TestCase): | ||
|
||
def setUp(self): | ||
self.project = get(Project, container_time_limit=None) | ||
self.project = get(Project, container_time_limit=None, main_language_project=None) | ||
self.version = get(Version, project=self.project) | ||
|
||
@mock.patch('readthedocs.projects.tasks.update_docs_task') | ||
|
@@ -101,6 +102,7 @@ def test_trigger_custom_queue(self, update_docs): | |
'queue': 'build03', | ||
'time_limit': 720, | ||
'soft_time_limit': 600, | ||
'priority': CELERY_HIGH, | ||
} | ||
update_docs.signature.assert_called_with( | ||
args=(self.version.pk,), | ||
|
@@ -123,6 +125,7 @@ def test_trigger_build_time_limit(self, update_docs): | |
'queue': mock.ANY, | ||
'time_limit': 720, | ||
'soft_time_limit': 600, | ||
'priority': CELERY_HIGH, | ||
} | ||
update_docs.signature.assert_called_with( | ||
args=(self.version.pk,), | ||
|
@@ -146,6 +149,7 @@ def test_trigger_build_invalid_time_limit(self, update_docs): | |
'queue': mock.ANY, | ||
'time_limit': 720, | ||
'soft_time_limit': 600, | ||
'priority': CELERY_HIGH, | ||
} | ||
update_docs.signature.assert_called_with( | ||
args=(self.version.pk,), | ||
|
@@ -169,6 +173,7 @@ def test_trigger_build_rounded_time_limit(self, update_docs): | |
'queue': mock.ANY, | ||
'time_limit': 3, | ||
'soft_time_limit': 3, | ||
'priority': CELERY_HIGH, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should modify/add a test that triggers a PR and check it's CELERY_LOW. |
||
} | ||
update_docs.signature.assert_called_with( | ||
args=(self.version.pk,), | ||
|
@@ -177,6 +182,7 @@ def test_trigger_build_rounded_time_limit(self, update_docs): | |
immutable=True, | ||
) | ||
|
||
|
||
@mock.patch('readthedocs.projects.tasks.update_docs_task') | ||
def test_trigger_max_concurrency_reached(self, update_docs): | ||
get( | ||
|
@@ -208,6 +214,7 @@ def test_trigger_max_concurrency_reached(self, update_docs): | |
'soft_time_limit': 600, | ||
'countdown': 5 * 60, | ||
'max_retries': 25, | ||
'priority': CELERY_HIGH, | ||
} | ||
update_docs.signature.assert_called_with( | ||
args=(self.version.pk,), | ||
|
@@ -218,6 +225,54 @@ def test_trigger_max_concurrency_reached(self, update_docs): | |
build = self.project.builds.first() | ||
self.assertEqual(build.error, BuildMaxConcurrencyError.message.format(limit=max_concurrent_builds)) | ||
|
||
@mock.patch('readthedocs.projects.tasks.update_docs_task') | ||
def test_trigger_external_build_low_priority(self, update_docs): | ||
"""Time limit should round down.""" | ||
self.version.type = 'external' | ||
trigger_build(project=self.project, version=self.version) | ||
kwargs = { | ||
'record': True, | ||
'force': False, | ||
'build_pk': mock.ANY, | ||
'commit': None | ||
} | ||
options = { | ||
'queue': mock.ANY, | ||
'time_limit': mock.ANY, | ||
'soft_time_limit': mock.ANY, | ||
'priority': CELERY_LOW, | ||
} | ||
update_docs.signature.assert_called_with( | ||
args=(self.version.pk,), | ||
kwargs=kwargs, | ||
options=options, | ||
immutable=True, | ||
) | ||
|
||
@mock.patch('readthedocs.projects.tasks.update_docs_task') | ||
def test_trigger_build_translation_medium_priority(self, update_docs): | ||
"""Time limit should round down.""" | ||
self.project.main_language_project = get(Project, slug='main') | ||
trigger_build(project=self.project, version=self.version) | ||
kwargs = { | ||
'record': True, | ||
'force': False, | ||
'build_pk': mock.ANY, | ||
'commit': None | ||
} | ||
options = { | ||
'queue': mock.ANY, | ||
'time_limit': mock.ANY, | ||
'soft_time_limit': mock.ANY, | ||
'priority': CELERY_MEDIUM, | ||
} | ||
update_docs.signature.assert_called_with( | ||
args=(self.version.pk,), | ||
kwargs=kwargs, | ||
options=options, | ||
immutable=True, | ||
) | ||
|
||
def test_slugify(self): | ||
"""Test additional slugify.""" | ||
self.assertEqual( | ||
|
This file contains 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
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.
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.
Want we check for being a translation here before checking if external and assigning
CELERY_MEDIUM
?