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

Add mas database integration #612

Draft
wants to merge 24 commits into
base: 2/main
Choose a base branch
from

Conversation

Thanhphan1147
Copy link
Collaborator

Overview

Rationale

Juju Events Changes

Module Changes

Library Changes

Checklist

Copy link
Contributor

Lint checks failed for 563bc35

```

--- /home/runner/work/synapse-operator/synapse-operator/src/state/mas.py:before 2024-11-28 22:08:32.088848
+++ /home/runner/work/synapse-operator/synapse-operator/src/state/mas.py:after 2024-11-28 22:09:04.285368
@@ -10,6 +10,7 @@

from charm_types import DatasourcePostgreSQL
from database_observer import DatabaseObserver
+
MAS_DATABASE_INTEGRATION_NAME = "mas-database"

--- /home/runner/work/synapse-operator/synapse-operator/tests/unit/test_smtp_observer.py:before 2024-11-28 22:08:32.092848
+++ /home/runner/work/synapse-operator/synapse-operator/tests/unit/test_smtp_observer.py:after 2024-11-28 22:09:04.334003
@@ -11,8 +11,8 @@
from charms.smtp_integrator.v0.smtp import AuthType, TransportSecurity
from ops.testing import Harness

+from charm_types import SMTPConfiguration
from state.charm_state import CharmConfigInvalidError
-from charm_types import SMTPConfiguration

def _test_get_relation_data_to_smtp_conf_parameters():
--- /home/runner/work/synapse-operator/synapse-operator/tests/unit/test_synapse_workload.py:before 2024-11-28 22:08:32.092848
+++ /home/runner/work/synapse-operator/synapse-operator/tests/unit/test_synapse_workload.py:after 2024-11-28 22:09:04.349992
@@ -18,8 +18,8 @@
from pydantic.v1 import ValidationError

import synapse
+from charm_types import SMTPConfiguration
from state.charm_state import CharmState, SynapseConfig
-from charm_types import SMTPConfiguration

def test_allow_public_rooms_over_federation_sucess(config_content: dict[str, typing.Any]):

Copy link
Contributor

Unit tests failed for 563bc35

```

============================= test session starts ==============================
platform linux -- Python 3.10.12, pytest-8.3.3, pluggy-1.5.0 -- /home/runner/work/synapse-operator/synapse-operator/.tox/unit/bin/python
cachedir: .tox/unit/.pytest_cache
rootdir: /home/runner/work/synapse-operator/synapse-operator
configfile: pyproject.toml
plugins: anyio-4.6.2.post1
collecting ... collected 0 items / 1 error

