From 560c62264fdc3178b2debc718ad8fc63c042d940 Mon Sep 17 00:00:00 2001 From: Weii Wang Date: Tue, 27 Feb 2024 00:13:30 +0800 Subject: [PATCH 1/3] Disable external HTTP in wp theme and plugin list --- src/charm.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/charm.py b/src/charm.py index c0ce0523..1521722e 100755 --- a/src/charm.py +++ b/src/charm.py @@ -858,7 +858,15 @@ def _wp_addon_list(self, addon_type: str): # FIXME: the feedwordpress plugin causes the `wp theme list` command to fail occasionally # use retries as a temporary workaround for this issue for wait in (1, 3, 5, 5, 5): - process = self._run_wp_cli(["wp", addon_type, "list", "--format=json"], timeout=600) + process = self._run_wp_cli( + [ + "wp", + addon_type, + "list", + "--exec=define( 'WP_HTTP_BLOCK_EXTERNAL', TRUE );", + "--format=json", + ], + ) if process.return_code == 0: break time.sleep(wait) From aba3b61cbd76bd672d7a7c019a95c3031fea2d2a Mon Sep 17 00:00:00 2001 From: Weii Wang Date: Tue, 27 Feb 2024 22:54:32 +0800 Subject: [PATCH 2/3] Use relate instead of add_relation --- tests/integration/conftest.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 07b17175..0a753a56 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -99,7 +99,7 @@ async def prepare_mysql(ops_test: OpsTest, wordpress: WordpressApp, model: Model "deploy", "mysql-k8s", "--channel=8.0/candidate", "--revision=75", "--trust" ) await model.wait_for_idle(status="active", apps=["mysql-k8s"], timeout=30 * 60) - await model.add_relation(f"{wordpress.name}:database", "mysql-k8s:database") + await model.relate(f"{wordpress.name}:database", "mysql-k8s:database") await model.wait_for_idle( status="active", apps=["mysql-k8s", wordpress.name], timeout=40 * 60, idle_period=30 ) @@ -113,7 +113,7 @@ async def prepare_machine_mysql( await machine_model.deploy("mysql", channel="8.0/edge", trust=True) await machine_model.create_offer("mysql:database") await machine_model.wait_for_idle(status="active", apps=["mysql"], timeout=30 * 60) - await model.add_relation( + await model.relate( f"{wordpress.name}:database", f"{machine_controller.controller_name}:admin/{machine_model.name}.mysql", ) @@ -211,7 +211,7 @@ async def prepare_nginx_ingress(wordpress: WordpressApp, prepare_mysql): await wordpress.model.wait_for_idle( status="active", apps=["nginx-ingress-integrator"], timeout=30 * 60 ) - await wordpress.model.add_relation(f"{wordpress.name}:nginx-route", "nginx-ingress-integrator") + await wordpress.model.relate(f"{wordpress.name}:nginx-route", "nginx-ingress-integrator") await wordpress.model.wait_for_idle(status="active") @@ -224,7 +224,7 @@ async def prepare_prometheus(wordpress: WordpressApp, prepare_mysql): await wordpress.model.wait_for_idle( status="active", apps=[prometheus.name], raise_on_error=False, timeout=30 * 60 ) - await wordpress.model.add_relation(f"{wordpress.name}:metrics-endpoint", prometheus.name) + await wordpress.model.relate(f"{wordpress.name}:metrics-endpoint", prometheus.name) await wordpress.model.wait_for_idle( status="active", apps=[prometheus.name, wordpress.name], @@ -238,7 +238,7 @@ async def prepare_loki(wordpress: WordpressApp, prepare_mysql): """Deploy and relate loki-k8s charm for integration tests.""" loki = await wordpress.model.deploy("loki-k8s", channel="1.0/stable", trust=True) await wordpress.model.wait_for_idle(apps=[loki.name], status="active", timeout=20 * 60) - await wordpress.model.add_relation(f"{wordpress.name}:logging", loki.name) + await wordpress.model.relate(f"{wordpress.name}:logging", loki.name) await wordpress.model.wait_for_idle( apps=[loki.name, wordpress.name], status="active", timeout=40 * 60 ) From bfe6e7a275cec88020db8b2b73cbc2521e03ea28 Mon Sep 17 00:00:00 2001 From: Weii Wang Date: Wed, 28 Feb 2024 00:18:42 +0800 Subject: [PATCH 3/3] Update conftest.py --- tests/integration/conftest.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 0a753a56..81d42450 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -208,9 +208,7 @@ async def prepare_swift(wordpress: WordpressApp, swift_config: Dict[str, str]): async def prepare_nginx_ingress(wordpress: WordpressApp, prepare_mysql): """Deploy and relate nginx-ingress-integrator charm for integration tests.""" await wordpress.model.deploy("nginx-ingress-integrator", series="focal", trust=True) - await wordpress.model.wait_for_idle( - status="active", apps=["nginx-ingress-integrator"], timeout=30 * 60 - ) + await wordpress.model.wait_for_idle(apps=["nginx-ingress-integrator"], timeout=30 * 60) await wordpress.model.relate(f"{wordpress.name}:nginx-route", "nginx-ingress-integrator") await wordpress.model.wait_for_idle(status="active")