Skip to content
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

feat increase frequency of schedulednotify credentials #36180

Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions cms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2520,6 +2520,8 @@
CREDENTIALS_INTERNAL_SERVICE_URL = 'http://localhost:8005'
CREDENTIALS_PUBLIC_SERVICE_URL = 'http://localhost:8005'
CREDENTIALS_SERVICE_USERNAME = 'credentials_service_user'
# time between scheduled runs, in seconds
NOTIFY_CREDENTIALS_FREQUENCY = 14400

ANALYTICS_DASHBOARD_URL = 'http://localhost:18110/courses'
ANALYTICS_DASHBOARD_NAME = 'Your Platform Name Here Insights'
Expand Down
2 changes: 2 additions & 0 deletions lms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -4331,6 +4331,8 @@ def _make_locale_paths(settings): # pylint: disable=missing-function-docstring

CREDENTIALS_INTERNAL_SERVICE_URL = 'http://localhost:8005'
CREDENTIALS_PUBLIC_SERVICE_URL = 'http://localhost:8005'
# time between scheduled runs, in seconds
NOTIFY_CREDENTIALS_FREQUENCY = 14400

COMMENTS_SERVICE_URL = 'http://localhost:18080'
COMMENTS_SERVICE_KEY = 'password'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

from datetime import datetime, timedelta
import dateutil.parser
from django.conf import settings
from django.core.management.base import BaseCommand, CommandError
from opaque_keys import InvalidKeyError
from opaque_keys.edx.keys import CourseKey
Expand Down Expand Up @@ -157,8 +158,9 @@ def handle(self, *args, **options):
options = self.get_args_from_database()

if options["auto"]:
run_frequency = settings.NOTIFY_CREDENTIALS_FREQUENCY
options["end_date"] = datetime.now().replace(minute=0, second=0, microsecond=0)
options["start_date"] = options["end_date"] - timedelta(hours=4)
options["start_date"] = options["end_date"] - timedelta(seconds=run_frequency)

log.info(
f"notify_credentials starting, dry-run={options['dry_run']}, site={options['site']}, "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from django.core.management import call_command
from django.core.management.base import CommandError
from django.test import TestCase, override_settings # lint-amnesty, pylint: disable=unused-import
from django.test import TestCase, override_settings
from freezegun import freeze_time

from openedx.core.djangoapps.catalog.tests.factories import ProgramFactory, CourseFactory, CourseRunFactory
Expand Down Expand Up @@ -125,6 +125,7 @@ def test_multiple_programs_uuid_args(self, mock_get_programs, mock_task):

@freeze_time(datetime(2017, 5, 1, 4))
def test_auto_execution(self, mock_task):
"""Verify that an automatic execution designed for scheduled windows works correctly"""
self.expected_options['auto'] = True
self.expected_options['start_date'] = datetime(2017, 5, 1, 0, 0)
self.expected_options['end_date'] = datetime(2017, 5, 1, 4, 0)
Expand All @@ -133,6 +134,19 @@ def test_auto_execution(self, mock_task):
assert mock_task.called
assert mock_task.call_args[0][0] == self.expected_options

@override_settings(NOTIFY_CREDENTIALS_FREQUENCY=3600)
@freeze_time(datetime(2017, 5, 1, 4))
def test_auto_execution_different_schedule(self, mock_task):
"""Verify that an automatic execution designed for scheduled windows
works correctly if the window frequency has been changed"""
self.expected_options["auto"] = True
self.expected_options["start_date"] = datetime(2017, 5, 1, 3, 0)
self.expected_options["end_date"] = datetime(2017, 5, 1, 4, 0)

call_command(Command(), "--auto")
assert mock_task.called
assert mock_task.call_args[0][0] == self.expected_options

def test_date_args(self, mock_task):
self.expected_options['start_date'] = datetime(2017, 1, 31, 0, 0, tzinfo=timezone.utc)
call_command(Command(), '--start-date', '2017-01-31')
Expand Down
Loading