==================================== ERRORS ====================================
_________________________ ERROR collecting tests/unit __________________________
Traceback (most recent call last):
File "/home/runner/work/synapse-operator/synapse-operator/.tox/unit/lib/python3.10/site-packages/_pytest/config/init.py", line 710, in _importconftest
mod = import_path(
File "/home/runner/work/synapse-operator/synapse-operator/.tox/unit/lib/python3.10/site-packages/_pytest/pathlib.py", line 582, in import_path
importlib.import_module(module_name)
File "/usr/lib/python3.10/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1050, in _gcd_import
File "", line 1027, in _find_and_load
File "", line 1006, in _find_and_load_unlocked
File "", line 688, in _load_unlocked
File "/home/runner/work/synapse-operator/synapse-operator/.tox/unit/lib/python3.10/site-packages/_pytest/assertion/rewrite.py", line 184, in exec_module
exec(co, module.dict)
File "/home/runner/work/synapse-operator/synapse-operator/tests/unit/conftest.py", line 22, in
from charm import SynapseCharm
File "/home/runner/work/synapse-operator/synapse-operator/src/charm.py", line 25, in
from database_observer import DatabaseObserver
File "/home/runner/work/synapse-operator/synapse-operator/src/database_observer.py", line 22, in
from state.mas import MASConfiguration
File "/home/runner/work/synapse-operator/synapse-operator/src/state/mas.py", line 12, in
from database_observer import DatabaseObserver
ImportError: cannot import name 'DatabaseObserver' from partially initialized module 'database_observer' (most likely due to a circular import) (/home/runner/work/synapse-operator/synapse-operator/src/database_observer.py)
=========================== short test summary info ============================
ERROR tests/unit - ImportError: cannot import name 'DatabaseObserver' from partially initializ...
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 0.77s ===============================

Copy link
Contributor

Test coverage for 563bc35

Name                                    Stmts   Miss Branch BrPart  Cover   Missing
-----------------------------------------------------------------------------------
src/actions/__init__.py                     1      0      0      0   100%
src/actions/register_user.py               21     11      2      0    43%   35, 61-77
src/admin_access_token.py                   9      0      0      0   100%
src/backup.py                             175    130     20      0    23%   79-81, 94-111, 119-127, 138-143, 157-166, 174-184, 198-205, 226-253, 273-296, 314-354, 372-381, 393-399, 415-430, 453-465, 477-485, 502-509, 521
src/backup_observer.py                    134    111     12      0    16%   36-49, 53-70, 74, 82-103, 114-122, 130-145, 164-198, 206-229
src/charm.py                              304    289     70      0     4%   26-569
src/charm_types.py                         30      0      0      0   100%
src/database_client.py                     57     43      8      0    22%   34-39, 47-65, 69-71, 79-105, 115-131
src/database_observer.py                   46     37      4      0    18%   23-101
src/exceptions.py                           3      1      0      0    67%   22
src/matrix_auth_observer.py                68     68     12      0     0%   6-167
src/media_observer.py                      45     45      2      0     0%   6-86
src/mjolnir.py                            102    102     30      0     0%   9-231
src/observability.py                       14     14      0      0     0%   7-50
src/pebble.py                             203    170     46      0    13%   40, 52-62, 71-78, 93-100, 109-113, 122-129, 139-141, 151-154, 163-164, 174-191, 203-206, 221-226, 244-247, 263-276, 299-398, 411-436, 448-453, 462-477, 486-502, 514-527, 536-549, 561-580
src/redis_observer.py                      39     39      4      0     0%   9-81
src/s3_parameters.py                       22      7      4      0    58%   48-51, 56-58
src/smtp_observer.py                       61     61     14      0     0%   6-139
src/state/charm_state.py                  131     63     32      0    42%   48, 140-143, 156-158, 176-183, 201-208, 226-245, 280-283, 319-359
src/state/mas.py                           20     15      2      0    23%   13-58
src/synapse/__init__.py                     4      0      0      0   100%
src/synapse/admin.py                       19      9      2      0    48%   40-41, 63-74
src/synapse/api.py                        175    122     20      0    27%   61, 113-114, 141-177, 202-234, 264-276, 288-295, 320-331, 351-360, 371-376, 395-412, 427-432, 447-484, 496-499, 514-519, 531-536
src/synapse/workload.py                   138     78     24      0    37%   65, 115-130, 142, 154-157, 173-183, 203-208, 222-245, 258-272, 286-295, 309-321, 334-365, 378-384, 398-402, 412-415
src/synapse/workload_configuration.py     148    118     34      0    16%   26, 36, 45, 54, 64, 73, 86-93, 102-103, 112, 122, 135-142, 152-156, 169-192, 201, 216-225, 235-241, 254-268, 281-289, 301-311, 327-340, 353-367, 376, 389-413, 422, 432-443, 456-464
src/user.py                                23      9      2      0    56%   28-30, 55-57, 75-77
-----------------------------------------------------------------------------------
TOTAL                                    1992   1542    344      0    19%
Coverage failure: total of 19 is less than fail-under=91

Static code analysis report

Working... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00
Run started:2024-11-28 22:09:21.957672

Test results:
  No issues identified.

Code scanned:
  Total lines of code: 10933
  Total lines skipped (#nosec): 4
  Total potential issues skipped due to specifically being disabled (e.g., #nosec BXXX): 0

Run metrics:
  Total issues (by severity):
  	Undefined: 0
  	Low: 0
  	Medium: 0
  	High: 0
  Total issues (by confidence):
  	Undefined: 0
  	Low: 0
  	Medium: 0
  	High: 0
Files skipped (0):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant