From 21d13a7f45beffdb90f60397508fcd1fe8142a4f Mon Sep 17 00:00:00 2001 From: Niels Robin-Aubertin Date: Fri, 20 Oct 2023 20:48:31 -0400 Subject: [PATCH] Add --use-existing feature to integ tests (#126) Co-authored-by: arturo-seijas <102022572+arturo-seijas@users.noreply.github.com> --- src/charm.py | 2 ++ tests/conftest.py | 6 ++++++ tests/integration/conftest.py | 5 +++++ 3 files changed, 13 insertions(+) diff --git a/src/charm.py b/src/charm.py index c4c62631..3dac77ca 100755 --- a/src/charm.py +++ b/src/charm.py @@ -492,6 +492,7 @@ def _set_workload_version(self) -> None: return env_settings = self._create_discourse_environment_settings() try: + logger.info("Setting workload version") get_version_process = container.exec( [f"{DISCOURSE_PATH}/bin/rails", "runner", "puts Discourse::VERSION::STRING"], environment=env_settings, @@ -511,6 +512,7 @@ def _run_s3_migration(self) -> None: env_settings = self._create_discourse_environment_settings() try: self.model.unit.status = MaintenanceStatus("Running S3 migration") + logger.info("Running S3 migration") process = container.exec( [f"{DISCOURSE_PATH}/bin/bundle", "exec", "rake", "s3:upload_assets"], environment=env_settings, diff --git a/tests/conftest.py b/tests/conftest.py index 7d4298dd..08fbd1c1 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -10,3 +10,9 @@ def pytest_addoption(parser): parser.addoption("--saml-email", action="store") parser.addoption("--saml-password", action="store") parser.addoption("--charm-file", action="store", default=None) + parser.addoption( + "--use-existing", + action="store_true", + default=False, + help="This will skip deployment of the charms. Useful for local testing.", + ) diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index fa90ae36..3c2eac8c 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -132,6 +132,11 @@ async def app_fixture( """Discourse charm used for integration testing. Builds the charm and deploys it and the relations it depends on. """ + use_existing = pytestconfig.getoption("--use-existing", default=False) + if use_existing: + yield model.applications[app_name] + return + postgres_app = await model.deploy( "postgresql-k8s", channel="14/edge",