diff --git a/cms/envs/common.py b/cms/envs/common.py index be837c518981..28d6752ac3b9 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -2521,6 +2521,7 @@ ANALYTICS_DASHBOARD_NAME = 'Your Platform Name Here Insights' COMMENTS_SERVICE_URL = 'http://localhost:18080' +COMMENTS_SERVICE_V2_URL = 'http://localhost:8000' COMMENTS_SERVICE_KEY = 'password' EXAMS_SERVICE_URL = 'http://localhost:18740/api/v1' diff --git a/lms/envs/common.py b/lms/envs/common.py index 9f9004976e0c..6bfd161bd92e 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -4328,6 +4328,7 @@ def _make_locale_paths(settings): # pylint: disable=missing-function-docstring CREDENTIALS_PUBLIC_SERVICE_URL = 'http://localhost:8005' COMMENTS_SERVICE_URL = 'http://localhost:18080' +COMMENTS_SERVICE_V2_URL = 'http://localhost:8000' COMMENTS_SERVICE_KEY = 'password' # Reverification checkpoint name pattern diff --git a/lms/envs/devstack.py b/lms/envs/devstack.py index 611017962852..e82a49b60e1b 100644 --- a/lms/envs/devstack.py +++ b/lms/envs/devstack.py @@ -245,6 +245,7 @@ def should_show_debug_toolbar(request): # lint-amnesty, pylint: disable=missing ############## Comments CONFIGURATION SETTINGS ############### COMMENTS_SERVICE_URL = 'http://edx.devstack.forum:4567' +COMMENTS_SERVICE_V2_URL = 'http://localhost:8000' ############## Credentials CONFIGURATION SETTINGS ############### CREDENTIALS_INTERNAL_SERVICE_URL = 'http://edx.devstack.credentials:18150' diff --git a/lms/envs/production.py b/lms/envs/production.py index a1acd692f4e1..cf03f2676e20 100644 --- a/lms/envs/production.py +++ b/lms/envs/production.py @@ -328,6 +328,7 @@ def get_env_setting(setting): COURSE_LISTINGS = ENV_TOKENS.get('COURSE_LISTINGS', {}) COMMENTS_SERVICE_URL = ENV_TOKENS.get("COMMENTS_SERVICE_URL", '') +COMMENTS_SERVICE_V2_URL = ENV_TOKENS.get("COMMENTS_SERVICE_V2_URL", '') COMMENTS_SERVICE_KEY = ENV_TOKENS.get("COMMENTS_SERVICE_KEY", '') CERT_QUEUE = ENV_TOKENS.get("CERT_QUEUE", 'test-pull') diff --git a/openedx/core/djangoapps/django_comment_common/comment_client/settings.py b/openedx/core/djangoapps/django_comment_common/comment_client/settings.py index 075aba03ede0..4e93ceec354d 100644 --- a/openedx/core/djangoapps/django_comment_common/comment_client/settings.py +++ b/openedx/core/djangoapps/django_comment_common/comment_client/settings.py @@ -7,3 +7,11 @@ SERVICE_HOST = 'http://localhost:4567' PREFIX = SERVICE_HOST + '/api/v1' + +# V2 url support for differential logging +if hasattr(settings, "COMMENTS_SERVICE_V2_URL"): + SERVICE_HOST_V2 = settings.COMMENTS_SERVICE_V2_URL +else: + SERVICE_HOST_V2 = 'http://localhost:8000' + +PREFIX_V2 = SERVICE_HOST_V2 + '/forum/forum_proxy/api/v1' diff --git a/openedx/core/djangoapps/django_comment_common/comment_client/utils.py b/openedx/core/djangoapps/django_comment_common/comment_client/utils.py index a67cdbdbc483..92a647bdc15c 100644 --- a/openedx/core/djangoapps/django_comment_common/comment_client/utils.py +++ b/openedx/core/djangoapps/django_comment_common/comment_client/utils.py @@ -8,7 +8,7 @@ import requests from django.utils.translation import get_language -from .settings import SERVICE_HOST as COMMENTS_SERVICE +from .settings import PREFIX, PREFIX_V2, SERVICE_HOST as COMMENTS_SERVICE log = logging.getLogger(__name__) @@ -30,6 +30,10 @@ def extract(dic, keys): return strip_none({k: dic.get(k) for k in keys}) +def _get_forum_v2_url(url): + return url.replace(PREFIX, PREFIX_V2) + + def perform_request(method, url, data_or_params=None, raw=False, metric_action=None, metric_tags=None, paged_results=False): # To avoid dependency conflict @@ -71,6 +75,24 @@ def perform_request(method, url, data_or_params=None, raw=False, timeout=config.connection_timeout ) + if method == "get": + forum_v2_url = _get_forum_v2_url(url) + response_v2 = requests.request( + method, + forum_v2_url, + data=data, + params=params, + headers=headers, + timeout=config.connection_timeout, + ) + log.info(f"requested forum v1 url: {url}") + log.info(f"requested forum v2 url: {forum_v2_url}") + if response_v2.json() != response.json(): + log.error( + f"Forum v2 difference, for endpoint {url} with params={params}. \ + Expected: {response.json()}. Got: {response_v2.json()}." + ) + metric_tags.append(f'status_code:{response.status_code}') status_code = int(response.status_code) if status_code > 200: