-
Notifications
You must be signed in to change notification settings - Fork 11
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
Enable DB replica #1104
Enable DB replica #1104
Conversation
99ebf44
to
bcf41d9
Compare
Codecov Report
@@ Coverage Diff @@
## master #1104 +/- ##
==========================================
- Coverage 73.02% 72.94% -0.08%
==========================================
Files 290 290
Lines 7439 7499 +60
Branches 1567 1580 +13
==========================================
+ Hits 5432 5470 +38
- Misses 1963 1985 +22
Partials 44 44
Flags with carried forward coverage won't be shown. Click here to find out more.
|
5e30cfa
to
10a84fa
Compare
The deployed env does not need host nor port since it uses a socket connection
Affects (integration) testing only, and simplifies local development
10a84fa
to
72fabb2
Compare
@HaGuesto priority |
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.
I like your solution, feels elegant. @pylipp
Just one comment: we started actually that we do not want the statviz queries to have an effect or block behavior in Boxtribute. Since now the replica is used for ALL querys, we just ensured that the statviz queries will not have an effect on the mutations in Boxtribute.
However, we also started at the point that we want to make these queries public and that is not happening at least for now. Therefore, I'm fine with this PR and it will be a nice test.
@@ -193,7 +193,8 @@ jobs: | |||
name: Run pytest | |||
command: | | |||
source $(pyenv root)/versions/3.10.4/envs/env/bin/activate | |||
ENVIRONMENT=test pytest --cov-report xml:test-results/coverage.xml --cov=boxtribute_server | |||
# overwrite environment variable because it must not depend on the CircleCI context | |||
ENVIRONMENT=development MYSQL_PORT=3306 pytest --cov-report xml:test-results/coverage.xml --cov=boxtribute_server |
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.
weird that the socket is needed here if you are using a socket
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.
What do you mean? weird that the port is needed? It's because the connection to the DB for integration tests is via TCP. Socket will only be effective in deployed environments.
unix_socket=os.getenv("MYSQL_SOCKET"), | ||
replica_socket=os.getenv("MYSQL_REPLICA_SOCKET"), |
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.
We need to remember to set this variable in the contexts in circleci
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.
I already set it as a project-wide variable
|
||
class BaseModel(self.base_model_class): | ||
@classmethod | ||
def select(cls, *args, **kwargs): |
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.
elegant
@pylipp we are tracking the latency of the server, right? We should have an alert or track it in order to compare before and after. Would love to see the difference. |
I implemented a custom class derived from peewee's
FlaskDB
to glue together Flask and the databases (the primary one and, for select-queries, the replica).Further changes are about cleaning up env variables related to configure the DB connection locally and in CircleCI.