Skip to content

Commit

Permalink
Add --use-existing feature to integ tests (#126)
Browse files Browse the repository at this point in the history
Co-authored-by: arturo-seijas <[email protected]>
  • Loading branch information
nrobinaubertin and arturo-seijas committed Oct 21, 2023
1 parent c5c2d39 commit 21d13a7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
)
5 changes: 5 additions & 0 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 21d13a7

Please sign in to comment.