From e315ab93330103a7314455cc2a8990f9ddd0f5b2 Mon Sep 17 00:00:00 2001 From: Tanmoy Sarkar <57363826+tanmoysrt@users.noreply.github.com> Date: Mon, 14 Oct 2024 11:42:00 +0530 Subject: [PATCH] chore: move db doctypes to database module --- press/api/tests/test_server.py | 4 +- press/database/__init__.py | 0 press/database/doctype/__init__.py | 0 .../doctype/database_server/__init__.py | 0 .../database_server/database_server.js | 8 + .../database_server/database_server.json | 559 ++++++++++++++++++ .../database_server/database_server.py | 9 + .../database_server/test_database_server.py | 30 + .../__init__.py | 0 .../database_server_mariadb_variable.json | 69 +++ .../database_server_mariadb_variable.py | 9 + press/hooks.py | 2 +- press/modules.txt | 3 +- press/patches.txt | 2 +- .../database_server/database_server.py | 6 +- .../database_server/test_database_server.py | 22 +- .../test_database_server_mariadb_variable.py | 50 +- .../mariadb_variable/mariadb_variable.py | 2 +- .../mariadb_variable/test_mariadb_variable.py | 2 +- .../doctype/root_domain/test_root_domain.py | 2 +- press/press/doctype/server/test_server.py | 2 +- press/press/doctype/site/site.py | 2 +- press/press/doctype/site/test_site.py | 2 +- 23 files changed, 734 insertions(+), 51 deletions(-) create mode 100644 press/database/__init__.py create mode 100644 press/database/doctype/__init__.py create mode 100644 press/database/doctype/database_server/__init__.py create mode 100644 press/database/doctype/database_server/database_server.js create mode 100644 press/database/doctype/database_server/database_server.json create mode 100644 press/database/doctype/database_server/database_server.py create mode 100644 press/database/doctype/database_server/test_database_server.py create mode 100644 press/database/doctype/database_server_mariadb_variable/__init__.py create mode 100644 press/database/doctype/database_server_mariadb_variable/database_server_mariadb_variable.json create mode 100644 press/database/doctype/database_server_mariadb_variable/database_server_mariadb_variable.py diff --git a/press/api/tests/test_server.py b/press/api/tests/test_server.py index 59f1033bb4..5295495659 100644 --- a/press/api/tests/test_server.py +++ b/press/api/tests/test_server.py @@ -14,7 +14,7 @@ from press.press.doctype.ansible_play.test_ansible_play import create_test_ansible_play from press.press.doctype.cluster.cluster import Cluster from press.press.doctype.cluster.test_cluster import create_test_cluster -from press.press.doctype.database_server.database_server import DatabaseServer +from press.database.doctype.database_server.database_server import DatabaseServer from press.press.doctype.proxy_server.test_proxy_server import create_test_proxy_server from press.press.doctype.server.server import BaseServer from press.press.doctype.team.test_team import create_test_press_admin_team @@ -316,7 +316,7 @@ def test_creation_of_db_server_adds_default_mariadb_variables(self): class TestAPIServerList(FrappeTestCase): def setUp(self): - from press.press.doctype.database_server.test_database_server import ( + from press.database.doctype.database_server.test_database_server import ( create_test_database_server, ) from press.press.doctype.press_tag.test_press_tag import create_and_add_test_tag diff --git a/press/database/__init__.py b/press/database/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/press/database/doctype/__init__.py b/press/database/doctype/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/press/database/doctype/database_server/__init__.py b/press/database/doctype/database_server/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/press/database/doctype/database_server/database_server.js b/press/database/doctype/database_server/database_server.js new file mode 100644 index 0000000000..29d45986f1 --- /dev/null +++ b/press/database/doctype/database_server/database_server.js @@ -0,0 +1,8 @@ +// Copyright (c) 2024, Frappe and contributors +// For license information, please see license.txt + +// frappe.ui.form.on("Database Server", { +// refresh(frm) { + +// }, +// }); diff --git a/press/database/doctype/database_server/database_server.json b/press/database/doctype/database_server/database_server.json new file mode 100644 index 0000000000..1959d6c4bb --- /dev/null +++ b/press/database/doctype/database_server/database_server.json @@ -0,0 +1,559 @@ +{ + "actions": [], + "creation": "2020-10-02 17:33:00.453792", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "status", + "hostname", + "hostname_abbreviation", + "domain", + "self_hosted_server_domain", + "title", + "column_break_4", + "cluster", + "provider", + "virtual_machine", + "is_self_hosted", + "is_server_setup", + "is_server_prepared", + "is_server_renamed", + "public", + "billing_section", + "team", + "column_break_11", + "plan", + "auto_add_storage_min", + "auto_add_storage_max", + "networking_section", + "ip", + "column_break_10", + "private_ip", + "private_mac_address", + "private_vlan_id", + "agent_section", + "agent_password", + "mariadb_section", + "self_hosted_mariadb_server", + "mariadb_root_password", + "server_id", + "is_primary", + "column_break_12", + "primary", + "is_replication_setup", + "ssh_section", + "frappe_user_password", + "frappe_public_key", + "column_break_18", + "ssh_user", + "ssh_port", + "root_public_key", + "section_break_cees", + "ram", + "column_break_apox", + "tags_section", + "tags", + "mariadb_settings_tab", + "memory_limits_section", + "memory_high", + "memory_max", + "memory_swap_max", + "column_break_eiyu", + "memory_allocator", + "memory_allocator_version", + "section_break_ladc", + "is_performance_schema_enabled", + "mariadb_system_variables", + "mariadb_stalk_section", + "is_stalk_setup", + "stalk_gdb_collector", + "stalk_strace_collector", + "column_break_qrkk", + "stalk_function", + "stalk_variable", + "stalk_threshold", + "column_break_objb", + "stalk_interval", + "stalk_cycles", + "stalk_sleep" + ], + "fields": [ + { + "fieldname": "status", + "fieldtype": "Select", + "in_list_view": 1, + "in_standard_filter": 1, + "label": "Status", + "options": "Pending\nInstalling\nActive\nBroken\nArchived", + "read_only": 1, + "reqd": 1 + }, + { + "fieldname": "hostname", + "fieldtype": "Data", + "label": "Hostname", + "reqd": 1, + "set_only_once": 1 + }, + { + "fieldname": "hostname_abbreviation", + "fieldtype": "Data", + "label": "Hostname Abbreviation" + }, + { + "fieldname": "domain", + "fieldtype": "Link", + "label": "Domain", + "options": "Root Domain", + "read_only": 1 + }, + { + "depends_on": "eval:doc.is_self_hosted", + "fieldname": "self_hosted_server_domain", + "fieldtype": "Data", + "label": "Self Hosted Server Domain" + }, + { + "fieldname": "title", + "fieldtype": "Data", + "label": "Title" + }, + { + "fieldname": "column_break_4", + "fieldtype": "Column Break" + }, + { + "fieldname": "cluster", + "fieldtype": "Link", + "in_list_view": 1, + "in_standard_filter": 1, + "label": "Cluster", + "options": "Cluster", + "set_only_once": 1 + }, + { + "default": "Generic", + "fieldname": "provider", + "fieldtype": "Select", + "label": "Provider", + "options": "Generic\nScaleway\nAWS EC2\nOCI", + "set_only_once": 1 + }, + { + "depends_on": "eval:doc.provider === \"AWS EC2\"", + "fieldname": "virtual_machine", + "fieldtype": "Link", + "label": "Virtual Machine", + "mandatory_depends_on": "eval:doc.provider === \"AWS EC2\"", + "options": "Virtual Machine" + }, + { + "default": "0", + "fieldname": "is_self_hosted", + "fieldtype": "Check", + "label": "Is Self Hosted" + }, + { + "default": "0", + "fieldname": "is_server_setup", + "fieldtype": "Check", + "label": "Server Setup", + "read_only": 1 + }, + { + "default": "0", + "fieldname": "is_server_prepared", + "fieldtype": "Check", + "label": "Is Server Prepared", + "read_only": 1 + }, + { + "default": "0", + "fieldname": "is_server_renamed", + "fieldtype": "Check", + "label": "Is Server Renamed", + "read_only": 1 + }, + { + "default": "0", + "fieldname": "public", + "fieldtype": "Check", + "label": "Public" + }, + { + "fieldname": "billing_section", + "fieldtype": "Section Break", + "label": "Billing" + }, + { + "fieldname": "team", + "fieldtype": "Link", + "label": "Team", + "options": "Team" + }, + { + "fieldname": "column_break_11", + "fieldtype": "Column Break" + }, + { + "fieldname": "plan", + "fieldtype": "Link", + "label": "Plan", + "options": "Server Plan" + }, + { + "default": "50", + "description": "Minimum storage to add automatically each time", + "fieldname": "auto_add_storage_min", + "fieldtype": "Int", + "label": "Auto Add Storage Min", + "non_negative": 1, + "options": "50" + }, + { + "default": "250", + "description": "Maximum storage to add automatically each time", + "fieldname": "auto_add_storage_max", + "fieldtype": "Int", + "label": "Auto Add Storage Max", + "non_negative": 1 + }, + { + "fieldname": "networking_section", + "fieldtype": "Section Break", + "label": "Networking" + }, + { + "fetch_from": "virtual_machine.public_ip_address", + "fieldname": "ip", + "fieldtype": "Data", + "in_list_view": 1, + "label": "IP", + "set_only_once": 1 + }, + { + "fieldname": "column_break_10", + "fieldtype": "Column Break" + }, + { + "fetch_from": "virtual_machine.private_ip_address", + "fieldname": "private_ip", + "fieldtype": "Data", + "label": "Private IP", + "set_only_once": 1 + }, + { + "depends_on": "eval: doc.provider === \"Scaleway\"", + "fieldname": "private_mac_address", + "fieldtype": "Data", + "label": "Private Mac Address", + "mandatory_depends_on": "eval: doc.provider === \"Scaleway\"", + "set_only_once": 1 + }, + { + "depends_on": "eval: doc.provider === \"Scaleway\"", + "fieldname": "private_vlan_id", + "fieldtype": "Data", + "label": "Private VLAN ID", + "mandatory_depends_on": "eval: doc.provider === \"Scaleway\"", + "set_only_once": 1 + }, + { + "fieldname": "agent_section", + "fieldtype": "Section Break", + "label": "Agent" + }, + { + "fieldname": "agent_password", + "fieldtype": "Password", + "label": "Agent Password", + "set_only_once": 1 + }, + { + "fieldname": "mariadb_section", + "fieldtype": "Section Break", + "label": "MariaDB" + }, + { + "depends_on": "eval:doc.is_self_hosted", + "fieldname": "self_hosted_mariadb_server", + "fieldtype": "Data", + "label": "Self Hosted MariaDB Server IP" + }, + { + "fieldname": "mariadb_root_password", + "fieldtype": "Password", + "label": "MariaDB Root Password", + "read_only": 1 + }, + { + "fieldname": "server_id", + "fieldtype": "Int", + "label": "Server ID", + "set_only_once": 1 + }, + { + "default": "1", + "fieldname": "is_primary", + "fieldtype": "Check", + "in_list_view": 1, + "in_standard_filter": 1, + "label": "Is Primary" + }, + { + "fieldname": "column_break_12", + "fieldtype": "Column Break" + }, + { + "depends_on": "eval: !doc.is_primary", + "fieldname": "primary", + "fieldtype": "Link", + "in_list_view": 1, + "in_standard_filter": 1, + "label": "Primary", + "mandatory_depends_on": "eval: !doc.is_primary", + "options": "Database Server" + }, + { + "default": "0", + "depends_on": "eval: !doc.is_primary", + "fieldname": "is_replication_setup", + "fieldtype": "Check", + "label": "Replication Setup", + "read_only": 1 + }, + { + "fieldname": "ssh_section", + "fieldtype": "Section Break", + "label": "SSH" + }, + { + "fieldname": "frappe_user_password", + "fieldtype": "Password", + "label": "Frappe User Password", + "set_only_once": 1 + }, + { + "fieldname": "frappe_public_key", + "fieldtype": "Code", + "label": "Frappe Public Key", + "read_only": 1 + }, + { + "fieldname": "column_break_18", + "fieldtype": "Column Break" + }, + { + "fieldname": "ssh_user", + "fieldtype": "Data", + "label": "SSH User" + }, + { + "default": "22", + "fieldname": "ssh_port", + "fieldtype": "Int", + "label": "SSH Port" + }, + { + "fieldname": "root_public_key", + "fieldtype": "Code", + "label": "Root Public Key", + "read_only": 1 + }, + { + "fieldname": "section_break_cees", + "fieldtype": "Section Break" + }, + { + "fieldname": "ram", + "fieldtype": "Float", + "label": "RAM (MB)" + }, + { + "fieldname": "column_break_apox", + "fieldtype": "Column Break" + }, + { + "fieldname": "tags_section", + "fieldtype": "Section Break", + "label": "Tags" + }, + { + "fieldname": "tags", + "fieldtype": "Table", + "label": "Tags", + "options": "Resource Tag" + }, + { + "fieldname": "mariadb_settings_tab", + "fieldtype": "Tab Break", + "label": "MariaDB Settings" + }, + { + "fieldname": "memory_limits_section", + "fieldtype": "Section Break", + "label": "Memory" + }, + { + "fieldname": "memory_high", + "fieldtype": "Float", + "label": "Memory High (GB)", + "non_negative": 1 + }, + { + "fieldname": "memory_max", + "fieldtype": "Float", + "label": "Memory Max (GB)", + "non_negative": 1 + }, + { + "default": "0.1", + "fieldname": "memory_swap_max", + "fieldtype": "Float", + "label": "Memory Swap Max (GB)", + "non_negative": 1 + }, + { + "fieldname": "column_break_eiyu", + "fieldtype": "Column Break" + }, + { + "default": "System", + "fieldname": "memory_allocator", + "fieldtype": "Select", + "label": "Memory Allocator", + "options": "System\njemalloc\nTCMalloc", + "read_only": 1 + }, + { + "fieldname": "memory_allocator_version", + "fieldtype": "Data", + "label": "Memory Allocator Version", + "read_only": 1 + }, + { + "fieldname": "section_break_ladc", + "fieldtype": "Section Break" + }, + { + "default": "0", + "fieldname": "is_performance_schema_enabled", + "fieldtype": "Check", + "label": "Is Performance Schema Enabled", + "read_only": 1 + }, + { + "fieldname": "mariadb_system_variables", + "fieldtype": "Table", + "label": "MariaDB System Variables", + "options": "Database Server MariaDB Variable" + }, + { + "collapsible": 1, + "fieldname": "mariadb_stalk_section", + "fieldtype": "Section Break", + "label": "MariaDB Stalk" + }, + { + "default": "0", + "fieldname": "is_stalk_setup", + "fieldtype": "Check", + "label": "Is Stalk Setup", + "read_only": 1 + }, + { + "default": "0", + "fieldname": "stalk_gdb_collector", + "fieldtype": "Check", + "label": "Stalk GDB Collector" + }, + { + "default": "0", + "fieldname": "stalk_strace_collector", + "fieldtype": "Check", + "label": "Stalk strace Collector" + }, + { + "fieldname": "column_break_qrkk", + "fieldtype": "Column Break" + }, + { + "default": "status", + "fieldname": "stalk_function", + "fieldtype": "Data", + "label": "Stalk Function" + }, + { + "default": "Threads_running", + "fieldname": "stalk_variable", + "fieldtype": "Data", + "label": "Stalk Variable" + }, + { + "default": "25", + "fieldname": "stalk_threshold", + "fieldtype": "Int", + "label": "Stalk Threshold" + }, + { + "fieldname": "column_break_objb", + "fieldtype": "Column Break" + }, + { + "default": "1", + "fieldname": "stalk_interval", + "fieldtype": "Float", + "label": "Stalk Interval" + }, + { + "default": "5", + "fieldname": "stalk_cycles", + "fieldtype": "Int", + "label": "Stalk Cycles" + }, + { + "default": "300", + "fieldname": "stalk_sleep", + "fieldtype": "Int", + "label": "Stalk Sleep" + } + ], + "index_web_pages_for_search": 1, + "links": [], + "modified": "2024-10-14 10:39:29.095299", + "modified_by": "Administrator", + "module": "Database", + "name": "Database Server", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "share": 1, + "write": 1 + }, + { + "create": 1, + "read": 1, + "role": "Press Admin", + "write": 1 + }, + { + "create": 1, + "read": 1, + "role": "Press Member", + "write": 1 + } + ], + "sort_field": "modified", + "sort_order": "DESC", + "states": [], + "track_changes": 1 +} \ No newline at end of file diff --git a/press/database/doctype/database_server/database_server.py b/press/database/doctype/database_server/database_server.py new file mode 100644 index 0000000000..3054d13d9e --- /dev/null +++ b/press/database/doctype/database_server/database_server.py @@ -0,0 +1,9 @@ +# Copyright (c) 2024, Frappe and contributors +# For license information, please see license.txt + +# import frappe +from frappe.model.document import Document + + +class DatabaseServer(Document): + pass diff --git a/press/database/doctype/database_server/test_database_server.py b/press/database/doctype/database_server/test_database_server.py new file mode 100644 index 0000000000..382e5e3a51 --- /dev/null +++ b/press/database/doctype/database_server/test_database_server.py @@ -0,0 +1,30 @@ +# Copyright (c) 2024, Frappe and Contributors +# See license.txt + +# import frappe +from frappe.tests import IntegrationTestCase, UnitTestCase + + +# On IntegrationTestCase, the doctype test records and all +# link-field test record depdendencies are recursively loaded +# Use these module variables to add/remove to/from that list +EXTRA_TEST_RECORD_DEPENDENCIES = [] # eg. ["User"] +IGNORE_TEST_RECORD_DEPENDENCIES = [] # eg. ["User"] + + +class TestDatabaseServer(UnitTestCase): + """ + Unit tests for DatabaseServer. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestDatabaseServer(IntegrationTestCase): + """ + Integration tests for DatabaseServer. + Use this class for testing interactions between multiple components. + """ + + pass diff --git a/press/database/doctype/database_server_mariadb_variable/__init__.py b/press/database/doctype/database_server_mariadb_variable/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/press/database/doctype/database_server_mariadb_variable/database_server_mariadb_variable.json b/press/database/doctype/database_server_mariadb_variable/database_server_mariadb_variable.json new file mode 100644 index 0000000000..72dc555ee4 --- /dev/null +++ b/press/database/doctype/database_server_mariadb_variable/database_server_mariadb_variable.json @@ -0,0 +1,69 @@ +{ + "actions": [], + "allow_rename": 1, + "creation": "2023-05-30 15:28:55.572163", + "default_view": "List", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "mariadb_variable", + "value_int", + "value_str", + "value_float", + "skip", + "persist" + ], + "fields": [ + { + "fieldname": "mariadb_variable", + "fieldtype": "Link", + "in_list_view": 1, + "label": "MariaDB Variable", + "options": "MariaDB Variable" + }, + { + "fieldname": "value_int", + "fieldtype": "Int", + "in_list_view": 1, + "label": "Value Int (MB)" + }, + { + "fieldname": "value_str", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Value Str" + }, + { + "fieldname": "value_float", + "fieldtype": "Float", + "label": "Value Float" + }, + { + "default": "0", + "fieldname": "skip", + "fieldtype": "Check", + "in_list_view": 1, + "label": "Skip" + }, + { + "default": "0", + "fieldname": "persist", + "fieldtype": "Check", + "in_list_view": 1, + "label": "Persist" + } + ], + "index_web_pages_for_search": 1, + "istable": 1, + "links": [], + "modified": "2024-10-14 10:40:01.146367", + "modified_by": "Administrator", + "module": "Database", + "name": "Database Server MariaDB Variable", + "owner": "Administrator", + "permissions": [], + "sort_field": "modified", + "sort_order": "DESC", + "states": [] +} \ No newline at end of file diff --git a/press/database/doctype/database_server_mariadb_variable/database_server_mariadb_variable.py b/press/database/doctype/database_server_mariadb_variable/database_server_mariadb_variable.py new file mode 100644 index 0000000000..3bb9bf8958 --- /dev/null +++ b/press/database/doctype/database_server_mariadb_variable/database_server_mariadb_variable.py @@ -0,0 +1,9 @@ +# Copyright (c) 2024, Frappe and contributors +# For license information, please see license.txt + +# import frappe +from frappe.model.document import Document + + +class DatabaseServerMariaDBVariable(Document): + pass diff --git a/press/hooks.py b/press/hooks.py index b9e539a012..7e2cfef44c 100644 --- a/press/hooks.py +++ b/press/hooks.py @@ -119,7 +119,7 @@ "Deploy": "press.press.doctype.deploy.deploy.get_permission_query_conditions", "Bench": "press.press.doctype.bench.bench.get_permission_query_conditions", "Server": "press.press.doctype.server.server.get_permission_query_conditions", - "Database Server": "press.press.doctype.database_server.database_server.get_permission_query_conditions", + "Database Server": "press.database.doctype.database_server.database_server.get_permission_query_conditions", "Virtual Machine": "press.press.doctype.virtual_machine.virtual_machine.get_permission_query_conditions", "Press Webhook": "press.press.doctype.press_webhook.press_webhook.get_permission_query_conditions", "Press Webhook Log": "press.press.doctype.press_webhook_log.press_webhook_log.get_permission_query_conditions", diff --git a/press/modules.txt b/press/modules.txt index 14733cbda7..c5e5ec3b2f 100644 --- a/press/modules.txt +++ b/press/modules.txt @@ -3,4 +3,5 @@ Experimental Marketplace SaaS Partner -Infrastructure \ No newline at end of file +Infrastructure +Database \ No newline at end of file diff --git a/press/patches.txt b/press/patches.txt index 5bc2dbd9ca..06c38cb6d3 100644 --- a/press/patches.txt +++ b/press/patches.txt @@ -96,7 +96,7 @@ press.press.doctype.site.patches.set_database_access_credentials press.press.doctype.team.patches.set_team_title press.press.doctype.telegram_group.patches.create_groups_from_press_settings press.press.doctype.app_release.patches.set_clone_directory -press.press.doctype.database_server_mariadb_variable.patches.add_unique_constraint +press.database.doctype.database_server_mariadb_variable.patches.add_unique_constraint press.press.doctype.release_group.patches.sync_common_site_config execute:frappe.delete_doc('Central Site Migration') execute:frappe.delete_doc('Central Server') diff --git a/press/press/doctype/database_server/database_server.py b/press/press/doctype/database_server/database_server.py index b5bcd197c4..449a74d021 100644 --- a/press/press/doctype/database_server/database_server.py +++ b/press/press/doctype/database_server/database_server.py @@ -11,7 +11,7 @@ from frappe.core.utils import find from press.overrides import get_permission_query_conditions_for_doctype -from press.press.doctype.database_server_mariadb_variable.database_server_mariadb_variable import ( +from press.database.doctype.database_server_mariadb_variable.database_server_mariadb_variable import ( DatabaseServerMariaDBVariable, ) from press.press.doctype.server.server import BaseServer @@ -27,9 +27,7 @@ class DatabaseServer(BaseServer): if TYPE_CHECKING: from frappe.types import DF - from press.press.doctype.database_server_mariadb_variable.database_server_mariadb_variable import ( - DatabaseServerMariaDBVariable, - ) + from press.database.doctype.database_server_mariadb_variable.database_server_mariadb_variable import DatabaseServerMariaDBVariable from press.press.doctype.resource_tag.resource_tag import ResourceTag agent_password: DF.Password | None diff --git a/press/press/doctype/database_server/test_database_server.py b/press/press/doctype/database_server/test_database_server.py index 9388facc27..410f28c7e0 100644 --- a/press/press/doctype/database_server/test_database_server.py +++ b/press/press/doctype/database_server/test_database_server.py @@ -10,7 +10,7 @@ from frappe.model.naming import make_autoname from frappe.tests.utils import FrappeTestCase -from press.press.doctype.database_server.database_server import DatabaseServer +from press.database.doctype.database_server.database_server import DatabaseServer from press.press.doctype.server.server import BaseServer from press.runner import Ansible from press.utils.test import foreground_enqueue_doc @@ -43,10 +43,10 @@ def tearDown(self): frappe.db.rollback() @patch( - "press.press.doctype.database_server.database_server.Ansible", + "press.database.doctype.database_server.database_server.Ansible", ) @patch( - "press.press.doctype.database_server.database_server.frappe.enqueue_doc", + "press.database.doctype.database_server.database_server.frappe.enqueue_doc", new=foreground_enqueue_doc, ) def test_mariadb_service_restarted_on_restart_mariadb_fn_call( @@ -66,10 +66,10 @@ def test_mariadb_service_restarted_on_restart_mariadb_fn_call( ) @patch( - "press.press.doctype.database_server.database_server.Ansible", + "press.database.doctype.database_server.database_server.Ansible", ) @patch( - "press.press.doctype.database_server.database_server.frappe.enqueue_doc", + "press.database.doctype.database_server.database_server.frappe.enqueue_doc", new=foreground_enqueue_doc, ) def test_memory_limits_updated_on_update_of_corresponding_fields( @@ -97,10 +97,10 @@ def test_memory_limits_updated_on_update_of_corresponding_fields( ) @patch( - "press.press.doctype.database_server.database_server.Ansible", + "press.database.doctype.database_server.database_server.Ansible", ) @patch( - "press.press.doctype.database_server.database_server.frappe.enqueue_doc", + "press.database.doctype.database_server.database_server.frappe.enqueue_doc", new=foreground_enqueue_doc, ) def test_reconfigure_mariadb_exporter_play_runs_on_reconfigure_fn_call( @@ -119,10 +119,10 @@ def test_reconfigure_mariadb_exporter_play_runs_on_reconfigure_fn_call( ) @patch( - "press.press.doctype.database_server.database_server.Ansible", + "press.database.doctype.database_server.database_server.Ansible", ) @patch( - "press.press.doctype.database_server.database_server.frappe.enqueue_doc", + "press.database.doctype.database_server.database_server.frappe.enqueue_doc", new=foreground_enqueue_doc, ) def test_exception_on_failed_reconfigure_fn_call(self, Mock_Ansible: Mock): @@ -130,9 +130,9 @@ def test_exception_on_failed_reconfigure_fn_call(self, Mock_Ansible: Mock): server = create_test_database_server() self.assertRaises(Exception, server.reconfigure_mariadb_exporter) - @patch("press.press.doctype.database_server.database_server.Ansible", new=Mock()) + @patch("press.database.doctype.database_server.database_server.Ansible", new=Mock()) @patch( - "press.press.doctype.database_server.database_server.frappe.enqueue_doc", + "press.database.doctype.database_server.database_server.frappe.enqueue_doc", new=foreground_enqueue_doc, ) def test_adjust_memory_config_sets_memory_limits_with_some_buffer(self): diff --git a/press/press/doctype/database_server_mariadb_variable/test_database_server_mariadb_variable.py b/press/press/doctype/database_server_mariadb_variable/test_database_server_mariadb_variable.py index 7cb8f4968a..b6d114daa3 100644 --- a/press/press/doctype/database_server_mariadb_variable/test_database_server_mariadb_variable.py +++ b/press/press/doctype/database_server_mariadb_variable/test_database_server_mariadb_variable.py @@ -5,7 +5,7 @@ import frappe from frappe.tests.utils import FrappeTestCase -from press.press.doctype.database_server.test_database_server import ( +from press.database.doctype.database_server.test_database_server import ( create_test_database_server, ) from press.runner import Ansible @@ -98,11 +98,11 @@ def test_only_skippable_variables_can_be_skipped(self): self.fail("Should be able to skip skippable variables") @patch( - "press.press.doctype.database_server_mariadb_variable.database_server_mariadb_variable.Ansible", + "press.database.doctype.database_server_mariadb_variable.database_server_mariadb_variable.Ansible", wraps=Ansible, ) @patch( - "press.press.doctype.database_server.database_server.frappe.enqueue_doc", + "press.database.doctype.database_server.database_server.frappe.enqueue_doc", new=foreground_enqueue_doc, ) def test_skip_implies_persist_and_not_dynamic(self, Mock_Ansible): @@ -136,11 +136,11 @@ def test_default_value_is_applied_if_empty(self): self.assertEqual(server.mariadb_system_variables[0].value_str, default_value) @patch( - "press.press.doctype.database_server_mariadb_variable.database_server_mariadb_variable.Ansible", + "press.database.doctype.database_server_mariadb_variable.database_server_mariadb_variable.Ansible", wraps=Ansible, ) @patch( - "press.press.doctype.database_server.database_server.frappe.enqueue_doc", + "press.database.doctype.database_server.database_server.frappe.enqueue_doc", wraps=foreground_enqueue_doc, ) def test_ansible_playbook_triggered_with_correct_input_on_update_of_child_table( @@ -175,14 +175,14 @@ def test_ansible_playbook_not_triggered_on_update_of_unrelated_things(self): server.save() server.status = "Broken" with patch( - "press.press.doctype.database_server_mariadb_variable.database_server_mariadb_variable.Ansible", + "press.database.doctype.database_server_mariadb_variable.database_server_mariadb_variable.Ansible", wraps=Ansible, ) as Mock_Ansible: server.save() Mock_Ansible.assert_not_called() @patch( - "press.press.doctype.database_server.database_server.frappe.enqueue_doc", + "press.database.doctype.database_server.database_server.frappe.enqueue_doc", new=foreground_enqueue_doc, ) def test_playbook_run_on_update_of_child_table(self): @@ -194,18 +194,18 @@ def test_playbook_run_on_update_of_child_table(self): server.save() server.mariadb_system_variables[0].value_int = 2000 with patch( - "press.press.doctype.database_server_mariadb_variable.database_server_mariadb_variable.Ansible", + "press.database.doctype.database_server_mariadb_variable.database_server_mariadb_variable.Ansible", wraps=Ansible, ) as Mock_Ansible: server.save() Mock_Ansible.assert_called_once() @patch( - "press.press.doctype.database_server_mariadb_variable.database_server_mariadb_variable.Ansible", + "press.database.doctype.database_server_mariadb_variable.database_server_mariadb_variable.Ansible", wraps=Ansible, ) @patch( - "press.press.doctype.database_server.database_server.frappe.enqueue_doc", + "press.database.doctype.database_server.database_server.frappe.enqueue_doc", wraps=foreground_enqueue_doc, ) def test_multiple_playbooks_triggered_for_multiple_variables( @@ -224,11 +224,11 @@ def test_multiple_playbooks_triggered_for_multiple_variables( self.assertEqual(2, Mock_Ansible.call_count) @patch( - "press.press.doctype.database_server_mariadb_variable.database_server_mariadb_variable.Ansible", + "press.database.doctype.database_server_mariadb_variable.database_server_mariadb_variable.Ansible", wraps=Ansible, ) @patch( - "press.press.doctype.database_server.database_server.frappe.enqueue_doc", + "press.database.doctype.database_server.database_server.frappe.enqueue_doc", new=foreground_enqueue_doc, ) def test_persist_check_passes_option_to_playbook_run(self, Mock_Ansible): @@ -246,7 +246,7 @@ def test_persist_check_passes_option_to_playbook_run(self, Mock_Ansible): self.assertTrue(kwargs["variables"]["persist"]) @patch( - "press.press.doctype.database_server.database_server.frappe.enqueue_doc", + "press.database.doctype.database_server.database_server.frappe.enqueue_doc", new=foreground_enqueue_doc, ) def test_playbook_run_on_addition_of_variable_and_only_that_variable(self): @@ -257,7 +257,7 @@ def test_playbook_run_on_addition_of_variable_and_only_that_variable(self): ) server.save() with patch( - "press.press.doctype.database_server_mariadb_variable.database_server_mariadb_variable.Ansible", + "press.database.doctype.database_server_mariadb_variable.database_server_mariadb_variable.Ansible", wraps=Ansible, ) as Mock_Ansible: server.append( @@ -268,7 +268,7 @@ def test_playbook_run_on_addition_of_variable_and_only_that_variable(self): Mock_Ansible.assert_called_once() @patch( - "press.press.doctype.database_server.database_server.frappe.enqueue_doc", + "press.database.doctype.database_server.database_server.frappe.enqueue_doc", new=foreground_enqueue_doc, ) def test_playbook_run_only_for_variable_changed(self): @@ -283,7 +283,7 @@ def test_playbook_run_only_for_variable_changed(self): ) server.save() with patch( - "press.press.doctype.database_server_mariadb_variable.database_server_mariadb_variable.Ansible", + "press.database.doctype.database_server_mariadb_variable.database_server_mariadb_variable.Ansible", wraps=Ansible, ) as Mock_Ansible: server.mariadb_system_variables[0].value_int = 2000 @@ -291,7 +291,7 @@ def test_playbook_run_only_for_variable_changed(self): Mock_Ansible.assert_called_once() @patch( - "press.press.doctype.database_server.database_server.frappe.enqueue_doc", + "press.database.doctype.database_server.database_server.frappe.enqueue_doc", new=foreground_enqueue_doc, ) def test_playbooks_triggered_for_added_and_changed_variables_in_one_save(self): @@ -302,7 +302,7 @@ def test_playbooks_triggered_for_added_and_changed_variables_in_one_save(self): ) server.save() with patch( - "press.press.doctype.database_server_mariadb_variable.database_server_mariadb_variable.Ansible", + "press.database.doctype.database_server_mariadb_variable.database_server_mariadb_variable.Ansible", wraps=Ansible, ) as Mock_Ansible: server.append( @@ -319,7 +319,7 @@ def test_playbooks_triggered_for_added_and_changed_variables_in_one_save(self): ) @patch( - "press.press.doctype.database_server.database_server.frappe.enqueue_doc", + "press.database.doctype.database_server.database_server.frappe.enqueue_doc", wraps=foreground_enqueue_doc, ) def test_background_jobs_not_created_for_new_server_doc(self, mock_enqueue_doc): @@ -327,7 +327,7 @@ def test_background_jobs_not_created_for_new_server_doc(self, mock_enqueue_doc): mock_enqueue_doc.assert_not_called() @patch( - "press.press.doctype.database_server.database_server.frappe.enqueue_doc", + "press.database.doctype.database_server.database_server.frappe.enqueue_doc", wraps=foreground_enqueue_doc, ) def test_update_of_doc_with_member_that_is_not_a_field_works(self, mock_enqueue_doc): @@ -340,14 +340,14 @@ def test_update_of_doc_with_member_that_is_not_a_field_works(self, mock_enqueue_ self.fail("Update of doc without variables failed") @patch( - "press.press.doctype.database_server.database_server.frappe.enqueue_doc", + "press.database.doctype.database_server.database_server.frappe.enqueue_doc", new=foreground_enqueue_doc, ) def test_add_variable_method_adds_and_updates_variables(self): server = create_test_database_server() with patch( - "press.press.doctype.database_server_mariadb_variable.database_server_mariadb_variable.Ansible", + "press.database.doctype.database_server_mariadb_variable.database_server_mariadb_variable.Ansible", wraps=Ansible, ) as Mock_Ansible: server.add_mariadb_variable("tmp_disk_table_size", "value_int", 10241) @@ -362,7 +362,7 @@ def test_add_variable_method_adds_and_updates_variables(self): self.assertEqual(10241, server.mariadb_system_variables[0].value_int) with patch( - "press.press.doctype.database_server_mariadb_variable.database_server_mariadb_variable.Ansible", + "press.database.doctype.database_server_mariadb_variable.database_server_mariadb_variable.Ansible", wraps=Ansible, ) as Mock_Ansible: server.add_mariadb_variable("tmp_disk_table_size", "value_int", 10242) @@ -376,14 +376,14 @@ def test_add_variable_method_adds_and_updates_variables(self): self.assertEqual(10242, server.mariadb_system_variables[0].value_int) with patch( - "press.press.doctype.database_server_mariadb_variable.database_server_mariadb_variable.Ansible", + "press.database.doctype.database_server_mariadb_variable.database_server_mariadb_variable.Ansible", wraps=Ansible, ) as Mock_Ansible: server.add_mariadb_variable("tmp_disk_table_size", "value_int", 10242) # no change Mock_Ansible.assert_not_called() with patch( - "press.press.doctype.database_server_mariadb_variable.database_server_mariadb_variable.Ansible", + "press.database.doctype.database_server_mariadb_variable.database_server_mariadb_variable.Ansible", wraps=Ansible, ) as Mock_Ansible: server.add_mariadb_variable( diff --git a/press/press/doctype/mariadb_variable/mariadb_variable.py b/press/press/doctype/mariadb_variable/mariadb_variable.py index e324357edf..637a02d2f6 100644 --- a/press/press/doctype/mariadb_variable/mariadb_variable.py +++ b/press/press/doctype/mariadb_variable/mariadb_variable.py @@ -4,7 +4,7 @@ import frappe from frappe.model.document import Document -from press.press.doctype.database_server.database_server import DatabaseServer +from press.database.doctype.database_server.database_server import DatabaseServer class MariaDBVariable(Document): diff --git a/press/press/doctype/mariadb_variable/test_mariadb_variable.py b/press/press/doctype/mariadb_variable/test_mariadb_variable.py index eac078327b..88a705dc8c 100644 --- a/press/press/doctype/mariadb_variable/test_mariadb_variable.py +++ b/press/press/doctype/mariadb_variable/test_mariadb_variable.py @@ -4,7 +4,7 @@ import frappe from frappe.tests.utils import FrappeTestCase -from press.press.doctype.database_server.test_database_server import ( +from press.database.doctype.database_server.test_database_server import ( create_test_database_server, ) diff --git a/press/press/doctype/root_domain/test_root_domain.py b/press/press/doctype/root_domain/test_root_domain.py index 2e5c334376..a51857d7ab 100644 --- a/press/press/doctype/root_domain/test_root_domain.py +++ b/press/press/doctype/root_domain/test_root_domain.py @@ -37,7 +37,7 @@ def tearDown(self): frappe.db.rollback() def _create_fake_rename_job(self, site_name: str, creation=None): - from press.press.doctype.database_server.test_database_server import ( + from press.database.doctype.database_server.test_database_server import ( create_test_database_server, ) from press.press.doctype.proxy_server.test_proxy_server import ( diff --git a/press/press/doctype/server/test_server.py b/press/press/doctype/server/test_server.py index d7429beb12..095adbbdc8 100644 --- a/press/press/doctype/server/test_server.py +++ b/press/press/doctype/server/test_server.py @@ -10,7 +10,7 @@ import frappe from frappe.model.naming import make_autoname -from press.press.doctype.database_server.test_database_server import ( +from press.database.doctype.database_server.test_database_server import ( create_test_database_server, ) from press.press.doctype.press_settings.test_press_settings import ( diff --git a/press/press/doctype/site/site.py b/press/press/doctype/site/site.py index 022f02d074..5df13fe6b8 100644 --- a/press/press/doctype/site/site.py +++ b/press/press/doctype/site/site.py @@ -83,7 +83,7 @@ from datetime import datetime from press.press.doctype.bench.bench import Bench - from press.press.doctype.database_server.database_server import DatabaseServer + from press.database.doctype.database_server.database_server import DatabaseServer from press.press.doctype.deploy_candidate.deploy_candidate import DeployCandidate from press.press.doctype.release_group.release_group import ReleaseGroup from press.press.doctype.server.server import BaseServer, Server diff --git a/press/press/doctype/site/test_site.py b/press/press/doctype/site/test_site.py index 3ccc42b4e4..fce773b630 100644 --- a/press/press/doctype/site/test_site.py +++ b/press/press/doctype/site/test_site.py @@ -17,7 +17,7 @@ from press.exceptions import InsufficientSpaceOnServer from press.press.doctype.agent_job.agent_job import AgentJob from press.press.doctype.app.test_app import create_test_app -from press.press.doctype.database_server.test_database_server import ( +from press.database.doctype.database_server.test_database_server import ( create_test_database_server, ) from press.press.doctype.release_group.release_group import ReleaseGroup