-
Notifications
You must be signed in to change notification settings - Fork 27
Add continuous writes test charm #36
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
Conversation
Codecov Report
@@ Coverage Diff @@
## main #36 +/- ##
==========================================
+ Coverage 60.11% 60.32% +0.20%
==========================================
Files 6 6
Lines 692 809 +117
Branches 103 119 +16
==========================================
+ Hits 416 488 +72
- Misses 256 293 +37
- Partials 20 28 +8
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
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.
This looks awesome! Initially when I did mine I wanted to do it as an application charm but I was too lazy. This is really awesome to see!
start-continuous-writes: | ||
description: Start continuous writes. | ||
stop-continuous-writes: | ||
description: Stop continuous writes. |
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.
Neat way of doing this
"""Starts continuous writes to PostgreSQL instance.""" | ||
if self._connection_string is None: | ||
return | ||
|
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.
Nit add '# stop any writes that might be going'
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.
Nice. Added on e9c2353.
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.
lgtm!
Thanks for the reviews! |
You made most part of the work needed on this, Mia! It was your amazing implementation that made it easy to create the charm. |
* Add continuous writes test charm * Add comment
Issue
Solution
Context
database_requires.py
is an imported library and can be ignored while reviewing this PR.You can
FOCUS
on the code from the following files while reviewing this PR:charm.py
:has event handlers to get the connections details from the PostgreSQL from the relation data (
postgresql_client
interface).has action handlers to start and stop the continuous writes process from
continuous_writes.py
and also for erasing the written data.continuous_writes.py
:this is a Python script that continuously writes data to the PostgreSQL database. It was adapted to PostgreSQL based on the amazing code that Mia implemented on Charmed MongoDB Operator.
it reconnects again to the database in every loop iteration because the current established connection can fail when the primary changes (Patroni sometimes take some seconds to reassign the primary role; this happens due to some values in some Patroni settings that are needed to avoid more frequent split brain scenarios).
Testing
Release Notes