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

22948 - update emailer to use new db versioning #3092

Conversation

eason-pan-bc
Copy link
Collaborator

@eason-pan-bc eason-pan-bc commented Nov 25, 2024

Issue #: /bcgov/entity#22948

Description of changes:

  • update emailer, tracker and their unit tests to use new db versioning (can switch between old and new db versioning)
  • update requirements.txt file in emailer to use legal-api from feature branch
  • update feature flags
  • fix some typos in the used files

Running Emailer when flag is on

image

Running Emailer when flag is off

image

Unit Tests Results with various combination of flags on / off (legal-api, emailer)

All flags - on

image

All flags - off

image

Legal-API - on & Emailer - off

image

Legal-API - off & Emailer - on

image

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the lear license (Apache 2.0).

@eason-pan-bc eason-pan-bc self-assigned this Nov 25, 2024
legal-api/flags.json Outdated Show resolved Hide resolved
@@ -67,7 +67,7 @@ rsa==4.7.2
semver==2.13.0
sentry-sdk==1.20.0
six==1.15.0
SQLAlchemy==1.3.24
SQLAlchemy==1.4.44
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update the SQLAlchemy version to make it compatible with the custom sql-versioning

# install updated legal-api from feature branch for development,
# TODO - change it back when the db versioning feature branch merged to main
git+https://github.com/bcgov/lear.git@feature-db-versioning#egg=legal_api&subdirectory=legal-api
# git+https://github.com/bcgov/lear.git#egg=legal_api&subdirectory=legal-api
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leodube-aot how about the legal-api package, installing from the feature branch?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup we'll be installing the legal-api package from the feature branch

Copy link

sonarcloud bot commented Nov 26, 2024

@@ -34,7 +34,7 @@
from entity_queue_common.service import QueueServiceManager
from entity_queue_common.service_utils import EmailException, QueueException, logger
from flask import Flask
from legal_api import db
from legal_api import db, init_db # noqa:F401,I001;pylint:disable=unused-import;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't remove the db as in test when mocking, the db attribute is needed for worker. As experimented, removing it caused unit-tests initialization errors. https://github.com/bcgov/lear/blob/feature-db-versioning/queue_services/entity-emailer/tests/conftest.py#L322C1-L322C42

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's interesting is that you can remove this unused db import along with the monkeypatch.setattr(worker, 'db', db) line, and the unit tests work fine again. I think we should leave it as is for now. It's been in the code for 3+ years to no ill effect, and we want to limit the number of changes we merge back into main.



# used to identify versioning flag
SERVICE_NAME = 'emailer'
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per discussion using flag emailer for the tracker. #3092 (comment)

@eason-pan-bc eason-pan-bc marked this pull request as ready for review November 26, 2024 22:37
Copy link
Collaborator

@AimeeGao AimeeGao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM(^-^) Thanks for sharing the detailed test screenshots

@eason-pan-bc eason-pan-bc merged commit 658e7ed into bcgov:feature-db-versioning Nov 28, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants